Threading Building Blocks (TBB) lets you write “parallel C++ programs that take full advantage of multicore performance, that are portable and composable, and that have future-proof scalability.”
TBB can be used with and without other Parallel Studio packages.
To make use of it you first need to start an interactive session that has access to multiple cores. Here we request six cores from the clusters’ scheduler:
$ qrsh -pe openmp 6
Next, we need to active a specific version of TBB:
$ module load libs/binlibs/intel-tbb/2017.0
You can find sample TBB programs in the directory
$ ls $TBB_SAMPLES common concurrent_hash_map concurrent_priority_queue GettingStarted graph index.html license.txt parallel_do parallel_for parallel_reduce pipeline task task_arena task_group test_all
We can compile and run a sample program by copying the samples to our (writable) home directory,
moving in to the directory containing the sample program (which should have a
$ cp -r $TBB_SAMPLES ~/tbb_samples $ cd ~/tbb_samples/GettingStarted/sub_string_finder/ $ ls license.txt Makefile readme.html sub_string_finder.cpp sub_string_finder_extended.cpp sub_string_finder_pretty.cpp $ make g++ -O2 -DNDEBUG -o sub_string_finder sub_string_finder.cpp -ltbb -lrt g++ -O2 -DNDEBUG -o sub_string_finder_pretty sub_string_finder_pretty.cpp -ltbb -lrt g++ -O2 -DNDEBUG -o sub_string_finder_extended sub_string_finder_extended.cpp -ltbb -lrt ./sub_string_finder_extended Done building string. Done with serial version. Done with parallel version. Done validating results. Serial version ran in 8.51745 seconds Parallel version ran in 1.51716 seconds
Many of the sample directories contain HTML documentation.
To read this you need to start an interactive graphical session (using
qrshx) then run:
$ firefox ~/tbb_samples/index.html