CS 377P: Programming for Performance

Assignment 5: Shared-memory parallel programming

Due date: Wednesday, November 9th, 2022, 10:00 PM CST



Partners: You can do this assignment with another student in the course. If you do, make sure you put both names on your report. Only one student needs to submit on Canvas.

Late submission policy: Submission can be at the most 2 days late. There will be a 10% penalty for each day after the due date (cumulative).

Clarifications: Clarifications to the assignment will be posted on Piazza.

In this assignment, you will implement parallel programs to compute an approximation to pi using the numerical integration program discussed in class. You will implement several variations of this program to understand factors that affect performance in shared-memory programs. Read the entire assignment before starting work since you will be incrementally changing your code in each section of the assignment, and it will be useful to see the overall structure of what you are being asked to do.

Numerical integration to compute an estimate for pi:

            How to compile (on orcrist machines): gcc -pthread pi.c -o pi -lm

            What to turn in:

            What to turn in:

              What to turn in:

             What to turn in:


std::atomic<double> pi{0.0};

void add_to_pi(double bar) {
  auto current = pi.load();
  while (!pi.compare_exchange_weak(current, current + bar));
}


            What to turn in:

           What to turn in:

What to turn in:

            What to turn in:

Submission instructions:

Only one partner needs to submit to Canvas. Make sure both your names are present in the submission or in a submission comment. Upload the following:

Notes: