-
Notifications
You must be signed in to change notification settings - Fork 190
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
[FEA]: Expose thrust::detail::contiguous_iterator_raw_pointer_cast
#1711
Comments
CC @ahendriksen |
I am not too happy about exposing this. It is a highly dangerous facility that should be used internally. Is there any reason you cannot use / improve an existing thrust algorithm? |
I think it's less dangerous than me calling
@ahendriksen and I would like to upstream some improvements at some point, but for now work externally. Independently, other uses may also want to use that functionality to define their own algorithms. |
Lifts the following functions into the public API and renames them: * contiguous_iterator_raw_pointer_t -> unwrap_contiguous_iterator_t * contiguous_iterator_raw_pointer_cast -> unwrap_contiguous_iterator * try_unwrap_contiguous_iterator_return_t -> try_unwrap_contiguous_iterator_t * try_unwrap_contiguous_iterator Fixes: NVIDIA#1711
@alliepiper mentioned during our VC yesterday that she is fine with exposing the functionality since it's there for a while and seems to have stabilized. |
Lifts the following functions into the public API and renames them: * contiguous_iterator_raw_pointer_t -> unwrap_contiguous_iterator_t * contiguous_iterator_raw_pointer_cast -> unwrap_contiguous_iterator * try_unwrap_contiguous_iterator_return_t -> try_unwrap_contiguous_iterator_t * try_unwrap_contiguous_iterator Fixes: NVIDIA#1711 Co-authored-by: Michael Schellenberger Costa <[email protected]>
Lifts the following functions into the public API and renames them: * contiguous_iterator_raw_pointer_t -> unwrap_contiguous_iterator_t * contiguous_iterator_raw_pointer_cast -> unwrap_contiguous_iterator * try_unwrap_contiguous_iterator_return_t -> try_unwrap_contiguous_iterator_t * try_unwrap_contiguous_iterator Fixes: #1711 Co-authored-by: Michael Schellenberger Costa <[email protected]>
Some more context: Thrust provides a trait to identify contiguous iterators. It is defined for all contiguous thrust iterators and some common STL vector implementations, etc, and users are allowed to opt-in through some The utilities exposed by this PR are safest solutions I can think of to solve the problem of converting generic iterators to raw pointers. If an input pointer type is not explicitly marked as contiguous, it is safely and by default returned unmodified. Only known contiguous iterators are decayed to a raw pointer. |
Is this a duplicate?
Area
Thrust
Is your feature request related to a problem? Please describe.
I have found
thrust::detail::contiguous_iterator_raw_pointer_cast
quite useful to unwrap iterators to their underlying pointers. I use this to unwrap a zip iterator and check whether I can use a kernel operating on contiguous memory or not:The function
contiguous_iterator_raw_pointer_cast
seems to do exactly what I need, but it is declared in adetail
namespace.Describe the solution you'd like
Move
contiguous_iterator_raw_pointer_cast
out of thedetail
namespace and make it part of thrust's public API.Describe alternatives you've considered
I can always circumvent this by using
thrust::raw_pointer_cast(&*it)
instead, but it would be nice if I could use the already implemented function.Additional context
No response
The text was updated successfully, but these errors were encountered: