Multiple Threads Make Chunk Change

Sept. 27, 2006
Making efficient use of multiple processing cores in a symmetrical multiprocessing (SMP) environment can be tricky. But Intel's Thread Building Blocks (TBB) aim to ease the challenge.

Making efficient use of multiple processing cores in a symmetrical multiprocessing (SMP) environment can be tricky. But Intel's Thread Building Blocks (TBB) aim to ease the challenge.

TBB is based on C++ templates that provide a set of thread-safe parallel control and data objects suitable for writing efficient parallel algorithms. Compared to approaches like OpenMP, these class templates make mapping conventional loop constructs such as for and while and data structures such as vectors and queues a straightforward process that allows the TBB objects to operate in parallel without requiring explicit thread management by the programmer.

TBB doesn't create a plethora of threads. Instead, it creates one thread per logical core. (A hyperthreading core may support two or more logical threads.) Each working thread manages a work queue (see Figure). The main thread creates the TBB objects like a vector and performs operations on the vector such as scanning all the entries.

In this case, the operation will be part of the program code. It will be referenced by multiple chunks to span the vector where each chunk will process a subset of the vector. These chunks are spread across the work queues of the working threads. An idle working thread grabs the next chunk out of the queue and then performs the work to be done on its block of data.

This approach is very similar to distributed Web-based servers like Java 2 Enterprise Edition (J2EE), except the J2EE fills the queue with incoming Web requests. In general, the TBB is much more data-structure-driven, whereas J2EE is more I/O-oriented. Likewise, J2EE threads typically are allocated based on the estimated I/O load versus the number of cores the system is running on. That’s because the J2EE threads often will have to wait on other operations, while the TBB threads have all the data available to them when the chunk is being processed.

Complementary products for Linux with 64-bit support include Thread Checker and Thread Profiler. These tools can be used with TBB, but they're just as useful for any multithreaded application. Thread Checker uses binary instrumentation. It can find problems such as race conditions and deadlock automatically. New command line support is ideal for batch mode and regression testing. The Thread Profiler presents TBB information in a more abstract fashion commensurate with TBB's source abstraction.

TBB costs $299. It's available for Windows, Linux, and Mac operating systems. Thread Checker costs $999, and Thread Profiler is $299.

Related Links Intel
www.intel.com

About the Author

William G. Wong | Senior Content Director - Electronic Design and Microwaves & RF

I am Editor of Electronic Design focusing on embedded, software, and systems. As Senior Content Director, I also manage Microwaves & RF and I work with a great team of editors to provide engineers, programmers, developers and technical managers with interesting and useful articles and videos on a regular basis. Check out our free newsletters to see the latest content.

You can send press releases for new products for possible coverage on the website. I am also interested in receiving contributed articles for publishing on our website. Use our template and send to me along with a signed release form. 

Check out my blog, AltEmbedded on Electronic Design, as well as his latest articles on this site that are listed below. 

You can visit my social media via these links:

I earned a Bachelor of Electrical Engineering at the Georgia Institute of Technology and a Masters in Computer Science from Rutgers University. I still do a bit of programming using everything from C and C++ to Rust and Ada/SPARK. I do a bit of PHP programming for Drupal websites. I have posted a few Drupal modules.  

I still get a hand on software and electronic hardware. Some of this can be found on our Kit Close-Up video series. You can also see me on many of our TechXchange Talk videos. I am interested in a range of projects from robotics to artificial intelligence. 

Sponsored Recommendations

Comments

To join the conversation, and become an exclusive member of Electronic Design, create an account today!