Monday December 8, 2014
This problem concerns an agent-based model of an ideal gas. You are challenged to write an OpenMP parallel version of the model given an already-written serial (non-parallel) version in C.
This problem concerns an agent-based model of an ideal gas and is based on Shodor's Ideal Gas Model (see the bottom of Two rectangular 2D flasks are connected via two stopcocks, one for each flask. Inside the first flask, a 2D block of gas particles is initially placed. At each time step, these particles move randomly into empty adjacent cells. The stopcocks are located between the two flasks, and each has an area of 1 cell. If a particle is adjacent to a stopcock, it may enter it. In this way, particles can move from flask 1 to flask 2 and vice versa.

At each time step in the simulation, ratios are calculated for the numbers of particles and volumes of each flask. At the end of the simulation, a final ratio is printed. This ratio is a ratio of ratios: (the number of particles in flask 1 to the number of particles in flask 2) to (the volume of flask 1 to the volume of flask 2).

A serial (non-parallel) version of the model in C is provided to you below in the "Parallel Ideal Gas starter zip file". This zip file contains the code, a Makefile, and a README with instructions on compiling and running the program.

Your challenge is to create an OpenMP version of the program. Your program should spawn OpenMP threads, and each thread should run a separate instance of the simulation. Each thread should calculate a value for the final ratio, and the master thread should average these values and print the final result.

To avoid cluttering the output, your program should only print the final ratio, not the ASCII pictures of each time step.
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