Mixing C++11 atomics and OpenMP

Michael Underhill 4145098@gmail.com
Sat Dec 24 12:17:00 GMT 2016


> The trick is not to try to be too cute by using OpenMP operations in
> one thread and hoping that they will synchronize with weaker C++11
> atomic operations in another thread.  It might work on one machine but
> not another.

I’m still uncertain what's supposed to work and what's not. Assume we
have a C++11 atomic variable and a loop that is associated with an
OpenMP loop directive. The atomic variable is accessed inside the loop
(e.g. compare-and-exchange). Does this work as we would expect, i.e.,
do the OpenMP threads access the variable atomically? And if so,
what's an example that does not work?



More information about the Gcc-help mailing list