OpenMP: problem with flush

I tried to compile an OpenMP program with pgcc 5.1 on an AMD Opteron. A snippet from the code looks like:

while( sync[neighbor] == 0 ) {
#pragma omp flush

According to the OpenMP specification, this should be fine - it is even an excerpt from an example from the specification. However, if I look at the generated assembly code, it seems that the “flush” directive is ignored. As a result, the program encounters a deadlock, since the memory in sync[neighbor] is not read again after the flush. So my question is if the PGI compiler I used supports the “flush” directive or if I have misinterpreted the specifications.


Unfortunately it’s a bug (TPR #3499). We do have the issue characterized and should have a fix in a future release.