2021-01-27 05:50:30 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2020-12-20 06:11:26 +00:00
|
|
|
, callPackage
|
2020-11-06 08:56:13 +00:00
|
|
|
, stdenvNoCC
|
2020-05-14 05:52:32 +01:00
|
|
|
, fetchurl
|
|
|
|
, rpmextract
|
|
|
|
, undmg
|
|
|
|
, darwin
|
2020-05-15 07:35:44 +01:00
|
|
|
, validatePkgConfig
|
2020-12-20 06:11:26 +00:00
|
|
|
, enableStatic ? stdenv.hostPlatform.isStatic
|
2020-05-14 05:52:32 +01:00
|
|
|
}:
|
|
|
|
|
2018-10-04 03:24:21 +01:00
|
|
|
/*
|
2018-10-23 22:33:49 +01:00
|
|
|
For details on using mkl as a blas provider for python packages such as numpy,
|
|
|
|
numexpr, scipy, etc., see the Python section of the NixPkgs manual.
|
|
|
|
*/
|
2019-10-27 19:34:16 +00:00
|
|
|
let
|
|
|
|
# Release notes and download URLs are here:
|
|
|
|
# https://registrationcenter.intel.com/en/products/
|
2021-03-23 10:50:54 +00:00
|
|
|
version = "${mklVersion}.${rel}";
|
2019-10-27 19:34:16 +00:00
|
|
|
|
|
|
|
# Darwin is pinned to 2019.3 because the DMG does not unpack; see here for details:
|
|
|
|
# https://github.com/matthewbauer/undmg/issues/4
|
2021-03-23 10:50:54 +00:00
|
|
|
mklVersion = if stdenvNoCC.isDarwin then "2019.3" else "2021.1.1";
|
|
|
|
rel = if stdenvNoCC.isDarwin then "199" else "52";
|
2020-09-03 14:28:01 +01:00
|
|
|
|
2021-03-23 10:50:54 +00:00
|
|
|
# Intel openmp uses its own versioning.
|
|
|
|
openmpVersion = if stdenvNoCC.isDarwin then "19.0.3" else "19.1.3";
|
|
|
|
openmpRel = "189";
|
2019-10-27 19:34:16 +00:00
|
|
|
|
2021-03-23 10:50:54 +00:00
|
|
|
# Thread Building Blocks release.
|
|
|
|
tbbRel = "119";
|
2019-10-27 19:34:16 +00:00
|
|
|
|
2020-05-08 02:42:47 +01:00
|
|
|
shlibExt = stdenvNoCC.hostPlatform.extensions.sharedLibrary;
|
|
|
|
|
2021-03-23 10:50:54 +00:00
|
|
|
oneapi-mkl = fetchurl {
|
|
|
|
url = "https://yum.repos.intel.com/oneapi/intel-oneapi-mkl-${mklVersion}-${mklVersion}-${rel}.x86_64.rpm";
|
|
|
|
hash = "sha256-G2Y7iX3UN2YUJhxcMM2KmhONf0ls9owpGlOo8hHOfqA=";
|
|
|
|
};
|
|
|
|
|
|
|
|
oneapi-mkl-common = fetchurl {
|
|
|
|
url = "https://yum.repos.intel.com/oneapi/intel-oneapi-mkl-common-${mklVersion}-${mklVersion}-${rel}.noarch.rpm";
|
|
|
|
hash = "sha256-HrMt2OcPIRxM8EL8SPjYTyuHJnC7RhPFUrvLhRH+7vc=";
|
|
|
|
};
|
|
|
|
|
|
|
|
oneapi-mkl-common-devel = fetchurl {
|
|
|
|
url = "https://yum.repos.intel.com/oneapi/intel-oneapi-mkl-common-devel-${mklVersion}-${mklVersion}-${rel}.noarch.rpm";
|
|
|
|
hash = "sha256-XDE2WFJzEcpujFmO2AvqQdipZMvKB6/G+ksBe2sE438=";
|
|
|
|
};
|
|
|
|
|
|
|
|
oneapi-mkl-devel = fetchurl {
|
|
|
|
url = "https://yum.repos.intel.com/oneapi/intel-oneapi-mkl-devel-${mklVersion}-${mklVersion}-${rel}.x86_64.rpm";
|
|
|
|
hash = "sha256-GhUJZ0Vr/ZXp10maie29/5ryU7zzX3F++wRCuuFcE0s=";
|
|
|
|
};
|
|
|
|
|
|
|
|
oneapi-openmp = fetchurl {
|
|
|
|
url = "https://yum.repos.intel.com/oneapi/intel-oneapi-openmp-${mklVersion}-${mklVersion}-${openmpRel}.x86_64.rpm";
|
|
|
|
hash = "sha256-yP2c4aQAFNRffjLoIZgWXLcNXbiez8smsgu2wXitefU=";
|
|
|
|
};
|
|
|
|
|
|
|
|
oneapi-tbb = fetchurl {
|
|
|
|
url = "https://yum.repos.intel.com/oneapi/intel-oneapi-tbb-${mklVersion}-${mklVersion}-${tbbRel}.x86_64.rpm";
|
|
|
|
hash = "sha256-K1BvhGoGVU2Zwy5vg2ZvJWBrSdh5uQwo0znt5039X0A=";
|
|
|
|
};
|
|
|
|
|
|
|
|
in stdenvNoCC.mkDerivation ({
|
2019-10-27 19:34:16 +00:00
|
|
|
pname = "mkl";
|
|
|
|
inherit version;
|
2018-08-18 01:48:40 +01:00
|
|
|
|
2021-03-23 10:50:54 +00:00
|
|
|
dontUnpack = stdenvNoCC.isLinux;
|
2018-08-18 01:48:40 +01:00
|
|
|
|
2020-05-15 07:35:44 +01:00
|
|
|
nativeBuildInputs = [ validatePkgConfig ] ++ (if stdenvNoCC.isDarwin
|
2019-03-20 09:45:57 +00:00
|
|
|
then
|
2019-10-27 19:34:16 +00:00
|
|
|
[ undmg darwin.cctools ]
|
2019-03-20 09:45:57 +00:00
|
|
|
else
|
2020-05-15 07:35:44 +01:00
|
|
|
[ rpmextract ]);
|
2020-05-14 05:52:32 +01:00
|
|
|
|
2018-10-03 03:53:48 +01:00
|
|
|
buildPhase = if stdenvNoCC.isDarwin then ''
|
2019-10-27 19:34:16 +00:00
|
|
|
for f in Contents/Resources/pkg/*.tgz; do
|
|
|
|
tar xzvf $f
|
|
|
|
done
|
2018-10-03 03:53:48 +01:00
|
|
|
'' else ''
|
2021-03-23 10:50:54 +00:00
|
|
|
rpmextract ${oneapi-mkl}
|
|
|
|
rpmextract ${oneapi-mkl-common}
|
|
|
|
rpmextract ${oneapi-mkl-common-devel}
|
|
|
|
rpmextract ${oneapi-mkl-devel}
|
|
|
|
rpmextract ${oneapi-openmp}
|
|
|
|
rpmextract ${oneapi-tbb}
|
|
|
|
'';
|
2018-08-18 01:48:40 +01:00
|
|
|
|
2021-03-23 10:50:54 +00:00
|
|
|
installPhase = if stdenvNoCC.isDarwin then ''
|
2019-09-16 16:05:54 +01:00
|
|
|
for f in $(find . -name 'mkl*.pc') ; do
|
|
|
|
bn=$(basename $f)
|
|
|
|
substituteInPlace $f \
|
|
|
|
--replace "prefix=<INSTALLDIR>/mkl" "prefix=$out" \
|
2020-05-14 05:52:32 +01:00
|
|
|
--replace $\{MKLROOT} "$out" \
|
2020-11-06 08:55:12 +00:00
|
|
|
--replace "lib/intel64_lin" "lib" \
|
|
|
|
--replace "lib/intel64" "lib"
|
2019-09-16 16:05:54 +01:00
|
|
|
done
|
|
|
|
for f in $(find opt/intel -name 'mkl*iomp.pc') ; do
|
|
|
|
substituteInPlace $f \
|
|
|
|
--replace "../compiler/lib" "lib"
|
|
|
|
done
|
2018-10-23 22:33:49 +01:00
|
|
|
|
2021-03-23 10:50:54 +00:00
|
|
|
mkdir -p $out/lib
|
|
|
|
|
|
|
|
cp -r compilers_and_libraries_${version}/mac/mkl/include $out/
|
2018-10-23 22:33:49 +01:00
|
|
|
|
2021-03-23 10:50:54 +00:00
|
|
|
cp -r compilers_and_libraries_${version}/licensing/mkl/en/license.txt $out/lib/
|
|
|
|
cp -r compilers_and_libraries_${version}/mac/compiler/lib/* $out/lib/
|
|
|
|
cp -r compilers_and_libraries_${version}/mac/mkl/lib/* $out/lib/
|
|
|
|
cp -r compilers_and_libraries_${version}/mac/tbb/lib/* $out/lib/
|
2019-09-16 16:05:54 +01:00
|
|
|
|
2021-03-23 10:50:54 +00:00
|
|
|
mkdir -p $out/lib/pkgconfig
|
|
|
|
cp -r compilers_and_libraries_${version}/mac/mkl/bin/pkgconfig/* $out/lib/pkgconfig
|
2018-10-03 03:53:48 +01:00
|
|
|
'' else ''
|
2021-03-23 10:50:54 +00:00
|
|
|
for f in $(find . -name 'mkl*.pc') ; do
|
|
|
|
bn=$(basename $f)
|
|
|
|
substituteInPlace $f \
|
|
|
|
--replace $\{MKLROOT} "$out" \
|
|
|
|
--replace "lib/intel64" "lib"
|
2018-10-23 22:33:49 +01:00
|
|
|
|
2021-03-23 10:50:54 +00:00
|
|
|
sed -r -i "s|^prefix=.*|prefix=$out|g" $f
|
|
|
|
done
|
2018-10-23 22:33:49 +01:00
|
|
|
|
2021-03-23 10:50:54 +00:00
|
|
|
for f in $(find opt/intel -name 'mkl*iomp.pc') ; do
|
|
|
|
substituteInPlace $f --replace "../compiler/lib" "lib"
|
|
|
|
done
|
|
|
|
|
|
|
|
# License
|
|
|
|
install -Dm0655 -t $out/share/doc/mkl opt/intel/oneapi/mkl/2021.1.1/licensing/en/license.txt
|
|
|
|
|
|
|
|
# Dynamic libraries
|
|
|
|
install -Dm0755 -t $out/lib opt/intel/oneapi/mkl/${mklVersion}/lib/intel64/*.so*
|
|
|
|
install -Dm0755 -t $out/lib opt/intel/oneapi/compiler/2021.1.1/linux/compiler/lib/intel64_lin/*.so*
|
|
|
|
install -Dm0755 -t $out/lib opt/intel/oneapi/tbb/2021.1.1/lib/intel64/gcc4.8/*.so*
|
|
|
|
|
|
|
|
# Headers
|
|
|
|
cp -r opt/intel/oneapi/mkl/${mklVersion}/include $out/
|
|
|
|
'' +
|
2019-12-19 09:23:26 +00:00
|
|
|
(if enableStatic then ''
|
2021-03-23 10:50:54 +00:00
|
|
|
install -Dm0644 -t $out/lib opt/intel/oneapi/mkl/${mklVersion}/lib/intel64/*.a
|
|
|
|
install -Dm0644 -t $out/lib/pkgconfig opt/intel/oneapi/mkl/2021.1.1/tools/pkgconfig/*.pc
|
2019-12-19 09:23:26 +00:00
|
|
|
'' else ''
|
2021-03-23 10:50:54 +00:00
|
|
|
cp opt/intel/oneapi/mkl/${mklVersion}/lib/intel64/*.so* $out/lib
|
|
|
|
install -Dm0644 -t $out/lib/pkgconfig opt/intel/oneapi/mkl/2021.1.1/tools/pkgconfig/*dynamic*.pc
|
2020-03-27 18:50:45 +00:00
|
|
|
'') + ''
|
|
|
|
# Setup symlinks for blas / lapack
|
2020-05-08 02:42:47 +01:00
|
|
|
ln -s $out/lib/libmkl_rt${shlibExt} $out/lib/libblas${shlibExt}
|
|
|
|
ln -s $out/lib/libmkl_rt${shlibExt} $out/lib/libcblas${shlibExt}
|
|
|
|
ln -s $out/lib/libmkl_rt${shlibExt} $out/lib/liblapack${shlibExt}
|
|
|
|
ln -s $out/lib/libmkl_rt${shlibExt} $out/lib/liblapacke${shlibExt}
|
2021-01-27 05:50:30 +00:00
|
|
|
'' + lib.optionalString stdenvNoCC.hostPlatform.isLinux ''
|
2020-05-08 02:42:47 +01:00
|
|
|
ln -s $out/lib/libmkl_rt${shlibExt} $out/lib/libblas${shlibExt}".3"
|
|
|
|
ln -s $out/lib/libmkl_rt${shlibExt} $out/lib/libcblas${shlibExt}".3"
|
|
|
|
ln -s $out/lib/libmkl_rt${shlibExt} $out/lib/liblapack${shlibExt}".3"
|
|
|
|
ln -s $out/lib/libmkl_rt${shlibExt} $out/lib/liblapacke${shlibExt}".3"
|
2020-03-27 18:50:45 +00:00
|
|
|
'';
|
2018-08-18 01:48:40 +01:00
|
|
|
|
2019-03-20 09:45:57 +00:00
|
|
|
# fixDarwinDylibName fails for libmkl_cdft_core.dylib because the
|
|
|
|
# larger updated load commands do not fit. Use install_name_tool
|
|
|
|
# explicitly and ignore the error.
|
2021-01-27 05:50:30 +00:00
|
|
|
postFixup = lib.optionalString stdenvNoCC.isDarwin ''
|
2019-10-27 19:34:16 +00:00
|
|
|
for f in $out/lib/*.dylib; do
|
|
|
|
install_name_tool -id $out/lib/$(basename $f) $f || true
|
|
|
|
done
|
|
|
|
install_name_tool -change @rpath/libiomp5.dylib $out/lib/libiomp5.dylib $out/lib/libmkl_intel_thread.dylib
|
|
|
|
install_name_tool -change @rpath/libtbb.dylib $out/lib/libtbb.dylib $out/lib/libmkl_tbb_thread.dylib
|
|
|
|
install_name_tool -change @rpath/libtbbmalloc.dylib $out/lib/libtbbmalloc.dylib $out/lib/libtbbmalloc_proxy.dylib
|
2019-03-20 09:45:57 +00:00
|
|
|
'';
|
|
|
|
|
2018-08-18 01:48:40 +01:00
|
|
|
# Per license agreement, do not modify the binary
|
|
|
|
dontStrip = true;
|
|
|
|
dontPatchELF = true;
|
|
|
|
|
2021-03-23 10:50:54 +00:00
|
|
|
passthru.tests = {
|
|
|
|
pkg-config-dynamic-iomp = callPackage ./test { enableStatic = false; execution = "iomp"; };
|
|
|
|
pkg-config-static-iomp = callPackage ./test { enableStatic = true; execution = "iomp"; };
|
|
|
|
pkg-config-dynamic-seq = callPackage ./test { enableStatic = false; execution = "seq"; };
|
|
|
|
pkg-config-static-seq = callPackage ./test { enableStatic = true; execution = "seq"; };
|
|
|
|
};
|
2020-11-06 08:56:13 +00:00
|
|
|
|
2021-01-27 05:50:30 +00:00
|
|
|
meta = with lib; {
|
2021-03-23 10:50:54 +00:00
|
|
|
description = "Intel OneAPI Math Kernel Library";
|
2018-08-18 01:48:40 +01:00
|
|
|
longDescription = ''
|
2021-03-23 10:50:54 +00:00
|
|
|
Intel OneAPI Math Kernel Library (Intel oneMKL) optimizes code with minimal
|
|
|
|
effort for future generations of Intel processors. It is compatible with your
|
2018-08-18 01:48:40 +01:00
|
|
|
choice of compilers, languages, operating systems, and linking and
|
|
|
|
threading models.
|
|
|
|
'';
|
2020-03-24 11:27:55 +00:00
|
|
|
homepage = "https://software.intel.com/en-us/mkl";
|
2018-10-23 22:33:49 +01:00
|
|
|
license = licenses.issl;
|
2018-10-03 03:53:48 +01:00
|
|
|
platforms = [ "x86_64-linux" "x86_64-darwin" ];
|
2019-10-27 19:34:16 +00:00
|
|
|
maintainers = with maintainers; [ bhipple ];
|
2018-08-18 01:48:40 +01:00
|
|
|
};
|
2021-03-23 10:50:54 +00:00
|
|
|
} // lib.optionalAttrs stdenvNoCC.isDarwin {
|
|
|
|
src = fetchurl {
|
|
|
|
url = "http://registrationcenter-download.intel.com/akdlm/irc_nas/tec/15235/m_mkl_${version}.dmg";
|
|
|
|
sha256 = "14b3ciz7995sqcd6jz7hc8g2x4zwvqxmgxgni46vrlb7n523l62f";
|
|
|
|
};
|
|
|
|
})
|