I’m currently using openMP to write code running on multi-core nodes. openMP has a specific memory model which guarantees that memory is synchronised between threads running on different cores when a lock is acquired.
I consider using C++11 constructs (std::thread with std::mutex and std::lock) instead of openMP (because of their larger flexibility) and wonder if/how memory synchronisation between processors is guaranteed here? And if not, how can I enforce it?
The standard makes the following guarantees about synchronization of
std::mutex, in §30.4.1.2[thread.mutex.requirements.mutex]/6-25And, likewise,
(Where "synchronizes with" is a specific term explained in $1.10, although it’s much easier to understand by reading C++ Concurrency In Action)