Parallel Building Blocks – Time vs. Freedom vs. THINK

So you're looking to parallelize that pesky for loop that's taking a lot of time in your code. You're probably thinking, when are we going to actually start talking about the different 'for' loops offered within PBB? Not yet...there are still some other things to consider. In this fashion, you will more quickly find what you need out of the three different models.

In the first blog, I talked about the issue of template library vs. language extension. If you don't have a specific requirement for either, your concerns now are time, degrees of API freedom, and how much you have to think.

I will rank the PBB models now for these from 1 to 3, with 1 being the highest.


Time: 2 for those with a parallel programming background, 1 for those just starting out

TBB is very convenient for those that already have a background in parallel programming. Most concepts that you have learned in a parallel programming course or through on-the-job training is templatized for easy use within the API.

Degrees of API Freedom: 1

This model out of all three offers the greatest ability to manipulate behind-the-scenes details. While the focus is more on tasking rather than managing threads, experts still have the freedom to dig deep. Just take a look here at the different aspects of parallel programming you can manipulate here. These are for the most part not present in the other models.

Think: 2

TBB abstracts away from a lot of the lower level threading concepts you would have to do with other tools. It's not a radically different idea, but not totally automatic either.


Time: 3

Cilk is only 3 keywords added as a compiler feature. As I will explain in subsequent blogs, you add in your keywords (fairly quickly) and rely on the compiler to do the necessary threading for you.

Degrees of API Freedom: 3

Again, since it's only 3 keywords, you don't have a great deal of flexibility. But as a consequence it is very easy to pick up and start with.

Think: 3

Cilk is the easiest way to parallelize a serial program. It's not a substitute for an expert TBB implementation, but is a great way to get some initial parallelism.


Time: 1.5 starting out, 2 after you’ve gotten the hang of it, 2.5 after you’re regularly using best known methods for performance

Since ArBB uses TBB under the hood for threading, there is that added level of abstraction where you're focusing on the underlying algorithm, your inputs/outputs, and what operations you'd like to do on those inputs/outputs.

Degrees of API Freedom: 2

ArBB is an entire library and language to specify an arbitrary computation, and the keyword there is arbitrary. It's much more high level than TBB. It's an entire programming platform when you compare it to Cilk's 3 keywords.

Think: 1

ArBB is a different way of thinking about parallel programming problems than you may be accustomed to. Once you get used to it though, it is hard to move back to the lower levels though and becomes quite convenient. It is geared for data parallel programming which historically was not taught as much as task parallel. You have to create new pockets of computation to get your code to run on multiple cores which does require more thought.

Para obter informações mais completas sobre otimizações do compilador, consulte nosso aviso de otimização.