Introduction to MPI - Exercise III
Write a parallel program using MPI to sum integers from
1 to 1000, using Send and Receive.
1. Copy send_mpi.c from /home/appl/mpiworkshop
2. Edit the partially developed parallel program send.c by following
the instructions in CAPITAL LETTTERS in the comments of the program.
- THIS TIME, the master will be the process with the highest rank/id (not 0)
- THIS TIME, you will not use an array to store the numbers to add
3. Compile/debug the program using the C compiler, linking in the MPI library:
/usr/local/apps/mpich-1.2.5(mpich-1.2.7p1)/bin/mpicc -o send.exe
Or linking in the PGI library:
/usr/local/apps/pgi-6.1/linux86/6.1/bin/pgcc -o send.exe send_mpi.c -lmpich
4. Run the executable, specifying the desired number of processes:
/usr/local/apps/mpich-1.2.5(mpich-1.2.7p1)/bin/mpirun -np 2 send.exe
(to run as 2 processes)
/usr/local/apps/mpich-1.2.5(mpich-1.2.7p1)/bin/mpirun -np 3 send.exe
(to run as 3 processes)
5. Debug and repeat, as necessary
6. (OPTIONAL) What happens when you run it on 4 nodes?
7. Modify send_mpi.c so that it will still work correctly even if
the number of slave processes does not evenly divide into the
number of elements to sum