[Omp] atomic directive semantics
Sven Karlsson
svenka-lists at sven.karlsson.name
Fri Sep 23 01:17:11 PDT 2005
Hi,
Richard Henderson wrote:
> Hmm. But since readers don't use #pragma omp atomic, critical
> sections for writers only are by themselves are not sufficient.
> The platform must have an atomic store instruction for the data
> type; otherwise a reader can read a partial update.
This is up to the programmer. The atomic directive support atomic
_updates_, see 2.7.4 in 2.5. There are no guarantees for reads of the
atomically updated entity unless you use extra synchronization. The
specification is very specific about atomic only providing protection
for the update.
Naturally, this can be implemented in a number of ways. Some
implementations, like mine, revert to locks if there is no hardware
support for a particular data type. This is allowed.
More refined implementations can use load linked/store conditional
instruction pairs, compare-and-swap or some other means of achieving
atomic operations. My implementation use such methods for the types that
have support in the architecture/hardware.
Naturally, I can only speak for my implementation but I would assume
most implementations do the same. At least the implementations I have
studied does something along these lines.
Sanjiv or Larry, step in if the ARB thinks otherwise. This is my
perception of atomic.
Best regards
Sven
More information about the Omp
mailing list