Skip to content

Commit 8bc6529

Browse files
committed
MPI detection: support Intel MPI on Windows
1 parent c42881a commit 8bc6529

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

mesonbuild/dependencies/mpi.py

+47
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from ..environment import detect_cpu_family
1212
from ..mesonlib import Popen_safe
13+
from ..options import OptionKey
1314
from .base import DependencyException, DependencyMethods, detect_compiler, SystemDependency
1415
from .configtool import ConfigToolDependency
1516
from .detect import packages
@@ -82,6 +83,8 @@ def mpi_factory(env: 'Environment',
8283
if DependencyMethods.SYSTEM in methods and env.machines[for_machine].is_windows():
8384
candidates.append(functools.partial(
8485
MSMPIDependency, 'msmpi', env, kwargs, language=language))
86+
candidates.append(functools.partial(
87+
IMPIDependency, 'impi', env, kwargs, language=language))
8588

8689
# Only OpenMPI has pkg-config, and it doesn't work with the intel compilers
8790
# for MPI, environment variables and commands like mpicc should have priority
@@ -244,3 +247,47 @@ def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any],
244247
self.compile_args = ['-I' + incdir, '-I' + os.path.join(incdir, post)]
245248
if self.language == 'fortran':
246249
self.link_args.append('-l' + os.path.join(libdir, 'msmpifec'))
250+
251+
252+
class IMPIDependency(SystemDependency):
253+
254+
"""Intel(R) MPI for Windows."""
255+
256+
def __init__(self, name: str, env: Environment, kwargs: T.Dict[str, T.Any],
257+
language: T.Optional[str] = None):
258+
super().__init__(name, env, kwargs, language=language)
259+
# only for windows
260+
if not self.env.machines[self.for_machine].is_windows():
261+
return
262+
# only for x86_64
263+
if detect_cpu_family(self.env.coredata.compilers.host) != 'x86_64':
264+
return
265+
266+
rootdir = os.environ.get('I_MPI_ROOT')
267+
if rootdir is None:
268+
self.is_found = False
269+
return
270+
271+
incdir = os.path.join(rootdir, 'include')
272+
libdir = os.path.join(rootdir, 'lib')
273+
274+
buildtype = env.coredata.optstore.get_value_for(OptionKey('buildtype'))
275+
assert isinstance(buildtype, str)
276+
libdir_post = 'debug' if buildtype.startswith('debug') else 'release'
277+
for subdirs in (['mpi', libdir_post], [libdir_post]):
278+
libdir_buildtype = os.path.join(libdir, *subdirs)
279+
if os.path.isdir(libdir_buildtype):
280+
libdir = libdir_buildtype
281+
break
282+
283+
found_header = os.path.isfile(os.path.join(incdir, 'mpi.h'))
284+
found_library = os.path.isfile(os.path.join(libdir, 'impi.lib'))
285+
if not found_header or not found_library:
286+
self.is_found = False
287+
return
288+
289+
self.is_found = True
290+
self.compile_args = ['-I' + incdir]
291+
self.link_args = ['-l' + os.path.join(libdir, 'impi')]
292+
if self.language == 'cpp':
293+
self.link_args = ['-l' + os.path.join(libdir, 'impicxx')]

0 commit comments

Comments
 (0)