MPI_Dims_create在远程计算机上抛出错误

时间:2017-10-11 22:51:35

标签: c++ openmpi

我正在尝试设置笛卡尔网格作为算法的第一步。在我的本地计算机(带有clang的OS X)上,我的代码运行。在研究集群(Linux with GNU)上,我收到以下错误。

$mpirun -n 4 ./test.exe
[shas0137:67495] *** An error occurred in MPI_Dims_create
[shas0137:67495] *** reported by process [3694788609,1]
[shas0137:67495] *** on communicator MPI_COMM_WORLD
[shas0137:67495] *** MPI_ERR_DIMS: invalid topology dimension
[shas0137:67495] *** MPI_ERRORS_ARE_FATAL (processes in this communicator will now abort,
[shas0137:67495] ***    and potentially your MPI job)
[shas0137:67491] 3 more processes have sent help message help-mpi-errors.txt / mpi_errors_are_fatal
[shas0137:67491] Set MCA parameter "orte_base_help_aggregate" to 0 to see all help / error messages

设置“orte_base_help_aggregate”参数只重复错误消息4次(每个进程一次)

大多数MPI例程都有文档中的错误代码列表,但MPI_Dims_create未列出MPI_ERR_DIMS

版本细节:本地

$ mpic++ -v
Apple LLVM version 9.0.0 (clang-900.0.37)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin 

版本细节:研究集群

$ mpic++ -v
Using built-in specs.
COLLECT_GCC=/curc/sw/gcc/6.1.0/bin/g++
COLLECT_LTO_WRAPPER=/curc/sw/gcc/6.1.0/libexec/gcc/x86_64-pc-linux-gnu/6.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-6.1.0/configure --prefix=/curc/sw/gcc/6.1.0 --enable-languages=c,c++,fortran,go --disable-multilib --with-tune=intel
Thread model: posix
gcc version 6.1.0 (GCC) 

MCVE

(或者尽可能接近可验证,因为这只会在某些配置上发生)

#include <mpi.h>

int main(int argc, char* argv[]) {

    MPI_Init(&argc, &argv);
    MPI_Status st;
    MPI_Comm comm = MPI_COMM_WORLD;

    MPI_Comm grid_comm;

    int size;
    int err = MPI_Comm_size(comm, &size);

    //Error handling
    if (err != MPI_SUCCESS) {
        return 1;
    }

    std::cout << size << std::endl;

    //This call throws the error
    int dims[3];
    err = MPI_Dims_create(size, 3, dims);

    //Error handling
    if (err != MPI_SUCCESS) {
        return 2;
    }

    MPI_Finalize();
    return 0;
}

1 个答案:

答案 0 :(得分:1)

TLDR

我声明但没有初始化昏暗的数组。在我的本地机器上,我巧妙地得到了一大块记忆。

为什么这很重要?

我错过了这一点非常重要,因为我错过了dims既是输入又是输出参数。我假设作为输出参数,dim中的任何值都将被MPI例程覆盖。

我咨询的原始文件(from MPICH)非常简短。

  

MPI_Dims_create

     

输入/输出参数

     

dims

     

大小为ndims的整数数组,指定其中的节点数   每个维度。 值为0表示MPI_Dims_create应该   填写合适的价值。(强调我的)

即。例程不会覆盖非零值。

有关MPI Forum MPI Documentation的更多信息:

  

6.5.2。笛卡尔便捷函数:MPI_DIMS_CREATE

     

(...)   调用者可以进一步限制该例程的操作   指定数组dims的元素。如果dims [i]设置为正数   数字,例程不会修改维度中的节点数   一世;只有调用修改了dims [i] = 0的条目。

     

dims [i]的负输入值是错误的。 (...)

简而言之,在研究集群中,未初始化的dims数组中的值要么是负数,要么大于我尝试分配的节点数。

相关问题