Link to this document's Jupyter Notebook

In order to successfully complete this assignment you need to participate both individually and in groups during class. If you attend class in-person then have one of the instructors check your notebook and sign you out before leaving class on Monday February 15. If you are attending asynchronously, turn in your assignment using D2L no later than _11:59pm on Monday February 15.


In-Class Assignment: OpenMP Critical Sections and Basic Loops

image of puppies eating out of their bowls as an analogy for parallel programming. Basically we want it to be neat but it turns out chaotic

Agenda for today's class (70 minutes)

  1. (20 minutes) Pre class review
  2. (20 minutes) Scheduling Shared memory jobs
  3. (25 minutes) Benchmark Loops

1. Pre class review


2. Scheduling Shared memory jobs

Today we are going to submit OpenMP jobs to the cluster and verify they run properly by inspecting their output. To start lets use the classic OMP hello world program:

#include "omp.h"
#include "stdio.h"
int main()
{
    #pragma omp parallel
    {
        int ID = omp_get_thread_num();
        printf("hello(%d)",ID);
        printf(" world(%d) \n",ID);
    }
}

DO THIS: Compile and test the above program on the command line. make a submission script and run the program with 7 cores on the HPCC.

HINT: Try adding the srun command before your parallel commands. This command does some checks to make sure everything is running properly. Although not required for OpenMP (based on my tests), it definatly comes in handy with GPU and MPI jobs.


Congratulations, we're done!

If you attend class in-person then have one of the instructors check your notebook and sign you out before leaving class. If you are attending asynchronously, turn in your assignment using D2L.

Course Resources:

Written by Dr. Dirk Colbry, Michigan State University Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.