From octave-sources-request at bevo dot che dot wisc dot edu Mon Oct 30 12:08:47 2000 Subject: MPI hack From: Andy Jacobson To: octave-sources at bevo dot che dot wisc dot edu Date: Mon, 30 Oct 2000 19:06:20 +0100 Howdy, This weekend, I grafted some MPI code into octave.cc with the result that I have a sort of parallelized Octave (v2.0.16, but it's portable) running under Linux and Solaris. I'm trying to minimize a nonlinear function which is expensive to compute, and I made this Frankenstein in order to farm the function evaluations out to a local network of workstations. The little test system I made doesn't do much right now, but it can get and set scalar variables in the local workspace of each client, and tell the clients to execute arbitrary octave commands. For proof of concept, I wrote a very simple driver which accepts commands and sends them to the clients, but I think the generalized SPMD solution would be more interesting. Here's an annotated example dialogue. When the clients start up, the variable "mpi_rank" is inserted into their local workspace. It is a scalar with the unique identifier of the process within the MPI application. In this example, the driver has rank 0 and the four clients have ranks 1-4. ~/packages/octave-2.0.16/src> mpirun -v appschema 17543 /home/jacobson/bin/octave-mpi-driver running on n0 (o) 17544 /home/jacobson/bin/octave-mpi running on n0 (o) 22532 /home/jacobson/bin/octave-mpi running on n1 25053 /home/jacobson/bin/octave-mpi running on n2 25154 /home/jacobson/bin/octave-mpi running on n3 mpi_set testvar <= send scalar double value of pi to clients, who create a local variable called testvar with this value testvar=testvar*mpi_rank <= arbitrary octave code using two variables in the local symtab mpi_get testvar <= clients send values of testvar back to the driver [r0] client at rank 1 reports that testvar is 3.141593 [r0] client at rank 2 reports that testvar is 6.283185 [r0] client at rank 3 reports that testvar is 9.424778 [r0] client at rank 4 reports that testvar is 12.566371 testvar=besselj(0,testvar) <= more arbitrary code mpi_get [r0] client at rank 1 reports that testvar is -0.304242 [r0] client at rank 2 reports that testvar is 0.220277 [r0] client at rank 3 reports that testvar is -0.181211 [r0] client at rank 4 reports that testvar is 0.157507 quit For those who are interested, I used the LAM/MPI implementation from Notre Dame (www.mpi.nd.edu). I would like to know how much interest there is in making this a more general tool. Due to the clean design of octave, the modifications necessary for this hack were surprisingly slight. What I think this could become without too much trouble is much more fun. The driver can go away and we can use an instance of octave as the server to do all the parsing and control for us. Finding a flexible way of passing octave_value objects back and forth is the obvious next step. Any takers? -Andy p.s. Is eval_string() really clumsy, inefficient or dangerously limited for any reason? That's how the clients execute their commands. -- andy-jacobson at psu dot edu ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------