问题描述
我想获取一个以mpirun/mpiexec工具开头的mpi应用程序的进程ID.
I would like to get the process ids of an mpi application which I start with mpirun/mpiexec tools.
例如,我运行带有8个进程的代码,并希望在执行开始时获取所有这8个进程的进程ID,以将另一个工具作为输入.
For example I run my code with lets say 8 processes and want to get the process ids of all these 8 processes right at the beginning of the execution to give to another tool as an input.
什么是正确的方法?
推荐答案
我不相信有任何MPI库例程可以返回正在运行MPI进程的o/s进程的pid.确切地说,我不认为MPI标准要求有一个:MPI流程和o/s流程之间的映射,也不需要任何其他映射基数,尽管我不认为我曾经使用过在流程的不同视图之间没有one:one映射的MPI实现.
I don't believe that there is any MPI library routine which will return the pid of the o/s process which is running an MPI process. To be absolutely precise I don't think that the MPI standard requires there to be a one:one mapping between MPI processes and o/s processes, nor any other cardinality of mapping, though I don't think I've ever used an MPI implementation where there wasn't a one:one mapping between the different views of processes.
除此之外,如果您在Linux机器上,为什么不简单地使用getpid
呢?每个MPI进程都应获得自己的pid.我猜有一个Windows系统调用可以执行相同的操作,但是我对Windows不太了解.
All that aside, why not simply use getpid
if you are on Linux machine ? Each MPI process should get its own pid. I guess there is a Windows system call which does the same thing but I don't know much about Windows.
这篇关于MPI进程ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!