Wikipedia page for Consistency models list four consistency models for shared memory architecture as which require specific explicit synchronization by the programmers (in order from strongest to weakest):
Weak ordering:
Classifies memory operations into two categories: 'data operations' and 'synchronization operations'. Synchronization operations signal the processor to make sure it has completed and seen all previous operations done by all processors.Release Consistency:
Distinguishes the entrance synchronization operation from the exit synchronization operation. During the entry to a critical section, termed as 'acquire', all operations with respect to the local memory variables need to be completed. During the exit, termed as 'release', all changes made by the local processor should be propagated to all other processors.Entry Consistency:
Every shared variable is assigned a synchronization variable specific to it. When the 'acquire' is to variable x, all operations related to x need to be completed with respect to that processor. When the 'release' is to variable x, all changes related to x should be propagated.Local Consistency:
Each process performs its own operations in the order defined by its program. There is no constraint on the ordering in which the write operations of other processes appear to be performed.
Many of these look similar to C++ memory order models. Can someone give a correct mapping of these concepts to C++ memory order models.
I'm not sure whether C++ memory order models are derived from these. But they do map to these consistency models pretty well.
Weak Ordering:
Using C++ sequentially-consistent fences do correspond to 'synchronization operations' in weak ordering.
Release Consistency:
This has two kinds (also mentioned in the Wikipedia page linked in question)
RCsc: Usage of C++ sequentially-consistent operations do map to 'acquire' and 'release' operations in release consistency (with sequential consistency between synchronization operations).
RCpc: Usage of C++ release-acquire operations do map to 'acquire' and 'release' operations in release consistency (with processor consistency between synchronization operations).
Entry Consistency:
The nearest you can get to these in C++ is by using C++ release-consume operations. But in case, release operation does synchronize entire memory instead of only dependent operations. Perhaps, due to its complexity, C++ didn't bother to add a produce operation. Also note that, even though consume operation is there, in most implementations it is implemented as acquire. I also have heard that use of it is discouraged as of now.
Also, by symmetry, Entry consistency may also have two types - ECsc and ECpc - though it is not mentioned in the Wikipedia. In that case, release-consume model is near to ECpc I think.
Local consistency:
This is the default model of single threaded C++ program. If you are using multiple threads with shared data, then have to use relaxed atomics.
I don't know where to fit release-acquire and release-consume fences. They seem to be stronger than release consistency models, but are definitely weaker than weak ordering.