OpenMP and C ++ 11 multithreading

I am currently working on a project that combines high performance computing (HPC) and interactivity.
Thus, part of the HPC relies on OpenMP (mainly for loops with a lot of the same calculations), but it is included in a larger structure with a graphical interface and a multi-threaded process, currently achieved with C ++ 11 streams ( std::thread and std::async ).

I read Is OpenMP different with C ++ promises and futures? and Why do C ++ 11 threads become irreconcilable when using nested pragmas OpenMP? that you should not mix OpenMP and C ++ 11 streams, but for now this works for me.
For various reasons, I would like to improve this, but I'm not sure which strategy to adopt.

In OpenMP vs C ++ 11 streams, I read that replacing OpenMP with std::thread has a significant impact on performance due to std::thread creation and destruction, but I couldn't find anything about replacing parallelism-based OpenMP acceleration based on std::async tasks std::async . In my opinion, this should be faster than std::thread , because then the flow control is performed by the operating system, but I'm not sure if this is applicable. I have not tried it yet, because it is connected with the load of refactoring, and I would like to hear other opinions first.

Do you have experience harmonizing HPC and interactivity? In your eyes, should std::async be relatively fast for OpenMP?

+4
source share

Source: https://habr.com/ru/post/1238395/


All Articles