atomic update missed case?

Comments and discussion of the 4.1 OpenMP Draft specifications. Comment period ends September 30, 2015. See http://openmp.org/wp/openmp-specifications/ to download the specifications. (Read Only)
Forum rules
The OpenMP Forums are now closed to new posts. Please visit Stack Overflow if you are in need of help: https://stackoverflow.com/questions/tagged/openmp
Locked
fewl9012
Posts: 73
Joined: Mon Jul 27, 2015 4:50 pm

atomic update missed case?

Post by fewl9012 »

atomic capture allows for a capture-stmt followed by a write-stmt, or a capture-stmt followed by an update-stmt, or an update-stmt followed by a capture-stmt, but not a write-stmt followed by a capture-stmt.
So
#pragma omp atomic capture
{ v = x; x++; }
is ok
#pragma omp atomic capture
{ v = x; x = expr; }
is ok
#pragma omp atomic capture
{ x++; v = x; }
is ok
#pragma omp atomic capture
{ x = expr; v = x; }
is not ok. I can see the argument that this is equivalent to {v=x=expr;} so why is the atomic capture needed, but then why is the atomic capture needed for v=x++? (page 152:16). Because after x is assigned, it may change before v gets assigned.

Locked