I have question regarding share variables in pragma single.
I have 2 for loops enclosed in a parallel region (to save the overhead cost). I have a pragma single in between to initialize some share variables for the second loop. My code is like this:
- Code: Select all
#pragma omp parallel
{
#pragma omp for
for (i=0; i<N; i++)
do_something(i);
#pragma omp single
{
initialize_share_variables_for_the_second_for_loop();
}
#pragma omp flush (list of share variables)
#pragma omp for
for (j=0; j<M; j++)
do_something (j);
}
My question is: does the "pragma omp flush" in my code needed ?
FYI, the program output is the same if I omit it, but I want to be safe here.
