- Notifications
You must be signed in to change notification settings - Fork31
Intel MKL linear algebra backend for Julia
License
JuliaLinearAlgebra/MKL.jl
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
MKL.jl is a Julia package that allows users to use the Intel MKL library for Julia's underlying BLAS and LAPACK, instead of OpenBLAS, which Julia ships with by default. Julia includeslibblastrampoline, which enables picking a BLAS and LAPACK library at runtime. AJuliaCon 2021 talk provides details on this mechanism.
This package requires Julia 1.8+, and only covers the forwarding of BLAS and LAPACK routines in Julia to MKL. Other packages likeIntelVectorMath.jl,Pardiso.jl, etc. wrap more of MKL's functionality. TheoneAPI.jl package provides support for Intel OneAPI and Intel GPUs.
If you want to useMKL.jl
in your project, make sure it is the first package you load before any other package. It is essential that MKL be loaded before other packages so that it can find the Intel OMP library and avoidissues resulting out of GNU OMP being loaded first.
Adding the package will replace the system BLAS and LAPACK with MKL provided ones at runtime. Note that the MKL package has to be loaded in every new Julia process. Upon quitting and restarting, Julia will start with the default OpenBLAS.
julia>using Pkg; Pkg.add("MKL")
Hint: On Windows the installation might fail due to a missing library with the nameVCRUNTIME140.dll
. To install it, download and executehttps://aka.ms/vs/17/release/vc_redist.x64.exe .
julia>using LinearAlgebrajulia> BLAS.get_config()LinearAlgebra.BLAS.LBTConfigLibraries: └ [ILP64] libopenblas64_.0.3.13.dylibjulia>using MKLjulia> BLAS.get_config()LinearAlgebra.BLAS.LBTConfigLibraries: └ [ILP64] libmkl_rt.1.dylib
We use ILP64 by default on 64-bit systems, and LP64 on 32-bit systems.
To set or get the global number of threads used byMKL
, useMKL.{set/get}_num_threads
. This does not affect specific domains where the number of threads is set withmkl_domain_set_num_threads
. CallingLinearAlgebra.BLAS.{set/get}_num_threads
is domain-specific and only refers to theBLAS
domain (unlike other backends, where the number of threads used byLAPACK
is also modified).
If you are usingDistributed
for parallelism on a single node, set MKL to single threaded mode toavoid over subcribing the CPUs.
MKL.set_num_threads(1)
MKL for Intel Macs is discontinued as of MKL 2024. Thus, in order to use MKL on Intel Macs, you will need to install the right version ofMKL_jll
and possibly also pin it.
julia> Pkg.add(name="MKL_jll", version="2023"); Resolving package versions... Updating`~/.julia/environments/v1.10/Project.toml`⌃ [856f044c]+ MKL_jll v2023.2.0+0 No Changes to`~/.julia/environments/v1.10/Manifest.toml`julia> Pkg.pin(name="MKL_jll", version="2023"); Resolving package versions... Updating`~/.julia/environments/v1.10/Project.toml`⌃ [856f044c]~ MKL_jll v2023.2.0+0⇒ v2023.2.0+0 ⚲ Updating`~/.julia/environments/v1.10/Manifest.toml`⌃ [856f044c]~ MKL_jll v2023.2.0+0⇒ v2023.2.0+0 ⚲ Info Packages marked with ⌃ have new versions available and may be upgradable.
MKL seems to havesome issues on Intel Macs when multi-threading is enabled. Threading can be disabled in such cases with:
MKL.set_threading_layer(THREADING_SEQUENTIAL)
About
Intel MKL linear algebra backend for Julia
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.