Skip navigation.
Home

Parallel and MPI Octave

There are some excellent packages for GNU Octave, the free and open-source numerical computation language that is "highly compatible" with the proprietary and closed-source MATLAB (tm).

Two excellent packages are the parallel and MPI packages. Installation is fairly trivial; from the Octave prompt simply run the command pkg install package-1.0.0.tar.gz. To run the package simply load it (e.g., pkg load pkgname). Note that the MPI package will not install in Octave 3.6.3 and lower, as it replaced openmpi_ex.

Compared to running similar parallel and MPI packages in MATLAB, GNU Octave's features on this are beautifully simple. Compare the following two traditional examples, based on a interactive job submission on a cluster.

For the parallel package:


[lev@trifid ~]$ qsub -I
qsub: waiting for job 483171.trifid-m.hpc.vpac.org to start
qsub: job 483171.trifid-m.hpc.vpac.org ready
[lev@trifid178 ~]$ module load octave/3.6.3
[lev@trifid178 ~]$ octave -q
warning: X11 DISPLAY environment variable not set
octave:1> fun = @(x) x^2;
octave:2> vector_x = 1:10;
octave:3> pkg load parallel
octave:4> fun = @(x) x^2;
octave:5> vector_x = 1:10;
octave:6> vector_y = pararrayfun(nproc, fun, vector_x)
parcellfun: 10/10 jobs done
vector_y =
1 4 9 16 25 36 49 64 81 100


[lev@trifid ~]$ qsub -l walltime=0:10:0,nodes=1:ppn=2 -I
[lev@trifid178 ~]$ module load octave/3.6.4
[lev@trifid178 ~]$ module load openmpi-gcc
[lev@trifid178 ~]$ mpirun -np 2 octave -q --eval 'pkg load mpi; Pi ()'
warning: X11 DISPLAY environment variable not set
warning: X11 DISPLAY environment variable not set
ans =
scalar structure containing the fields:
pi = 0
err = 0
time = 0
results =
scalar structure containing the fields:
pi = 3.1416
err = 1.9185e-13
time = 0.47692
ans =
scalar structure containing the fields:
pi = 3.1416
err = 1.9185e-13
time = 0.47692
[lev@trifid178 ~]$