MPI_Rank为所有进程返回相同的进程号 [英] MPI_Rank return same process number for all process

查看:476
本文介绍了MPI_Rank为所有进程返回相同的进程号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在debian 7上使用openmpi和mpirun运行此示例hello world程序.

I'm trying to run this sample hello world program with openmpi and mpirun on debian 7.

#include <stdio.h>
#include <mpi/mpi.h>

int main (int argc, char **argv) {
   int nProcId, nProcNo;

   int nNameLen;
   char szMachineName[MPI_MAX_PROCESSOR_NAME];

   MPI_Init (&argc, &argv); // Start up MPI

   MPI_Comm_size (MPI_COMM_WORLD,&nProcNo); // Find out number of processes
   MPI_Comm_rank (MPI_COMM_WORLD, &nProcId); // Find out process rank
   MPI_Get_processor_name (szMachineName, &nNameLen); // Get machine name

   printf ("Hello World from process %d on %s\r\n", nProcId, szMachineName);

   if (nProcId == 0)
      printf ("Number of Processes: %d\r\n", nProcNo);

   MPI_Finalize (); // Shut down MPI

   return 0;
}

我的问题是MPI_Comm_Rank为该进程的所有副本返回0.当我在shell上运行此命令时:

My problem is MPI_Comm_Rank returns 0 for all copies of the process. When I run this command on the shell:

mpirun -np 4  helloWorld

它产生以下输出:

Hello World from process 0 on debian
Number of Processes: 1
Hello World from process 0 on debian
Number of Processes: 1
Hello World from process 0 on debian
Number of Processes: 1
Hello World from process 0 on debian
Number of Processes: 1

为什么进程数仍为1?

推荐答案

请确保mpiccmpirun都来自相同的MPI实现.当mpirun无法为启动的进程提供必要的Universe信息时,最常见的原因是可执行文件是针对不同的MPI实现(甚至是同一实现的不同版本)构建的,因此MPI_Init()回到所谓的 singleton MPI初始化,并创建一个仅包含调用过程的MPI_COMM_WORLD.因此,结果是许多MPI进程在各自独立的MPI_COMM_WORLD实例中.

Make sure that both mpicc and mpirun come from the same MPI implementation. When mpirun fails to provide the necessary universe information to the launched processes, with the most common reason for that being that the executable was build against a different MPI implementation (or even a different version of the same implementation), MPI_Init() falls back to the so-called singleton MPI initialisation and creates an MPI_COMM_WORLD that only contains the calling process. Thus the result is many MPI processes within their own separate MPI_COMM_WORLD instances.

通常,像mpicc --showmewhich mpiccwhich mpirun这样的命令可以帮助您确定是否确实如此.

Usually commands like mpicc --showme, which mpicc and which mpirun could help you find out if that is the case indeed.

这篇关于MPI_Rank为所有进程返回相同的进程号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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