-
Notifications
You must be signed in to change notification settings - Fork 32
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
Switch between MKL and OpenBLAS at runtime #90
Comments
While it is easy to switch from OpenBLAS to MKL ( |
With |
Yeah, in #58 we already agreed that it would be great to have a built-in function for switching back to the default BLAS. It's on my todo list (but not very high priority). So if someone want to beat me to implementing it, feel free to do so :) |
I would also be interested in having this. Related: https://discourse.julialang.org/t/from-mkl-back-to-openblas/37722 |
In case someone runs into this, one can switch at runtime using
Credits to @giordano for suggesting this to me, and for also mentioning that this is not the "official way" to do this. |
Why close? If this is fixed in LinearAlgebra, can you link the corresponding issue/commit? |
The suggestion that @cossio made above should work, right? |
Well, it works, yes, but it isn't a proper solution IMO. It relies on internals (i.e. isn't part of documented API) and thus might stop working at any point (also might have side effects). |
Ok, we can keep it open until we have a robust solution. |
Amazing. It works once, but does not seem to be reversible.
|
My bad. Using
instead of |
We just need a nice API in base Julia to reset back to openblas. |
Here's a hack job that is working for me.
|
Would it be better in general to have an API for switching BLAS providers, rather than doing something by default when the packages like MKL.jl or AppleAccelerate.jl are loaded? |
I'd like that, especially if it goes into base. |
I mean, there's already: BLAS.lbt_forward(OpenBLAS_jll.libopenblas_path; clear=true) Everybody's using |
Here's a version that avoids the @giordano @ViralBShah have I left anything out and/or broken anything?
|
Yes - I think it should be possible to have a single package that allows you to pick a BLAS of your choice. Is it a good idea to combine all the BLAS into a common package and then lazily pick the BLAS implementation at runtime (including installing it and such using some of the new fangled package extensions?) |
Also note, now there is a ReferenceBLAS_jll package in Yggdrasil. |
Doesn't sound like a bad idea. I might give it a try if I can find the time for it.
What does it do? |
It is just the netlib reference BLAS, so you can think of it as just the for-loop versions of BLAS without any manual or architecture-specific optimizations (outside of what the compiler will do naturally). |
Ah, I see, thanks! |
How do I get to the reference BLAS. I tried and got this ...
|
You need to pass the library handle from the JLL package to the forward function, so it should be:
|
The main idea is to have it for certain use cases where OpenBLAS and others use too much memory, where performance is not critical but memory/simplicity is. |
I'm still confused. When I try to load the reference BLAS, OpenBLAS won't go away and any timings I try to do are the same as with OpenBLAS. When I load AppleAccelerate, OpenBLAS vanishes.
|
#90 (comment) you're missing the |
With refernce BLAS and LAPACK:
With default (openblas):
|
Thanks @giordano. That did it. |
Nope.
|
That's because you didn't forward LAPACK. Once you clear, all BLAS and LAPACK symbols don't point to anything. At that point, you are only forwarding BLAS, but not LAPACK. See my example above. |
Somewhere the |
Before I give this a go, I would like to hear the opinion of the (main) authors of some of the other LBT-forward packages, specifically, @giordano (FujitsuBLAS), @staticfloat (MKL), @simonbyrne (AppleAccelerate). Personally I like the idea of a single, unified "BLAS Switcher" package. After all, each of the backend-specific packages has essentially only a few lines of code these days. The central question for me is whether we should
For perspective, FujitsuBLAS.jl and BLISBLAS.jl currently have around 20 lines of code each. MKL.jl has around 50. AppleAccelerate.jl is bigger (because it also provides array-oriented functions) but if we only count the LBT forwarding part we are definitely <100 as well. Overall, we're thus talking about <≈ 200 lines of code. What do you guys think? PS: I think that just BLAS.jl might be a good name for this overarching package. |
I think a single BLAS.jl is a great idea. Of course it would also do LAPACK. Although one might argue that using our stock LAPACK is better except in some cases like MKL. But only makes sense if the binary artifacts can be installed based on user preferences. Ideally we would then use the Preferences mechanism to pick the BLAS. I think the individual packages can simply be deprecated. They mostly exist as a way to install the JLL and do the forwarding. |
Is there a way to switch between the two at runtime?
The text was updated successfully, but these errors were encountered: