Installing and Using Intel® Threading Building Blocks (Intel® TBB) on Linux

These directions are for the open-source development release of TBB 2.1. The development release includes some features under development for TBB 2.2. See http://www.threadingbuildingblocks.org/ for the latest information on TBB and links to the commercial license version.

Installing TBB

Below are the steps to download and build TBB:
  1. Download the compressed archive http://www.threadingbuildingblocks.org/uploads/76/139/2.1%20update%204/tbb21_20090511oss_src.tgz to a temporary directory. For example, download it as "/tmp/tbb21_20090511oss_src.tgz".
  2. Create the directory where you want to install TBB. For example, "mkdir /usr/foo/".
  3. Go to the installation directory. For example, "cd /usr/foo/".
  4. Unpack the compressed archive into the installation directory. For example, run "tar xvfz /tmp/tbb21_20090511oss_src.tgz".
  5. "cd tbb21_20090511oss". In the directory, you should see:
    build/  CHANGES  COPYING  doc/  examples/  include/  index.html  Makefile  README  src/
  6. [Optional] If using the Intel compiler, set the environment variable "compiler" to icc. The default is gcc.
  7. Build TBB by running "make" with no arguments. It usually takes less than a minute on a modern machine.
  8. The makefile builds two copies of TBB: a debug version with internal checking and a release version without. After the build, these will be in separate directories with names matching the pattern build/linux*cc*libc*kernel*{debug,release}. The expansion of * indicates the compiler and platform.
  9. [Optional] Run "make test" to build and run unit tests. This step is CPU intensive and takes on the order of a quarter hour on a modern quad-core machine.
TBB can be built for different compilers and platforms using the same initial directory. The makefile puts each configuration in its own build/*/ directory. Such builds can proceed concurrently.

Using TBB

TBB consists of a run-time library and header files. One way to let the compiler find them is to source the appropriate file tbbvars.* from your shell as follows: For example, if using bash and compiling against the release version, run
source /usr/foo/tbb21_20090511oss/build/linux*cc*libc*kernel*release/tbbvars.sh
To check your environment, "cd tbb21_20090511oss/examples/parallel_reduce/primes" and run "make". It will build and run the program primes if your environment is correct. Below is a sample transcript:
$ cd examples/parallel_reduce/primes/
$ make
g++ -O2 -DNDEBUG  -o primes primes.cpp -ltbb
./primes 100000000 0:4
#primes from [2..100000000] = 5761455 (0.47 sec with serial code)
#primes from [2..100000000] = 5761455 (0.50 sec with 1-way parallelism)
#primes from [2..100000000] = 5761455 (0.24 sec with 2-way parallelism)
#primes from [2..100000000] = 5761455 (0.19 sec with 3-way parallelism)
#primes from [2..100000000] = 5761455 (0.14 sec with 4-way parallelism)
Chapter 2 of the TBB Tutorial describes the TBB directory layout in detail.

Documentation

Documentation on TBB can be downloaded from http://www.threadingbuildingblocks.org/documentation.php". Reading the Tutorial found there is strongly recommended.

Last updated July 2, 2009