There are several ways to implement multithreading. std::thread
was eventually brought by C++11 standard but boost::thread
could be effectively used instead. Each technology has specific syntax and stuff, but - roughly - used for CPU parallel programming. But they have different effect. I know that, for instance, MPI and OpenMP used for different memory models.
I also know that the choice of a technology is not actually exclusive so another one can be used (again, MPI and OpenMP). How come they are used for different effect but still working with the same source (CPU)?
What the difference would be (from the operation system and hardware point of view) if I compile a C++ program with parallelism based on each of those technologies? Does, for example, OpenMP or std::thread
use POSIX threads? If so, how does C++11's threads work on Windows? Or does each of these technologies work directly with CPU via assembly language or something?
std::thread
, is not a specified behaviour. It is not explicitly forbidden in the specification. but still whether it works or not is very implementation-specific. Combining MPI with OpenMP or other threading paradigm is fine, as long as MPI is properly initialised with support for threads. – Hristo Iliev