-
Notifications
You must be signed in to change notification settings - Fork 163
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
Roll out address stability optimization #2403
Comments
Here is a list of what I think we can proclaim to allow copying arguments before calling. A ✔ indicates that the optimization was implemented and merged. Proclaiming certain categories of types as allowing copies of their arguments:
In #2389 we made a late design choice to simplify the trait to This really leaves us in a pitiful situation where we can barely allow copying for any function object that we don't know all types involved (i.e. they are thrust functors + fundamental types or thrust types). In addition, hardcoding a set of blessed thrust types (e.g. as template argument to I therefore suggest we should consider giving up stable address guarantees in some situations. E.g.:
We could also consider documenting that users are not allowed to rely on the address of arguments to their functors. We cannot give them a warning when they do though. Further down the road, e.g. at a major library release, we could consider enabling the optimization for all types in the end, which would cause undefined behavior in user programs (a bad breaking change). However, I have observed that in such cases the program crashes due to pointer arithmetic being performed between different state spaces. I don't know whether this is deterministic, but it could be a cost we may deem worth it at some point. |
I discussed this with @gevtushenko today and we concluded to focus on the low-hanging fruits for now. |
Once #2389 is merged,thrust::transform
queries a trait in libcu++ whether it is safe to make copies of the arguments to the transformation function before passing them. This allows various optimizations incub::DeviceTransform
.For now, the user has to explicitly opt into this optimization by annotating their function objects or specializing the trait. We should introduce some automatic detection of whether copying of arguments is possible.
This detection can/must consider:
thrust::plus
orcuda::std::plus
) for which we (or the C++ standard) defines the behaviorTasks
thrust::transform
for generic known function objects #2799The text was updated successfully, but these errors were encountered: