-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[libclc] Use __scoped_atomic_udec/uinc_wrap to implement _clc_atomic_dec/inc #168327
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
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.
Pull Request Overview
This PR fixes a critical bug in the libclc atomic operation implementations where the increment and decrement functions were using the wrong underlying atomic operations. The __clc_atomic_inc function was incorrectly using __scoped_atomic_fetch_sub (subtraction) instead of __scoped_atomic_fetch_add (addition), and conversely, __clc_atomic_dec was using addition instead of subtraction.
- Corrected
__clc_atomic_incto use__scoped_atomic_fetch_addinstead of__scoped_atomic_fetch_sub - Corrected
__clc_atomic_decto use__scoped_atomic_fetch_subinstead of__scoped_atomic_fetch_add
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| libclc/clc/lib/generic/atomic/clc_atomic_inc.cl | Fixed atomic increment to use addition operation instead of subtraction |
| libclc/clc/lib/generic/atomic/clc_atomic_dec.cl | Fixed atomic decrement to use subtraction operation instead of addition |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
arsenm
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 think __clc_atomic_inc/dec should be deleted, or renamed. inc is a different op (i.e., atomicrmw uinc_wrap)
can we add new __scoped_atomic_uinc_wrap/udec_wrap clang builtin and use it for __clc_atomic_inc/dec implementation? |
Yes, should do that |
changed to use __scoped_atomic_uinc_wrap for __clc_atomic_inc and __scoped_atomic_udec_wrap for __clc_atomic_dec |
arsenm
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 take it this function was just completely broken before? Is there no testing for it anywhere?
Yes. |
No description provided.