- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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)?
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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)?
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
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page