Barrier synchronization in tbb threads

Barrier synchronization in tbb threads

Hej

I am new to intel TBB. I am trying to parallelize a looping structure with parallel_for. Structure of code is like:

for i=0:size
{
for j=i+1:size
------do something------

for j=i+1:size
for k=i+1:size
---do something---
}

>>>>>>>>>>>>>>>>>>>>for i=0:size
{
parallel_for(i+1:size) with looping

parallel_for(i+1:size) with nested looping
}

But this has drastically slowed down my speedup even much below than serial execution:( I rather need a parallelized structure of the form:

parallel_for(i,size)
{
for j=i+1:size
------do something------

/*------SYNCHRONIZATION-BARRIER------------*/

for j=i+1:size
for k=i+1:size
---do something---
}

i-e synchronization barrier of MPI kind that the second looping structure only begins when first looping has finished, so I guess i will get some speedup.... I have no idea if intel tbb has this kind of barrier, I looked through synchronization structures but they only talk about mutexes for shared variable accesses... Need urgent help with this, and thanks so much in advance....

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Leave a Comment

Please sign in to add a comment. Not a member? Join today