C ++未知调用约定

时间:2019-06-27 05:31:06

标签: c++ syntax mpi icc

我正在构建的程序包(SPRNG,链接为here,但对于该问题不是必需的)在我不熟悉的某些地方使用了调用语法。对于我以前的依赖项堆栈(具有OpenMPI 1.10.1的Intel 16.0),它可以工作。不幸的是,我当前的堆栈(带有OpenMPI 3.1.3的Intel 19)不喜欢它。我不是c++人,除非有必要,我也不想大幅修改软件包。

示例代码为:

#include <mpi.h>

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

  MPI::Init(argc, argv);
  myid = MPI::COMM_WORLD.Get_rank();
}

在以前的堆栈中,这似乎很好:

$ mpic++ --version
icpc (ICC) 16.0.0 20150815
Copyright (C) 1985-2015 Intel Corporation.  All rights reserved.

$ mpirun --version
mpirun (Open MPI) 1.10.1

Report bugs to http://www.open-mpi.org/community/help/
$ mpic++ sprng_issue.cpp
<no errors>

但是有了新的堆栈:

$ mpic++ --version
icpc (ICC) 19.0.1.144 20181018
Copyright (C) 1985-2018 Intel Corporation.  All rights reserved.

$ mpirun --version
mpirun (Open MPI) 3.1.3

Report bugs to http://www.open-mpi.org/community/help/
$ mpic++ sprng_issue.cpp 
sprng_issue.cpp(6): error: name followed by "::" must be a class or namespace name
    MPI::Init(argc, argv);
    ^

sprng_issue.cpp(7): error: name followed by "::" must be a class or namespace name
    myid = MPI::COMM_WORLD.Get_rank();
           ^

compilation aborted for sprng_issue.cpp (code 2)

我的问题是:

  1. 此调用方法是否有名称?我只是在搜索时遇到了麻烦。

  2. 是否有用于启用旧版行为的编译器标志(Intel或其他)?

  3. 是否有其他建议可以轻松通过而又无需实质上修改程序包代码?

1 个答案:

答案 0 :(得分:6)

C++绑定已在很多年前从标准中删除,并且默认情况下在Open MPI中不再构建它们。

从长远来看,您应该对代码进行现代化(使用简单的C绑定或其他抽象层,例如Boost.MPI)。

与此同时,您只需使用configure --enable-mpi-cxx来重建Open MPI。