
The ``dsm'' in ``Rdsm'' stands for distributed shared memory, a term from the parallel processing community in which nodes in a cluster share (real or conceptual) memory. It is based on a similar package I wrote for Perl some years ago (Matloff (2002)).
MatMul.r
in the examples included in
this package serves as as a quick introduction, using a
matrix-multiply example common in parallel processing packages.
There are especially detailed comments in this example. Suppose for instance we wish to copy x
to y
. In a
message-passing setting such as x
and y
may
reside in processes 2 and 5, say. The programmer would write code
(described here in pseudocode)
send x to process 5
to run on process 2, and write code
receive data item from process 2
set y to received item
to run on process 5. By contrast, in a shared-memory environment,
the programmer would merely write
y <- x
which is vastly simpler.
This also means that it is easy to convert sequential Rcode to parallel
Packages such as
Most of these applications can also be done via non-shared memory paradigms, but the shared-memory paradigm makes the applications easier to develop, maintain and extend.
Data communication is binary in the case of vectors and matrices for
speed, but serialize
and unserialize
are used for lists.
Then:
srvr()
in your server window. (Or runsrvrinit()
and thensrvrloop()
;srvr()
is merely a convenience that calls both.)init()
.srvrinit()
. You must still rerun srvrloop
, but you
do not need to rerun init
on the client side.
Application-program The script
The main functions available in
alint(nclnt=NULL,nds=NULL)
Call this to create the client windows, and start anRprocess in
each one. Ifnds
is NULL, then this sets upnclnt
windows/Rprocesses onlocalhost
, i.e. the machine on
which the script is run.setldir(libdir)
This addslibdir
to theRlibrary search path at the
server and clients.setdir(cdir=NULL)
This changes the working directory tocdir
at each client.
Ifcdir
is NULL, then the client directories are changed to
the current working directory of theRprocess runing this
script.alinits(nclnt=NULL,nds=NULL)
This combinesalinit
andsetdir
(withcdir
NULL), as a convenience.cmdtoclnts(cmd)
This sends the commandcmd
, single-quoted, to all the
clients.loadrdsm()
This loadscmdtosrvr(cmd)
This sends the commandcmd
, single-quoted, to the
server.cmdtoall(cmd)
This sends the commandcmd
, single-quoted, to the server
and all the clients.alquit()
This call causes theRprocesses at the server and all the
clients to exit, and the corresponding windows to close. For example, suppose your m
, a 4x5
matrix variable of class dsmm
. If you wished to fill the
second column with 1, 2, 3 and 4, you would write
m[,2] <- 1:4
just as you would in ordinary R.
Note carefully that you must always use brackets with x
to
an ordinary Rvariable y
, write
y <- x[]
not y <- x
myinfo
, a list consisting of these components:
myid
: the ID number of this client, starting with 1nclnt
: the total number of clientsbarr()
: barrier operationlock()
: lock operationunlock()
: unlock operationwait()
: wait operationsignal()
: signal operationfa()
: fetch-and-add operationrpc()
: remote procedure call operationinit()
: initializes a client's connection to the serversrvrinit()
: initializes the serversrvrloop()
: runs the serversrvr()
: calls bothsrvrinit()
andsrvrloop()
dsmexit()
: called when a client has finished its work The
dsmv
, dsmm
and
dsml
, respectively. Indexing operations for these classes
communicate with the server to read or write the desired objects.
Again, all this is transparent to the
It should be noted that this is not just an issue with
Hess, Matthias et al (2003), Experiences Using OpenMP Based on Compiler Directive Software DSM on a PC Cluster, in OpenMP Shared Memory Parallel Programming: International Workshop on OpenMP Applications and Tools, Michael Voss (ed.), Springer, p.216.
Matloff, Norman (2002), PerlDSM: A Distributed Shared Memory System for Perl. Proceedings of PDPTA 2002, 2002, 63-68.