Intel Threading Building Blocks 3.0 (TBB) was released yesterday, enabling programmers to take advantage of concurrency features in C++ 0x and Microsoft Visual Studio 2010. As with previous releases, the software is available under a commercial licence with support from Intel or under a free open source licence with support from the open source community.
TBB brings task-based abstractions to C++, so that programmers do not need to focus on threads. The TBB library was first released in the summer of 2006 and has been regularly updated since then, winning the support of companies including Adobe Systems, Avid, Epic Games, and DreamWorks. Adobe Creative Suite 5, which has just started shipping, uses TBB to increase performance for end users.
New features in TBB 3.0 include:
- Support for Windows 7 and Snow Leopard.
- The introduction of parallel_pipeline, which is strongly typed and lambda-friendly.
- TBB_USE_CAPTURED_EXCEPTION, which uses the C++ 0x mechanism for one thread to capture an exception and another thread to throw it. If C++ 0x is not available, it will use the less precise TBB fixes moveable_exception and captured_exception.
- A new synchronisation primitive based on condition variables, which are in C++ 0x. This enables threads to wait on a variable to be changed by another thread, and to be notified when that variable changes. The implementation does not require C++ 0x support, but provides a clean migration path for it.
- A design patterns manual which explains how to implement common parallel programming idioms using TBB. There is already an O’Reilly Nutshell book on TBB available in English, Japanese, Chinese and Korean. The design patterns manual provides recipes for common challenges.
- New concurrent_unordered_map container. This mimics C++ 0x unordered_map and is based on a specification agreed by Intel and Microsoft.
- Support for the Concurrency Runtime in Visual Studio 2010, which helps avoid oversubscription caused by excessive duplication of thread pools.
- Support for PPL in Visual Studio, so that a single application can use both TBB and PPL in different parts because both run on the Concurrency Runtime layer.
- New lock interfaces to match reader_writer_lock and critical_section in Visual Studio 2010. These are portable and do not require Windows.
- Independent task scheduling for different master threads, improving task scheduling predictability and responsiveness. This also helps to eliminate some conditions that could cause deadlocks.
- More information about synchronisation primitives is exposed to debugging tools.
- Tasks can be enqueued, for scenarios where approximately first-in-first-out behaviour is preferred, such as where latency of response matters more than throughput.
- Performance improvements for enumerable_thread_specific and combinable.
- Improved efficiency of the memory allocator.
- A task group context can be created or destroyed in different threads, making task cancellation and exception handling more usable.
For an in-depth study of the new additions and a short history of TBB to date, read James Reinders’ extensive blog post.
The software is available for download now for free under the open source licence, or under a commercial licence. While the software is largely backwards compatible, there are a few breaking changes, which Arch Robison explains in his blog post here. For further questions, try posting in the forum or leave a comment on this blog post and I’ll try to find an answer for you.