-
Notifications
You must be signed in to change notification settings - Fork 215
[BUG]: device_reference assignement operator should be const #4621
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
Labels
bug
Something isn't working right.
Comments
bernhardmgruber
added a commit
to bernhardmgruber/cccl
that referenced
this issue
May 19, 2025
This is in line with device_reference being a proxy reference, where assigning to a proxy reference does not change the reference itself, but the referred object (the const is shallow). This also makes device_ptr satisfy std::indirectly_writable Fixes: NVIDIA#4621
Thanks a lot for the detailed bug description! This made it easy to provide a fix, see #4740. |
bernhardmgruber
added a commit
to bernhardmgruber/cccl
that referenced
this issue
May 19, 2025
This is in line with device_reference being a proxy reference, where assigning to a proxy reference does not change the reference itself, but the referred object (the const is shallow). This also makes device_ptr satisfy std::indirectly_writable Fixes: NVIDIA#4621
bernhardmgruber
added a commit
that referenced
this issue
May 20, 2025
This is in line with device_reference being a proxy reference, where assigning to a proxy reference does not change the reference itself, but the referred object (the const is shallow). This also makes device_ptr satisfy std::indirectly_writable Fixes: #4621 Co-authored-by: Michael Schellenberger Costa <miscco@nvidia.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is this a duplicate?
Type of Bug
Compile-time Error
Component
Thrust
Describe the bug
The
device_reference<T>
type acts as a transparent proxy for an object that resides in device memory.It has an assignment operator declared as follows:
I believe the signature of this operator should be relaxed as marked as const. A constant memory location can still be represented as a
device_reference<const T>
.The motivation for this comes from the indirectly_writable concept. This concept requires that the iterator's "reference" type be assignable to, even when const-qualified. See the cppreference page for more details and rationale on this requirement.
This in turn prevents
std::output_iterator
from being satisfied, which is needed by many STL ranges algorithms.How to Reproduce
https://godbolt.org/z/bMd9Yaa5h
Expected behavior
std::indirectly_writable<thrust::device_ptr<uint8_t>, uint8_t>
should be satisfied.Reproduction link
https://godbolt.org/z/bMd9Yaa5h
Operating System
No response
nvidia-smi output
No response
NVCC version
Same results with 12.5.1 on Godbolt.
The text was updated successfully, but these errors were encountered: