|
10 | 10 |
|
11 | 11 | from ..environment import detect_cpu_family
|
12 | 12 | from ..mesonlib import Popen_safe
|
| 13 | +from ..options import OptionKey |
13 | 14 | from .base import DependencyException, DependencyMethods, detect_compiler, SystemDependency
|
14 | 15 | from .configtool import ConfigToolDependency
|
15 | 16 | from .detect import packages
|
@@ -82,6 +83,8 @@ def mpi_factory(env: 'Environment',
|
82 | 83 | if DependencyMethods.SYSTEM in methods and env.machines[for_machine].is_windows():
|
83 | 84 | candidates.append(functools.partial(
|
84 | 85 | MSMPIDependency, 'msmpi', env, kwargs, language=language))
|
| 86 | + candidates.append(functools.partial( |
| 87 | + IMPIDependency, 'impi', env, kwargs, language=language)) |
85 | 88 |
|
86 | 89 | # Only OpenMPI has pkg-config, and it doesn't work with the intel compilers
|
87 | 90 | # for MPI, environment variables and commands like mpicc should have priority
|
@@ -244,3 +247,53 @@ def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any],
|
244 | 247 | self.compile_args = ['-I' + incdir, '-I' + os.path.join(incdir, post)]
|
245 | 248 | if self.language == 'fortran':
|
246 | 249 | 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 and x64 |
| 263 | + arch = detect_cpu_family(self.env.coredata.compilers.host) |
| 264 | + if arch not in ('x86', 'x86_64'): |
| 265 | + self.is_found = False # TODO: is this line correct? |
| 266 | + return |
| 267 | + |
| 268 | + rootdir = os.environ.get('I_MPI_ROOT') |
| 269 | + if rootdir is None: |
| 270 | + self.is_found = False |
| 271 | + return |
| 272 | + |
| 273 | + subdir = 'ia32' if arch == 'x86' else 'intel64' |
| 274 | + prefix = os.path.join(rootdir, subdir) |
| 275 | + if not os.path.isdir(prefix): |
| 276 | + prefix = rootdir |
| 277 | + |
| 278 | + incdir = os.path.join(prefix, 'include') |
| 279 | + libdir = os.path.join(prefix, 'lib') |
| 280 | + |
| 281 | + buildtype = env.coredata.optstore.get_value_for(OptionKey('buildtype')) |
| 282 | + libdir_post = 'debug' if buildtype.startswith('debug') else 'release' |
| 283 | + for subdir in (('mpi', libdir_post), (libdir_post,)): |
| 284 | + libdir_buildtype = os.path.join(libdir, *subdir) |
| 285 | + if os.path.isdir(libdir_buildtype): |
| 286 | + libdir = libdir_buildtype |
| 287 | + break |
| 288 | + |
| 289 | + found_header = os.path.isfile(os.path.join(incdir,'mpi.h')) |
| 290 | + found_library = os.path.isfile(os.path.join(libdir,'impi.lib')) |
| 291 | + if not found_header or not found_library: |
| 292 | + self.is_found = False |
| 293 | + return |
| 294 | + |
| 295 | + self.is_found = True |
| 296 | + self.compile_args = ['-I' + incdir] |
| 297 | + self.link_args = ['-l' + os.path.join(libdir, 'impi')] |
| 298 | + if self.language == 'cpp': |
| 299 | + self.link_args = ['-l' + os.path.join(libdir, 'impicxx')] |
0 commit comments