-
Notifications
You must be signed in to change notification settings - Fork 878
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
Fix hostdevice_vector::subspan
#13187
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.
Looks like a proper fix. Part of me wishes subspan
was a free function rather than a method, so that hostdevice_vector
would be closer in API to std::vector
. If it were a method, I think it could be written for any container with hostdevice
semantics (hostdevice_vector
or hostdevice_span
).
edit: I see there's a method std::span<T>::subspan
, and this is based on that but applied to hostdevice_vector
. This is taking the wrong lesson about container design from the STL, in my view, where a method could have been avoided in favor of a free function accepting any span-like object and returning a subspan (a non-owning view of partial extent).
/merge |
This fixes a bug in
hostdevice_vector::subspan
that incorrectly constructs ahostdevice_span
with the input parameters.In particular, instead of passing the
count
parameter tohostdevice_span
constructor, it (incorrectly) subtractsoffset
fromcount
.