- Code: Select all
globalFlag = 0
#pragma omp parallel for
for ( i=1 ; i<N; i++) {
#pragma omp flush (globalFlag)
if (!globalFlag)
do_something_here(i) // globalFlag may be set to 1 in this function.
if (globalFlag) {
#pragma omp flush (globalFlag)
}
}
Which seems that I overdo the flush pragma, and slow down the program. My question is:
Can I drop the first "#pragma omp flush" statement?
Is the second "#pragma omp flush" statement execute everytime? or only when globalFlag is set?
