Skip navigation.

Blu3c4t Journal

randomly blu3c4t's logs on the shell...

Installing Octave+MPITB on FreeBSD

For scientific computing purpose we need more powerful computing technique and to provide that we can using message passing paradigm to boost the performance of our application which run in parallel mode on cluster computers. Now, I just want to show process that I do to install Octave (Matlab-like application) and MPITB (as Octave connector library to MPI middleware) on FreeBSD based cluster. I'm using FreeBSD 6.3-Release, Octave 2.1.73, mpitb-beta-FC6-OCT2912-LAM713-OMPI123, dan LAM-MPI 7.1.4 (or we can use OpenMPI 1.2.3).
What is Octave ?
Octave is a high-level language, primarily intended for numerical computations. It provides a convenient command line interface for solving linear and nonlinear problems numerically, and for performing other numerical experiments. It may also be used as a batch-oriented language.
What is MPI ?
MPI (Message Passing Interface) is middleware for doing distributed computation based on Single-Program-Multiple-Data (SPMD) programming model or specifically is a specification for an API that allows many computers to communicate both point-to-point and collective communication are supported. Although MPI belongs in layers 5 and higher of the OSI Reference Model, implementations may cover most layers of the reference model, with socket and TCP being used in the transport layer.
Most MPI implementations consist of a specific set of routines (i.e., an API) callable from Fortran, C, or C++ and from any language capable of interfacing with such routine libraries. The advantages of MPI over older message passing libraries are portability (because MPI has been implemented for almost every distributed memory architecture) and speed (because each implementation is in principle optimized for the hardware on which it runs). It is used in computer clusters and supercomputers.
What is LAM-MPI/OpenMPI ?
LAM (Local Area Multicomputer) is an MPI programming environment and development system for heterogeneous computers on a network. With LAM, a dedicated cluster or an existing network computing infrastructure can act as one parallel computer solving one problem. LAM features extensive debugging support in the application development cycle and peak performance for production applications. LAM features a full implementation of the MPI communication standard. And OpenMPI is a project combining technologies and resources from several other projects (FT-MPI, LA-MPI, LAM-MPI, and PACX-MPI) with the stated aim of building the best Message Passing Interface (MPI) library available. It is used by many TOP500 supercomputers including Roadrunner, which is as of 2008 the world's fastest supercomputer.
Install !!!

With an assumption that specific host configuration for LAM-MPI or OpenMPI implementation in our cluster is already done and running well. Now, we can start to install Octave via FreeBSD's ports :
$ whereis octave 
octave: /usr/ports/math/octave
$ cd /usr/ports/math/octave
$ sudo make install clean
...

Make sure you have a shared-libraries LAM installation available in all nodes in your cluster :
$ ls `laminfo -path libdir | cut -d: -f2` | grep "libmpi"                                  
libmpi.a
libmpi.la
libmpi.so
libmpi.so.0
Notice the libXXX.so dynamic libraries, as opposed to the static libXXX.a ones. Recompile LAM (configuring with --enable-shared) or OpenMPI (not overriding with --disable-shared the default) if you have no .so libraries. Do not forget to double-check that the same installation is available in all nodes :
Make sure your octave executable has been compiled with DLD support, and it's the same version in all cluster nodes.
$ octave
octave-2.1.73:3> octave_config_info
ans =
{
  dld = 1
  exec_prefix = /usr/local
  fcnfiledir = /usr/local/share/octave/2.1.73/m
  ...
  SHARED_LIBS = true
  SHLEXT = so
  SHLEXT_VER = so.2.1.73
  SH_LD = cc
  SH_LDFLAGS = -shared
  ...
  octfiledir = /usr/local/libexec/octave/2.1.73/oct/i386-portbld-freebsd6.3
  octincludedir = /usr/local/include/octave-2.1.73
  octlibdir = /usr/local/lib/octave-2.1.73
  prefix = /usr/local
  startupfiledir = /usr/local/share/octave/2.1.73/m/startup
  unix = 1
  version = 2.1.73
  windows = 0
  words_big_endian = 0
  words_little_endian = 1
}

Notice the dld=1 line. Recompile Octave (configuring with --enable-shared) if you haven't it.

Then download MPITB, and unpack the archive and put it to /usr/local/libexec/octave/2.1.73 :
$ sudo tar -xjvf mpitb-beta-FC6-OCT2912-LAM713-OMPI123.tar.bz2 -C /usr/local/libexec/octave/2.1.73

Because precompiled binary not working on FreeBSD system, then we need to recompile mpitb :
$ cd /usr/local/libexec/octave/2.1.73/mpitb
$ rm DLD*
$ mkdir DLD-LAM7.1.4
$ ln -s DLD-LAM7.1.4 DLD
$ rm src
$ ln -s src-2.1.73 src
$ cd src-2.1.73/
$ rm Makefile.inc
$ ln -s Makefile.inc.LAM Makefile.inc
$ gmake
...

WE need a bhost file to boot a LAM-MPI. Recent LAM versions will pick a ./lam-bhost.def file if it exists in your current directory, instead of just relying on a $LAMBHOST environment variable pointing to the file. This greatly simplifies configuration, since most users will never use $LAMBHOST. Simply create ./lam-bhost.def and add some hostnames on which you have an account. See "man bhost" if you require special syntax for multiprocessors or for different username on those hosts. Then boot the LAM :
$ lamboot -x -v
$ pwd
/home/blu3c4t
$ ln -s /usr/local/libexec/octave/2.1.73/mpitb/startups/startup_MPITB.m  .octaverc

Modify file .octaverc like this:
%%%%%%%%
% PATH %
%%%%%%%%
L=path;

###if using openmpi instead lam-mpi
#r = '/usr/local/mpi/openmpi/lib';
#putenv('LD_LIBRARY_PATH', r);

p = getenv('MPITB_HOME');
if isempty(p)
 p= '/usr/local/libexec/octave';
    putenv('MPITB_HOME', p)
end

q = '/usr/local/libexec/octave/2.1.73/mpitb/mpi/';
#if exist(q, 'dir'), clear p q, error('MPI Toolbox not found (help files)'), end
L=path(L,q);
q = '/usr/local/libexec/octave/2.1.73/mpitb/DLD/';
#if exist(q, 'dir'), clear p q, error('MPI Toolbox not found (DLD files)'), end
L=path(L,q);
q = '/usr/local/libexec/octave/2.1.73/mpitb/startups/';
#if exist(q, 'dir'), clear p q, error('MPI Toolbox not found (startups)'), end
L=path(L,q);
q = '/usr/local/libexec/octave/2.1.73/mpitb/utils/';
#if exist(q, 'dir'), clear p q, error('MPI Toolbox not found (utilities)'), end
L=path(L,q);

% q = [p '/<myappname>'];
% if ~exist(q, 'dir'), clear p q, error('<myappname> not found'), end
% L=path(L,q);

clear p q L

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Greeting / Slave startup %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ignore_function_time_stamp='all';

if isempty(getenv('LAMPARENT'))% Parent task - welcome message
  disp('     .::Octave on Blu3c4t Box::.')
  disp('Set SSI rpi to tcp with the command:')
  disp('->  putenv(''LAM_MPI_SSI_rpi'',''tcp''), MPI_Init')
  disp('Help on MPI: help mpi')
% disp('Help on this demo: help <myappname>')

else% spawned Octave process

end  


Test it :
$ octave
     .::Octave on Blu3c4t Box::.
Set SSI rpi to tcp with the command:
->  putenv('LAM_MPI_SSI_rpi','tcp'), MPI_Init
Help on MPI: help mpi
octave-2.1.73:1> MPI_Init
ans = 0
octave-2.1.73:2> MPI_Finalize
ans = 0
octave-2.1.73:3> quit

If you don't get error messages, then our installation is success. If you get errors, you must solve them before using MPITB under Octave. LAM-MPI must be already booted when you use MPI_Init from inside Octave (ok, system("lamboot") would have worked too. For LAM-related errors, read the LAM-MPI FAQ :
http://www.lam-mpi.org/faq/

Ok, now you can run this simple 'helloworld' octave script to test the cluster :
function Hello
  info       =  MPI_Init;
  [info rank] =  MPI_Comm_rank (MPI_COMM_WORLD);
  [info size] =  MPI_Comm_size (MPI_COMM_WORLD);
  [info name] =  MPI_Get_processor_name;

  fprintf("Hello, MPI_COMM_world! My rank is %d/%d (%s)\n", rank, size, name);

  info       =  MPI_Finalize;

MPITB_Clean
Save it as Hello.m . And, I just have 3 nodes on my cluster, so we will running that helloworld script on them :
$ cat lam-bhost.def
h1
h2
h3

$ mpirun -c 3 -hostfile lam-bhost.def octave -q --eval Hello
Hello, MPI_COMM_world! My rank is 0/3 (h1)
Hello, MPI_COMM_world! My rank is 1/3 (h2)
Hello, MPI_COMM_world! My rank is 2/3 (h3)

You can try and modify another demo scripts which available at MPITB directory. And I wrote papers about MPI programming (in Indonesian language), you can download it below. Ok, that's all folks, hope you enjoy!

MPI_Middleware.pdf
Makalah_Jacobi_Parallel.pdf

Learn QtInstalling OMNet++ on FreeBSD

How to use Quote function:

  1. Select some text
  2. Click on the Quote link

Write a comment

Comment
(BBcode and HTML is turned off for anonymous user comments.)

If you can't read the words, press the small reload icon.


Smilies