Octave parallel execution package for cluster computers
This is a package to add parallel computing functions to Octave. The
parallel computing functions are supported without any additional
parallel computing libraries such as MPI and PVM. The operation has
been confirmed only on Linux (but it may be applicable to other
1. GNU Octave 2.1.43 that is available at http://www.octave.org/
2. two or more computers
How to use
Note first that this package assumes the use in a multiple-computer
system consisting of a master (your console) computer and some
slave computers. Run Octave with argument "server.m" on every slave
$ octave /usr/local/share/octave/2.1.43/site/m/octave-forge/parallel/server.m
Run Octave without argument "server.m" on the master computer
$ octave -q -f script.m
Make bi-directional connections among the computers specified by
the matrix "hosts" and return the matrix of the sockets (file
descriptors) directed to the listed computers.
This command should be executed on the master computer before
starting parallel computation. For example,
you can execute the following command on the master computer:
connect ([ "host1"; "host2"; "host3" ])
=> [ 0, 0; 5, 3; 6, 4 ]
where host1, host2 and host3 are the host names (or IP addresses).
In a typical situation, host1 is the master, and host2 and host3
are the slave computers. A pair of socket numbers (e.g., "5, 3")
is assigned to each host. As a side effect, this command automatically
issues the connect commands at the slave computers host2 and host3
in order to establish the connection from each slave computer
(host2 or host3) to the other master/slave computers. Note that
the return value of the connect command automatically executed
on each slave computer is stored in the variable "sockets". The
slave computer can refer this variable to send/receive data to/from
other computers. As a result, the bi-directional complete connection
among the listed computers is established.
send (x, sockets)
Send the variable "x" to the computers specified by matrix "sockets".
send ([ 1+2i, 3; 4, 5+6i ],sockets(2:3,:));
The variable can be any Octave data type.
Receive a variable from the computer specified by the row vector "socket".
=> [ 1+2i, 3; 4, 5+6i ]
reval (commands, sockets)
Evaluate "commands" at the remote hosts specified by the matrix "sockets".
reval ([ "a=[ 1:3 ]"; "a=a'*a" ],socket(2,:));
Close the connections specified by the matrix "sockets".
Returns zero on success, or nonzero if an error occurred.
Notes for the current version:
* The slave computer must have the directory whose name and path are
identical with the current directory of the master computer.
The following Octave script calculates the sum of the integers
from 1 to 100. The computation is divided into half and assigned
to "host2" and "host3".
hosts = [ "host1"; "host2"; "host3" ];
sockets = connect(hosts);
psum = zeros(1,2);
reval( "send(sum([1:50]),sockets(1,:))", sockets(2,:));
reval( "send(sum([51:100]),sockets(1,:))", sockets(3,:));
psum(1) = recv(sockets(2,:));
psum(2) = recv(sockets(3,:));
In the following script, the variable s="Hello, again!"
passes through 4 computers.
hosts = [ "host1"; "host2"; "host3"; "host4" ];
sockets = connect(hosts);
This package is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
Comments and suggestions should be directed to: