Skip to content

TBB: Thread Building Blocks

Xiaoguang Dai edited this page Jan 29, 2014 · 2 revisions

Environment Setup

HPCLinux On VirtualBox

The suggested way to practice TBB in this class is trying to use the HPCLinux OVA image on VirtualBox. This is a ready to use environment. To show that, you can try to compile and run some TBB examples:

$ cp -r /opt/intel/composer_xe_2013_sp1.0.080/tbb/examples/ .

$ make -C examples/parallel_do/parallel_preorder/

Linux Distribution

If you prefer to install and run TBB on the real machine and you are running Linux, most likely TBB is already in the software repository of your Linux distribution. For example, on Debian Sid, simply run following commands:

$ apt-get install libtbb2 libtbb2-dev

This will install TBB headers and library binaries into standard directory, which means you don't need "-I" or "-L" when invoke g++.

Standalone Installation

Next option is to download and unzip the pre-compiled binary package from TBB Website. As TBB is just a library, to use it you just need to let the compiler know where to find the TBB header files and library binaries. For gcc, you need to use "-I", "-L" and "-l" options.

TBB comes with a script which helps you setup some environment variables so you don't need to use those compiler options explicitly. In other words, instead of

$ g++ -I<TBB_header_dir> -L<TBB_lib_dir> <your_tbb_program.cpp> -ltbb

You can simply do this:

$ source <TBB_ROOTDIR>/bin/tbbvars.sh

$ g++ <your_tbb_program.cpp> -ltbb

tbbvars.sh is a very simple script. You may want to read it to understand how it works.

Reference Materials

The official TBB tutorial is a very good reference for the student as it covers mostly every aspect of TBB. It's well organized and rich with examples.