Scientific Computing & Visualization
Help Contact
About Accounts Computation Visualization Documentation Services

Multiprocessing by Message Passing MPI

MPMD (Multiple Program Multiple Data) Programming Paradigm

Once again, we will use the Numerical Integration Example to demonstrate the MPMD programming paradigm. All parallel implementations of this example to demonstrate many basic MPI functions have been of the SPMD style. Here, we will convert one of them into a MPMD program by separating it into a master program and a worker program. The master is responsible for computing its share of the integration as well as the final summation of local integrations sent in by all other participating processes (i.e., workers). On the other hand, the worker program is responsible for computing its local integration and, upon completion, send the result back to the master process. There is need for only one worker program in this case since all workers perform identical task but on different data.

Compiling and linking MPMD programs are no different than for SPMD programs other than the fact that there are multiple programs to compile instead of one. If corresponding executables for the master and worker programs are called mpmd_master and mpmd_worker, job execution may be exercised in the following ways:

twister:~/MPI/mpmd % poe -procs 3 -pgmmodel mpmd
0031-503  Enter program name and flags for each node
0:loopback> mpmd_master
1:loopback> mpmd_worker
2:loopback> mpmd_worker
 myid= 0 ,  my_result= 0.5000001788
 myid= 1 ,  my_result= 0.3660252690
 myid= 2 ,  my_result= 0.1339745522
 Final Result = 1.000000000

In the above interactive job, we request 3 processors and specify that the MPMD paradigm be used. Otherwise, by default, the SPMD paradigm would be in effect. In addition, as a result of the MPMD mode, poe prompts the user to provide the name of the executables to be used in the job. Note that the input order of the executables are important. The first entry is assigned to process rank 0, which is followed by rank 1 for the second entry, and so on. For this example, the worker program sends data to the master which has been designated to be rank 0. Hence, it is imperative that mpmd_master appears as the first entry.

For batch processing or if console typing is not preferred, the information regarding the executables and their ordering may be saved in a file, say, cmdf. Then, poe submission takes the following form:

twister:~/MPI/mpmd % poe -procs 3 -pgmmodel mpmd -cmdfile cmdf

 myid= 0 ,  my_result= 0.5000001788
 myid= 1 ,  my_result= 0.3660252690
 myid= 2 ,  my_result= 0.1339745522
 Final Result = 1.000000000

Since the above command line flags for poe are also available as environment variables, a third form of job submission may also be used:

twister:~/MPI/mpmd % setenv MP_PGMMODEL mpmd
twister:~/MPI/mpmd % setenv MP_CMDFILE cmdf
twister:~/MPI/mpmd % poe -procs 3
 myid= 0 ,  my_result= 0.5000001788
 myid= 1 ,  my_result= 0.3660252690
 myid= 2 ,  my_result= 0.1339745522
 Final Result = 1.000000000
Documentation
Boston University
Boston University
 
OIT | CCS | September 16, 2008  
Scientific Computing & Visualization Boston University home page Boston University home page