MPI_Send和MPI_Recv [英] MPI_Send and MPI_Recv
问题描述
我将MPICH2安装到装有Windows 7操作系统的两台计算机('suaddell'和'o01')上.我使用VC ++ Express Edition 2008进行编译.一切都很好.我可以在两个主机中运行简单的"Hello World" MPI应用程序.但是,当我尝试运行简单的MPI_Send和MPI_Recv应用程序时,该程序没有结束,但挂起了.通过使用资源监视器,我可以看到它在我的计算机和远程主机上无休止地运行.如果我按"Ctrl + C",则结束并显示以下消息,它假装一切正常.
I installed MPICH2 to two computers ( 'suaddell' and 'o01' ) with Windows 7 operating system. I use VC++ Express Edition 2008 for compiling. Everything is good. I can run simple "Hello World" MPI applications in both hosts. But when I try to run simple MPI_Send and MPI_Recv applications, the program does not end, it hangs. I can see it runs without end on my computer and remote host by using Resource Monitor. If I press "Ctrl+C", it is ended and it displays below message, it pretends that every things work fine.
C:\>mpiexec.exe -hosts 2 suaddell o01 -noprompt mesajlasma.exe
mpiexec aborting job...
Received Message :Hello World
_OK!_
job aborted:
rank: node: exit code[: error message]
0: suaddell: 123: mpiexec aborting job
1: o01: 123
代码在这里:
#include "stdafx.h"
#include "string.h"
#include "mpi.h"
int main(int argc, char* argv[])
{
int nTasks, rank;
char mesaj[20];
MPI_Status status;
MPI_Init(&argc,&argv);
MPI_Comm_size(MPI_COMM_WORLD,&nTasks);
MPI_Comm_rank(MPI_COMM_WORLD,&rank);
if(rank == 1)
{
strcpy_s(mesaj, "Hello World");
if (MPI_SUCCESS==MPI_Send(mesaj, strlen(mesaj)+1, MPI_CHAR, 0, 7, MPI_COMM_WORLD)) printf("_OK!_\n");
}
if(rank == 0)
{
MPI_Recv(mesaj, 20, MPI_CHAR, 1, 7, MPI_COMM_WORLD, &status);
printf("Received Message :%s\n", mesaj);
}
MPI_Finalize();
return 0;
}
当程序使用"-verbose"运行时,我可以看到系统在这里等待,直到按"Ctrl + C":
. (这里有很多行)
When the program runs by using "-verbose" , i can see that the system is waiting here untill pressing "Ctrl+C":
. (There are a lot of lines here) .
......command written to left: "cmd=result src=0 dest=2 tag=5 cmd_tag=0 ctx_key=
0 result=SUCCESS "
......\smpd_free_command
.......\smpd_init_command
......./smpd_init_command
....../smpd_free_command
...../smpd_state_writing_cmd
..../smpd_handle_op_write
....sock_waiting for the next event.
....\SMPDU_Sock_wait
(这是我按"Ctrl + C"之前的最后一行)
如何解决此问题.
预先感谢
推荐答案
升级到MPICH2的最新版本1.4.1p1.
Upgrade to the latest version of MPICH2, version 1.4.1p1.
这篇关于MPI_Send和MPI_Recv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!