View
214
Download
1
Embed Size (px)
Citation preview
Parallel Ruby - pp111יוני 2003 3
Presented by pp11 group
Mezhibovsky Ilya
Yampolsky Michael
Reznikov Genady
Parallel Ruby - pp112יוני 2003 3
Ruby is a powerful and dynamic
open source, object-oriented
programming language.
Parallel Ruby - pp113יוני 2003 3
Yukihiro Matsumoto ("Matz"), the
creator of Ruby, is a professional
programmer who worked for the
Japanese open source company ,
netlab.jp. Matz is also known as one of
the open source evangelists in Japan.
Parallel Ruby - pp114יוני 2003 3
Parallel Ruby - pp115יוני 2003 3
19951995
First release
19991999
Overtakes Python in Japan
20002000
•Comp.lang.ruby (newsgroup)
•First English-language Ruby book
•IBM, Inform IT,Brave GNU World ,Sun World Feature
Ruby on web
Parallel Ruby - pp116יוני 2003 3
Smalltalk Perl
Python
CLU
Lisp
Eiffel
Sather
Ada
Parallel Ruby - pp117יוני 2003 3
Ruby is developed under Linux, and is written in
fairly straightforward C.
It runs under
UNIX, DOS, Windows 95/98/NT/2000,
Mac OS X, BeOS, Amiga ,
Acorn Risc OS, and OS/2 .
Parallel Ruby - pp118יוני 2003 3
Ruby's primary focus is productivity of program development, and users will find that programming in Ruby is productive and even fun. Ruby is well
suited for the problem domains such as these :
Text processing — Ruby's File, String, and Regexp classes help you process text data quickly and cleanly .
Network programming — Network programming can be fun with Ruby's well-designed socket classes .
Parallel Ruby - pp119יוני 2003 3
CGI programming — Ruby has everything you need to do CGI programming, including text-handling classes, a CGI library, database interface, and even eRuby (embedded Ruby) and mod_ruby for Apache.
GUI programming — GUI tool kit interfaces such as Ruby/Tk and Ruby/Gtk are available
Parallel Ruby - pp1110יוני 2003 3
Prototyping — With its high productivity, Ruby is often used to make prototypes. Prototypes sometimes become production systems by replacing the bottlenecks with C written extensions .
XML programming — Text-handling features and the UTF-8-aware regular expression engine make XML programming handy in Ruby. The interface to the expat XML parser library is also available .
Parallel Ruby - pp1111יוני 2003 3
emacs/xemacs
www.gnu.org/software/emacs/emacs.html or http://www.xemacs.org/ name="XEmacs": ruby-mode.el is supplied in the Ruby distribution. With some versions of XEmacs, you may need to add (load "font-lock") to your .emacs file to allow ruby-mode.el to detect the syntax highlighting package you’re using.
Jedit
jedit.sourceforge.net :A portable editor written in Java, comes with support for Ruby.
Parallel Ruby - pp1112יוני 2003 3
Vim
http://www.vim.org/ :Vim 5.7 and later have Ruby syntax files as standard in the runtime package. For prior versions, a syntax file for Ruby is available at www.xs4all.nl/~hipster/lib/ruby/ruby.vim.
Jed
space.mit.edu/~davis/jed.html : An s-lang file supporting Ruby is available at www.kondara.org/~g/slang/ruby.sl.
Parallel Ruby - pp1113יוני 2003 3
Nedit
http://www.nedit.org : Eric Santonacci has written Ruby support for Nedit, available from ftp.talc.fr/pub/ruby/ruby.nedit-0.1.tar.gz
TextPad
Barry Shultz has written a Ruby definition file for TextPad, available at
www.textpad.com/add-ons/ntsyn.html
Parallel Ruby - pp1114יוני 2003 3
For me, the purpose of life is, at least partly, to have joy. Programmers often feel joy when they can concentrate on the creative side of programming, so Ruby is designed to make programmers happy. I consider a programming language as a user interface, so it should follow the principles of user interface.
Parallel Ruby - pp1115יוני 2003 3
Principle of Conciseness
I want computers to be my servants, not my masters. Thus, I'd like to give them orders quickly. A good servant should do a lot of work with a short order.
Parallel Ruby - pp1116יוני 2003 3
Principle of Consistency
As with uniform object treatment, as stated before, a small set of rules covers the whole Ruby language. Ruby is a relatively simple language, but it's not too simple. I've tried to follow the principle of "least surprise." Ruby is not too unique, so a programmer with basic knowledge of programming languages can learn it very quickly.
Parallel Ruby - pp1117יוני 2003 3
Principle of Flexibility
Because languages are meant to express thought, a language should not restrict human thought, but should help it. Ruby consists of an unchangeable small core (that is, syntax) and arbitrary extensible class libraries. Because most things are done in libraries, you can treat user-defined classes and objects just as you treat built-in ones.
Programming is incredibly less stressful in Ruby because of these principles.
Parallel Ruby - pp1118יוני 2003 3
def fact(n)
if n == 0
1
else
n * fact(n-1)
end
end
Eiffel
Return
Parallel Ruby - pp1119יוני 2003 3
• Ruby has simple syntax, partially inspired by
Eiffel and Ada.
• Ruby has exception handling features, like Java or
Python, to make it easy to handle errors.
• Ruby's operators are syntax sugar for the methods.
You can redefine them easily.
Parallel Ruby - pp1120יוני 2003 3
• Ruby is a complete, full, pure object oriented
language: OOL. This means all data in Ruby is
an object, not in the sense of Python or Perl, but in the
sense of Smalltalk: no exceptions.
• Ruby features true closures. Not just unnamed
function, but with present variable bindings.
Parallel Ruby - pp1121יוני 2003 3
• Ruby's OO is carefully designed to be both
complete and open for improvements.
Example:
Ruby has the ability to add methods to a class,or even
to an instance during runtime.
So, if needed, an instance of one class *can* behave
differently from other instances of the same class
Parallel Ruby - pp1122יוני 2003 3
• Ruby features a true mark-and-sweep garbage
collector. It works with all Ruby objects.
You don't have to care about maintaining reference
counts in extension libraries
• Writing C extensions in Ruby is easier than in Perl
or Python, due partly to the garbage collector,
and partly to the fine extension API.
Parallel Ruby - pp1123יוני 2003 3
• Ruby needs no variable declarations. It uses
simple naming conventions to denote the scope
of variables.
Examples:
simple 'var' = local variable,
'@var' = instance variable,
'$var' = global variable.
Parallel Ruby - pp1124יוני 2003 3
• Ruby can load extension libraries
dynamically if an OS allows.
• Ruby features OS independent threading.
Thus, for all platforms on which Ruby runs,
you also have multithreading, regardless of
if the OS supports it or not, even on MS-DOS!
Parallel Ruby - pp1125יוני 2003 3
Parallel Ruby - pp1126יוני 2003 3
MPI Ruby is a Ruby binding of MPI.
The primary goal in making this binding was to make
the power of MPI available to Ruby users in a way
that fits into the language's object oriented model.
In order to do this, the buffer and datatype management
necessary in the C, C++, and Fortran bindings
have been removed.
Parallel Ruby - pp1127יוני 2003 3
What this means is that MPI Ruby allows you to treat
objects as messages.
MPI Ruby also aims to be a complete binding to MPI,
in that it offers access to nearly all functionality of MPI
Parallel Ruby - pp1128יוני 2003 3
. Output values are returned
Ruby only has pass by value
Multiple values passed back by arrays
Errors are returned by exceptions
User-defined operations specified by Proc Objects
Blocks
Methods
Parallel Ruby - pp1129יוני 2003 3
All classes are contained in Module MPI
o MPI::Comm
o MPI::Group
o MPI::Op
o MPI::Keyval
o MPI::Request
o MPI::Status
o MPI::Exception
Parallel Ruby - pp1130יוני 2003 3
MPI::Comm#dup()
Duplicates the communicator and returns a new communicator
C equivalent: MPI_Comm_dup()
MPI::Comm.create(grp)
Creates a new communicator from the grp (of type MPI::Group)
C equivalent: MPI_Comm_create()
Parallel Ruby - pp1131יוני 2003 3
MPI::Comm#graph_create(index, edges, reorder)
Creates a new communicator to which graph topology information is attached. index is an array in which the i-th entry is the the total number of neighbors of the first i nodes. edges is a flattened array of the edge lists for nodes 0, 1, ...index.length reorder is a logical value indicating whether the processes may be reordered in the new topology
C equivalent: MPI_Graph_create()
Parallel Ruby - pp1132יוני 2003 3
Attributes
Informational Methods
Topology Specific Information Methods
Point-to-Point Communications
Non-blocking Point-to-Point Communications
Persistent Communications
Buffering Methods
Collective Operations
Probing
Comparison
Abortive Methods
Constants
Parallel Ruby - pp1133יוני 2003 3
Constructors
Informational Methods
MPI::Group#size()
Returns the size of the group
C equivalent: MPI_Group_size()
MPI::Group#|(grp)
Returns the union of the receiver group and grp.
C equivalent: MPI_Group_union()
Parallel Ruby - pp1134יוני 2003 3
Constructors
MPI::Op.create(proc, commute)
Returns a new MPI::Op based on the Proc object proc. proc must accept two arguments. If commute is true, proc is considered to be commutative.
C equivalent: MPI_Op_create()
Parallel Ruby - pp1135יוני 2003 3
Constructors
MPI::Keyval.create(uniq)
Returns a new MPI::Keyval. If uniq is true, then the attribute associated with a keyval will be deleted from the original communicator to which it was attached when that communicator is duplicated. If uniq is false, then the attribute will simply be copied to the new communicator.
C equivalent: MPI_Keyval_create()
Parallel Ruby - pp1136יוני 2003 3
Informational Methods
MPI::Request#null()?
Returns true if the request is null.
C equivalent: request == MPI_REQUEST_NULL
Wait Methods
Test Methods
Initiation and Cancellation
Accessors
Parallel Ruby - pp1137יוני 2003 3
Informational Methods
MPI::Status#source()
Returns the source of the message to which the status
object refers.
C equivalent: status.MPI_STATUS
Parallel Ruby - pp1138יוני 2003 3
An exception class used for passing back MPI errors
Parallel Ruby - pp1139יוני 2003 3
Parallel computation (with MPI) of PI in two languages
1 .C.
2 .Ruby.
Comparison between two programs.
Parallel Ruby - pp1140יוני 2003 3
Parallel Ruby - pp1141יוני 2003 3
Parallel Ruby - pp1142יוני 2003 3
http://www.ruby-lang.org/en/
http://www.ruby-lang.org/en/hotlinks.html
http://www-unix.mcs.anl.gov/mpi/mpi_ruby/
http://www.ddj.com/articles/2002/0209/
http://www.rubygarden.org/ruby
http://www.rubycentral.com/
[email protected] - Matz
[email protected] - Emil Ong