I am trying to parallelize a section in my application which comprises of 2 consecutive for-loops. These loops are independent with each other, so, ideally, I would like to follow a 2-level parallelization approach: spawn each loop as a different task at the higher level, and then parallelize each one with tbb::parallel_for.Would it be possible to compose in such a way different TBB parallel constructs, i.e. use a parallel_for inside a task or task_group? And if yes, would it work well, i.e., as if the 2 loops were handled as a single, twice as large parallel for loop? My intuition says that, once the 2 loops are scheduled simultaneously onto some worker queue and their recursive splitting starts, the execution from that point on would not be much different from the case of a unified, larger loop.
For more complete information about compiler optimizations, see our Optimization Notice.