MPI排名流程 [英] MPI rank process

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

问题描述

我是MPI初学者,所以我想确切地了解MPI程序等级的定义,以及为什么我们需要它

I am an MPI beginner, so I 'd like to know exactly the definition of rank of an MPI program, and why we need it

例如,这里有两行代码:

For example, there are 2 lines of code here:

int world_rank;
MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);

推荐答案

要理解这一点,您需要认识到MPI使用SPMD(单程序多数据)模型.这意味着如果您并行运行此程序,例如同时在4个进程上,每个进程都运行同一程序的独立副本.因此,基本问题是:为什么每个过程都做不到相同的事情?要使用并行编程,您需要一些流程来做不同的事情.例如,您可能希望一个进程充当控制器,将作业发送给多个工作人员.等级是每个进程的基本标识符.如果在4个进程上运行,则上述程序将在不同进程上返回0、1、2和3的等级.一旦进程知道其等级,它就可以适当地采取行动,例如如果我的等级为零,则调用控制器函数,否则调用辅助函数".

To understand this, you need to realise that MPI uses the SPMD (Single Program Multiple Data) model. This means that if you run this program in parallel, e.g. on 4 processes at the same time, every process runs its own independent copy of the same program. So, the basic question is: why doesn't every process do the same thing? To make use of parallel programming, you need processes to do different things. For example, you might want one process to act as a controller sending jobs to multiple workers. The rank is the fundamental identifier for each process. If run on 4 processes, then the above program would return ranks of 0, 1, 2 and 3 on the different processes. Once a process knows its rank it can then act appropriately, e.g. "if my rank is zero then call the controller function else call the worker function".

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

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