# Copyright (c) 2016 Dave Love, Liverpool University # Licence: MIT %global sover 3 %global gslsover 0 # Ensure we're installable in case the Intel rpms haven't been # installed locally (typical shared HPC setup). %global __requires_exclude \(libmkl*\) %{?filter_setup: %filter_from_requires /libmkl*/d %filter_setup } Name: mkl-compat Version: 1.0 Release: 1%{?dist} Summary: MKL compatibility libraries for reference blas/lapack etc. License: MIT # I don't know the appropriate link incantation for ix86 anyhow. ExclusiveArch: x86_64 %description This package provides trivial shared LAPACK/BLAS libraries which can replace those from the reference blas, lapack, atlas, gsl, and R packages at run time so that binaries dynamically linked against those automatically call into the (proprietary :-() Intel MKL library instead. (This is primarily for testing, or production use on systems with AVX512, since OpenBLAS, via the openblas-compat package is fine for other x86 systems but unfortunately doesn't currently have AVX512 support.) It is similar in effect to openblas-compat (q.v.), but doesn't affect the load path by default (set LD_LIBRARY_PATH and/or R_LD_LIBRARY_PATH to pick up %_libdir/%name). Also it only provides OpenMP substitutes, even for the serial libraries -- set OMP_NUM_THREADS as appropriate, e.g. 1 to avoid multiple threads. The library shims set rpath to the MKL location with which they were built, but obviously you need to have MKL installed and LD_LIBRARY_PATH set appropriately if the MKL build and run time locations differ. %prep rm -rf %name-%version mkdir %name-%version %build if [[ -z $MKLROOT ]]; then echo "MKLROOT not defined, e.g. by environment module" >&2 exit 1 fi # Idea: we could have dummy libmkl_intel_lp64 etc. at build time to # allow building without anything proprietary, but then we'd have to # know what MKLROOT should be to avoid needing LD_LIBRARY_PATH and # rather defeating the object. %global mkl_flags -Wl,--no-as-needed -L$MKLROOT/lib/intel64 -lmkl_intel_lp64 -lmkl_core -lmkl_gnu_thread -fopenmp -Wl,-rpath=$MKLROOT/lib/intel64 cd %name-%version # We need libraries with the right filename and soname, so build # trivial ones which just pull in openblas. (Debian builds # non-trivial versions as alternatives.) %if 0%{?__isa_bits} == 64 %global lib64s blas64 lapack64 %else %global lib64s %nil %endif # ATLAS changed at 3.10 %if 0%{?el6} || 0%{?el5} %global atlibs cblas clapack f77blas %else %global atlibs satlas %endif for n in blas lapack lapacke %lib64s %atlibs openblas openblaso; do cc -shared -o lib$n.so.%sover -Wl,-soname,lib$n.so.%sover %mkl_flags done cc -shared -o libgslcblas.so.%gslsover -Wl,-soname,libgslcblas.so.%gslsover %mkl_flags # atlas threaded %if 0%{?fedora} > 20 cc -shared -o libtatlas.so.%sover -Wl,-soname,libtatlas.so.%sover %mkl_flags %else for n in ptf77blas ptcblas; do cc -shared -o lib$n.so.%sover -Wl,-soname,lib$n.so.%sover %mkl_flags done %endif # R sanctions linking optimized libraries to these in its library # area, but that gets a spurious link made by ldconfig and this is # cleaner and robust through package updates. cc -shared -o libRblas.so %mkl_flags cc -shared -o libRlapack.so %mkl_flags %install cd %name-%version mkdir -p %buildroot%_libdir/%name install -m 755 *.so* %buildroot%_libdir/%name %files %_libdir/%name %changelog * Thu Oct 20 2016 Dave Love - 1.0-1 - Initial version