summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Cohn <robert.s.cohn@intel.com>2021-11-16 15:55:24 -0500
committerGitHub <noreply@github.com>2021-11-16 12:55:24 -0800
commit67cba372e83379c0c5d27838be6540d9f70daa6b (patch)
tree5b10f130f42bb8df08db0d5a1ab97ef1267df83e
parentb194b957cea39338a1ab6cde169fab2222bdd4e7 (diff)
downloadspack-67cba372e83379c0c5d27838be6540d9f70daa6b.tar.gz
spack-67cba372e83379c0c5d27838be6540d9f70daa6b.tar.bz2
spack-67cba372e83379c0c5d27838be6540d9f70daa6b.tar.xz
spack-67cba372e83379c0c5d27838be6540d9f70daa6b.zip
Intel mpi: allow use of external libfabric (#27292)
Intel mpi comes with an installation of libfabric (which it needs as a dependency). It can use other implementations of libfabric at runtime though, so if you install a package that depends on `mpi` and `libfabric`, you can specify `intel-mpi+external-libfabric` and ensure that the Spack-built instance is used (both by `intel-mpi` and the root). Apply analogous change to intel-oneapi-mpi.
-rw-r--r--lib/spack/spack/build_systems/intel.py19
-rw-r--r--var/spack/repos/builtin/packages/intel-mpi/package.py3
-rw-r--r--var/spack/repos/builtin/packages/intel-oneapi-mpi/package.py20
3 files changed, 23 insertions, 19 deletions
diff --git a/lib/spack/spack/build_systems/intel.py b/lib/spack/spack/build_systems/intel.py
index 2c6732c19a..c087596087 100644
--- a/lib/spack/spack/build_systems/intel.py
+++ b/lib/spack/spack/build_systems/intel.py
@@ -994,6 +994,16 @@ class IntelPackage(PackageBase):
libnames,
root=self.component_lib_dir('mpi'),
shared=True, recursive=True) + result
+ # Intel MPI since 2019 depends on libfabric which is not in the
+ # lib directory but in a directory of its own which should be
+ # included in the rpath
+ if self.version_yearlike >= ver('2019'):
+ d = ancestor(self.component_lib_dir('mpi'))
+ if '+external-libfabric' in self.spec:
+ result += self.spec['libfabric'].libs
+ else:
+ result += find_libraries(['libfabric'],
+ os.path.join(d, 'libfabric', 'lib'))
if '^mpi' in self.spec.root and ('+mkl' in self.spec or
self.provides('scalapack')):
@@ -1091,15 +1101,6 @@ class IntelPackage(PackageBase):
# which performs dizzyingly similar but necessarily different
# actions, and (b) function code leaves a bit more breathing
# room within the suffocating corset of flake8 line length.
-
- # Intel MPI since 2019 depends on libfabric which is not in the
- # lib directory but in a directory of its own which should be
- # included in the rpath
- if self.version_yearlike >= ver('2019'):
- d = ancestor(self.component_lib_dir('mpi'))
- libfabrics_path = os.path.join(d, 'libfabric', 'lib')
- env.append_path('SPACK_COMPILER_EXTRA_RPATHS',
- libfabrics_path)
else:
raise InstallError('compilers_of_client arg required for MPI')
diff --git a/var/spack/repos/builtin/packages/intel-mpi/package.py b/var/spack/repos/builtin/packages/intel-mpi/package.py
index 76bc35b0ca..91eaf9b4a6 100644
--- a/var/spack/repos/builtin/packages/intel-mpi/package.py
+++ b/var/spack/repos/builtin/packages/intel-mpi/package.py
@@ -59,6 +59,9 @@ class IntelMpi(IntelPackage):
provides('mpi')
+ variant('external-libfabric', default=False, description='Enable external libfabric dependency')
+ depends_on('libfabric', when='+external-libfabric', type=('build', 'link', 'run'))
+
def setup_dependent_build_environment(self, *args):
# Handle in callback, conveying client's compilers in additional arg.
# CAUTION - DUP code in:
diff --git a/var/spack/repos/builtin/packages/intel-oneapi-mpi/package.py b/var/spack/repos/builtin/packages/intel-oneapi-mpi/package.py
index 2672613c5a..789931f9c7 100644
--- a/var/spack/repos/builtin/packages/intel-oneapi-mpi/package.py
+++ b/var/spack/repos/builtin/packages/intel-oneapi-mpi/package.py
@@ -4,9 +4,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import glob
import platform
-import subprocess
from spack import *
@@ -38,11 +36,11 @@ class IntelOneapiMpi(IntelOneApiLibraryPackage):
variant('ilp64', default=False,
description='Build with ILP64 support')
+ variant('external-libfabric', default=False, description='Enable external libfabric dependency')
+ depends_on('libfabric', when='+external-libfabric', type=('link', 'run'))
provides('mpi@:3.1')
- depends_on('patchelf', type='build')
-
@property
def component_dir(self):
return 'mpi'
@@ -87,17 +85,19 @@ class IntelOneapiMpi(IntelOneApiLibraryPackage):
libs += find_libraries(['libmpicxx', 'libmpifort'], lib_dir)
libs += find_libraries('libmpi', release_lib_dir)
libs += find_system_libraries(['libdl', 'librt', 'libpthread'])
+
+ # Find libfabric for libmpi.so
+ if '+external-libfabric' in self.spec:
+ libs += self.spec['libfabric'].libs
+ else:
+ libs += find_libraries(['libfabric'],
+ join_path(self.component_path, 'libfabric', 'lib'))
+
return libs
def install(self, spec, prefix):
super(IntelOneapiMpi, self).install(spec, prefix)
- # Patch libmpi.so rpath so it can find libfabric
- libfabric_rpath = join_path(self.component_path, 'libfabric', 'lib')
- for libmpi in glob.glob(join_path(self.component_path,
- 'lib', '**', 'libmpi*.so')):
- subprocess.call(['patchelf', '--set-rpath', libfabric_rpath, libmpi])
-
# When spack builds from source
# fix I_MPI_SUBSTITUTE_INSTALLDIR and
# __EXEC_PREFIX_TO_BE_FILLED_AT_INSTALL_TIME__