Intel invited me to attend their super seekrit media event (read: booze &amp food) this evening. They didn’t tell us anything about the topic of the event, so I decided to go check it out and see what sorts of food/drinks Intel had to offer. I wasn’t thinking that their event would really get my attention and have me writing another blog entry this evening. But, I was wrong.

Turns out the majority of the presentation was a rehash from the earlier session (”Exploiting Parallelism in Multicore“). However, towards the end of the presentation James went into a little more detail and also started heavily focusing on the Threading Building Blocks Toolkit (TBB) that I mentioned earlier today.

The big seekrit of the day was the Intel has taken the toolkit, fixed more bugs and ported it to run on Solaris, more compilers including gcc and released it under the GPL v2.0 with a runtime exception (the runtime exception allows template code generated by the compiler to not be subject to the GPL). Not twenty minutes before the presentation, Ryan Paul from ARS Technica voiced some objections to the TBB, saying that it was a commercial product only for the Intel compiler and Intel processors. It was a valid, but short-lived objection, as Intel wiped out all these objections during this presentation.

I’m pleased to see that Intel recognized the shortcomings of their previous approach and decided to go the full open source route. Even more interesting were some more details that James revealed about the toolkit. In his afternoon presentation James focused on the general approach to preparing your programs for multi-core, but he only mentioned the Threading Building Blocks toolkit very briefly.

In this evening’s presentation James did a demonstration of a ray-tracer modified by Intel to use the new toolkit. James showed the rendering of an image without TBB and with two approaches using TBB on an 8 core machine. The single threaded ray tracer was positively sluggish on without TBB, but with TBB it became significantly faster.

After the presentation James answered questions about the toolkit, so I decided to pester him with a few more questions when I realized the real power of the toolkit. TBB doesn’t simply make an application multithreaded by adding pthread support to the application — TBB does a lot more than that under the hood.

The important difference between a TBB application and a pthread application is that in pthreads the programmer tells the program exactly how many threads to create and what each of the threads should do. In TBB the programmer describes the task at hand and hands it to TBB to slice and dice before it hands off threads to the OS to execute. TBB will divide the task and pass it to a pool of threads for execution. However, what wasn’t apparent before is that TBB will actually do something akin to load balancing where it may decide to subdivide a task further in order to properly spread the task between multiple processors/cores.

My previous blog post outlined that moving towards multi-core programming was as simple as converting your application to pthreads and firing off threads for each task. While this is still true, I’ve learned that in order to do a good job with that approach you would need to do a fair amount of analyzing of your program in order to properly break tasks into threads. TBB aids in this process by giving you the tools to automatically help you balance your threads onto multiple processors.

Now that Intel has decided to GPL the TBB toolkit, it opens the possibility for this technogolgy to make its way into open source projects so that this functionality can be incorporated into our favorite open source packages. I’ve learned long ago that parallel programmming is not for the faint of heart and that mutlithreaded programming was also a nice challenge. Having a toolkit that neatly abstracts out these complicated concepts and hides them from the programmer is going make a big difference for many people preparing to move to the multicore future.

Thanks for the food, drinks and presentation Intel!