Just compiled julia with mkl and libm on macOS, ran some tests and it looks to be working fine. It took a while and the info I found online are in various places (mainly from this github issue and the the intel documentation), so here’s the steps in one place for easy reference:
- mkl: Accelerate Fast Math with Intel® oneAPI Math Kernel Library
- libm: not included in mkl for mac, it’s in Compilers Redistributable Libraries: Intel® C++ and Fortran Compilers Redistributable Libraries by Version
(I used [Parallel Studio XE 2019 (All Editions)], c++ compiler)
Then, basically the steps listed in the intel documentation:
-
clone the julia git repo to a local folder:
git clone https://github.com/JuliaLang/julia.git
-
check out the latest version, e.g.
git checkout v1.1.0
-
modify
Make.inc
to use mkl and libm:
change USE_INTEL_MKL
from 0 to 1 for mkl
change USE_INTEL_LIBM
from 0 to 1 for libm
The default intel mkl install does not have the intel64
subfolder, so change that too:
MKLLIB := $(MKLROOT)/lib/intel64
to
MKLLIB := $(MKLROOT)/lib/
for libm,
LIBM := -L$(MKLROOT)/../compiler/lib/intel64 -limf
to
LIBM := -L$(MKLROOT)/../compiler/lib/ -limf
git diff:
diff --git a/Make.inc b/Make.inc
index e9cb241198..870464aecf 100644
--- a/Make.inc
+++ b/Make.inc
@@ -56,9 +56,9 @@ USE_LLVM_SHLIB := 1
## Settings for various Intel tools
# Set to 1 to use MKL
-USE_INTEL_MKL ?= 0
+USE_INTEL_MKL ?= 1
# Set to 1 to use Intel LIBM
-USE_INTEL_LIBM ?= 0
+USE_INTEL_LIBM ?= 1
# Set to 1 to enable profiling with Intel VTune Amplifier
USE_INTEL_JITEVENTS ?= 0
# Set to 1 to use Intel C, C++, and FORTRAN compilers
@@ -1083,14 +1083,14 @@ endif
ifeq ($(USE_INTEL_LIBM), 1)
USE_SYSTEM_LIBM := 1
-LIBM := -L$(MKLROOT)/../compiler/lib/intel64 -limf
+LIBM := -L$(MKLROOT)/../compiler/lib/ -limf
LIBMNAME := libimf
endif
ifeq ($(USE_INTEL_MKL), 1)
ifeq ($(USE_BLAS64), 1)
export MKL_INTERFACE_LAYER := ILP64
-MKLLIB := $(MKLROOT)/lib/intel64
+MKLLIB := $(MKLROOT)/lib/
else
MKLLIB := $(MKLROOT)/lib/ia32
endif
Note that the compilers redistributable libraries by default installs to ~\intel\redist
, so further copy/symlink is needed for libm. libm has references to libintlc so need to symlink/copy that too (also, writing to /opt/ so need sudo):
sudo ln -s ~/intel/redist/compilers_and_libraries_2019.2.184/mac/compiler/lib/libimf.dylib /opt/intel/lib/libimf.dylib
sudo ln -s ~/intel/redist/compilers_and_libraries_2019.2.184/mac/compiler/lib/libintlc.dylib /opt/intel/lib/libintlc.dylib
change compilers_and_libraries_2019.2.184
to the installed version if different.
- Now run the build, will take a while.
cd to the git repo cloned and
source /opt/intel/mkl/bin/mklvars.sh intel64 ilp64
then make
- The source statement above setup the env variable but julia may need further sym links, from the cloned git repo directory, do
ln -s /opt/intel/mkl/lib/libmkl_rt.dylib usr/lib/julia/libmkl_rt.dylib
ln -s /opt/intel/lib/libimf.dylib usr/lib/julia/libimf.dylib
ln -s /opt/intel/lib/libintlc.dylib usr/lib/julia/libintlc.dylib
Note the lack of /
in front of usr: it symlinks to the usr folder in the current directory (cloned julia repo directory), not the /usr/ folder on root
Now, julia should be compiled and you may run it as ./julia
from the current directory (or make install
; run with make install -n
to see which files will be copied where). You may need to recompile some packages, such as Pkg.build("SpecialFunctions")
.