Monday November 10, 2014
This problem challenges you to create a hybrid MPI+OpenMP model of a chemical reaction.
The model in this problem is based on Shodor's Chemical Reaction system dynamics model ( You may find it helpful to reference that model as you solve the problem.

This challenge problem is also similar to five previous "Hybrid Parallel" challenge problems, and you may find it helpful to reference those as you solve the problem:

Your task is to implement a hybrid MPI+OpenMP parallel program, wherein each MPI process spawns OpenMP threads. The threads are each responsible for running a simulation with different parameters. The parameters are determined by the thread's MPI rank and OpenMP thread number, as follows:

k1 = mpi_rank / 1000
k2 = thread_num / 100

The other parameters in the model are constant for all threads:
TIME_STEP = 0.0625

At each current_time_step from START_TIME through END_TIME, incrementing by TIME_STEP, each OpenMP thread performs the following calculations:
reactant{new} = reactant{old} - TIME_STEP * rxn_1{old}
intermediary{new} = intermediary{old} + TIME_STEP * (rxn_1{old} - rxn_2{old})
product{new} = product{old} + TIME_STEP * rxn_2{old}
rxn_1{new} = k1 * reactant{new} * intermediary{new}
rxn_2{new} = k2 * intermediary{new}

At the end of the simulation, the thread stores the final amounts of reactant, intermediary, and product in 3 arrays, one for each quantity. The arrays are shared by all threads and indexed by each thread's OpenMP thread number. Thus, each MPI process will have 3 arrays that contain all of its threads' final amounts.

Each MPI process is responsible for sending its final data to the MPI process rank 0, who is responsible for printing the results in the following format:

X1 Y1 A1 B1 C1
X2 Y2 A2 B2 C2
where X is k1, Y is k2, A is the final amount of reactant, B is the final amount of intermediary, and C is the final amount of product. This list of results should be ordered first by MPI rank and then by OpenMP thread number.

A sample output file for a working program running with 6 MPI processes and 6 OpenMP threads is provided in the "Hybrid Parallel Chemical Reaction sample output" file below.
Show solution
Challenge Resources:
©1994-2022   |   Shodor   |   Privacy Policy   |   NSDL   |   XSEDE   |   Blue Waters   |   ACM SIGHPC   |   feedback  |   facebook   |   twitter   |   rss   |   youtube   |   XSEDE Code of Conduct   |   Not Logged In. Login