MPI installation on ubuntu server 12.04
Type a command below
$ sudo aptitude install openmpi-bin libopenmpi-dev
and after installation, check whether it has correctly done.
#include <mpi/mpi.h> int main( int argc, char *argv[] ) { int myid, numprocs; volatile int i; MPI_Init( &argc, &argv ); MPI_Comm_size( MPI_COMM_WORLD, &numprocs ); MPI_Comm_rank( MPI_COMM_WORLD, &myid ); printf( "Hello World! %d\n", myid ); for ( i = 0; i < 100000000; i++ ); MPI_Finalize(); return 0; }
save the above as mpihello.c, compile and run it like below
$ mpicc mpihello.c -W -Wall $ mpirun -np 4 ./a.out Hello World! 2 Hello World! 3 Hello World! 1 Hello World! 0