Docsity

CS415/515 Advanced Parallel Programming - Message Passing with LAM MPI System - Prof. Jing, Study Guides, Projects, Research of Computer Science

Toggle sidebar
bg1
Spring ’09: CS415/515 Advanced Parallel Programming 5/07/09
Prof. Ji ngke Li(FAB 120-06, [email protected]); Classes: TTh noon-1:50pm @ FAB150; Office Hours: TTh 10-11am.
Programming Project #3
(Due Thursday, 5/21/09 @ noon)
This project is to practice basic message-passing programming with the LAM MPI system. For this
project, you’ll need to use the CS Linux machines.
1. Preparation. LAM MPI (version 7.1.2) is already installed on the CS Linux machines. You just need
to create one or more LAM host files in your home directory. The following are the names of available
Linux machines:
african chatham chinstrap emperor erect-crested fiordland galapagos
gentoo king kororaa little macaroni magellanic rockhopper royal
snares white-flipper yellow-eyed
You may want to create two host files, one containing just two notes for debugging use, and the other
containing all nodes for timing use.
2. A simple ring program. Read and understand the attached program trivial.c. Compile and run
it. Now write a program ring1.c. Instead of sending and receiving a message between two processes,
your program will involve all processes that are active in the MPI run (Note: the total number of
processes is not controlled by an MPI program itself.)
In your program, process 0 (i.e. process with rank==0) sends a message containing an arbitrary integer
number (say 10) to process 1; upon receiving the number, process 1 decreases its value by 1, and sends
the new number to process 2; and this goes on. The last process in the chain decreases the number it
receives by 1, and sends it back to process 0. Like in trivial.c, each process should make the sending
and receiving of messages visible by printing out a message containing it’s rank and the integer’s value,
and it should terminate itself after printing.
A sample output from the new program is shown here:
mpirun -v N ring1
8442 ring1 running on n0 (o)
4962 ring1 running on n1
7165 ring1 running on n2
23380 ring1 running on n3
rank 1 received integer 10
rank 1 sent integer 9
rank 2 received integer 9
rank 2 sent integer 8
rank 3 received integer 8
rank 3 sent integer 7
rank 0 sent integer 10
rank 0 received integer 7
3. A second ring program. Copy your program ring1.c to ring2.c, and extend it as follows.
(a) The program reads in two command-line arguments, low and high; and convert them both to
integers. Verify that low <= high. (Note: In LAM/MPI, command-line arguments are passed at
the end of mpirun command with a preceding double dash --, e.g.:
mpirun N <program> -- <arg1> <arg2>)
1
pf2

Partial preview of the text

Download CS415/515 Advanced Parallel Programming - Message Passing with LAM MPI System - Prof. Jing and more Study Guides, Projects, Research Computer Science in PDF only on Docsity!

Spring ’09: CS415/515 Advanced Parallel Programming 5/07/ Prof. Jingke Li(FAB 120-06, [email protected]); Classes: TTh noon-1:50pm @ FAB150; Office Hours: TTh 10-11am.

Programming Project

(Due Thursday, 5/21/09 @ noon)

This project is to practice basic message-passing programming with the LAM MPI system. For this project, you’ll need to use the CS Linux machines.

  1. Preparation. LAM MPI (version 7.1.2) is already installed on the CS Linux machines. You just need to create one or more LAM host files in your home directory. The following are the names of available Linux machines:

african chatham chinstrap emperor erect-crested fiordland galapagos gentoo king kororaa little macaroni magellanic rockhopper royal snares white-flipper yellow-eyed

You may want to create two host files, one containing just two notes for debugging use, and the other containing all nodes for timing use.

  1. A simple ring program. Read and understand the attached program trivial.c. Compile and run it. Now write a program ring1.c. Instead of sending and receiving a message between two processes, your program will involve all processes that are active in the MPI run (Note: the total number of processes is not controlled by an MPI program itself.) In your program, process 0 (i.e. process with rank==0) sends a message containing an arbitrary integer number (say 10) to process 1; upon receiving the number, process 1 decreases its value by 1, and sends the new number to process 2; and this goes on. The last process in the chain decreases the number it receives by 1, and sends it back to process 0. Like in trivial.c, each process should make the sending and receiving of messages visible by printing out a message containing it’s rank and the integer’s value, and it should terminate itself after printing. A sample output from the new program is shown here:

mpirun -v N ring 8442 ring1 running on n0 (o) 4962 ring1 running on n 7165 ring1 running on n 23380 ring1 running on n rank 1 received integer 10 rank 1 sent integer 9 rank 2 received integer 9 rank 2 sent integer 8 rank 3 received integer 8 rank 3 sent integer 7 rank 0 sent integer 10 rank 0 received integer 7

  1. A second ring program. Copy your program ring1.c to ring2.c, and extend it as follows.

(a) The program reads in two command-line arguments, low and high; and convert them both to integers. Verify that low <= high. (Note: In LAM/MPI, command-line arguments are passed at the end of mpirun command with a preceding double dash --, e.g.: mpirun N -- )

(b) The program allocates an integer array of size high. (Process 0 may initialize its array with any values, though it’s optional.) (c) The program executes a sequence of tests. In each test, a message of certain size gets sent around the ring from process 0. (The message eventually gets back to process 0.) The allocated array serves as both the send and receive buffers. (d) The message sizes for the tests are defined by the number of array elements to be sent/received, ranging from low to high, with each test doubles the previous test’s message size. So the sequence of tests can be expressed by the following loop header for (cnt = low; cnt <= high; cnt *= 2) (e) Use MPI Wtime() routine to collect timing result for each test: for each test process 0 call Wtime (start clock) send message around the ring process 0 call Wtime again (stop clock) process 0 computes the elapsed time Don’t forget to delete all printf statements before conducting timing measurements. (f) The program should repeat the tests 5 times. And it should compute the min, max, and average of the elapsed time for each test. At the end, the program should print out the timing results.

Execution Requirements:

  • For testing your ring1 and for collecting timing results in ring2, run each program with at least 8 hosts in the ring.
  • Don’t forget to run lamhalt to terminate your LAM daemons after you are done with running your programs.

What to Turn In:

Zip your two programs and a short summary about the project; submit it to [email protected]. (Note: From this project on, please submit to my email account.)