2010-11-23 42 views
0

如何使用MPI_Comm_spawn启动远程节点上的工作进程?远程节点上的mpi_comm_spawn

使用的openmpi 1.4.3,我试过这段代码:

MPI_Info info; 
MPI_Info_create(&info); 
MPI_Info_set(info, "host", "node2"); 
MPI_Comm intercom; 
MPI_Comm_spawn("worker", 
     MPI_ARGV_NULL, 
     nprocs, 
     info, 
     0, 
     MPI_COMM_SELF, 
     &intercom, 
     MPI_ERRCODES_IGNORE); 

但失败与此错误消息:

 
-------------------------------------------------------------------------- 
There are no allocated resources for the application 
    worker 
that match the requested mapping: 


Verify that you have mapped the allocated resources properly using the 
--host or --hostfile specification. 
-------------------------------------------------------------------------- 
-------------------------------------------------------------------------- 
A daemon (pid unknown) died unexpectedly on signal 1 while attempting to 
launch so we are aborting. 

There may be more information reported by the environment (see above). 

This may be because the daemon was unable to find all the needed shared 
libraries on the remote node. You may set your LD_LIBRARY_PATH to have the 
location of the shared libraries on the remote nodes and this will 
automatically be forwarded to the remote nodes. 
-------------------------------------------------------------------------- 

如果我取代 “节点2” 有名称我的本地机器,然后它工作正常。如果我ssh进入node2并在那里运行相同的东西(在info字典中使用“node2”),那么它也可以正常工作。

我不想用mpirun启动父进程,所以我只是寻找一种方法来动态生成远程节点上的进程。这可能吗?

回答

1

我不想启动父 过程与的mpirun,所以我只是 寻找一种方式来动态产卵在远程节点上 过程。这可能是 吗?

我不确定你为什么不想用mpirun启动它?无论如何,只要您点击MPI_Init(),您就会默认启动整个MPI机器,这样您只需传递选项而不是依赖默认值即可。

这里的问题很简单,当MPI库启动时(在MPI_Init()),它看不到任何其他可用的主机,因为你没有给出--host或--hostfile选项到mpirun。它不会只是在你说的其他地方启动进程(事实上,产卵不需要Info主机,所以一般来说它甚至不知道该去哪里),所以它失败了。

所以你需要做的 mpirun --host myhost,host2 -np 1 ./parentjob ,或者更一般地说,提供HOSTFILE,最好用可

myhost slots=1 
host2 slots=8 
host3 slots=8 

时隙数和启动工作这种方式,mpirun --hostfile mpihosts.txt -np 1 ./parentjob这是一个特点,不是一个bug;现在MPI需要找出工作人员去哪里,如果您没有在信息中明确指定主机,它会尝试将其置于未充分利用的地方。这也意味着你不必重新编译来改变你将产生的主机。

+0

谢谢。我想避免mpirun的原因是我正在写一个MATLAB mex文件来卸载一些计算。所以我只有一个MATLAB为我调用的C文件,这意味着主机名需要以编程方式进行指定。我想这意味着我必须以某种方式从我的mex文件的新进程中调用mpirun? – krashalot 2010-11-24 00:25:59