I'm trying to parallelise some code with OpenMP in C, where I have 2 nested loops. I'm wondering if it's feasible to parallelise my inner loop.
#pragma omp parallel for
for (int i = A; i < B; i++)
{
int number_of_multiples= 0;
for (int j = 1; j < i; j++)
if (is_multiple(i, j))
number_of_multiples++;
...
}
I've looked into collapse()
but I don't think that's feasible here, given I need to initialise number_of_multiples
outside the inner loop so that I can calculate the number_of_multiples
for each iteration of the outer loop.
Additionally, since the inner loop's condition depends on i
, I'm unsure if it's even appropriate to parallelise?