ArticleslgStudy

computer science

Threading Building Blocks

Threading Building Blocks is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Threading Building Blocks rather than just read about it. In short: oneAPI Threading Building Blocks (oneTBB; formerly Threading Building Blocks or TBB) is a C++ template library developed by Intel for parallel programming on multi-core processors. Using TBB, a computation is broken down into tasks that can run in parallel.

Key takeaways

  • Threading Building Blocks belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Threading Building Blocks to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Threading Building Blocks from memory before moving on to harder problems.

Reference excerpt

oneAPI Threading Building Blocks (oneTBB; formerly Threading Building Blocks or TBB) is a C++ template library developed by Intel for parallel programming on multi-core processors. Using TBB, a computation is broken down into tasks that can run in parallel. The library manages and schedules threads to execute these tasks.

Overview A oneTBB 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 techniques for parallel programming aiming to decouple the programming from the particulars of the underlying machine. oneTBB implements work stealing to balance a parallel workload across available processing cores in order to increase core utilization and therefore scaling. 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, oneTBB 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. In a 2008 assessment of the work stealing implementation in TBB, researchers from Princeton University found that it was suboptimal for large numbers of processors cores, causing up to 47% of computing time spent in scheduling overhead when running certain benchmarks on a 32-core system. oneTBB, 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. oneTBB is available commercially as a binary distribution with support, and as open-source software in both source and binary forms. oneTBB does not provide guarantees of determinism or freedom from data races.

Library contents oneTBB is a collection of components for parallel programming:

Basic algorithms: parallel_for, parallel_reduce, parallel_scan Advanced algorithms: parallel_pipeline, parallel_sort Containers: concurrent_queue, concurrent_priority_queue, concurrent_vector, concurrent_hash_map, concurrent_unordered_map, concurrent_unordered_set, concurrent_map, concurrent_set 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 Timing: portable fine grained global time stamp Task scheduler: direct access to control the creation and activation of tasks

See also Intel oneAPI Base Toolkit Intel Integrated Performance Primitives (IPP) Intel oneAPI Data Analytics Library (oneDAL) Intel oneAPI Math Kernel Library (oneMKL) Intel Cryptography Primitives Library Intel Advisor Intel Inspector Intel VTune Profiler Intel Concurrent Collections (CnC) Algorithmic skeleton Parallel computing List of C++ multi-threading libraries List of C++ template libraries Parallel Patterns Library Grand Central Dispatch (GCD) Software Architecture Building Blocks

Notes

References Voss, Michael; Asenjo, Rafael; Reinders, James (2019), Pro TBB, Apress, doi:10.1007/978-1-4842-4398-5, ISBN 978-1-4842-4397-8, S2CID 195847637 Reinders, James (July 2007), Intel Threading Building Blocks: Outfitting C++ for Multi-core Processor Parallelism (Paperback ed.), Sebastopol: O'Reilly Media, ISBN 978-0-596-51480-8 Voss, M. (October 2006), Demystify Scalable Parallelism with Intel Threading Building Blocks' Generic Parallel Algorithms, archived from the original on 2012-02-05, retrieved 2007-06-06 Voss, M. (December 2006), Enable Safe, Scalable Parallelism with Intel Threading Building Blocks' Concurrent Containers, archived from the original on 2012-02-05, retrieved 2007-06-06 Hudson, Richard L.; Saha, Bratin; Adl-Tabatabai, Ali-Reza; Hertzberg, Benjamin C. (2006), "McRT-Malloc", Proceedings of the 2006 international symposium on Memory management - ISMM '06, pp. 74–83, doi:10.1145/1133956.1133967, ISBN 978-1595932211, S2CID 9120368

External links oneTBB Industry Specification oneTBB on GitHub Official website at Intel

Worked examples

Example 1 — a first encounter with Threading Building Blocks

Start with the simplest possible case. Write down what Threading Building Blocks claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Threading Building Blocks before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Threading Building Blocks ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Threading Building Blocks

In research
Threading Building Blocks appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Threading Building Blocks in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Threading Building Blocks is common in secondary-school and first-year university syllabi. It links to neighbouring topics Application programming interfaces, C++ libraries, C++ programming language family, so understanding it makes those chapters shorter.
In everyday life
Look for Threading Building Blocks outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Threading Building Blocks” →

How to study Threading Building Blocks in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Threading Building Blocks means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Threading Building Blocks out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Threading Building Blocks in simple terms?

oneAPI Threading Building Blocks (oneTBB; formerly Threading Building Blocks or TBB) is a C++ template library developed by Intel for parallel programming on multi-core processors. Using TBB, a computation is broken down into tasks that can run in parallel.

Why does Threading Building Blocks matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Threading Building Blocks?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Threading Building Blocks.

Tags

  • Application programming interfaces
  • C++ libraries
  • C++ programming language family
  • Concurrent programming libraries
  • Generic programming
  • Intel software
  • Threads (computing)

Keep exploring