Skip to content

Commit

Permalink
Fix loading Pardiso on mac when MKL does not support it (#95)
Browse files Browse the repository at this point in the history
* allow Pardiso.jl to load when MKL is not available

* add a small note about MKL versions on mac
  • Loading branch information
KristofferC authored Feb 14, 2024
1 parent a43a6e4 commit e62b47a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ library.
### MKL PARDISO

By default Julia, will automatically install a suitable MKL for your platform.
Note that if you use a mac you will need to pin `MKL_jll` to version 2022.

If you rather use a self installed MKL follow these instructions:

* Set the `MKLROOT` environment variable. See the [MKL getting started
Expand All @@ -33,7 +35,7 @@ If you rather use a self installed MKL follow these instructions:

### PARDISO 6.0

* Put the PARDISO library `libpardiso600-WIN-X86-64.dll`, `libpardiso600-GNUXXX-X86-64.so` or
* Put the PARDISO library `libpardiso600-WIN-X86-64.dll`, `libpardiso600-GNUXXX-X86-64.so` or
`libpardiso600-MACOS-X86-64.dylib` in a folder somewhere and set the environment variable `JULIA_PARDISO` to that folder.
For example, create an entry `ENV["JULIA_PARDISO"] = "/Users/Someone/Pardiso"` in the
`.julia/config/startup.jl` file and download the Pardiso library to that folder.
Expand Down Expand Up @@ -128,8 +130,8 @@ which gives
julia> S
5×5 Array{Float64,2}:
-0.121404 1.49473 -1.25965 7.40326 0.571538
-19.4928 -7.71151 12.9496 -7.13646 -20.4194
9.88029 3.35502 -7.2346 1.70651 13.9759
-19.4928 -7.71151 12.9496 -7.13646 -20.4194
9.88029 3.35502 -7.2346 1.70651 13.9759
-9.06094 -5.86454 7.44917 -2.54985 -9.17327
-33.7006 -17.8323 20.2588 -19.5863 -37.6132
```
Expand Down
8 changes: 5 additions & 3 deletions src/Pardiso.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ const pardiso_get_schur_f = Ref{Ptr}()
const PARDISO_LOADED = Ref(false)

function __init__()
if !LOCAL_MKL_FOUND
if MKL_jll.is_available()
libmkl_rt[] = MKL_jll.libmkl_rt_path
else
elseif LOCAL_MKL_FOUND
if Sys.iswindows()
libmkl_rt[] = "mkl_rt"
elseif Sys.isapple()
Expand All @@ -130,7 +130,9 @@ function __init__()

# This is apparently needed for MKL to not get stuck on 1 thread when
# libpardiso is loaded in the block below...
get_nprocs_mkl()
if libmkl_rt[] !== ""
get_nprocs_mkl()
end

if PARDISO_LIB_FOUND
try
Expand Down
3 changes: 3 additions & 0 deletions src/mkl_pardiso.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ mutable struct MKLPardisoSolver <: AbstractPardisoSolver
end

function MKLPardisoSolver()
if !MKL_jll.is_available()
error("MKL is not available no this platform")
end
pt = zeros(Int, 64)
iparm = zeros(MklInt, 64)
mtype = REAL_NONSYM
Expand Down

4 comments on commit e62b47a

@KristofferC
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error while trying to register: Register Failed
@KristofferC, it looks like you are not a publicly listed member/owner in the parent organization (JuliaSparse).
If you are a member/owner, you will need to change your membership to public. See GitHub Help

@jd-lara
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KristofferC looks like the fix wasn't released.

@KristofferC
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.