I have a nested loop that looks as follows -
for(int i=0; i<limit1; i++)
{
for(int j=0; j<limit2; j++){
/*
Code with Custom function calls, branching etc etc.
*/
}
}
The inner and outer loop iterations are independent of each other. Since this loop cannot trivially be vectorized, I would like to collapse it into one huge iteration space so that it can be unrolled more efficiently, in the sense that, instead of unrolling only the inner loop, the combined iteration space can be unrolled.
I do not want to parallelize it. From my understanding, I do not think openmp provides a stand alone collapsing pragma like - #pragma omp collapse(2), rather the collapse clause is used in conjunction with other pragmas like simd or for.
Can acheive this via OpenMP, or maybe some other method as well.
PS - I am not sure about the pros and cons of this method, whether one would get a significant performance increase etc. etc. If someone explain how can one (or for that matter if one can) theoretically(i.e. before benchmarking) ascertain this, it would be great.
TIA