【问题标题】:Waiting for other processors to finish their tasks in MPI等待其他处理器在 MPI 中完成它们的任务
【发布时间】:2012-05-05 11:40:06
【问题描述】:

使用 MPI,如何等待线程完成?

例如:

for (int i = localstart; i < localend; i++)
{
    // do stuff that is computationally intensive
}
// I need to wait for all other threads to finish here
if (rank == 0) do_something();

【问题讨论】:

    标签: mpi


    【解决方案1】:

    如果线程是指进程/等级,那么答案是MPI_Barrier

    但也请看看其他集体操作:它们可能在您的应用程序中有意义,并且提供比手动编码通信更好的性能。例如,您可以使用MPI_Allgather 将所有数据传递给所有等级,等等。

    如果您指的是线程(如 pthreads),那么您必须使用线程库提供的任何内容。

    【讨论】:

    • 我的意思是进程/等级。谢谢,这正是我想要的。
    猜你喜欢
    • 2012-12-26
    • 2013-05-26
    • 1970-01-01
    • 1970-01-01
    • 2016-05-27
    • 1970-01-01
    • 1970-01-01
    • 2018-08-20
    • 1970-01-01
    相关资源
    最近更新 更多