1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
|
Octave parallel execution package for cluster computers
Description
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
operating systems).
Requirements
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
computer.
$ 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
or
$ octave
> script
Command references
connect (hosts)
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".
For example,
send ([ 1+2i, 3; 4, 5+6i ],sockets(2:3,:));
The variable can be any Octave data type.
recv (socket)
Receive a variable from the computer specified by the row vector "socket".
For example,
recv (sockets(1,:))
=> [ 1+2i, 3; 4, 5+6i ]
reval (commands, sockets)
Evaluate "commands" at the remote hosts specified by the matrix "sockets".
For example,
reval ([ "a=[ 1:3 ]"; "a=a'*a" ],socket(2,:));
sclose (sockets)
Close the connections specified by the matrix "sockets".
Returns zero on success, or nonzero if an error occurred.
For example,
sclose (sockets);
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.
Sample program:
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".
clear;
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,:));
sum(psum)
scloseall(sockets);
In the following script, the variable s="Hello, again!"
passes through 4 computers.
clear;
hosts = [ "host1"; "host2"; "host3"; "host4" ];
sockets = connect(hosts);
s="Hello, again!";
send(s,sockets(2,:));
reval( "s=recv(sockets(1,:));",sockets(2,:));
reval( "send(s,sockets(3,:));",sockets(2,:));
reval( "s=recv(sockets(2,:));",sockets(3,:));
reval( "send(s,sockets(4,:));",sockets(3,:));
reval( "s=recv(sockets(3,:));",sockets(4,:));
reval( "send(s,sockets(1,:));",sockets(4,:));
s2=recv(sockets(4,:))
scloseall(sockets);
License:
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:
h_fujiwara@users.sourceforge.net
|