我正在尝试使用MPI_Comm_spawn来启动第二个进程。只是为了演示pourposes。该计划非常简单:
int main(int argc, char* argv[])
{ int my_id, numprocs;
MPI_Comm All;
MPI_Init(&argc, &argv) ;
MPI_Comm_rank(MPI_COMM_WORLD, &my_id) ;
MPI_Comm_size(MPI_COMM_WORLD, &numprocs) ;
cout << "I'm process "<< my_id << " and we are " << numprocs <<endl;
MPI_Comm_spawn("child.exe",MPI_ARGV_NULL,2,MPI_INFO_NULL,my_id,MPI_COMM_WORLD, &All,MPI_ERRCODES_IGNORE);
MPI_Comm_size(All, &numprocs) ;
cout << "I'm process "<< my_id << " and we are " << numprocs <<endl;
{
int i;
cin >> i;
}
MPI_Finalize();
return 0;
}
child.exe与编译程序位于同一目录中,并且非常简单:
int main(int argc, char* argv[])
{
int my_id, numprocs,length;
MPI_Comm Parent;
MPI_Win pwin,gwin;
MPI_Init(&argc, &argv) ;
MPI_Comm_rank(MPI_COMM_WORLD, &my_id) ;
MPI_Comm_size(MPI_COMM_WORLD, &numprocs) ;
MPI_Comm_get_parent(&Parent);
cout << "I'm child process "<< my_id << " and we are " << numprocs <<endl;
MPI_Comm_size(Parent, &numprocs) ;
cout << "My parent communicator size is: "<< numprocs <<endl;
MPI_Finalize();
return 0;
}
父进程失败,出现了一个错误: C:\ Users ..... \ Documents \ Visual Studio 2010 \ Projects \ mpi \ x64 \ Release&gt; mpi.exe 我处理0,我们是1
工作中止: [排名]消息
[0]致命错误 MPI_Comm_spawn中的致命错误:其他MPI错误,错误堆栈: MPI_Comm_spawn(106)..........:MPI_Comm_spawn(cmd =“child.exe”,argv = 0x0000000000 000000,maxprocs = 2,MPI_INFO_NULL,root = 0,MPI_COMM_WORLD,intercomm = 0x000000000 026FC20,错误= 0x0000000000000000)失败 MPID_Comm_spawn_multiple(314):函数未实现
我做错了......看起来很简单.... MSMPI没有实现MPI_Comm_spawn?
答案 0 :(得分:2)
根据this document,它不受支持,至少在Windows HPC Server 2008中不受支持。
来自文件:
MS MPI包含一整套MPI2 在MPICH2中实现的功能 ,但动态进程spawn 除外 和出版,可能是 包括在以后的版本中。