2020-06-29 20:46:30 +02:00
{ stdenv
, rpmextract
2020-07-01 17:57:31 +02:00
, gcc
, zlib
2020-08-17 18:51:51 +02:00
, ucx
, numactl
, rdma-core
, libpsm2
, patchelf
2020-07-01 17:57:31 +02:00
, autoPatchelfHook
2020-06-29 20:46:30 +02:00
, enableDebug ? false
2020-09-28 12:21:41 +02:00
# The _mt version seems to cause seg-faults and deadlocks with the libpsm2
# provider library with programs that call the MPI library without any locking
# mechanism. See https://pm.bsc.es/gitlab/rarias/bscpkgs/-/issues/28. By
# default, we use the non-mt variant, which provides a big lock. If you want to
# use it, take a look at the I_MPI_THREAD_SPLIT env-var as well.
, enableMt ? false
2020-06-29 20:46:30 +02:00
} :
2020-09-28 12:21:41 +02:00
let
lib_variant = ( if enableDebug then " d e b u g " else " r e l e a s e " ) ;
# See https://software.intel.com/content/www/us/en/develop/documentation/mpi-developer-reference-linux/top/environment-variable-reference/other-environment-variables.html
lib_mt = ( if enableMt then " _ m t " else " " ) ;
lib_name = " ${ lib_variant } ${ lib_mt } " ;
in
2020-06-29 20:46:30 +02:00
stdenv . mkDerivation rec {
name = " i n t e l - m p i - ${ version } " ;
2020-08-17 18:51:51 +02:00
version = " 2 0 1 9 . 8 . 2 5 4 " ;
dir_nr = " 1 6 8 1 4 " ;
internal-ver = " 2 0 2 0 . 2 . 2 5 4 " ;
2020-06-29 20:46:30 +02:00
2020-07-23 18:47:20 +02:00
src = builtins . fetchTarball {
2020-08-17 18:51:51 +02:00
url = " h t t p : / / r e g i s t r a t i o n c e n t e r - d o w n l o a d . i n t e l . c o m / a k d l m / i r c _ n a s / t e c / ${ dir_nr } / l _ m p i _ ${ version } . t g z " ;
sha256 = " 1 z a 4 z y v x m 5 b f k r c a 8 4 3 n a 6 s x q 2 g q 7 q b 8 7 s 0 z y s a 7 d n y q j w a 1 1 n 4 5 " ;
2020-06-29 20:46:30 +02:00
} ;
2020-06-30 15:41:18 +02:00
buildInputs = [
rpmextract
2020-07-01 17:57:31 +02:00
autoPatchelfHook
gcc . cc . lib
zlib
2020-08-17 18:51:51 +02:00
ucx
numactl
rdma-core
libpsm2
patchelf
2020-06-30 15:41:18 +02:00
] ;
postUnpack = ''
pushd $ sourceRoot
rpmextract rpm/intel-mpi- * . rpm
popd
'' ;
2020-06-29 20:46:30 +02:00
2020-06-30 15:41:18 +02:00
patches = [
./mpicc.patch
./mpicxx.patch
] ;
postPatch = ''
2020-08-17 18:51:51 +02:00
pushd opt/intel/compilers_and_libraries_ $ { internal-ver } /linux/mpi/intel64/bin
2020-07-20 16:05:00 +02:00
for i in mpi * ; do
echo " F i x i n g p a t h s i n $ i "
sed - i " s : I _ M P I _ S U B S T I T U T E _ I N S T A L L D I R : $ o u t : g " " $ i "
done
popd
2020-06-30 15:41:18 +02:00
'' ;
2020-06-29 20:46:30 +02:00
2020-06-30 15:41:18 +02:00
dontBuild = true ;
installPhase = ''
2020-08-17 18:51:51 +02:00
cd opt/intel/compilers_and_libraries_ $ { internal-ver } /linux/mpi/intel64
2020-06-30 15:41:18 +02:00
mkdir - p $ out
2020-06-29 20:46:30 +02:00
mv etc $ out
mv bin $ out
mv include $ out
mkdir $ out/lib
cp - a lib/lib * $ out/lib
2020-09-28 12:21:41 +02:00
cp - a lib / $ { lib_name } /lib * $ out/lib
2020-08-17 18:51:51 +02:00
cp - a libfabric/lib /* $ o u t / l i b
cp - a libfabric/lib/prov /* $ o u t / l i b
cp - a libfabric/bin /* $ o u t / b i n
2020-07-20 16:05:00 +02:00
ln - s . $ out/intel64
2020-07-01 17:57:31 +02:00
rm $ out/lib/libmpi.dbg
2020-08-17 18:51:51 +02:00
# Fixup Intel PSM2 library missing (now located at PSMX2)
ln - s $ out/lib/libpsmx2-fi.so $ out/lib/libpsm2-fi.so
'' ;
dontAutoPatchelf = true ;
# The rpath of libfabric.so bundled with Intel MPI is patched to include the
# rdma-core lib path, as is required for dlopen to find the rdma components.
# TODO: Try the upstream libfabric library with rdma support, so we can avoid
# this hack.
postFixup = ''
autoPatchelf - - $ out
patchelf - - set-rpath " $ o u t / l i b : ${ rdma-core } / l i b : ${ libpsm2 } / l i b " $ out/lib/libfabric.so
echo " P a t c h e d R P A T H i n l i b f a b r i c . s o t o : $ ( p a t c h e l f - - p r i n t - r p a t h $ o u t / l i b / l i b f a b r i c . s o ) "
2020-06-29 20:46:30 +02:00
'' ;
}