MPI detection: mpicc/mpiicc before pkg-config

The standard way to compile MPI applications (recommanded by all MPI implementations)
is to use the commands mpicc/mpiicc (and friends). Therefore, it is standard to
just set PATH such that mpicc points towards a wrapper of the MPI implementation
that one wants to use.

In contrast, pkg-config is supported only by OpenMPI.

Therefore, Meson has first to take into account the mpicc command to get chance
to use mpicc of MPICH or IntelMPI in the case OpenMPI is installed
(so that pkg-config would find it).
pull/13712/head
paugier 2 months ago committed by Eli Schwartz
parent b7bf61e33e
commit e2ab61627a
  1. 25
      mesonbuild/dependencies/mpi.py

@ -37,18 +37,6 @@ def mpi_factory(env: 'Environment',
return [] return []
compiler_is_intel = compiler.get_id() in {'intel', 'intel-cl'} compiler_is_intel = compiler.get_id() in {'intel', 'intel-cl'}
# Only OpenMPI has pkg-config, and it doesn't work with the intel compilers
if DependencyMethods.PKGCONFIG in methods and not compiler_is_intel:
pkg_name = None
if language == 'c':
pkg_name = 'ompi-c'
elif language == 'cpp':
pkg_name = 'ompi-cxx'
elif language == 'fortran':
pkg_name = 'ompi-fort'
candidates.append(functools.partial(
PkgConfigDependency, pkg_name, env, kwargs, language=language))
if DependencyMethods.CONFIG_TOOL in methods: if DependencyMethods.CONFIG_TOOL in methods:
nwargs = kwargs.copy() nwargs = kwargs.copy()
@ -90,6 +78,19 @@ def mpi_factory(env: 'Environment',
candidates.append(functools.partial( candidates.append(functools.partial(
MSMPIDependency, 'msmpi', env, kwargs, language=language)) MSMPIDependency, 'msmpi', env, kwargs, language=language))
# Only OpenMPI has pkg-config, and it doesn't work with the intel compilers
# for MPI, environment variables and commands like mpicc should have priority
if DependencyMethods.PKGCONFIG in methods and not compiler_is_intel:
pkg_name = None
if language == 'c':
pkg_name = 'ompi-c'
elif language == 'cpp':
pkg_name = 'ompi-cxx'
elif language == 'fortran':
pkg_name = 'ompi-fort'
candidates.append(functools.partial(
PkgConfigDependency, pkg_name, env, kwargs, language=language))
return candidates return candidates
packages['mpi'] = mpi_factory packages['mpi'] = mpi_factory

Loading…
Cancel
Save