-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
Added note to BLAS.[g|s]et_num_threads about Apple Accelerate not supporting it #1195
Added note to BLAS.[g|s]et_num_threads about Apple Accelerate not supporting it #1195
Conversation
Adding @staticfloat and @danielwe for input |
Linking JuliaLinearAlgebra/AppleAccelerate.jl#75 for the discussion on how to improve support for accelerate's threading API in Julia/LBT |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1195 +/- ##
=======================================
Coverage 91.89% 91.89%
=======================================
Files 34 34
Lines 15360 15360
=======================================
Hits 14115 14115
Misses 1245 1245 ☔ View full report in Codecov by Sentry. |
How can I test my change which uses |
One pattern is to save & reset the number of BLAS threads: n = get_num_threads()
set_num_threads(1)
Threads.@threads for ...
# do some work, calling BLAS
end
set_num_threads(n) # restore original setting This isn't ideal with Accelerate, but making packages which do this suddenly print warnings seems sub-optimal. |
@mcabbott Apple Accelerate does not support |
I think the issue is that someone may write packages or other cross-platform code with the pattern @mcabbott showed. This currently works just fine with Accelerate---it doesn't have any effect, but it doesn't cause anything bad to happen either. With this PR, every user of such code also using Accelerate will start seeing warnings they can't easily control or silence. (Imagine if this pattern is used in an objective function passed to an optimizer---before you know it, hundreds of warnings have flooded your terminal.) A compromise could be to add |
I agree that |
Another thing to consider is whether libblastrampoline will see any updates to this behavior in the foreseeable future. Users will probably only get this PR once it's made it into the sysimage of a Julia release, so whatever change is made here should reflect the expected behavior at that point. |
I see. Sorry I misunderstood. I added |
Should I add "As of LinearAlgebra v'x.y.z' Apple Accelerate does not ......" |
I do think that this warning should be thrown from inside libblastrampoline or |
But I still don't really see why this needs to print a warning, in code that is probably working fine. Can you explain what's wrong with |
@ajinkya-k what would you think of, instead of this PR, putting something like the following in the !!! note
Some BLAS libraries, such as Apple Accelerate, cannot be configured to use a fixed number of threads. For these backends, `get_num_threads()` always returns `1`. While we're at it the docstring should probably also have an xref |
My concern with making this a warning is that most users will not manually import AppleAccelerate, they’ll import some package that imports it instead. Same goes for setting threads. So I also prefer doc string over warning. |
That’s fair. I’ll make a push with the docstring to this PR by tomorrow |
b313cd3
to
adef1ed
Compare
@staticfloat @mcabbott I modified the PR to only add a note in the docstring. Let me know what you think |
@mcabbott @staticfloat Is the docstring note good? Or should i make any more changes? |
Per the documentation for
AppleAccelerate.jl
,BLAS.get_num_threads()
returns a hard coded default when usingAppleAccelerate
. This PR simply adds a warning message when this function is called to alert the user in the console itself.