Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.
2421 Discussions

atomic_read & set will act as memory barrier?

softarts
Beginner
130 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
Black Belt
130 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?).
Dmitry_Vyukov
Valued Contributor I
130 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.

Reply