Sunday, April 3, 2011

Getting Started with MPI with your laptop

Yes, to do something serious with MPI you need a cluster. But to try it out, you can do that in your laptop. Main setup should only take 10-15 minutes. Following is how to do it.


1. Download open MPI, http://www.open-mpi.org/software/ompi/v1.4/
2. Build by issuing ./configure and make
3. Write the mpi program and compile it with mpic++ -o hello hello.c
4. Run it with mpirun -np 10 hello. Here "hello" is the program and "-np" is the number of processes.

Note that to run N process program, you can run it in a single CPU. MPI will just run N OS processes. 

Well learning MPI might take some thinking. This and this might help. One thing to remember is that MPI model is bit different. If process 0 is broadcasting and all other processes are receiving the message, every process call MPI_Broadcast and call behave different on the root than in other processes. Good luck.