MPI流程是如何开始的? [英] How are MPI processes started?

查看:269
本文介绍了MPI流程是如何开始的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用mpirunmpiexec启动MPI作业时,我可以理解如何启动每个单独的进程.但是,在没有任何编译器魔术的情况下,这些包装可执行文件如何将安排(MPI通讯器)传达给MPI进程?

When starting an MPI job with mpirun or mpiexec, I can understand how one might go about starting each individual process. However, without any compiler magic, how do these wrapper executables communicate the arrangement (MPI communicator) to the MPI processes?

我对详细信息或寻找外观的指针感兴趣.

I am interested in the details, or a pointer on where to look.

推荐答案

有关各个进程如何建立MPI Universe的详细信息是特定于实现的.您应该查看特定库的源代码,以了解其工作方式.但是,有两种几乎通用的方法:

Details on how individual processes establish the MPI universe are implementation specific. You should look into the source code of the specific library in order to understand how it works. There are two almost universal approaches though:

  • 命令行参数:MPI启动器可以将参数传递给生成的进程,以指示如何建立连接以及在何处建立宇宙.这就是为什么必须通过在C中用argcargv调用MPI_Init()来初始化MPI的原因,因此库可以访问命令行并提取所有针对它的参数;
  • 环境变量:MPI启动器可以设置特定的环境变量,其内容可以指示在何处以及如何进行连接.
  • command line arguments: the MPI launcher can pass arguments to the spawned processes indicating how and where to connect in order to establish the universe. That's why MPI has to be initialised by calling MPI_Init() with argc and argv in C - thus the library can get access to the command line and extract all arguments that are meant for it;
  • environment variables: the MPI launcher can set specific environment variables whose content can indicate where and how to connect.

例如,Open MPI设置环境变量,并且还在运行在同一节点上的所有进程都知道的磁盘位置中写入某些Universe状态.通过执行mpirun -np 1 printenv:

Open MPI for example sets environment variables and also writes some universe state in a disk location known to all processes that run on the same node. You can easily see the special variables that its run-time component ORTE (OpenMPI Run-Time Environment) uses by executing a command like mpirun -np 1 printenv:

$ mpiexec -np 1 printenv | grep OMPI
... <many more> ...
OMPI_MCA_orte_hnp_uri=1660944384.0;tcp://x.y.z.t:43276;tcp://p.q.r.f:43276
OMPI_MCA_orte_local_daemon_uri=1660944384.1;tcp://x.y.z.t:36541
... <many more> ...

(出于安全原因更改了IP)

(IPs changed for security reasons)

一旦远程启动子进程并调用MPI_Init()MPI_Init_thread(),ORTE就会启动并读取这些环境变量.然后,它使用"home" mpirun/mpiexec进程连接回指定的网络地址,该进程随后协调所有产生的进程以建立MPI Universe.

Once a child process is launched remotely and MPI_Init() or MPI_Init_thread() is called, ORTE kicks in and reads those environment variables. Then it connects back to the specified network address with the "home" mpirun/mpiexec process which then coordinates all spawned processes into establishing the MPI universe.

其他MPI实现的工作方式与此相似.

Other MPI implementations work in a similar fashion.

这篇关于MPI流程是如何开始的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆