本文介绍了我可以使用`std :: this_thread :: sleep_for()`与MPI过程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

MPI使用多个进程运行我的程序。



我会让其中一个进程休眠一段时间,以便使用最少的CPU。



std :: this_thread :: sleep_for()看起来像我想要的,但线程



>解决方案

这是完全可以做的 - 没有什么应该崩溃或挂起作为结果。



但是,使用最少的CPU是有点担心。你运行的MPI进程比你有硬件线程可以执行吗?这种超额预订对于性能通常是可怕的,并且应当避免。每个硬件节点的最佳性能通常比其提供的硬件线程数少一个,以允许系统进程在不预先应用应用程序的情况下运行。



在这种情况下,这可以很好地证明(我刚刚发布了 )是如果你有一个程序的部分,你有更少的并行性比你有进程。如果你在使用Turbo Boost的Intel CPU上运行,那么使空闲进程实际上休眠可以允许运行工作进程的核心以更高的时钟速度运行。


MPI runs my program with multiple processes.

I'd one of these processes to sleep for a while so that it's using minimal CPU.

std::this_thread::sleep_for() looks like what I want, but that thread bit looks a little sketchy in this context.

Is it okay to do this?

解决方案

This is perfectly OK to do - nothing should crash or hang as a result of it.

However, your "so that it's using minimal CPU" is a little worrying. Are you running more MPI processes than you have hardware threads available to execute them? That sort of oversubscription is generally terrible for performance, and should be avoided. Best performance is often seen with one fewer process per hardware node than the number of hardware threads it offers, to allow system processes someplace to run without pre-empting the application.

The case where this could be well-justified (on which I just published a paper) is if you have a section of your program where you have less parallelism than you have processes. If you're running on Intel CPUs with Turbo Boost, then having the idle processes actually sleep can allow the core(s) running the working process(es) to run at a higher clock speed.

这篇关于我可以使用`std :: this_thread :: sleep_for()`与MPI过程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 03:04