Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
9 Views

more complicated than OpenMP

I am a newbie to learn tbb, however, it seems that TBB is much more complicated than openMP. One must rewrite his existing source code, while openMP only require insert a few #pragma.
0 Kudos
3 Replies
Highlighted
9 Views

Yes, you are right. If OpenMP fits your needs well, use OpenMP.
However TBB has some value-add over OpenMP. In TBB, there are useful patterns that can't be easily matched with OpenMP (e.g. pipeline and parallel_do), also concurrent containers, etc. Not the least, TBB is better at supporting nested parallelism and so helps to avoid some composability issues one may have with OpenMP.
For more information, you can read the article we wrote on the subject.
0 Kudos
Highlighted
New Contributor I
9 Views

Let me add a few words.
Myself I dislike OpenMP very much - I'm probably a bit unfair at it, but IMHO OpenMP's simplicity is only formal and very decepting.
Indeed, for simple example programs (particularly if what you're parallelizing is a for loop) it suffices to add a compiler directive and - voila! - it gets parallelized. But for just a bit more complicated programs you have to do several changes to make them parallel - adding private variables, conditions to nish computations, etc.
Consider parallelizing any do...while loop and yoy'll se what I mean.

Yes, if you are experienced enough, parallelizing a program using OMP requires adding less lines than with other tools. But - especially for beginners - it is IMHO much simpler to overlook sth in OMP than in other technologies, because you don't "see" what exactly you're doing - how the code will be partitioned, etc.

Add to it all the great stuff TBB offers - atomic operations, concurrent data structures, etc.
I work with TBB just for a few months, but am already its great fan.
0 Kudos
Highlighted
Employee
9 Views

Quoting - afd.lml
I am a newbie to learn tbb, however, it seems that TBB is much more complicated than openMP. One must rewrite his existing source code, while openMP only require insert a few #pragma.

To add to the other responses...

In my own experience, I also found parallelizing existing code with TBB a little challenging at first. But I must say, the addition a the C++0x lambdas has made a world of difference. With them, you can use much of TBB now without changing the visual flow of your original code. TBB and OMP codes that do the same thing now look comparable. If you haven't tried using them with TBB 2.2 yet, I recommend it. Less pain, more gain.

Cheers,
Terry
0 Kudos