10 , enableStatic ? stdenv.hostPlatform.isStatic
14 For details on using mkl as a blas provider for python packages such as numpy,
15 numexpr, scipy, etc., see the Python section of the NixPkgs manual.
18 # Release notes and download URLs are here:
19 # https://registrationcenter.intel.com/en/products/
20 version = "${mklVersion}.${rel}";
22 # Darwin is pinned to 2019.3 because the DMG does not unpack; see here for details:
23 # https://github.com/matthewbauer/undmg/issues/4
24 mklVersion = if stdenvNoCC.isDarwin then "2019.3" else "2021.1.1";
25 rel = if stdenvNoCC.isDarwin then "199" else "52";
27 # Intel openmp uses its own versioning.
28 openmpVersion = if stdenvNoCC.isDarwin then "19.0.3" else "19.1.3";
31 # Thread Building Blocks release.
34 shlibExt = stdenvNoCC.hostPlatform.extensions.sharedLibrary;
36 oneapi-mkl = fetchurl {
37 url = "https://yum.repos.intel.com/oneapi/intel-oneapi-mkl-${mklVersion}-${mklVersion}-${rel}.x86_64.rpm";
38 hash = "sha256-G2Y7iX3UN2YUJhxcMM2KmhONf0ls9owpGlOo8hHOfqA=";
41 oneapi-mkl-common = fetchurl {
42 url = "https://yum.repos.intel.com/oneapi/intel-oneapi-mkl-common-${mklVersion}-${mklVersion}-${rel}.noarch.rpm";
43 hash = "sha256-HrMt2OcPIRxM8EL8SPjYTyuHJnC7RhPFUrvLhRH+7vc=";
46 oneapi-mkl-common-devel = fetchurl {
47 url = "https://yum.repos.intel.com/oneapi/intel-oneapi-mkl-common-devel-${mklVersion}-${mklVersion}-${rel}.noarch.rpm";
48 hash = "sha256-XDE2WFJzEcpujFmO2AvqQdipZMvKB6/G+ksBe2sE438=";
51 oneapi-mkl-devel = fetchurl {
52 url = "https://yum.repos.intel.com/oneapi/intel-oneapi-mkl-devel-${mklVersion}-${mklVersion}-${rel}.x86_64.rpm";
53 hash = "sha256-GhUJZ0Vr/ZXp10maie29/5ryU7zzX3F++wRCuuFcE0s=";
56 oneapi-openmp = fetchurl {
57 url = "https://yum.repos.intel.com/oneapi/intel-oneapi-openmp-${mklVersion}-${mklVersion}-${openmpRel}.x86_64.rpm";
58 hash = "sha256-yP2c4aQAFNRffjLoIZgWXLcNXbiez8smsgu2wXitefU=";
61 oneapi-tbb = fetchurl {
62 url = "https://yum.repos.intel.com/oneapi/intel-oneapi-tbb-${mklVersion}-${mklVersion}-${tbbRel}.x86_64.rpm";
63 hash = "sha256-K1BvhGoGVU2Zwy5vg2ZvJWBrSdh5uQwo0znt5039X0A=";
66 in stdenvNoCC.mkDerivation ({
70 dontUnpack = stdenvNoCC.isLinux;
72 nativeBuildInputs = [ validatePkgConfig ] ++ (if stdenvNoCC.isDarwin
74 [ undmg darwin.cctools ]
78 buildPhase = if stdenvNoCC.isDarwin then ''
79 for f in Contents/Resources/pkg/*.tgz; do
83 rpmextract ${oneapi-mkl}
84 rpmextract ${oneapi-mkl-common}
85 rpmextract ${oneapi-mkl-common-devel}
86 rpmextract ${oneapi-mkl-devel}
87 rpmextract ${oneapi-openmp}
88 rpmextract ${oneapi-tbb}
91 installPhase = if stdenvNoCC.isDarwin then ''
92 for f in $(find . -name 'mkl*.pc') ; do
94 substituteInPlace $f \
95 --replace "prefix=<INSTALLDIR>/mkl" "prefix=$out" \
96 --replace $\{MKLROOT} "$out" \
97 --replace "lib/intel64_lin" "lib" \
98 --replace "lib/intel64" "lib"
100 for f in $(find opt/intel -name 'mkl*iomp.pc') ; do
101 substituteInPlace $f \
102 --replace "../compiler/lib" "lib"
107 cp -r compilers_and_libraries_${version}/mac/mkl/include $out/
109 cp -r compilers_and_libraries_${version}/licensing/mkl/en/license.txt $out/lib/
110 cp -r compilers_and_libraries_${version}/mac/compiler/lib/* $out/lib/
111 cp -r compilers_and_libraries_${version}/mac/mkl/lib/* $out/lib/
112 cp -r compilers_and_libraries_${version}/mac/tbb/lib/* $out/lib/
114 mkdir -p $out/lib/pkgconfig
115 cp -r compilers_and_libraries_${version}/mac/mkl/bin/pkgconfig/* $out/lib/pkgconfig
117 for f in $(find . -name 'mkl*.pc') ; do
119 substituteInPlace $f \
120 --replace $\{MKLROOT} "$out" \
121 --replace "lib/intel64" "lib"
123 sed -r -i "s|^prefix=.*|prefix=$out|g" $f
126 for f in $(find opt/intel -name 'mkl*iomp.pc') ; do
127 substituteInPlace $f --replace "../compiler/lib" "lib"
131 install -Dm0655 -t $out/share/doc/mkl opt/intel/oneapi/mkl/2021.1.1/licensing/en/license.txt
134 install -Dm0755 -t $out/lib opt/intel/oneapi/mkl/${mklVersion}/lib/intel64/*.so*
135 install -Dm0755 -t $out/lib opt/intel/oneapi/compiler/2021.1.1/linux/compiler/lib/intel64_lin/*.so*
136 install -Dm0755 -t $out/lib opt/intel/oneapi/tbb/2021.1.1/lib/intel64/gcc4.8/*.so*
139 cp -r opt/intel/oneapi/mkl/${mklVersion}/include $out/
141 (if enableStatic then ''
142 install -Dm0644 -t $out/lib opt/intel/oneapi/mkl/${mklVersion}/lib/intel64/*.a
143 install -Dm0644 -t $out/lib/pkgconfig opt/intel/oneapi/mkl/2021.1.1/tools/pkgconfig/*.pc
145 cp opt/intel/oneapi/mkl/${mklVersion}/lib/intel64/*.so* $out/lib
146 install -Dm0644 -t $out/lib/pkgconfig opt/intel/oneapi/mkl/2021.1.1/tools/pkgconfig/*dynamic*.pc
148 # Setup symlinks for blas / lapack
149 ln -s $out/lib/libmkl_rt${shlibExt} $out/lib/libblas${shlibExt}
150 ln -s $out/lib/libmkl_rt${shlibExt} $out/lib/libcblas${shlibExt}
151 ln -s $out/lib/libmkl_rt${shlibExt} $out/lib/liblapack${shlibExt}
152 ln -s $out/lib/libmkl_rt${shlibExt} $out/lib/liblapacke${shlibExt}
153 '' + lib.optionalString stdenvNoCC.hostPlatform.isLinux ''
154 ln -s $out/lib/libmkl_rt${shlibExt} $out/lib/libblas${shlibExt}".3"
155 ln -s $out/lib/libmkl_rt${shlibExt} $out/lib/libcblas${shlibExt}".3"
156 ln -s $out/lib/libmkl_rt${shlibExt} $out/lib/liblapack${shlibExt}".3"
157 ln -s $out/lib/libmkl_rt${shlibExt} $out/lib/liblapacke${shlibExt}".3"
160 # fixDarwinDylibName fails for libmkl_cdft_core.dylib because the
161 # larger updated load commands do not fit. Use install_name_tool
162 # explicitly and ignore the error.
163 postFixup = lib.optionalString stdenvNoCC.isDarwin ''
164 for f in $out/lib/*.dylib; do
165 install_name_tool -id $out/lib/$(basename $f) $f || true
167 install_name_tool -change @rpath/libiomp5.dylib $out/lib/libiomp5.dylib $out/lib/libmkl_intel_thread.dylib
168 install_name_tool -change @rpath/libtbb.dylib $out/lib/libtbb.dylib $out/lib/libmkl_tbb_thread.dylib
169 install_name_tool -change @rpath/libtbbmalloc.dylib $out/lib/libtbbmalloc.dylib $out/lib/libtbbmalloc_proxy.dylib
172 # Per license agreement, do not modify the binary
177 pkg-config-dynamic-iomp = callPackage ./test { enableStatic = false; execution = "iomp"; };
178 pkg-config-static-iomp = callPackage ./test { enableStatic = true; execution = "iomp"; };
179 pkg-config-dynamic-seq = callPackage ./test { enableStatic = false; execution = "seq"; };
180 pkg-config-static-seq = callPackage ./test { enableStatic = true; execution = "seq"; };
184 description = "Intel OneAPI Math Kernel Library";
186 Intel OneAPI Math Kernel Library (Intel oneMKL) optimizes code with minimal
187 effort for future generations of Intel processors. It is compatible with your
188 choice of compilers, languages, operating systems, and linking and
191 homepage = "https://software.intel.com/en-us/mkl";
192 license = licenses.issl;
193 platforms = [ "x86_64-linux" "x86_64-darwin" ];
194 maintainers = with maintainers; [ bhipple ];
196 } // lib.optionalAttrs stdenvNoCC.isDarwin {
198 url = "http://registrationcenter-download.intel.com/akdlm/irc_nas/tec/15235/m_mkl_${version}.dmg";
199 sha256 = "14b3ciz7995sqcd6jz7hc8g2x4zwvqxmgxgni46vrlb7n523l62f";