Threading Building Blocks

From Wikipedia, the free encyclopedia
  (Redirected from Intel Threading Building Blocks)
Jump to: navigation, search
Threading Building Blocks
Developer(s) Intel
Stable release 4.4 / August 25, 2015; 2 months ago (2015-08-25)[1][2]
Written in C++
Operating system FreeBSD, Linux, Solaris, OS X, Windows, Android
Type library or framework
License dual: commercial / open source (GPLv2 with the (libstdc++) runtime exception), plus Freeware[3]

Threading Building Blocks (TBB) is a C++ template library developed by Intel for writing software programs that take advantage of multi-core processors. The library consists of data structures and algorithms that allow a programmer to avoid some complications arising from the use of native threading packages such as POSIX threads, Windows threads, or the portable Boost Threads in which individual threads of execution are created, synchronized, and terminated manually. Instead the library abstracts access to the multiple processors by allowing the operations to be treated as "tasks", which are allocated to individual cores dynamically by the library's run-time engine, and by automating efficient use of the CPU cache. A TBB program creates, synchronizes and destroys graphs of dependent tasks according to algorithms, i.e. high-level parallel programming paradigms (a.k.a. Algorithmic Skeletons). Tasks are then executed respecting graph dependencies. This approach groups TBB in a family of solutions for parallel programming aiming to decouple the programming from the particulars of the underlying machine.


TBB implements work stealing to balance a parallel workload across available processing cores in order to increase core utilization and therefore scaling. The TBB work stealing model is similar to the work stealing model applied in Cilk. Initially, the workload is evenly divided among the available processor cores. If one core completes its work while other cores still have a significant amount of work in their queue, TBB reassigns some of the work from one of the busy cores to the idle core. This dynamic capability decouples the programmer from the machine, allowing applications written using the library to scale to utilize the available processing cores with no changes to the source code or the executable program file.

TBB, like the STL (and the part of the C++ standard library based on it), uses templates extensively. This has the advantage of low-overhead polymorphism, since templates are a compile-time construct which modern C++ compilers can largely optimize away.

Intel TBB is available commercially as a binary distribution with support,[4] and as open-source software in both source and binary forms.[5]

Library contents[edit]

TBB is a collection of components for parallel programming:

  • Basic algorithms: parallel_for, parallel_reduce, parallel_scan
  • Advanced algorithms: parallel_while, parallel_do, parallel_pipeline, parallel_sort
  • Containers: concurrent_queue, concurrent_priority_queue, concurrent_vector, concurrent_hash_map
  • Scalable memory allocation: scalable_malloc, scalable_free, scalable_realloc, scalable_calloc, scalable_allocator, cache_aligned_allocator
  • Mutual exclusion: mutex, spin_mutex, queuing_mutex, spin_rw_mutex, queuing_rw_mutex, recursive_mutex
  • Atomic operations: fetch_and_add, fetch_and_increment, fetch_and_decrement, compare_and_swap, fetch_and_store
  • Timing: portable fine grained global time stamp
  • Task Scheduler: direct access to control the creation and activation of tasks


Version 1.0 was introduced by Intel on August 29, 2006, the year after the introduction of Intel's first dual-core x86 processor, the Pentium D.

Version 1.1 was introduced on April 10, 2007. This version introduced auto_partitioner which offered an automatic alternative to specifying a grain size parameter to estimate the best granularity for particular tasks. This version was added to the Intel C++ Compiler 10.0 with the new Professional Edition later that year on June 5.

Version 2.0 was introduced on July 24, 2007. This version included the release of the source code and the creation of an open source project.[5] The license used for open source is the same as the one previously used by the GNU Compiler Collection C++ standard library, a GPLv2 with a "runtime exception" (because of being template heavy code that usually becomes part of the executable after compilation). TBB is still available in a commercial version (without source code) with support but with no differences in functionality from the open source version.

Version 2.1 was introduced on July 22, 2008. Version 2.1 features included task-to-thread affinity, cancellation support, exception handling, and a portable thread wrapper.[6] Version 2.2 features support for lambda functions in C++0x.

Version 3.0 was introduced on May 4, 2010. It has a number of improvements, see (

Version 4.0 was introduced on September 8, 2011. It has several new features, see (

Version 4.1 was introduced on September 5, 2012. It has improvements in TBB memory allocator, full support of parallel_deterministic_reduce template function and other updates, see (

Version 4.2 was introduced on September 4, 2013. It introduces support for the new speculative locking synchronization primitive speculative_spin_mutex which takes advantage of with Intel Transactional Synchronization Extensions (Intel TSX) feature in 4th generation Intel Core processors. It now also supports C++11 exact exception propagation as well as adding support for more concurrent container types (concurrent_unordered_multiset and concurrent_unordered_multimap).[7]

Version 4.3 was introduced on August 26, 2014. It introduces support tasks arenas. It also improves C++11 support.[8]

Version 4.4 was introduced on August 25, 2015. It adds Global control for better resource management (parallelism level and thread stack size), some new types of Flow Graph nodes: composite_node and async_node. Flow graph also has improved “reset” functionality, more C++11 features are utilized to improve performance.[9]

Systems supported[edit]

The TBB commercial release 3.0 supports Windows (XP or newer), OS X (version 10.5.8 or higher) and Linux using Visual C++ (version 8.0 or higher, on Windows only), Intel C++ Compiler (version 11.1 or higher) or the GNU Compiler Collection (gcc).[10] Additionally, the TBB open source community has contributed patches for Solaris,[11] PowerPC, Xbox 360, QNX Neutrino, and FreeBSD.

Open source operating systems[edit]

As of March 2010, TBB has been packaged into the following operating system distributions:

See also[edit]



External links[edit]