Intel Threading Building Blocks

Overview

IntelĀ® Threading Building Blocks (TBB) is a relatively new higher level API for threading. It replaces the concept of threads with the concept of tasks, which are defined by the user and queued up. TBB then maps those tasks to threads efficiently.

TBB is available on all platforms that Maya supports. It provides wrappers for common functionality such as for, while, reduce and sort operations. It also provides atomic primitives a scalable memory allocator (allocators such as malloc access the global heap and so are locking operations, leading to contention when many threads are working with memory.) Finally, there are threadsafe containers based on STL such as lists, queues, and hash maps. These threadsafe containers have poor single threaded performance than regular containers because they usually require internal locking, and they must be used only when required for threadsafety.

The task-based approach avoids the problem of oversubscription encountered with OpenMP. In particular, oversubscription can create issues when using the Maya Evaluation Manager.

Pros and cons of TBB

TBB is a higher level library than OpenMP and provides increased flexibility at the cost of greater complexity. Parallel code must be extracted into separate classes, which is more invasive than OpenMP.

The task-based approach avoids the problem of oversubscription encountered with OpenMP. In particular, oversubscription can create issues when using the Maya Evaluation Manager. Maya makes use of TBB in several places, partly to avoid the oversubscription issues of OpenMP, and partly to make use of the higher level algorithms and containers. Writing threadsafe cross-platform primitives and containers is remarkably difficult, and using a third party library designed for the purpose allows developers to focus on optimizing their specific application rather than building the required threading infrastructure.

Although TBB is used by Maya, it is not exposed in a way that plug-in writers can access directly. You must acquire a license to use TBB in your plug-ins. There is no requirement to use TBB when threading Maya plug-ins, however the Maya API does provide an indirect way for plug-ins to use TBB without needing their own license. See Threading and Maya for more information.

The version compatibility is important for TBB. In Maya 2018, it is necessary to use TBB version 4.4 Update 6. The compatible TBB re-distributable files that are shipped with Maya should be sufficient to use TBB.

You can also download the corresponding commercial aligned releases from the TBB web site (http://threadingbuildingblocks.org/download#stable-releases).