I am currently working on a project that mixes high-performance computing (HPC) and interactivity.
As such, the HPC part relies on OpenMP (mainly for-loops with lots of identical computations) but it is included in a larger framework with a GUI and multithreading, currently achieved with c++11 threads (std::thread
and std::async
).
I have read Does OpenMP play nice with C++ promises and futures? and Why do c++11 threads become unjoinable when using nested OpenMP pragmas? that it is no good idea to mix OpenMP and C++11 threads, but so far it has been working for me.
For different reasons, I would like to improve on this, but I am not sure which strategy to adopt.
At OpenMP vs C++11 threads, I read that replacing OpenMP by std::thread
has a considerable impact on performance due to creation and destruction of threads, but I couldn't find anything about replacing OpenMP acceleration by task-based parallelism with std::async
. In my opinion, this should be faster than std::thread
because then the thread managing is done by the operating system, but I am not convinced yet that this is applicable. I haven't tried it yet because it would involve loads of refactoring and I would have liked to hear other opinions first.
Do you have any experience with reconciling HPC and interactivity? In your eyes, should std::async
be comparably fast to OpenMP?