Introduction to TBB programming

CS 300, Parallel and Distributed Computing (PDC)
Due Thursday, January 15, 2015

Preliminary material

Basic laboratory exercises: TBB containers

    On a manycore computer (either a thing or the MTL), create a PDC/lab7 subdirectory of your personal directory for work on the lab, and change directory to that directory.

  1. Try TBB computation as follows.

    To compile with lambda expressions, on a thing, include the flag -std=c++0x. For example,

        thingn$  g++ -std=c++0x -o trap_tbbL trap_tbbL.cpp -ltbb
    
    ______

  2. Begin with a copy of the sequential program omprimes1.cpp and its Makefile. Copy from a link machine to your 32-core machine, using the name sieve.cpp for the copy of omprimes1.cpp on that 32-core machine. For example, for thingn,

        %  scp ~cs300/lab6/omprimes1.cpp thingn.cs.stolaf.edu:PDC/lab7/sieve.cpp
        %  scp ~cs300/lab6/Makefile thingn.cs.stolaf.edu:PDC/lab7 
    

    Also copy the Makefile for compiling, and verify that the sequential sieve program compiles and produces correct answers on your 32-core machine.

    Once the program is running correctly, perform benchmark tests, and record observations in a file README. Also, make a copy of this version of sieve.cpp, called tbbprimes1.cpp.

  3. Modify your program to use a TBB concurrent_vector instead of an STL vector for pset.

    Compile and run, then perform benchmark tests. Compare to the STL sequential code's performance, and record observations in README. Then, make a copy tbbprimes2.cpp of this version of sieve.cpp.

  4. Add a loop for precomputing primes up to sqrt(prime_max) and storing those primes in another concurrent_vector named pset0.

    Compile, run, benchmark, observe in README, and copy to tbbprimes3.cpp

  5. Shared data structure patterns in Introduction to TBB programming.

    • Shared Array______

    • Shared Queue______

    • Task Queue______

    ______

    ______
    ______

    Change pset0 to be a concurrent_queue instead of a concurrent_vector, and use that work queue to control the outer loop for determining all primes.

    Compile, run, benchmark, observe in README, and copy to tbbprimes4.cpp

Parallel extensions

Try one (or optionally both) of these parallelization extensions of the basic lab assignment above.

  1. Try adding TBB parallelism to the inner for loop... tbbprimes5.cpp. Record benchmark results and comments from experience in README.

  2. Starting with tbbprimes4.cpp, try adding OpenMP parallelism... tbbprimes6.cpp. Record benchmark results and comments from experience in README.

    Notes.

  3. Algorithm patterns in Introduction to TBB programming.

    ______

    • Loop Parallel, trap_tbb* and tbbprimes4

    • Master-Worker______

    ______
    ______
  4. ______

Deliverables

Use one of the git stratgies in lab1 Deliverables to submit your work in this lab. For example, if you worked exclusively on thing3, include the name thing3 in your commit message.

    thing3$  cd ~/PDC
    thing3$  git pull origin master
    thing3$  git add -A
    thing3$  git commit -m "Lab 7 submit (thing3)"
    thing3$  git push origin master
Likewise, if you worked on both link machines and a thing, you can rename your lab7 folders and submit each, with commit messages indicating the computer on which that commit was created.

Also, fill out this form to report on your work.

See lab1 Deliverables section if you need to set up the cluster you used for git.

If you did your work on two different clusters, submit work from both of them using one of the strategies in lab1 Deliverables.

This lab is due by Thursday, January 15, 2015.