MPI_Barrier在Ubuntu中无法正常工作

时间:2013-04-13 03:54:24

标签: mpi

我是使用MPI的初学者。在这里,我写了一个非常简单的程序来测试MPI是否可以运行。这是我的hello.c:

#include <stdio.h>
#include <mpi.h>

int main(int argc, char *argv[]) {
  int numprocs, rank, namelen;
  char processor_name[MPI_MAX_PROCESSOR_NAME];

  MPI_Init(&argc, &argv);
  MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  MPI_Get_processor_name(processor_name, &namelen);
  MPI_Barrier(MPI_COMM_WORLD);
  printf("Process %d on %s out of %d\n", rank, processor_name, numprocs);

  MPI_Finalize();
}

我用来节点测试,主机文件是:node1 node2

所以我有两台名为node1和node2的机器。我可以在没有密码的情况下互相交换。

我输入以下内容启动该程序:mpirun -np 2 -f hostfile ./hello

可执行文件hello位于两台计算机的同一目录中。

然后在我跑步后,我收到一个错误:

  

PMPI_Barrier中的致命错误:其他MPI错误,错误堆栈:   PMPI_Barrier(425).........:MPI_Barrier(MPI_COMM_WORLD)失败   MPIR_Barrier_impl(331)....:集体失败   MPIR_Barrier_impl(313)....:MPIR_Barrier_intra(83)....:   dequeue_and_set_error(596):秩0的通信错误致命   PMPI_Barrier中的错误:其他MPI错误,错误堆栈:   PMPI_Barrier(425).........:MPI_Barrier(MPI_COMM_WORLD)失败   MPIR_Barrier_impl(331)....:集体失败   MPIR_Barrier_impl(313)....:MPIR_Barrier_intra(83)....:   dequeue_and_set_error(596):秩为1的通信错误

如果我注释掉MPI_Barrier(),它可以正常工作。看来机器之间的通信有问题吗?或者我没有正确安装openmpi?有什么想法吗?

我正在使用Ubuntu 12.10

我得到了一些提示:这在MPICH2中效果不好,如果我使用openmpi,那么它可以工作。我只是通过sudo apt-get install mpich2安装了MPICH。我错过了什么吗? mpich2的大小远小于openmpi

1 个答案:

答案 0 :(得分:0)

在/ etc / hosts中,某些Linux发行版的较新版本会在文件顶部添加以下类型的行:

127.0.0.1 localhost
127.0.0.1 [hostname]

应更改此名称,以便主机名行包含您的实际IP地址。如果您不做出如下错误的更改,MPI hydra进程将中止:

Fatal error in PMPI_Barrier: Other MPI error, error stack:
PMPI_Barrier(425)...........: MPI_Barrier(MPI_COMM_WORLD) failed
MPIR_Barrier_impl(292)......: 
MPIR_Barrier_or_coll_fn(121): 
MPIR_Barrier_intra(83)......: 
dequeue_and_set_error(596)..: Communication error with rank 0
相关问题