-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Warn @inbounds @threads for pattern etc. during macro expansion
#41893
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
Conversation
vchuravy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this approach. But maybe triage should have a chat about it, since I don't think we do something like this anywhere else
|
Given that we are able to detect this specific scenario, could we instead make the macro do what the user intended and propagate the |
|
The implementation in this PR is not enough to reliably support @inbounds begin @threads for x in xs; end; end
@inbounds begin
@threads for x in xs; end
@threads for x in xs; end
end
@inbounds for y in ys
@threads for x in xs; end
endWarning can have false-negative and I think it's OK as long as it helps people understand how I think tweaking macro inbounds_capturing_thunk(ex)
quote
checkbounds = true
@boundscheck checkbounds = false
if checkbounds
thunk_checkbounds() = $(esc(ex))
else
thunk_nocheckbounds() = @inbounds $(esc(ex))
end
end
end(It can be simplified if we can put Having said that, I'm against such a change. I think Julia programmers need to know how |
|
I really do think |
|
I think it'd be ideal if (Perhaps That said, looking at the current documentation Lines 541 to 543 in c5f3487
it's probably most natural to interpret that If we consider that |
Codecov Report
@@ Coverage Diff @@
## master #41893 +/- ##
===========================================
+ Coverage 78.04% 89.17% +11.12%
===========================================
Files 351 343 -8
Lines 74091 79363 +5272
===========================================
+ Hits 57824 70771 +12947
+ Misses 16267 8592 -7675
Continue to review full report at Codecov.
|
|
We want to |
I've seen users trying
@inbounds @threads forand@inbounds @spawnfor their attempt to improve performance [1]. Since@inboundsdoes not work across function boundaries, these annotations are useless and people can be confused by the performance of the code. So, it is rather tempting to just warn the users while expanding@inboundswhich is much more efficient than keep paying attention in discourse/slack/zulip. What do people think about this kind of approach? Would it be too noisy?Here's an example output:
(with https://github.com/JuliaLogging/TerminalLoggers.jl)
[1] Examples: