Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Intel MKL linear algebra backend for Julia

License

NotificationsYou must be signed in to change notification settings

JuliaLinearAlgebra/MKL.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Using Julia with Intel's MKL

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.

Usage

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.

To Install:

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 .

To Check Installation:

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

Using the 64-bit vs 32-bit version of MKL

We use ILP64 by default on 64-bit systems, and LP64 on 32-bit systems.

Threading control

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).

NOTE: Using MKL with Distributed

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)

NOTE: MKL on Intel Macs

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

Stars

Watchers

Forks

Contributors18

Languages


[8]ページ先頭

©2009-2025 Movatter.jp