3 ms·
I think you're trying to talk about Independent-Read / Independent Write (IRIW) Sequential Consistency (https://stackoverflow.com/questions/50462948/acquire-rel
by dragontamer 7y ago
I think you're trying to talk about Independent-Read / Independent Write (IRIW) Sequential Consistency (https://stackoverflow.com/questions/50462948/acquire-release-vs-sequential-consistency-in-c11 https://stackoverflow.com/questions/50462948/acquire-release...)
It seems like there are roughly 4 levels of consistency
1. Sequential Consistency -- Total ordering exists for all atomics.
2. Acquire-Release Consistency -- Acquire barrier ensures all memory operations before the Acquire "happened before" the read of the spinlock. Release barrier ensures all memory operations before the release barrier "happens before" the write of the spinlock.
3. Consume-Release Consistency -- C++11 hypothetical: has not been used by C++ Compilers yet. This weaker memory ordering is a guarantee in some older chips but very few people seem to understand it.
4. Relaxed Consistency -- Atomics remain atomic, but no ordering is specified.
---------
It seems like #2 is sufficient for most cases, #1 is needed for a few obscure cases (the IRIW / Independent read-Independent write case). #3 is (probably) sufficient in cases where pointers are being used as the synchronization point, but very few programmers have studied consume-release and its straight up not-implemented in any major compiler yet. (Some CPUs do offer consume-release, which is why it is included in the C++11 standard).
#4 is rare, but useful if anyone wants the absolute fastest and knows atomics are enough (ex: a global multithreaded counter)