Collapsing Multiple parallel_for's

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)?

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

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)?

Leave a Comment

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