OpenMP and C++11 multithreading

别说谁变了你拦得住时间么 提交于 2019-12-22 08:20:59

问题


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?

来源:https://stackoverflow.com/questions/34316191/openmp-and-c11-multithreading

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!