Saturday October 11, 2014
This problem challenges you to create a hybrid MPI+OpenMP model of a water cycle in a pan of water.
The model in this problem is based on Shodor's Pan Water Cycle model (http://www.shodor.org/talks/ncsi/vensim/pan_water_cycle.html). You may find it helpful to reference that model as you solve the problem.

This challenge problem is also similar to three previous "Hybrid Parallel" challenge problems, and you may find it helpful to reference those as you solve the problem:
http://hpcuniversity.org/students/weeklyChallenge/81/
http://hpcuniversity.org/students/weeklyChallenge/82/
http://hpcuniversity.org/students/weeklyChallenge/83/

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 of the pan water cycle with different parameters. The parameters are determined by the thread's MPI rank and OpenMP thread number, as follows:

Condensation factor = MPI rank / (MPI size - 1),
unless MPI size is 1, in which case Condensation factor = 0

Precipitation factor = OpenMP thread number / (OpenMP num threads - 1),
unless OpenMP num threads is 1, in which case Precipitation factor = 0

The other parameters in the model are constant for all threads:
Temperature = 100
Evaporation per degree = 0.05
Initial amount of water in pan = 100
Initial amount of water on cover = 0
Initial amount of water in air = 0
Number of time steps = 10

At each time step, each OpenMP thread calculates the condensation, precipitation, and evaporation, as well as the new amount of water in the pan, on the cover, and in the air, as follows:
Condensation = Condensation factor * Amount of water in air.
Precipitation = Precipitation factor * Amount of water on cover.
Evaporation = Temperature * Evaporation per degree.
New amount of water in pan = Old amount of water in pan + Precipitation - Condensation.
New amount of water on cover = Old amount of water on cover + Condensation - Precipitation.
New amount of water in air = Old amount of water in air + Evaporation - Condensation.

At the end of the simulation, the thread stores its final water amounts in 3 arrays, one for each type of water, indexed by the thread's OpenMP thread number. Thus, each MPI process will have 3 arrays that contain all of its threads' final amounts of water.

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 the Condensation factor, Y is the Precipitation factor, A is the final amount of water in the pan, B is the final amount of water on the cover, and C is the final amount of water in the air. 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 3 MPI processes and 11 OpenMP threads is provided in the "Hybrid Parallel Pan Water Cycle sample output" file below.
Show solution
Challenge Resources:
©1994-2020   |   Shodor   |   Privacy Policy   |   NSDL   |   XSEDE   |   Blue Waters   |   ACM SIGHPC   |   feedback  |   facebook   |   twitter   |   rss   |   youtube   |   XSEDE Code of Conduct   |   Not Logged In. Login