Git Product home page Git Product logo

mkl.jl's Introduction

MKL.jl

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 includes libblastrampoline, which enables picking a BLAS and LAPACK library at runtime. A JuliaCon 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 like IntelVectorMath.jl, Pardiso.jl, etc. wrap more of MKL's functionality. The oneAPI.jl package provides support for Intel OneAPI and Intel GPUs.

Usage

If you want to use MKL.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 avoid issues 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 name VCRUNTIME140.dll. To install it, download and execute https://aka.ms/vs/17/release/vc_redist.x64.exe .

To Check Installation:

julia> using LinearAlgebra

julia> BLAS.get_config()
LinearAlgebra.BLAS.LBTConfig
Libraries: 
└ [ILP64] libopenblas64_.0.3.13.dylib

julia> using MKL

julia> BLAS.get_config()
LinearAlgebra.BLAS.LBTConfig
Libraries: 
└ [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.

NOTE: Using MKL with Distributed

If you are using Distributed for parallelism on a single node, set MKL to single threaded mode to avoid over subcribing the CPUs.

BLAS.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 of MKL_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 have some issues on Intel Macs when multi-threading is enabled. Threading can be disabled in such cases with:

MKL.set_threading_layer(THREADING_SEQUENTIAL)

mkl.jl's People

Contributors

viralbshah avatar andreasnoack avatar dilumaluthge avatar aminya avatar staticfloat avatar daviehh avatar kristofferc avatar dependabot[bot] avatar amontoison avatar giordano avatar danielwe avatar fgerick avatar imciner2 avatar roger-luo avatar ranocha avatar prbzrg avatar pallharaldsson avatar

Stargazers

Pierre Navaro avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.