Repository: spack/spack

Issue:
Using internal libfrabric from Intel MPI 2019.x
**Intel MPI 2019.x comes bundled with a version of libfabric in $I_MPI_ROOT/intel64/libfabric/lib. Howver, SPACK does not make use of it.**

### Rationale

Intel MPI 2019.x depends on libfabric; Intel installs an appropriate version in $I_MPI_ROOT/intel64/libfabric/lib/. The advantage of Intel's version compared to e.g. the one installed as part of RHEL7 (libfabric-1.6.1-2.el7.x86_64) is that Intel's version works well with different provides and not just expects libpsm_infinipath.so.1

### Description

If Intel's mpivars.sh is sourced with "-ofi_internal" the libfabric provided by Intel is added to LD_LIBRARY_PATH / LIBARY_PATH and preferred over the one from the OS.

It would be good if SPACK would add an option to the intel-mpi (and intel-parallel-studio) package for versions >=2019 to also allow using Intel's libfabric with its MPI. For that to work, the LD_LIBRARY_PATH not only has to be extended when loading the module but also when using intel-mpi internally as build dependency.



Discussion:
I noticed that Intel 2019.x is not listed in the intel-mpi builtin for spack 0.13.3 so I made one with this package as source: http://registrationcenter-download.intel.com/akdlm/irc_nas/tec/15838/l_mpi_2019.5.281.tgz

It creates the modulefile correctly including libfabric: 
prepend-path     LIBRARY_PATH /shared/home/mk/azure-spack/spack/opt/spack/linux-centos7-zen/gcc-9.2.0/intel-mpi-2019.5.281-sqlojgmqnkflbxwg3r2lkuvfuca3arei/compilers_and_libraries_2019.5.281/linux/mpi/intel64/libfabric/lib

However, when I build a dependent : 
spack install --verbose osu-micro-benchmarks@5.6.1%gcc@9.2.0 ^intel-mpi@2019.5.281%gcc@9.2.0 

This fails as spack doesn't load the module/LIBRARY_PATH, only the compiler wrappers. 

If I simply module load intel-mpi@2019.5.281%gcc@9.2.0  and then manually build the osu-micro-benchmarks with ./configure, then libfabric is in the environment and it works. 

I'm surprised that spack doesn't load the whole module I'm depending on into the build environment (I noticed that it does do a module load on gcc@9.2.0, so why not module loading intel-mpi@2019 ?)

What would be the correct way to force libfabric into the build library path for dependents?  (or as an option as this feature request is asking for?)




Resolving patch:
diff --git a/lib/spack/spack/build_systems/intel.py b/lib/spack/spack/build_systems/intel.py
--- a/lib/spack/spack/build_systems/intel.py
+++ b/lib/spack/spack/build_systems/intel.py
@@ -1073,6 +1073,15 @@ def _setup_dependent_env_callback(
                 # 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 >= 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')
 


Test patch: