-
Notifications
You must be signed in to change notification settings - Fork 0
Compiling Julia with MKL on macOS
This was written with assumption that MKL is provided via conda. However, the same should work for standalone MKL installations with some minor tweaks.
Create a new conda environment with mkl and set environment variables.
$ conda create -n mkl mkl -c intel
$ export MKLROOT=/usr/local/conda/envs/mkl
Clone julia repo
$ git clone https://github.com/julialang/julia
Create a Make.user file with the following contents:
USE_INTEL_MKL = 1
USE_INTEL_MKL_FFT = 1
MKLLIB = $(MKLROOT)/lib
USE_INTEL_LIBM ?= 0
USE_INTEL_JITEVENTS ?= 0
USEICC ?= 0
USEIFC ?= 0
Start compiling
make
The build will likely break with an error like
make[1]: *** [/Users/hjkim/Downloads/julia/usr/lib/julia/libmkl_rt.dylib] Error 1
Bypass this by making symlink from $MKLROOT/lib/libmkl.rt
to ./usr/lib/julia
ln -s $MKLROOT/lib/libmkl.rt usr/lib/julia
Run the Makefile under ./contrib/mac/app
. To make it actually distributable, replace the symlink with a copy instead. Compiling with MARCH=haswell
for my computers will help.
You may encounter an issue with Distributions.jl with something like
[ Info: Precompiling Distributions [31c24e10-a181-5473-b8eb-7969acd0382f]
ERROR: LoadError: LoadError: InitError: could not load library "/Users/hjkim/.julia/artifacts/7c9ef733699a1d86b8a6073ed08a4457e3e790f7/lib/libgfortran.5.dylib"
dlopen(/Users/hjkim/.julia/artifacts/7c9ef733699a1d86b8a6073ed08a4457e3e790f7/lib/libgfortran.5.dylib, 1): Library not loaded: @rpath/libquadmath.0.dylib
Referenced from: /Users/hjkim/.julia/artifacts/7c9ef733699a1d86b8a6073ed08a4457e3e790f7/lib/libgfortran.5.dylib
Reason: image not found
Stacktrace:
...
I fixed it by symlinking from my system libgfortran. /usr/local/Cellar/gcc/9.3.0_1/lib/gcc/9/libquadmath.dylib