How can I properly parallelize the inner loop:
int found = -1;
#pragma omp parallel for ordered schedule(dynamic, 1) shared(found)
for (long i = 0; i < big_number; ++i)
{
if( function() )
{
#pragma omp ordered
if( found == -1 )
{
found = i;
}
}
}
bool function()
{
for(int i =0; i < another_big_number; i++)
{
if( some_condition)
{
return true;
}
}
}
I cannot post the whole of the code, but I kept most the part which seems to be necessary for the question. The idea for the first loop is to find the lowest iteration which the function returns true.
EDIT: of course any idea about improving the parallelization is appreciated, However, my question is more about how I can improve performance of the function() itself alongside the outer for loop using Nested methodology .
Please note that I am aware of collapse clause, however I cannot use it (thanks to the visual studio which does not support later versions of the openMP).
Any idea for improving the whole parallel loop is appreciated as well. :)
Do you think there would be an increase in performance by parallelizing the for loop inside function()?