2013-04-13 85 views
1

我是使用MPI的初学者。在这里我写了一个非常简单的程序来测试MPI是否可以运行。这是我的hello.c:MPI_Barrier在Ubuntu中无法正常工作

#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(); 
} 

我使用节点测试中,HOSTFILE是:节点1节点2

所以我有两台机器名节点1和节点。我可以没有密码ssh对方。

我通过输入:mpirun -np 2 -f hostfile ./hello来启动程序。

可执行文件hello位于两台机器的相同目录中。

然后我跑后,我得到一个错误:

Fatal error in PMPI_Barrier: Other MPI error, error stack: PMPI_Barrier(425).........: MPI_Barrier(MPI_COMM_WORLD) failed MPIR_Barrier_impl(331)....: Failure during collective MPIR_Barrier_impl(313)....: MPIR_Barrier_intra(83)....: dequeue_and_set_error(596): Communication error with rank 0 Fatal error in PMPI_Barrier: Other MPI error, error stack: PMPI_Barrier(425).........: MPI_Barrier(MPI_COMM_WORLD) failed MPIR_Barrier_impl(331)....: Failure during collective MPIR_Barrier_impl(313)....: MPIR_Barrier_intra(83)....: dequeue_and_set_error(596): Communication error with rank 1

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

我使用Ubuntu 12.10

我得到了一些提示:这不会在MPICH2很好地工作,如果我使用了openmpi,那么它的工作原理。我只是通过sudo apt-get install mpich2来安装MPICH。我想念什么? MPICH2的大小比了openmpi

+1

1)HOSTFILE需要在单独的行的计算机名称,是否如此? 2)如果您评论MPI_Barrier行,程序输出是什么? 3)你是如何编译程序的? –

+1

http://stackoverflow.com/questions/12854879/mpi-barrier-does-not-work-on-a-small-cluster这听起来有关 –

+1

@RafaelReiter是正确的;这通常是一个配置问题。两个节点之间的无密码ssh是必要的,但MPI通常还需要打开各种各样的端口,因此请查看任何防火墙,iptables规则等:https://wiki.mpich.org/mpich/index.php/ Frequently_Asked_Questions#问:_My_MPI_program_aborts_with_an_error_saying_it_cannot_communicate_with_other_processes –

回答

0

在/ etc/hosts中,一些Linux发行版的新版本在文件的顶部添加以下类型的行小得多:

127.0.0.1 localhost 
127.0.0.1 [hostname] 

这个应该这么改主机名行包含您的实际IP地址。如果不进行此更改与类似错误的MPI水螅过程将中止:

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 
相关问题