From 4f2d7949f03e1c198bc888f2d05f421d35c57e21 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Mon, 9 Oct 2017 18:53:29 +0100 Subject: reinit the tree, so we can have metadata --- sci-libs/mkl/Manifest | 8 + sci-libs/mkl/files/mkl-10.0.2.018-openmpi.patch | 18 ++ sci-libs/mkl/files/mkl-10.0.2.018-tests.patch | 21 ++ sci-libs/mkl/metadata.xml | 20 ++ sci-libs/mkl/mkl-10.0.5.025-r1.ebuild | 366 +++++++++++++++++++++++ sci-libs/mkl/mkl-10.0.5.025.ebuild | 368 ++++++++++++++++++++++++ 6 files changed, 801 insertions(+) create mode 100644 sci-libs/mkl/Manifest create mode 100644 sci-libs/mkl/files/mkl-10.0.2.018-openmpi.patch create mode 100644 sci-libs/mkl/files/mkl-10.0.2.018-tests.patch create mode 100644 sci-libs/mkl/metadata.xml create mode 100644 sci-libs/mkl/mkl-10.0.5.025-r1.ebuild create mode 100644 sci-libs/mkl/mkl-10.0.5.025.ebuild (limited to 'sci-libs/mkl') diff --git a/sci-libs/mkl/Manifest b/sci-libs/mkl/Manifest new file mode 100644 index 000000000000..24e400def8e8 --- /dev/null +++ b/sci-libs/mkl/Manifest @@ -0,0 +1,8 @@ +AUX mkl-10.0.2.018-openmpi.patch 332 SHA256 758c3aef0124932426002aa502c0e7b721a026d6c54c37c679d3ee7eb607b58c SHA512 5efb139622a6f0e8f03c5a76a12298685a9dfe9e816b8eaabd2874fda6c0d468a111a46df8e6885cd62a40ec611c322a99762a805dc74a4c684c85fdf222b530 WHIRLPOOL b846db00af9cf3dcefe0422323a1871f1486ca6f51bd440c829b0c6c8ae6e956f9ca172ba9730560db7ddd204dcf6096ea185736ab10499d3f56cedcb5df7e56 +AUX mkl-10.0.2.018-tests.patch 528 SHA256 f65a074c64a3969b08d41f88874f25fdc06693b5a5aee930bd7ef9763e94e71d SHA512 6dd716f5d6764cd79c6de22703729d77be71f35e5f600a11f01ccff06c87309471ac5289e68ef40ae830d5917cbd20d4b2b9f1b5554384977f1b83c4b3556382 WHIRLPOOL b413212509adf6501f709ab867b17e120a28df8c9e427c22bd7871d9630ff61f0c24e8ffdd06c8c1052101a3cb08be8873a0815bf0874de7ac81545560431b26 +DIST l_mkl_p_10.0.5.025.tgz 230389719 SHA256 c98f2c5c652c02ac7200cba40d996b1f11b567278d849016b7ee3b0320e26e3c SHA512 621c3bfdecb57313e375424e391c0630a29efd70196e3e4bfc5b4ddd03aa45fda4761523652d875f2e60d466a0010c06659306b11f20966fba4943c308fa6f84 WHIRLPOOL 6c96123254aebd897e061ee971f487bd5d51586e74572da18bb5461ab8f7fb2cbb34e5f782c11712a7ece8b58b348554c07a68dd91ff5fc9771894e3aef04352 +EBUILD mkl-10.0.5.025-r1.ebuild 9905 SHA256 5db8bfc0772c924f3eba8714f0c82f35299f3a0180affdd5d4e88b8bff58f55a SHA512 a9c8638edf0472314d87ce6cbcd803fdb4c7f725f06e51868950bd521bf0053789d0ae2b40c6072cc905d4c1d646f783ef09b1dc42b48058ea50c3fa8ef7364b WHIRLPOOL a034c57c0535c9e56901f1f40cba4ffc1b5fc6ea4b89563c1989fe76dca3b3efe6f89351c6c342207964d6869be50597fe2487e3e230270838ebb3e67af4af60 +EBUILD mkl-10.0.5.025.ebuild 10066 SHA256 a3e842f7e9321858fa39bf91a753bca781efa0e4ec440cb2933a9dca6b48805e SHA512 3b79dced34319543dc04804e1df965580471c485aff6282a1b60d7402229c1e4e7dc65f19ad4971a366936ba74fbf75d3f7724f77e0f692a1b2c3c11be1e077f WHIRLPOOL e4d53bce4b44025d4d4bfe7259297220dc7c84a21dd6faacb75c732c36ef4cc54e19a5968a4272cefcb87c1b5dcd4d85d9a0f8e7e5c656ee5e547d57fa4e025d +MISC ChangeLog 3520 SHA256 5fc7b9e7edf7a497c7d1b208a27e420b21926ae55cffabbfda34d77cfb939c9b SHA512 332d7a2372d71de1ea454e2f44b062edabddd9fdf5db93a37472a2ec8cafec191285626a24c3fdaa2b038de36a405000cd94602ad374aff1b2675d6bab08be39 WHIRLPOOL d50931a3f002714518d5432c652116ef4b5a936b630b1c48351ac4e8a95dd6fefcdb5edc9ffe81cd9c48cb4d1a1293a9a05def4944ea6923a299482a6530ae3a +MISC ChangeLog-2015 10144 SHA256 c7ebc5f269988f9409e4a1f27372c818a21d7010407979472480aeedf0ab1489 SHA512 e9d17e8b2e7e5fc846dcf48f014b6e498032eee189fa79a78c23cd8af7b51ddb5eb165ca95168c5da2f3a1bfd47511713d956561416ac5f825f64df9919b053f WHIRLPOOL 09e87b94c99e0cbb813b0719411610518e76753c5d8fb6fdd465c05990007b90787898a46c4b01a88732a0f8b7089db477d1f4a84816c3588b7c7773e37b0ffe +MISC metadata.xml 881 SHA256 1309f5de049b93c75536a78f42be40c223e5d4fb7a44396d9ab40b4417c9a481 SHA512 8930dec116eac1fe455b4eab4940acf370d6b72f15829bfe18375c5308f69189303753a858433eeb6367381e0601f593474073996d447f11030f718ff1264bb9 WHIRLPOOL b6d1d0961cc896a8e4421fd0f435ed1f146870502b698c2a5727c6b6366593dfd66e50cb672e0f7b3f4b59aee129d6ccaca01e9d7fb20920b4f61ae6c35cd127 diff --git a/sci-libs/mkl/files/mkl-10.0.2.018-openmpi.patch b/sci-libs/mkl/files/mkl-10.0.2.018-openmpi.patch new file mode 100644 index 000000000000..6f7f9edebb0f --- /dev/null +++ b/sci-libs/mkl/files/mkl-10.0.2.018-openmpi.patch @@ -0,0 +1,18 @@ +--- interfaces/fftw2x_cdft/makefile.orig 2008-03-11 23:26:26.287984332 +0000 ++++ interfaces/fftw2x_cdft/makefile 2008-03-13 10:56:44.755095617 +0000 +@@ -172,6 +172,15 @@ + endif + + ++ifeq ($(mpi),openmpi) ++CS = mpicc ++ifdef mpidir ++_CS = $(mpidir)/bin/$(CS) ++else ++_CS = $(CS) ++endif ++endif ++ + vpath %.c wrappers + + $(WRP): %.o: %.c diff --git a/sci-libs/mkl/files/mkl-10.0.2.018-tests.patch b/sci-libs/mkl/files/mkl-10.0.2.018-tests.patch new file mode 100644 index 000000000000..975170f7dbc0 --- /dev/null +++ b/sci-libs/mkl/files/mkl-10.0.2.018-tests.patch @@ -0,0 +1,21 @@ +--- tests/scalapack/make.inc.orig 2008-03-13 22:36:06.119890888 +0000 ++++ tests/scalapack/make.inc 2008-03-13 22:54:58.201781899 +0000 +@@ -59,6 +59,9 @@ + IFACE_PART = _ilp64 + COPTS = -DMKL_ILP64 + FOPTS = -i8 ++ifeq ($(compiler),gnu) ++FOPTS = -fdefault-integer-8 ++endif + else + ADD_IFACE = _lp64 + IFACE_PART = _lp64 +@@ -203,7 +206,7 @@ + # Compiler flags + F77FLAGS=-w -u $(OPTS) + ifeq ($(comp),gnu) +-F77FLAGS=$(OPTS) -ff90 -fno-globals -Wno-globals ++F77FLAGS=$(OPTS) + endif + # Remove objects variable + RMOBJ=rm -f *.o core work.pc* diff --git a/sci-libs/mkl/metadata.xml b/sci-libs/mkl/metadata.xml new file mode 100644 index 000000000000..2504a4ee49a8 --- /dev/null +++ b/sci-libs/mkl/metadata.xml @@ -0,0 +1,20 @@ + + + + + sci@gentoo.org + Gentoo Science Project + + + The Intel(R) Math Kernel Library is a mathematical library mostly + optimized for Intel processors (also works on AMDs). It contains BLAS + and LAPACK implementations, Fast Fourier Transforms, a vector math + library, and random number generators. It also has multiprocessor + capacities. The package is installed as binary and has a restrictive + license. Please see license terms and home page for proper use. + + + Installs the BLAS/LAPACK FORTRAN95 static libraries + Installs the 64 bits integer libraries + + diff --git a/sci-libs/mkl/mkl-10.0.5.025-r1.ebuild b/sci-libs/mkl/mkl-10.0.5.025-r1.ebuild new file mode 100644 index 000000000000..ed1c3a7da3f0 --- /dev/null +++ b/sci-libs/mkl/mkl-10.0.5.025-r1.ebuild @@ -0,0 +1,366 @@ +# Copyright 1999-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +EAPI=6 + +inherit check-reqs fortran-2 toolchain-funcs + +PID=1232 +PB=${PN} +P_ARCHIVE=l_${PN}_p_${PV} + +DESCRIPTION="Intel(R) Math Kernel Library: linear algebra, fft, math functions" +HOMEPAGE="http://developer.intel.com/software/products/mkl/" +SRC_URI="http://registrationcenter-download.intel.com/irc_nas/${PID}/${P_ARCHIVE}.tgz" + +SLOT="0" +LICENSE="Intel-SDP" +KEYWORDS="-* ~amd64 ~ia64 ~x86" +IUSE="doc fftw fortran95 int64 mpi" + +RESTRICT="strip mirror" + +DEPEND=" + app-eselect/eselect-blas + app-eselect/eselect-cblas + app-eselect/eselect-lapack" +RDEPEND="${DEPEND} + doc? ( app-doc/blas-docs app-doc/lapack-docs ) + mpi? ( virtual/mpi )" + +PATCHES=( + "${FILESDIR}"/${PN}-10.0.2.018-openmpi.patch # allow openmpi to work +) + +MKL_DIR=/opt/intel/${PN}/${PV} +INTEL_LIC_DIR=/opt/intel/licenses + +CHECKREQS_DISK_BUILD=3500M + +QA_PREBUILT="opt/intel/${PN}/${PV}/*" + +get_fcomp() { + case $(tc-getFC) in + *gfortran* ) + FCOMP="gfortran" ;; + ifort ) + FCOMP="ifc" ;; + * ) + FCOMP=$(tc-getFC) ;; + esac +} + +pkg_setup() { + check-reqs_pkg_setup + fortran-2_pkg_setup + # Check the license + if [[ -z ${MKL_LICENSE} ]]; then + MKL_LICENSE="$(grep -ls MKern ${ROOT}${INTEL_LIC_DIR}/* | tail -n 1)" + MKL_LICENSE=${MKL_LICENSE/${ROOT}/} + fi + if [[ -z ${MKL_LICENSE} ]]; then + eerror "Did not find any valid mkl license." + eerror "Register at ${HOMEPAGE} to receive a license" + eerror "and place it in ${INTEL_LIC_DIR} or run:" + eerror "export MKL_LICENSE=/my/license/file emerge mkl" + die "license setup failed" + fi + + # Check if we have enough free diskspace to install + CHECKREQS_DISK_BUILD="1100M" + check-reqs_pkg_setup + + # Check and setup fortran + if use fortran95; then + # blas95 and lapack95 don't compile with gfortran < 4.2 + [[ $(tc-getFC) =~ (gfortran|g77) ]] && [[ $(gcc-major-version)$(gcc-minor-version) -lt 42 ]] && + die "blas95 and lapack95 don't compile with gfortran < 4.2" + fi + MKL_FC="gnu" + [[ $(tc-getFC) =~ if ]] && MKL_FC="intel" + + # build profiles according to what compiler is installed + MKL_CC="gnu" + [[ $(tc-getCC) == icc ]] && MKL_CC="intel" + + if has_version sys-cluster/mpich; then + MKL_MPI=mpich + elif has_version sys-cluster/mpich2; then + MKL_MPI=mpich2 + elif has_version sys-cluster/openmpi; then + MKL_MPI=openmpi + else + MKL_MPI=intelmpi + fi + get_fcomp +} + +src_unpack () { + default + cd "${WORKDIR}/${P_ARCHIVE}"/install || die + + cp ${MKL_LICENSE} "${WORKDIR}"/ || die + MKL_LIC="$(basename ${MKL_LICENSE})" + + # binary blob extractor installs rpm leftovers in /opt/intel + addwrite /opt/intel + # undocumented features: INSTALLMODE_mkl=NONRPM + + # We need to install mkl non-interactively. + # If things change between versions, first do it interactively: + # tar xf l_*; ./install.sh --duplicate mkl.ini; + # The file will be instman/mkl.ini + # Then check it and modify the ebuild-created one below + # --norpm is required to be able to install 10.x + cat > mkl.ini <<-EOF || die + [MKL] + EULA_ACCEPT_REJECT=ACCEPT + FLEXLM_LICENSE_LOCATION=${WORKDIR}/${MKL_LIC} + INSTALLMODE_mkl=NONRPM + INSTALL_DESTINATION=${S} + EOF + einfo "Extracting ..." + ./install \ + --silent ./mkl.ini \ + --installpath "${S}" \ + --log log.txt &> /dev/null \ + || die + + if [[ -z $(find "${S}" -name libmkl.so) ]]; then + eerror "Could not find extracted files" + eerror "See ${PWD}/log.txt to see why" + die "extracting failed" + fi +} + +src_prepare() { + default + + # remove left over + rm -f /opt/intel/.*mkl*.log /opt/intel/intel_sdp_products.db || die + + # remove unused stuff and set up intel names + rm -rf "${WORKDIR}"/l_* || die + + case ${ARCH} in + x86) MKL_ARCH=32 + MKL_KERN=ia32 + rm -rf lib*/{em64t,64} || die + ;; + + amd64) MKL_ARCH=em64t + MKL_KERN=em64t + rm -rf lib*/{32,64} || die + ;; + + ia64) MKL_ARCH=64 + MKL_KERN=ipf + rm -rf lib*/{32,em64t} || die + ;; + esac + MKL_LIBDIR=${MKL_DIR}/lib/${MKL_ARCH} + # fix env scripts + sed -i \ + -e "s:${S}:${MKL_DIR}:g" \ + tools/environment/*sh || die "sed support file failed" +} + +src_compile() { + cd "${S}"/interfaces || die + if use fortran95; then + einfo "Compiling fortan95 static lib wrappers" + local myconf="lib${MKL_ARCH}" + [[ $(tc-getFC) =~ gfortran ]] && \ + myconf="${myconf} FC=gfortran" + if use int64; then + myconf="${myconf} interface=ilp64" + [[ $(tc-getFC) =~ gfortran ]] && \ + myconf="${myconf} FOPTS=-fdefault-integer-8" + fi + local x + for x in blas95 lapack95; do + emake -C ${x} ${myconf} + done + fi + + if use fftw; then + local fftwdirs="fftw2xc fftw2xf fftw3xc fftw3xf" + local myconf="lib${MKL_ARCH} compiler=${MKL_CC}" + if use mpi; then + fftwdirs="${fftwdirs} fftw2x_cdft" + myconf="${myconf} mpi=${MKL_MPI}" + fi + einfo "Compiling fftw static lib wrappers" + local x + for x in ${fftwdirs}; do + emake -C ${x} ${myconf} + done + fi +} + +src_test() { + cd "${S}"/tests + local myconf + local testdirs="blas cblas" + local x + use int64 && myconf="${myconf} interface=ilp64" + # buggy with g77 and gfortran + #if use mpi; then + # testdirs="${testdirs} scalapack" + # myconf="${myconf} mpi=${MKL_MPI}" + #fi + for x in ${testdirs}; do + einfo "Testing ${x}" + emake -C ${x} \ + compiler=${MKL_FC} \ + ${myconf} \ + so${MKL_ARCH} + done +} + +mkl_make_generic_profile() { + cd "${S}" || die + # produce eselect files + # don't make them in FILESDIR, it changes every major version + cat > eselect.blas <<-EOF || die + ${MKL_LIBDIR}/libmkl_${MKL_KERN}.a /usr/@LIBDIR@/libblas.a + ${MKL_LIBDIR}/libmkl.so /usr/@LIBDIR@/libblas.so + ${MKL_LIBDIR}/libmkl.so /usr/@LIBDIR@/libblas.so.0 + EOF + cat > eselect.cblas <<-EOF || die + ${MKL_LIBDIR}/libmkl_${MKL_KERN}.a /usr/@LIBDIR@/libcblas.a + ${MKL_LIBDIR}/libmkl.so /usr/@LIBDIR@/libcblas.so + ${MKL_LIBDIR}/libmkl.so /usr/@LIBDIR@/libcblas.so.0 + ${MKL_DIR}/include/mkl_cblas.h /usr/include/cblas.h + EOF + cat > eselect.lapack <<-EOF || die + ${MKL_LIBDIR}/libmkl_lapack.a /usr/@LIBDIR@/liblapack.a + ${MKL_LIBDIR}/libmkl_lapack.so /usr/@LIBDIR@/liblapack.so + ${MKL_LIBDIR}/libmkl_lapack.so /usr/@LIBDIR@/liblapack.so.0 + EOF +} + +# usage: mkl_add_profile +mkl_add_profile() { + cd "${S}" || die + local prof=${1} + local x + for x in blas cblas lapack; do + cat > ${x}-${prof}.pc <<-EOF || die + prefix=${MKL_DIR} + libdir=${MKL_LIBDIR} + includedir=\${prefix}/include + Name: ${x} + Description: Intel(R) Math Kernel Library implementation of ${x} + Version: ${PV} + URL: ${HOMEPAGE} + EOF + done + cat >> blas-${prof}.pc <<-EOF || die + Libs: -Wl,--no-as-needed -L\${libdir} ${2} ${3} -lmkl_core ${4} -lpthread + EOF + cat >> cblas-${prof}.pc <<-EOF || die + Requires: blas + Libs: -Wl,--no-as-needed -L\${libdir} ${2} ${3} -lmkl_core ${4} -lpthread + Cflags: -I\${includedir} + EOF + cat >> lapack-${prof}.pc <<-EOF || die + Requires: blas + Libs: -Wl,--no-as-needed -L\${libdir} ${2} ${3} -lmkl_core -lmkl_lapack ${4} -lpthread + EOF + insinto ${MKL_LIBDIR} + for x in blas cblas lapack; do + doins ${x}-${prof}.pc + cp eselect.${x} eselect.${x}.${prof} || die + echo "${MKL_LIBDIR}/${x}-${prof}.pc /usr/@LIBDIR@/pkgconfig/${x}.pc" \ + >> eselect.${x}.${prof} || die + eselect ${x} add $(get_libdir) eselect.${x}.${prof} ${prof} + done +} + +mkl_make_profiles() { + local clib="gf" + has_version 'dev-lang/ifc' && clib+=" intel" + local slib="-lmkl_sequential" + local rlib="-liomp5" + local pbase=${PN} + local c + for c in ${clib}; do + local ilib="-lmkl_${c}_lp64" + use x86 && ilib="-lmkl_${c}" + local tlib="-lmkl_${c/gf/gnu}_thread" + local comp="${c/gf/gfortran}" + comp="${comp/intel/ifort}" + mkl_add_profile ${pbase}-${comp} ${ilib} ${slib} + mkl_add_profile ${pbase}-${comp}-threads ${ilib} ${tlib} ${rlib} + if use int64; then + ilib="-lmkl_${c}_ilp64" + mkl_add_profile ${pbase}-${comp}-int64 ${ilib} ${slib} + mkl_add_profile ${pbase}-${comp}-threads-int64 ${ilib} ${tlib} ${rlib} + fi + done +} + +src_install() { + dodir ${MKL_DIR} + + # install license + if [[ ! -f ${INTEL_LIC_DIR}/${MKL_LIC} ]]; then + insinto ${INTEL_LIC_DIR} + doins "${WORKDIR}"/${MKL_LIC} || die "install license failed" + fi + + # install main stuff: cp faster than doins + einfo "Installing files..." + local cpdirs="benchmarks doc examples include interfaces lib man tests" + local doinsdirs="tools" + cp -pPR ${cpdirs} "${D}"${MKL_DIR} \ + || die "installing mkl failed" + insinto ${MKL_DIR} + doins -r ${doinsdirs} || die "doins ${doinsdirs} failed" + dosym mkl_cblas.h ${MKL_DIR}/include/cblas.h + + # install blas/lapack profiles + mkl_make_generic_profile + mkl_make_profiles + + # install env variables + cat > 35mkl <<-EOF || die + MKLROOT=${MKL_DIR} + LDPATH=${MKL_LIBDIR} + MANPATH=${MKL_DIR}/man + EOF + doenvd 35mkl +} + +pkg_postinst() { + # if blas profile is mkl, set lapack and cblas profiles as mkl + local blas_prof=$(eselect blas show | cut -d' ' -f2) + local def_prof="mkl-gfortran-threads" + local x + has_version 'dev-lang/ifc' && def_prof="mkl-ifort-threads" + use int64 && def_prof="${def_prof}-int64" + for x in blas cblas lapack; do + local cur_prof=$(eselect ${x} show | cut -d' ' -f2) + if [[ -z ${cur_prof} || ${cur_prof} == ${def_prof} ]]; then + # work around eselect bug #189942 + local configfile="${ROOT}"/etc/env.d/${x}/$(get_libdir)/config + rm -f ${configfile} || die + eselect ${x} set ${def_prof} + elog "${x} has been eselected to ${def_prof}" + else + elog "Current eselected ${x} is ${current_lib}" + elog "To use one of mkl profiles, issue (as root):" + elog "\t eselect ${x} set " + fi + if [[ ${blas_prof} == mkl* && ${cur_prof} != ${blas_prof} ]]; then + eselect blas set ${def_prof} + elog "${x} is now set to ${def_prof} for consistency" + fi + done + if [[ $(gcc-major-version)$(gcc-minor-version) -lt 42 ]]; then + elog "Multi-threading OpenMP for GNU compilers only available" + elog "with gcc >= 4.2. Make sure you have a compatible version" + elog "and select it with gcc-config before selecting gnu profiles" + fi +} diff --git a/sci-libs/mkl/mkl-10.0.5.025.ebuild b/sci-libs/mkl/mkl-10.0.5.025.ebuild new file mode 100644 index 000000000000..dc66e4a23e98 --- /dev/null +++ b/sci-libs/mkl/mkl-10.0.5.025.ebuild @@ -0,0 +1,368 @@ +# Copyright 1999-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +EAPI=5 + +inherit check-reqs eutils fortran-2 multilib toolchain-funcs + +PID=1232 +PB=${PN} +P_ARCHIVE=l_${PN}_p_${PV} + +DESCRIPTION="Intel(R) Math Kernel Library: linear algebra, fft, math functions" +HOMEPAGE="http://developer.intel.com/software/products/mkl/" +SRC_URI="http://registrationcenter-download.intel.com/irc_nas/${PID}/${P_ARCHIVE}.tgz" + +SLOT="0" +LICENSE="Intel-SDP" +KEYWORDS="-* amd64 ~ia64 x86" +IUSE="doc fftw fortran95 int64 mpi" + +RESTRICT="strip mirror" + +DEPEND=" + app-eselect/eselect-blas + app-eselect/eselect-cblas + app-eselect/eselect-lapack" +RDEPEND="${DEPEND} + doc? ( app-doc/blas-docs app-doc/lapack-docs ) + mpi? ( virtual/mpi )" + +MKL_DIR=/opt/intel/${PN}/${PV} +INTEL_LIC_DIR=/opt/intel/licenses + +CHECKREQS_DISK_BUILD=3500M + +QA_PREBUILT="opt/intel/${PN}/${PV}/*" + +get_fcomp() { + case $(tc-getFC) in + *gfortran* ) + FCOMP="gfortran" ;; + ifort ) + FCOMP="ifc" ;; + * ) + FCOMP=$(tc-getFC) ;; + esac +} + +pkg_setup() { + check-reqs_pkg_setup + fortran-2_pkg_setup + # Check the license + if [[ -z ${MKL_LICENSE} ]]; then + MKL_LICENSE="$(grep -ls MKern ${ROOT}${INTEL_LIC_DIR}/* | tail -n 1)" + MKL_LICENSE=${MKL_LICENSE/${ROOT}/} + fi + if [[ -z ${MKL_LICENSE} ]]; then + eerror "Did not find any valid mkl license." + eerror "Register at ${HOMEPAGE} to receive a license" + eerror "and place it in ${INTEL_LIC_DIR} or run:" + eerror "export MKL_LICENSE=/my/license/file emerge mkl" + die "license setup failed" + fi + + # Check if we have enough free diskspace to install + CHECKREQS_DISK_BUILD="1100M" + check-reqs_pkg_setup + + # Check and setup fortran + if use fortran95; then + # blas95 and lapack95 don't compile with gfortran < 4.2 + [[ $(tc-getFC) =~ (gfortran|g77) ]] && [[ $(gcc-major-version)$(gcc-minor-version) -lt 42 ]] && + die "blas95 and lapack95 don't compile with gfortran < 4.2" + fi + MKL_FC="gnu" + [[ $(tc-getFC) =~ if ]] && MKL_FC="intel" + + # build profiles according to what compiler is installed + MKL_CC="gnu" + [[ $(tc-getCC) == icc ]] && MKL_CC="intel" + + if has_version sys-cluster/mpich; then + MKL_MPI=mpich + elif has_version sys-cluster/mpich2; then + MKL_MPI=mpich2 + elif has_version sys-cluster/openmpi; then + MKL_MPI=openmpi + else + MKL_MPI=intelmpi + fi + get_fcomp +} + +src_unpack () { + default + cd "${WORKDIR}/${P_ARCHIVE}"/install || die + + cp ${MKL_LICENSE} "${WORKDIR}"/ || die + MKL_LIC="$(basename ${MKL_LICENSE})" + + # binary blob extractor installs rpm leftovers in /opt/intel + addwrite /opt/intel + # undocumented features: INSTALLMODE_mkl=NONRPM + + # We need to install mkl non-interactively. + # If things change between versions, first do it interactively: + # tar xf l_*; ./install.sh --duplicate mkl.ini; + # The file will be instman/mkl.ini + # Then check it and modify the ebuild-created one below + # --norpm is required to be able to install 10.x + cat > mkl.ini <<-EOF + [MKL] + EULA_ACCEPT_REJECT=ACCEPT + FLEXLM_LICENSE_LOCATION=${WORKDIR}/${MKL_LIC} + INSTALLMODE_mkl=NONRPM + INSTALL_DESTINATION=${S} + EOF + einfo "Extracting ..." + ./install \ + --silent ./mkl.ini \ + --installpath "${S}" \ + --log log.txt &> /dev/null + + if [[ -z $(find "${S}" -name libmkl.so) ]]; then + eerror "Could not find extracted files" + eerror "See ${PWD}/log.txt to see why" + die "extracting failed" + fi +} + +src_prepare() { + # remove left over + rm -f /opt/intel/.*mkl*.log /opt/intel/intel_sdp_products.db || die + + # remove unused stuff and set up intel names + rm -rf "${WORKDIR}"/l_* || die + + # allow openmpi to work + epatch "${FILESDIR}"/${PN}-10.0.2.018-openmpi.patch + # make scalapack tests work for gfortran + #epatch "${FILESDIR}"/${PN}-10.0.2.018-tests.patch + case ${ARCH} in + x86) MKL_ARCH=32 + MKL_KERN=ia32 + rm -rf lib*/{em64t,64} || die + ;; + + amd64) MKL_ARCH=em64t + MKL_KERN=em64t + rm -rf lib*/{32,64} || die + ;; + + ia64) MKL_ARCH=64 + MKL_KERN=ipf + rm -rf lib*/{32,em64t} || die + ;; + esac + MKL_LIBDIR=${MKL_DIR}/lib/${MKL_ARCH} + # fix env scripts + sed -i \ + -e "s:${S}:${MKL_DIR}:g" \ + tools/environment/*sh || die "sed support file failed" +} + +src_compile() { + cd "${S}"/interfaces || die + if use fortran95; then + einfo "Compiling fortan95 static lib wrappers" + local myconf="lib${MKL_ARCH}" + [[ $(tc-getFC) =~ gfortran ]] && \ + myconf="${myconf} FC=gfortran" + if use int64; then + myconf="${myconf} interface=ilp64" + [[ $(tc-getFC) =~ gfortran ]] && \ + myconf="${myconf} FOPTS=-fdefault-integer-8" + fi + local x + for x in blas95 lapack95; do + pushd ${x} > /dev/null || die + emake ${myconf} + popd > /dev/null || die + done + fi + + if use fftw; then + local fftwdirs="fftw2xc fftw2xf fftw3xc fftw3xf" + local myconf="lib${MKL_ARCH} compiler=${MKL_CC}" + if use mpi; then + fftwdirs="${fftwdirs} fftw2x_cdft" + myconf="${myconf} mpi=${MKL_MPI}" + fi + einfo "Compiling fftw static lib wrappers" + local x + for x in ${fftwdirs}; do + pushd ${x} > /dev/null || die + emake ${myconf} + popd > /dev/null || die + done + fi +} + +src_test() { + cd "${S}"/tests + local myconf + local testdirs="blas cblas" + use int64 && myconf="${myconf} interface=ilp64" + # buggy with g77 and gfortran + #if use mpi; then + # testdirs="${testdirs} scalapack" + # myconf="${myconf} mpi=${MKL_MPI}" + #fi + for x in ${testdirs}; do + pushd ${x} + einfo "Testing ${x}" + emake \ + compiler=${MKL_FC} \ + ${myconf} \ + so${MKL_ARCH} \ + || die "emake ${x} failed" + popd + done +} + +mkl_make_generic_profile() { + cd "${S}" || die + # produce eselect files + # don't make them in FILESDIR, it changes every major version + cat > eselect.blas <<-EOF + ${MKL_LIBDIR}/libmkl_${MKL_KERN}.a /usr/@LIBDIR@/libblas.a + ${MKL_LIBDIR}/libmkl.so /usr/@LIBDIR@/libblas.so + ${MKL_LIBDIR}/libmkl.so /usr/@LIBDIR@/libblas.so.0 + EOF + cat > eselect.cblas <<-EOF + ${MKL_LIBDIR}/libmkl_${MKL_KERN}.a /usr/@LIBDIR@/libcblas.a + ${MKL_LIBDIR}/libmkl.so /usr/@LIBDIR@/libcblas.so + ${MKL_LIBDIR}/libmkl.so /usr/@LIBDIR@/libcblas.so.0 + ${MKL_DIR}/include/mkl_cblas.h /usr/include/cblas.h + EOF + cat > eselect.lapack <<-EOF + ${MKL_LIBDIR}/libmkl_lapack.a /usr/@LIBDIR@/liblapack.a + ${MKL_LIBDIR}/libmkl_lapack.so /usr/@LIBDIR@/liblapack.so + ${MKL_LIBDIR}/libmkl_lapack.so /usr/@LIBDIR@/liblapack.so.0 + EOF +} + +# usage: mkl_add_profile +mkl_add_profile() { + cd "${S}" || die + local prof=${1} + local x + for x in blas cblas lapack; do + cat > ${x}-${prof}.pc <<-EOF + prefix=${MKL_DIR} + libdir=${MKL_LIBDIR} + includedir=\${prefix}/include + Name: ${x} + Description: Intel(R) Math Kernel Library implementation of ${x} + Version: ${PV} + URL: ${HOMEPAGE} + EOF + done + cat >> blas-${prof}.pc <<-EOF + Libs: -Wl,--no-as-needed -L\${libdir} ${2} ${3} -lmkl_core ${4} -lpthread + EOF + cat >> cblas-${prof}.pc <<-EOF + Requires: blas + Libs: -Wl,--no-as-needed -L\${libdir} ${2} ${3} -lmkl_core ${4} -lpthread + Cflags: -I\${includedir} + EOF + cat >> lapack-${prof}.pc <<-EOF + Requires: blas + Libs: -Wl,--no-as-needed -L\${libdir} ${2} ${3} -lmkl_core -lmkl_lapack ${4} -lpthread + EOF + insinto ${MKL_LIBDIR} + for x in blas cblas lapack; do + doins ${x}-${prof}.pc + cp eselect.${x} eselect.${x}.${prof} || die + echo "${MKL_LIBDIR}/${x}-${prof}.pc /usr/@LIBDIR@/pkgconfig/${x}.pc" \ + >> eselect.${x}.${prof} + eselect ${x} add $(get_libdir) eselect.${x}.${prof} ${prof} + done +} + +mkl_make_profiles() { + local clib="gf" + has_version 'dev-lang/ifc' && clib+=" intel" + local slib="-lmkl_sequential" + local rlib="-liomp5" + local pbase=${PN} + local c + for c in ${clib}; do + local ilib="-lmkl_${c}_lp64" + use x86 && ilib="-lmkl_${c}" + local tlib="-lmkl_${c/gf/gnu}_thread" + local comp="${c/gf/gfortran}" + comp="${comp/intel/ifort}" + mkl_add_profile ${pbase}-${comp} ${ilib} ${slib} + mkl_add_profile ${pbase}-${comp}-threads ${ilib} ${tlib} ${rlib} + if use int64; then + ilib="-lmkl_${c}_ilp64" + mkl_add_profile ${pbase}-${comp}-int64 ${ilib} ${slib} + mkl_add_profile ${pbase}-${comp}-threads-int64 ${ilib} ${tlib} ${rlib} + fi + done +} + +src_install() { + dodir ${MKL_DIR} + + # install license + if [[ ! -f ${INTEL_LIC_DIR}/${MKL_LIC} ]]; then + insinto ${INTEL_LIC_DIR} + doins "${WORKDIR}"/${MKL_LIC} || die "install license failed" + fi + + # install main stuff: cp faster than doins + einfo "Installing files..." + local cpdirs="benchmarks doc examples include interfaces lib man tests" + local doinsdirs="tools" + cp -pPR ${cpdirs} "${D}"${MKL_DIR} \ + || die "installing mkl failed" + insinto ${MKL_DIR} + doins -r ${doinsdirs} || die "doins ${doinsdirs} failed" + dosym mkl_cblas.h ${MKL_DIR}/include/cblas.h + + # install blas/lapack profiles + mkl_make_generic_profile + mkl_make_profiles + + # install env variables + cat > 35mkl <<-EOF + MKLROOT=${MKL_DIR} + LDPATH=${MKL_LIBDIR} + MANPATH=${MKL_DIR}/man + EOF + doenvd 35mkl +} + +pkg_postinst() { + # if blas profile is mkl, set lapack and cblas profiles as mkl + local blas_prof=$(eselect blas show | cut -d' ' -f2) + local def_prof="mkl-gfortran-threads" + has_version 'dev-lang/ifc' && def_prof="mkl-ifort-threads" + use int64 && def_prof="${def_prof}-int64" + for x in blas cblas lapack; do + local cur_prof=$(eselect ${x} show | cut -d' ' -f2) + if [[ -z ${cur_prof} || ${cur_prof} == ${def_prof} ]]; then + # work around eselect bug #189942 + local configfile="${ROOT}"/etc/env.d/${x}/$(get_libdir)/config + [[ -e ${configfile} ]] && rm -f ${configfile} + eselect ${x} set ${def_prof} + elog "${x} has been eselected to ${def_prof}" + else + elog "Current eselected ${x} is ${current_lib}" + elog "To use one of mkl profiles, issue (as root):" + elog "\t eselect ${x} set " + fi + if [[ ${blas_prof} == mkl* && ${cur_prof} != ${blas_prof} ]]; then + eselect blas set ${def_prof} + elog "${x} is now set to ${def_prof} for consistency" + fi + done + if [[ $(gcc-major-version)$(gcc-minor-version) -lt 42 ]]; then + elog "Multi-threading OpenMP for GNU compilers only available" + elog "with gcc >= 4.2. Make sure you have a compatible version" + elog "and select it with gcc-config before selecting gnu profiles" + fi +} -- cgit v1.2.3