Openmpi mpmd 获取通信大小
问题描述
我有两个 openmpi 程序,我是这样开始的
I have two openmpi programs which I start like this
现在我如何使用 MPI_Comm_size(MPI_COMM_WORLD, &size)
以便我获得大小值
Now how do I use MPI_Comm_size(MPI_COMM_WORLD, &size)
such that i get size values as
截至目前,我在两个程序中都获得了6".
As of now I get "6" in both programs.
推荐答案
这是可行的,虽然实现起来有点麻烦.其原理是根据argv[0]
的值将MPI_COMM_WORLD
拆分为多个通信器,其中包含可执行文件的名称.
This is doable albeit a bit cumbersome to get that. The principle is to split MPI_COMM_WORLD
into communicators based on the value of argv[0]
, which contains the executable's name.
可能是这样的:
在我的机器上,我编译并运行它如下:
On my machine, I compiled and ran it as follow:
理想情况下,如果存在用于按二进制文件进行排序的相应类型,则可以通过使用 MPI_Comm_split_type()
来大大简化这一过程.不幸的是,在 3.1 MPI 标准中没有预定义这样的 MPI_COMM_TYPE_
.唯一的预定义是 MPI_COMM_TYPE_SHARED
用于在运行在相同共享内存计算节点上的进程之间进行排序......太糟糕了!也许该标准的下一个版本需要考虑什么?
Ideally, this could be greatly simplified by using MPI_Comm_split_type()
if the corresponding type for sorting out by binaries existed. Unfortunately, there is no such MPI_COMM_TYPE_
pre-defined in the 3.1 MPI standard. The only pre-defined one is MPI_COMM_TYPE_SHARED
to sort-out between processes running on the same shared memory compute nodes... Too bad! Maybe something to consider for the next version of the standard?
这篇关于Openmpi mpmd 获取通信大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!