15 Agustus 2010

Installing MPICH2 on Ubuntu

Installing MPICH2 parallel computing from package manager or Ubuntu software center, will need lot configurations of available real processors in the system environment.
There for using MPICH2 from available .tar or .gz package is easier.




To download MPICH2 package goto here:http://www.mcs.anl.gov/research/projects/mpich2/downloads/index.php?s=downloads

or use here

Direct link for mpich2-1.3a2.tar.gz

change user to root or user super user privilege on every command


sudo -i


cd to the package location :
#cd /location

Then uncompress the package
#tar xzvf filename.tar.gz

go to the 'package root' :
#cd filename

then configure environment

#./configure


compile the package
# make


install the compiled package

#make install 

Another small thing to do to start the mpich2 daemon:

insert the following 3 lines to the /usr/local/bin/mpdlib.py as root

import warnings
warnings.filterwarnings('ignore', '.*the md5 module is deprecated.*', DeprecationWarning)
warnings.filterwarnings('ignore', '.*the popen2 module is deprecated.*', DeprecationWarning)

file may look like this:



then, make the user specific configuration file:

cd $HOME
touch .mpd.conf
chmod 600 .mpd.conf
gedit .mpd.conf

add the following line to the newly created .mpd.conf file

MPD_SECRETWORD=secret

now its time to start the daemon process for MPICH2

use either:

mpd or mpd &

 Now its time to enjoy your Parallel programming lessons...

here is a sample parallel program,

#include
#include

int main(int argc,char** argv)
{
int p_id,size;

MPI_Init(&argc,&argv);
MPI_Comm_rank(MPI_COMM_WORLD,&p_id);
MPI_Comm_size(MPI_COMM_WORLD,&size);

printf("Hello from prpcess %d of %d \n",p_id,size);
MPI_Finalize();
return 0;
}


save this in a 'hpc.c' file.

compile the application

mpicc hpc.c -o hello

change access to executable of the output file

chmod +x ./hello

run the application

mpirun -np 4 ./hello

here -np 4 gives the number of processors for the application to be run on.

Final output of the above program will be something like this(warning message exists)



for further readings of parallel computing tutorials, please stay with my blog.

Discussion on any problems are welcome... :-)

regards,
chandpriyankara@engineering.com