【发布时间】:2015-05-18 06:28:47
【问题描述】:
我使用以下命令在我的 Ubuntu 14.04 笔记本电脑上安装了 mpich2:
sudo apt-get install libcr-dev mpich2 mpich2-doc
这是我要执行的代码:
#include <mpi.h>
#include <stdio.h>
int main()
{
int myrank, size;
MPI_Init(NULL, NULL);
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
printf("Hello world! I am %d of %d\n", myrank, size);
MPI_Finalize();
return 0;
}
将其编译为mpicc helloworld.c 不会出错。但是当我将程序执行为:mpirun -np 5 ./a.out 没有输出时,程序只是继续执行,就好像它处于无限循环中一样。按 Ctrl+C 时,我得到的是:
$ mpirun -np 5 ./a.out
^C[mpiexec@user] Sending Ctrl-C to processes as requested
[mpiexec@user] Press Ctrl-C again to force abort
[mpiexec@user] HYDU_sock_write (./utils/sock/sock.c:291): write error (Bad file descriptor)
[mpiexec@user] HYD_pmcd_pmiserv_send_signal (./pm/pmiserv/pmiserv_cb.c:170): unable to write data to proxy
[mpiexec@user] ui_cmd_cb (./pm/pmiserv/pmiserv_pmci.c:79): unable to send signal downstream
[mpiexec@user] HYDT_dmxu_poll_wait_for_event (./tools/demux/demux_poll.c:77): callback returned error status
[mpiexec@user] HYD_pmci_wait_for_completion (./pm/pmiserv/pmiserv_pmci.c:197): error waiting for event
[mpiexec@user] main (./ui/mpich/mpiexec.c:331): process manager error waiting for completion
我无法通过谷歌搜索找到任何解决方案。是什么导致了这个错误?
【问题讨论】:
-
试试
int main(int argc, char *argv[])和MPI_Init(&argc,&argv);...但是,正如documentation of MPICH2 中所述,MPI_Init()将接受 NULL 作为输入参数...尝试which mpicc,which mpirun和mpirun -version知道 mpirun 和 mpicc 是否都对应于 mpich。如果 mpicc 指 mpich 和 mpirun 指 openmpi,就会发生奇怪的事情。也可以试试mpirun -np 5 a.out -
感谢您的回复。我尝试添加 argc、argv、
mpirun np 5 a.out但得到了同样的错误。which mpicc给了/usr/bin/mpicc,而 mpirun 给了/usr/bin/mpirun。 mpirun -version 在多次出现 mpich 时给出了很多输出,所以我猜它一定是指 mpich。我还能尝试什么? -
mpiexec给出了同样的错误。 -
其他 cmets 正在解决此问题的最常见原因:mpi 实现之间的不匹配。您是否安装了任何其他 MPI? OpenMPI,您构建的 MPICH 的旧版本?
-
您可以尝试
mpicc helloword.c -v打印编译器调用的程序吗?openmpi或mpich已链接,它将作为库的调用出现在GCC_OPTIONS中。