Basic questions on semantics of release and acquire flushes
#pragma omp atomic write release
then thread 1 performs the following operations, in order:
1. a release flush, which completes, then
2. the assignment x=1, then
3. a strong flush on x, which could complete some time in the future.
If thread 2 executes
#pragma omp atomic read acquire
then thread 2 performs the following operations, in order:
1. a strong flush on x, which must complete, then
2. a read tmp=x
3. an acquire flush
How can these operations guarantee that the value 1 written by thread 1 is
read by thread 2, when according to Sec. 1.4.4., what is required is
that "the following sequence of events happen in the specified order:
1. The value is written to the variable by the first thread.
2. The first thread performs a release flush.
3. The second thread performs an acquire flush.
4. The value is read from the variable by the second thread."
I.e., we need to have the release flush happen after the assignment
x=1, not before it, and we need to have the acquire flush happen
before the read tmp=x, not after it. And somehow we need to have the
acquire flush happen after the release flush.
I think this mechanism would be much more clear if there were some
examples with real C (or Fortran) code showing how implicit and
explicit release and acquire flushes can be used to "enforce
consistency between two synchronizing threads’ view of memory".