Community
cancel
Showing results for 
Search instead for 
Did you mean: 
tony_az
Beginner
37 Views

Collapsing Multiple parallel_for's

I have the following pseudo-code that I'd like to optimize:
for (int i = 0; i < outerLoopCount; i++ {
parallel_for(blocked_range(0, count0, grainsize0),
*parallelForClass0);
SerialFunction0();
parallel_for(blocked_range(0, count1, grainsize1),
*parallelForClass1);
SerialFunction1();
}
The outer loop must remain serial. I'd like to combine the 2 parallel_for's into 1 call, to minimize the overhead of setting up the two parallel_for's on every iteration of the outer loop.
o Is it possible to combine the two parallel_for's so that they are only called once per outer loop iteration?
o Is it possible to combine all of the loops so that initialization is performed only once for the whole loop structure (outer loop included)?
0 Kudos
1 Reply
RafSchietekat
Black Belt
37 Views

You seem to be asking for the impossible, and it's not clear what overhead you suspect and why.

Have you tried using affiniity_partitioner with both loops (create instances outside of serial loop, use across serial-loop iterations, with each parallel_for having a separate partitioner)?
Reply