The purpose of this programming assignment is to gain experience in parallel programming on a cluster and OpenMP. You will start with working serial versions of four different programs, and add OpenMP directives to parallelize them. You should examine the loops in the code and figure out how to add OpenMP directives. The programs will be run on a single compute node of zaratan. There are four different serial programs that solve different problems:
To compile OpenMP code, we will use gcc/g++ version 11.3.0 (the default version on
zaratan, which you can get by doing module load gcc
on the zaratan
login node), which nicely has OpenMP support built in. In general, you can
compile problems in this assignment with:
g++ -fopenmp -O2 -o problem1 problem1.cpp
The -fopenmp tells the compiler to, you guessed it, recognize OpenMP
directives.
The environment variable OMP_NUM_THREADS sets the number of
threads (and presumably cores) that will run the program. Set the value of this
environment variable in the script you submit the job from. The value of this variable defaults to
using all available cores, and you might
not want to do that always.
A sample batch script can be found here.
Each problem can run without any command line arguments to run a small test problem. This can be used to test correctness of your modified program. This is how you can test correctness for the default case:
Finally, we want you to time the problems to study their performance when using an increasing number of threads. To time your program, use omp_get_wtime() by placing one call before the function call you want to time and another after it. Sample timing code below:
double totalTime = 0.0;
double start = omp_get_wtime();
... work to be timed ...
totalTime = omp_get_wtime() - start;
printf("TIME %.5f\n", totalTime);
Also, in order to minimize performance variability, you
want to add these to your job submission steps or script:
#SBATCH --mem-bind=local
#SBATCH --exclusive
export OMP_PROCESSOR_BIND=true
You must submit the following files and no other files:
report-assign1.pdf
) that describes what you did.LastName-FirstName-assign1
), compress it to .tar.gz (LastName-FirstName-assign1.tar.gz
) and upload that to gradescope.
The project will be graded as follows:
Component | Percentage |
---|---|
Problem 1 Runs correctly on 4 and 16 threads | 10 + 10 |
Problem 2 Runs correctly on 4 and 16 threads | 10 + 10 |
Problem 3 Runs correctly on 4 and 16 threads | 10 + 10 |
Problem 4 Runs correctly on 4 and 16 threads | 15 + 15 |
Writeup | 10 |