Re: Mixing C++11 atomics and OpenMP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 24/12/16 12:17, Michael Underhill wrote:
>> 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?

Yes, given some reasonable assumptions.

> And if so, what's an example that does not work?

It's trickier if you try to use both OpenMP atomic operations and C++
atomics and expect there to be some kind of total order across
threads.  For this to work you'd have to be very careful about using
FENCE operations and even then it's not guaranteed.

Andrew.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux