Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.

Channels ▼


Intel Upgrades Threaded Building Blocks

At OSCON today, Intel announced a major upgrade to its Threading Building Blocks (TBB), a C++ template library available on Windows, Mac OS X, and Linux. TBB is a developer tool that helps programmers implement threading into applications and improves application performance on multi-core processors. TBB 2.1 makes it easier for developers to apply TBB to new uses in their software, including GUIs, artificial intelligence, network input/output and more.

Among the enhancements are:

  • Task-to-thread affinity. A new "affinity partitioner" class that implements "soft"task-to-thread affinity. Performance has increased to within 10 percent of OpenMP static scheduling for cases where the latter works well for cache affinity, such as a serial (e.g., time-step) loop containing repeated parallel work on the same data. The improvements provide a 4x performance improvement over Intel TBB 1.0 on some cases. An example can be found in examples/parallel_for/seismic which was restructured to use the affinity partitioner and significantly increased performance.

  • Task cancellation support. Ability to cancel (terminate early) a running TBB task. For example, used in an application when some event happens that causes, unexpectedly, a computation already in progress no longer to be needed.

  • ISO C++ thread class. Used to be referred to as blocking ("I/O") tasks. An implementation in TBB of the recently-proposed ISO C++ standard thread class. Allows other threads to be created, independent of TBB task scheduler worker threads, for:

    • GUI, I/O or network interface threads.
    • Threads that need to wait on external events.
    • Programs that previously needed to use both native threads and TBB tasks because of a mix of computation + GUI or I/O.

    The implementation is based on the ISO C++ standard thread class.

  • Container and interface improvements. These improvements address a series of customer requests for new containers, containers that line up with STL more closely, adding other interfaces or functionality to existing containers, etc. The items addressed in TBB 2.1 include:

    • Fix concurrent_unordered_map interface to follow unordered_map more closely. This was implemented by improving the interfaces within the existing concurrent_hash_map class to align better with STL.
    • Improvements in TBB container interfaces (concurrent queue, hash map, vector):

      • Allow user-defined memory allocator in all containers
      • New tbb_allocator class
      • Eliminating spin-waiting in concurrent queue
      • Exception safety in containers
      • Refactor cache aligned allocator

  • Improved Intel Thread Checker and Intel Thread Profiler support. Significantly reduce current false positives when using Intel Thread Checker with Intel TBB, and make Intel Thread Profiler information for programs using Intel TBB more useful and insightful.

  • Important customer tbb::pipeline changes. A specific list of customer-requested improvements for the pipeline class:

    • Now worker threads are able to execute other tasks, or block if no other work to do, instead of spin-waiting when waiting for input (important customer fix request).
    • Now allows parallel input stage instead of only serial input stage.
    • Now has enumeration to distinguish filter types, not just parallel vs. serial filters.
    • Automatic removal of filters when destroyed. Previous versions required that the pipeline be manually cleared prior to filter deletion, which is inconvenient.
    • Clarify in documentation if pipeline can have stages added, then be run, then have more stages added, then be run again.

  • Worker thread callback hooks. A new "task scheduler observer"class that allows TBB worker thread creation or deletion to be hooked. Can be used to monitor thread creation, change created thread properties (e.g., priority, affinity, etc.). For expert users only.

  • Recursive mutex. While not a recommended programming practice, some existing native-threads apps use recursive mutexes. This is a customer requested feature to have an TBB wrapper around native-threads recursive mutexes to make porting to TBB easier. This is not a high-performance mutex like the other TBB mutexes such as the tbb::spin_mutex.

  • Allow user-defined memory allocator in all containers. Allows selection of the default system allocator, the TBB scalable memory allocator, or a user-defined allocator in the containers (concurrent vector, queue, hash map). See also the new tbb_allocator class, directly below.

  • New tbb_allocator class. This class allows easy switching between the TBB scalable memory allocator and std::allocator. It is similar to the existing cache aligned allocator class except that it performs no alignment. It is used in conjunction with the previous feature so the allocator can be selected to use with the containers.

  • Better binary compatibility support. Ensure that newer versions of the TBB shared libraries can always be used with code compiled against an earlier version of TBB. Includes explicit support for library and individual interface versioning.

  • Microsoft Visual Studio IDE integration plug-in. A new plug-in that's currently being shipped as a separate package, with its own documentation, on the TBB OSS WWW site. It allows different versions of TBB to be set up for use inside any version of Visual Studio easily.

  • API to set thread stack size. New parameter to task_scheduler_init that allows the worker thread stack size optionally to be specified.

  • New blocked_range3d class. Analogous to blocked_range2d for 3-D parallel loop iteration spaces. Includes code contributed by the Intel' TBB open-source community.

  • Improvements in mutexes. General performance/scaling tuning, introducing futex on Linux (and comparable events on Windows).

  • New parallel_do class. Suggested by open-source community customer shortly afterTBB 2.0 launch at OSCON. Provides a new alternative to the existing parallel_do and parallel_while algorithms.

  • Eliminating spin-waiting in concurrent queue. Important customer bug fix request, along with similar request for spin-waiting in pipeline.

  • Exception safety/support. Allows improved ability to use exceptions with Intel' TBB code. Specific changes include:

    • Exception safety in containers. For concurrent vector, queue, hash map.
    • Better exception handling support. Prototype done in scheduler, extending to algorithms.

  • Refactor cache aligned allocator. To remove double-padding when cache aligned allocator is used with TBB scalable allocator, and to support user-defined allocators in containers.

Related Reading

More Insights

Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.