尝试排除进程级别0时出现MPI_Group_excl致命错误.c ++

问题描述 投票:0回答:1

大家好,我对编码和MPI都很陌生。我敢肯定这一定是一个非常愚蠢的错误,但我无法理解为什么这段代码:

#include <mpi.h>

int main(int arg, char** argvs) {
    int rank, numOfProcess;
    MPI_Init(&arg, &argvs);
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    MPI_Comm_size(MPI_COMM_WORLD, &numOfProcess);

    int ranks[1] = { 0 };
    MPI_Group orig_group, new_group;
    MPI_Comm new_comm;
    MPI_Comm_group(MPI_COMM_WORLD, &orig_group);
    MPI_Group_excl(orig_group, numOfProcess - 1, ranks, &new_group);
    MPI_Comm_create(MPI_COMM_WORLD, new_group, &new_comm);
    MPI_Finalize();
    return 0;
}

给我以下错误:

 $ mpiexec -n 3 Documents/Visual\ Studio\ 2015/Projects/MPImisc/Debug/MPImisc.exe

 job aborted:
 [ranks] message

 [0] fatal error
 Fatal error in MPI_Group_excl: Invalid rank, error stack:
 MPI_Group_excl(group=0x88000000, n=2, ranks=0x008FF800, 
 new_group=0x008FF7E8) failed
 Invalid rank in rank array at index 1; value is -858993460 but must be in 
 the range 0 to 2

 [1] fatal error
 Fatal error in MPI_Group_excl: Invalid rank, error stack:
 MPI_Group_excl(group=0x88000000, n=2, ranks=0x012FF860, 
 new_group=0x012FF848) failed
 Invalid rank in rank array at index 1; value is -858993460 but must be in 
 the range 0 to 2

[2] fatal error
Fatal error in MPI_Group_excl: Invalid rank, error stack:
MPI_Group_excl(group=0x88000000, n=2, ranks=0x012FFB10, 
new_group=0x012FFAF8) failed
Invalid rank in rank array at index 1; value is -858993460 but must be in 
the range 0 to 2

---- error analysis -----

[0-2] on ASUSPC
mpi has detected a fatal error and aborted Documents/Visual Studio 
2015/Projects/MPImisc/Debug/MPImisc.exe

---- error analysis -----

纠正我,如果我错了,但我正在创建的“new_group”应该包含每个进程,但是那个等级为0.为什么它会给我这个错误?我在数组“rank”中指定我要删除等级0,我迷路了。

非常感谢。

c++ parallel-processing runtime-error mpi
1个回答
0
投票

你没有正确使用MPI_Group_excl()

句法

   int MPI_Group_excl(MPI_Group group, int n, const int ranks[],
        MPI_Group *newgroup)

输入参数

   n         Number of elements in array ranks (integer).

   ranks     Array of integer ranks in group not to appear in newgroup.

因为ranks是一个包含一个元素的数组,所以这就是你应该如何更新你的通话

MPI_Group_excl(orig_group, 1, ranks, &new_group);
© www.soinside.com 2019 - 2024. All rights reserved.