-
Notifications
You must be signed in to change notification settings - Fork 70
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
adding attempt to force inbounds at the kernel level #429
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #429 +/- ##
==========================================
- Coverage 83.84% 83.28% -0.56%
==========================================
Files 9 9
Lines 625 634 +9
==========================================
+ Hits 524 528 +4
- Misses 101 106 +5
☔ View full report in Codecov by Sentry. |
Ok, I think this PR is done. I made it kinda on a whim and I'm not sure if people actually want it. I could use it for a few specific workflows and think it might be useful for debugging JuliaGPU/AMDGPU.jl#536 Maybe we can wait a few days to see if anyone else thinks it could be useful? The way I see it, it's one of those things that makes the code more "kernel" like, but can also really hurt some people who are not careful. |
It's non breaking so I am happy to include it. |
test/runtests.jl
Outdated
@test_throws BoundsError(Int64[],(1,)) my_bounded_kernel(CPU())(Int[], ndrange=1) | ||
|
||
@kernel inbounds=true my_inbounds_kernel(a) = a[1] | ||
@test nothing == my_inbounds_kernel(CPU())(Int[], ndrange=1) |
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 think CI runs with --check-bounds=true
which overrides @inbounds
.
That's nice to have! And can definitively help while debugging and developing. |
Love it! |
Ok, looks like some other folks might find this useful. Also, after looking at JuliaGPU/AMDGPU.jl#354, and JuliaLang/julia#48245, I think this is a fair PR to merge. Also EDIT: |
Co-authored-by: Valentin Churavy <[email protected]>
Ok, I think the tests pass (except nightly). So I think the PR is good to go. |
This adds an additional flag at the
@kernel
level to force@inbounds
across the entire kernel. It works like:Note that this comes with all the caveats of using
@inbounds
and is certainly not good for default behaviour, but... Geez I'm tired of all the@inbounds
I'll rebase and add some tests soon if people think this could be useful.