Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable use of multi-threaded MKL on mac #98

Closed
ViralBShah opened this issue Dec 27, 2021 · 11 comments
Closed

Disable use of multi-threaded MKL on mac #98

ViralBShah opened this issue Dec 27, 2021 · 11 comments

Comments

@ViralBShah
Copy link
Contributor

ViralBShah commented Dec 27, 2021

Based on the discussions in

JuliaLang/LinearAlgebra.jl#845
JuliaLang/LinearAlgebra.jl#896

It seems the simplest thing may be to not allow multi-threaded MKL on the mac. What would be the easiest way to achieve this?

@ViralBShah ViralBShah changed the title Disable use of MKL on mac Disable use of multi-threaded MKL on mac Dec 27, 2021
@ViralBShah
Copy link
Contributor Author

ViralBShah commented Dec 27, 2021

I wonder if THREADING_GNU will help address this. I will note that on mac, MKL does not provide the GNU libraries (only Intel and TBB). It is possible it is a linux only thing.

THREADING_GNU

@pablosanjose
Copy link

pablosanjose commented Dec 27, 2021

Disabling multithreading in MKL kills most of the benefit of the package versus OpenBLAS. I don't think that's a good approach. JuliaLang/LinearAlgebra.jl#845 is only an issue if one uses SpecialFunctions. Not sure about JuliaLang/LinearAlgebra.jl#896, but wouldn't it be better to try to understand where the bug in threading is instead of simply disabling it? (Apologies if I misunderstood the issue here)

@ViralBShah
Copy link
Contributor Author

It is not just SpecialFunctions. It is possibly triggered through any fortran library. The bug is not in Julia's threading - it is that Intel OpenMP that MKL uses is incompatible with gcc libgomp (loaded by almost any fortran library). On linux, Intel provides a version that will use libgomp - but not on mac.

Can you try the TBB option to see if that works reliably and also can use threads?

@ViralBShah
Copy link
Contributor Author

ViralBShah commented Dec 27, 2021

See JuliaLang/LinearAlgebra.jl#896 for another potential case that does not use SpecialFunctions.

@pablosanjose
Copy link

pablosanjose commented Dec 27, 2021

Can you try the TBB option to see if that works reliably and also can use threads?

No luck:

julia> using MKL
[ Info: Precompiling MKL [33e6dc65-8f57-5167-99aa-e5a354878fb2]
INTEL MKL ERROR: dlopen(/Users/pablo/.julia/artifacts/be4d5c9f8ccb92916ceb22a6b15085b57f81d05d/lib/libmkl_tbb_thread.1.dylib, 9): Library not loaded: @rpath/libtbb.12.dylib
  Referenced from: /Users/pablo/.julia/artifacts/be4d5c9f8ccb92916ceb22a6b15085b57f81d05d/lib/libmkl_tbb_thread.1.dylib
  Reason: image not found.
Intel MKL FATAL ERROR: Cannot load libmkl_tbb_thread.1.dylib.

[Process completed]

@ViralBShah
Copy link
Contributor Author

A better solution is what is discussed in JuliaPackaging/BinaryBuilder.jl#700

@ViralBShah
Copy link
Contributor Author

@ViralBShah
Copy link
Contributor Author

ViralBShah commented Mar 3, 2022

We may have to disable MKL multi-threading on mac - it is quite problematic: #104 (comment)

Issues have been reported in 1.7 as well.

@pablosanjose
Copy link

pablosanjose commented Mar 3, 2022

Perhaps, since the future of Macs seems to be decoupled from Intel hardware, disabling multithreading in MKL on mac may not be such an issue going forward (correctness always comes before performance). But it does place a higher priority to get the Accelerate API to work with LBT. My 2c.

@ViralBShah
Copy link
Contributor Author

The Accelerate API already works with LBT. The missing piece is LAPACK (since Apple ships a 10 year old LAPACK and we use some of the nice new capabilities like dgesdd etc.). Good news is this is not too difficult - needs addressing JuliaPackaging/Yggdrasil#2657 and then some integration and testing since this is the first time we'll have a separate BLAS and LAPACK.

@ViralBShah
Copy link
Contributor Author

I have seen too many issues with MKL on mac - that I don't feel it is right to give people something that is highly likely to give the wrong answer. I'm going to make single threaded the default here and people can always change that through the API to enable threading.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants