Business
Intel opens up high performance multi-core library
The Intel Threading Building Blocks (TBB) library was released this week as open source under the GPLv2 (plus runtime exception) license. The library makes it much easier for programmers to take advantage of all those multiple-core CPUs on the market now (and in the future), including non-Intel machines!
The Intel Threading Building Blocks (TBB) library was released this week as open source under the GPLv2 (plus runtime exception) license. The library makes it much easier for programmers to take advantage of all those multiple-core CPUs on the market now (and in the future), including non-Intel machines!
James Reinders, software evangelist and director of Intel’s Developer Products Division, says that the Linux, Mac OS X and Windows ports for IA32, IA64 and Intel 64 have been in use for over a year. But when asked about other operating systems, he replied:
The TBB download will build for a G5 on MacOS X, and it will build on Solaris and FreeBSD for x86. Absolutely! We did the work ourselves. These have not been tested for long nor used by customers – I know of no problems… but these would be “alpha” release status now. We’ll help others as they join the community – for instance, we’re working with some engineers at Sun to expand Solaris support (to build with their compiler, and for SPARC)… there is no schedule, just engineers working together to see if there are issues and get it working.According to Intel, the runtime exception used for the license is the same one used by libstdc++, which allows commercial/proprietary use (though Intel will be happy to sell you a commercial version if you need it). TBB is currently specific to C++ programmers and makes heavy use of templates, though there is talk of porting it to other languages like Java in the future. Conceptually it's similar to raw thread interfaces such as POSIX threads and Windows threads. However it operates at much higher level of abstraction. For example, say you have to iterate over an array with a million elements in it. Using raw threads, you might create two threads (or a thread pool), assign each thread to work on half the array, start the threads, and wait for the result. Using TBB you would create a 'task' class (not to be confused with an operating system task or process) which has a method that operates on a subset of an array. Then you ask TBB to iterate over the array using the task you just defined. For example,
00:#include "tbb/blocked_range.h"
01: class ApplyFoo {
02: float *const my_a;
03: public:
04: void operator()( const blocked_range< size_t >& r ) const {
05: float *a = my_a;
06: for( size_t i=r.begin(); i!=r.end(); ++i ) {
07: Foo(a[i]);
08: }
09: }
10: ApplyFoo( float a[] ) :
11: my_a(a) {}
12: };
13: void ParallelApplyFoo( float a[], size_t n ) {
14: parallel_for(blocked_range< size_t >(0,n,IdealGrainSize),
15: ApplyFoo(a) );
16: }
- parallel_for
- parallel_reduce
- parallel_scan
- parallel_sort
- parallel_while
- pipeline
- blocked_range (for use with algorithms, containers, etc.)
- blocked_range2d (for use with algorithms, containers, etc.)
- concurrent_hash_map
- concurrent_queue
- concurrent_vector
- atomic
- spin_mutex
- spin_rw_mutex (reader-writer spin mutex)
- queuing_mutex
- queuing_rw_mutex (reader-writer queuing mutex)
- mutex
- scalable_allocator
- cache_aligned_allocator
- aligned_space
- tick_count
- TBB home page
- TBB Book by James Reinders
- Chapter one of Reinders' book (pdf; see especially the comparison with threads, MBI, and OpenMP).
- TBB FAQs
- Commercial home page
- Press release
- Intel releases the Threading Building Blocks Toolkit as Open Source (July 2007, Robert Kaye)
- Coding with TBB Contest
- Scalable Parallelism with Intel Threading Building Blocks (July 2007, Shwetha Doss, Intel)
- Why Too Many Threads Hurts Performance (April 2007, Arch Robison, Intel)
- Product Review: Intel Threading Building Blocks (December 2006)
- Enable Safe, Scalable Parallelism with Intel Threading Building Block's Concurrent Containers (December 2006, Michael Voss, Intel)
- Demystify Scalable Parallelism with Intel Threading Building Block’s Generic Parallel Algorithms (October 2006, Michael Voss, Intel) (This is a good introduction to TBB for programmers)