MPI 是否提供预处理器宏?

Does MPI provide preprocessor macros?

MPI 标准是否提供预处理器宏,所以如果我的 C/C++ 代码是由支持 MPI 的编译器编译的,它可以分支吗?类似于 OpenMP 的 _OPENMP 宏。

根据 MPI standard(第 335 页),您可以检查 MPI_VERSION 宏:

In order to cope with changes to the MPI Standard, there are both compile-time and runtime ways to determine which version of the standard is in use in the environment one is using.

The "version" will be represented by two separate integers, for the version and subversion:

In C,

#define MPI_VERSION 3
#define MPI_SUBVERSION 0