Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.

Barrier synchronization in tbb threads

akhal
Beginner
232 Views
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....
0 Kudos
1 Reply
RafSchietekat
Black Belt
232 Views
Reply