Introduction to TBB, continued

CS 300, Parallel and Distributed Computing (PDC)
Due Monday, January 19, 2015

Preliminary material

Laboratory exercises

  1. On a 32-core computer (either a thing or the MTL), create a lab8 subdirectory of your personal directory for work on the lab, and change directory to that directory.

  2. Begin with a copy of a version tbbprimesn.cpp from the previous lab, where n ≥ 4. Make a copy of that program in your lab8 directory, naming the copy sieve.cpp.

  3. Add a TBB parallel_for to parallelize the for loop for initializing your "premarked[]" array, i.e., the "marked[]" array of char that you use for precomputing an initial subset of primes.

    Notes:

    Compile, run, benchmark, record observations in a file lab8/README, and copy to tbbprimes10.cpp

  4. Next, use TBB's parallel_for to parallelize the loop for marking multiples of a given prime p in the array premarked[].

  5. Next, use TBB's parallel_for to parallelize the loop that assigns the starter set of primes to your (thread-safe!) concurrent_queue variable.

    This will require defining and using a body class, perhaps named PushPrimes. That class will need state variables for both premarked and your queue variable. Here, we don't want to construct new copies of that queue, so use reference types concurrent_queue& for both the constructor argument and the state variable for that queue. (Use a pointer type for premarked, as before.)

    Compile, run, benchmark, record observations in a file lab8/README, and copy to tbbprimes12.cpp

  6. Parallelize at least one more loop in the program, aiming to improve performance the most when compared to tbbprimes12.cpp.

    Compile, run, benchmark, record observations in a file lab8/README, and copy to tbbprimes13.cpp

Deliverables

If your 32-core machine is a thing, submit your work using the following command on your thingn

$ cd ~
$ labsubmit.cs300 lab8 

Otherwise, if you are using MTL, make a tar archive of your work, scp that archive to a Link computer (or shelob), unpack the tar archive, and use the labsubmit.cs300 command above to submit from that St. Olaf computer.

This lab is due by Monday, January 19, 2015.