9. Parallelize traffic model using OpenMP
You are going to parallelize the Nagel-Schreckenberg model, which you implemented in the last assignment. For fairness, since the submitted implementations were rather divergent in completeness and approach, for this assignment, start from the reference solution which can be git-cloned on the Teach cluster with
$ git clone /scinet/course/phy1610/trafficYou should note that this is an 'agent-based' implementation, i.e., an implementation that keeps track of the positions and velocities of the N cars as (two) vectors of length N. An alternative representation, the 'grid' representation, which assigns a value to every point on the road of length L (used by some of you in your solution to assignment 8), is here only used in the netcdf output routines.
You will see that the default parameters in params.ini are larger than they were in assignment 8. This makes the simulation take longer and will show the effects of parallization better.
In addition, there's a new parameter per in params.ini, which controls how often output is done. In params.ini, per is set to 100, which means the cars positions and velocities are only output once every 100 time steps.
Your task is as follows:
- Speed up this code using shared-memory parallelism, by adding OpenMP directives and thread-safe mechanisms for the pseudo-random number generator as discussed in class. Remember to always use default(none) in pragma omp parallel directives.
- You should parallelize as much as possible, but you do not have to parallelize the netcdf output routines.
- In addition to parallelizing the code, you should write one or more job scripts that can be submitted to the SLURM scheduler on the Teach cluster, and that would run the applications for values of the number of threads ranging from 1 to 16 and record the timings.
- Make a plot of the speedups, and, assuming Amdahl's law holds, try to estimate the serial fraction f by fitting to Amdahl's law.
- Write a one-paragraph report on the outcomes of the scaling analysis.
Add the plots and report to the git repo, and submit its git2zip-ed version. Submission deadline is April 2, 2021 at 11:55 PM. The usual penalty for late submissions applies.
- 14 août 2023, 16:29