Tutorial to install eoMpi module.
This commit is contained in:
parent
3613618544
commit
7c6e1f6200
2 changed files with 98 additions and 0 deletions
63
eo/tutorial/Parallelization/INSTALL
Normal file
63
eo/tutorial/Parallelization/INSTALL
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
How to install EoMPI
|
||||||
|
====================
|
||||||
|
|
||||||
|
Install OpenMpi
|
||||||
|
---------------
|
||||||
|
|
||||||
|
1) Download OpenMPI on their website or with the following command:
|
||||||
|
|
||||||
|
wget http://www.open-mpi.org/software/ompi/v1.6/downloads/openmpi-1.6.tar.bz2
|
||||||
|
|
||||||
|
2) Untar the downloaded archive in a directory and change working directory to there:
|
||||||
|
|
||||||
|
tar -xvjf openmpi*.tar.bz2
|
||||||
|
cd openmpi-X.Y
|
||||||
|
|
||||||
|
3) Use configuration script to indicate in which directory OpenMPI should be installed, and other options:
|
||||||
|
|
||||||
|
Simplest configuration:
|
||||||
|
./configure --prefix=/home/`whoami`/openmpi/
|
||||||
|
|
||||||
|
Only static libraries:
|
||||||
|
./configure --enable-static --disable-shared
|
||||||
|
|
||||||
|
Only static libraries, with prefix, disable build for Fortran77 and Fortran90, add support for SGE:
|
||||||
|
./configure --enable-static --disable-shared --prefix=/home/`whoami`/openmpi/ --disable-mpi-f77 --disable-mpi-f90 --with-sge
|
||||||
|
|
||||||
|
Other options are available in the README file.
|
||||||
|
|
||||||
|
4) Make it and install:
|
||||||
|
|
||||||
|
In sequential:
|
||||||
|
make all install
|
||||||
|
|
||||||
|
Or in parallel:
|
||||||
|
make -j 2 all
|
||||||
|
make install
|
||||||
|
|
||||||
|
5) Try to compile and run the sample program:
|
||||||
|
|
||||||
|
~/openmpi/bin/mpicxx -o sample mpi.c
|
||||||
|
~/openmpi/bin/mpirun -np 3 ./sample
|
||||||
|
|
||||||
|
Configure EO to use MPI
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
You only need to configure eo-conf.cmake so as to use MPI :
|
||||||
|
|
||||||
|
1) Put the WITH_MPI boolean to true:
|
||||||
|
|
||||||
|
SET(WITH_MPI TRUE CACHE BOOL "Use mpi ?" FORCE)
|
||||||
|
|
||||||
|
2) Indicate in which directories you have installed openmpi:
|
||||||
|
|
||||||
|
SET(MPI_DIR "/where/did/you/install/openmpi" CACHE PATH "OpenMPI directory" FORCE)
|
||||||
|
|
||||||
|
3) Recompile eo:
|
||||||
|
|
||||||
|
./distclean
|
||||||
|
./build_gcc_linux_release.sh
|
||||||
|
|
||||||
|
4) If you meet any issue, don't hesitate to contact the EO mailing list:
|
||||||
|
|
||||||
|
eodev-main@lists.sourceforge.net
|
||||||
35
eo/tutorial/Parallelization/mpi.c
Normal file
35
eo/tutorial/Parallelization/mpi.c
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
# include <mpi.h>
|
||||||
|
# include <stdio.h>
|
||||||
|
# include <string.h>
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int rank, size;
|
||||||
|
char someString[] = "Can haz cheezburgerz?";
|
||||||
|
|
||||||
|
MPI_Init(&argc, &argv);
|
||||||
|
|
||||||
|
MPI_Comm_rank( MPI_COMM_WORLD, & rank );
|
||||||
|
MPI_Comm_size( MPI_COMM_WORLD, & size );
|
||||||
|
|
||||||
|
if ( rank == 0 )
|
||||||
|
{
|
||||||
|
int n = 42;
|
||||||
|
int i;
|
||||||
|
for( i = 1; i < size; ++i)
|
||||||
|
{
|
||||||
|
MPI_Send( &n, 1, MPI_INT, i, 0, MPI_COMM_WORLD );
|
||||||
|
MPI_Send( &someString, strlen( someString )+1, MPI_CHAR, i, 0, MPI_COMM_WORLD );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
char buffer[ 128 ];
|
||||||
|
int received;
|
||||||
|
MPI_Status stat;
|
||||||
|
MPI_Recv( &received, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &stat );
|
||||||
|
printf( "[Worker] Number : %d\n", received );
|
||||||
|
MPI_Recv( buffer, 128, MPI_CHAR, 0, 0, MPI_COMM_WORLD, &stat );
|
||||||
|
printf( "[Worker] String : %s\n", buffer );
|
||||||
|
}
|
||||||
|
|
||||||
|
MPI_Finalize();
|
||||||
|
}
|
||||||
Reference in a new issue