CS 377P: Programming for Performance

Assignment 5: Shared-memory parallel programming

Due date: April 13th, 2020, 9:00 PM

Late submission policy: Submission can be at the most 2 days late with 10% penalty for each day.

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. Use a separate file for each modification. Submit a pdf report and a tar.gz file including all your code files in Canvas.

Numerical integration to compute an estimate for pi:

            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:

Notes: