2

我正在尝试使用 MPI_Comm_spawn 来启动第二个进程。只是为了演示。该程序非常简单:

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>mpi.exe 我是进程 0,我们是 1

作业中止:[ranks] 消息

[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, errors=0x0000000000000000) 失败 MPID_Comm_spawn_multiple(314): 功能未实现

我做错了什么......看起来很简单...... MSMPI没有实现 MPI_Comm_spawn ?

4

1 回答 1

2

根据此文档,它不受支持,至少在 Windows HPC Server 2008 中不受支持。

从文件:

MS MPI 包括一整套在 MPICH2 中实现的 MPI2 功能, 但动态进程生成 和发布除外,这些功能可能包含在以后的版本中。

于 2011-03-07T01:07:16.233 回答