Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

atomic_read & set will act as memory barrier?

softarts
Beginner
242 Views
I remember someone said on WIN32, read/set volatile variable willimplicitlycarry a memory fence
but how is it on Linux?
no memory fence when read/set volatile variable?
0 Kudos
2 Replies
RafSchietekat
Valued Contributor III
242 Views
Some compilers do that, but it is not and never will be standard behaviour, so don't write nonportable code that will fail with your most likely weapon of choice on Linux (g++). It is a compiler issue rather than an O.S. one, though: if I'm not mistaken, Intel's icc does this on Linux as well as on Windows (configurable?).
0 Kudos
Dmitry_Vyukov
Valued Contributor I
242 Views
Quoting softarts
I remember someone said on WIN32, read/set volatile variable willimplicitlycarry a memory fence
but how is it on Linux?
no memory fence when read/set volatile variable?

Yes, gcc does not emit any memory fences for volatile reads/writes.

0 Kudos
Reply