This quick tutorial will show you how to use MPI on the rlogin nodes – either OpenMPI or mpich. MPI (message passing interface) is primarily used to parrallelize applications. To use MPI on rlogin you will need to set up the environment. You can do this by loading modules.
Use the following command to list available modules:
module avail
Use the following command to assign a module:
module add <name>
You will likely want to add this command to your .bashrc file so it is run during non-interactive shell processes.
Example with 64 parallel processes on the local machine:
$ module add mpi/openmpi-x86_64 $ mpicc program.c $ mpiexec -np 64 a.out Send/Recv with 64 processes: Count,Mintime 1,7.734e-05 2,4.558e-05 4,4.998e-05 8,4.872e-05 16,5.183e-05 32,4.664e-05 64,6.570e-05 128,7.245e-05 256,8.883e-05 512,1.126e-04 1024,6.448e-04 2048,9.037e-04 4096,1.149e-03 8192,1.396e-03 16384,1.767e-03 32768,2.495e-03 65536,4.006e-03 131072,7.112e-03 262144,1.502e-02 524288,2.938e-02 Complete $
To run MPI on multiple nodes, you will need to do the following:
Set up SSH key login:
$ ssh-keygen -t rsa . . . $ cat .ssh/id_rsa.pub >> .ssh/authorized_keys $
Add the module command to your .bashrc file:
$ echo "module add mpi/openmpi-x86_64" >> ~/.bashrc $
Create a text file with the hostnames you want to run MPI on:
$ echo $'birch.rlogin\nmaple.rlogin\nhackberry.rlogin' > hosts.txt $
Run MPI:
$ mpiexec -np 3 --hostfile hosts.txt a.out Send/Recv with 3 processes: Count,Mintime 1,4.588e-06 2,3.211e-06 4,2.995e-06 8,3.070e-06 16,3.280e-06 32,3.807e-06 64,4.789e-06 128,6.596e-06 256,9.447e-06 512,9.391e-06 1024,2.140e-05 2048,3.866e-05 4096,5.744e-05 8192,1.063e-04 16384,1.657e-04 32768,2.829e-04 65536,5.118e-04 131072,9.384e-04 262144,1.794e-03 524288,3.517e-03 Complete $