-
Notifications
You must be signed in to change notification settings - Fork 906
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
Refactor scatter.cuh
and gather.cuh
#8464
Conversation
I am not a fan of requiring materializing any iterator based gather or scatter map into a |
Me too. However, most (maybe 90% or so) cudf APIs already did it (use |
THis should probably be a draft PR. |
@@ -200,10 +200,13 @@ std::unique_ptr<column> scatter_gather_based_if_else(Left const& lhs, | |||
auto const gather_lhs = make_counting_transform_iterator( | |||
size_type{0}, lhs_gather_map_functor<Filter>{is_left, null_map_entry}); | |||
|
|||
rmm::device_uvector<size_type> gather_map(size, stream); | |||
thrust::copy(rmm::exec_policy(stream), gather_lhs, gather_lhs + size, gather_map.begin()); |
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.
Yuck.
I don't like the idea of forcing materialization. That kills the benefit of an iterator interface.
|
I just tried to convert it to a draft but was told that "subscribed people will be unsubscribed" 😄, so just keep a normal (WIP) PR to let other participants know the activities here. |
Yeap, this is a trade-off. Based on the opinions, it seems that we should not continue this PR, since explicit instantiation for the APIs accepting any free iterator type is impossible. |
This PR refactors
scatter.cuh
andgather.cuh
, totally moving all the implementations of the templated functionsdetail::scatter
anddetail::gather
into separates*.cu
files with explicit instantiations.Typically, this is not a trivial task since the APIs
scatter
andgather
take templated iterator parameters (iterators for scatter/gather maps), and the types of those iterators can be very complex templatedthrust::transform_iterator
. In this PR, in order to explicitly instantiate thescatter
andgather
APIs, I have to limit the iterators types to be only pointers andthrust::constant_iterator
. Forthrust::transform_iterator
, I create a temporarydevice_uvector
and fill it with the transformed iterator values then pass itsbegin()/end()
iterators to thescatter
andgather
APIs. Since most cudf APIs are passing scatter/gather maps from adevice_uvector
iterators, I don't think this would incur much overhead. The files affected by this are here: 37366cf.After doing this (rough) refactoring, I gained about 5% speedup in compile time (on a 18 cores machine, 64 compile threads):
Before:
After:
It seems that 5% is not much worth do this, but if we merge this (after more cleanup) we will have a very nice scatter and gather APIs implementations: the header files
*.cuh
contain only declarations, and the implementations will be freed from including into many many others*cu
file. Thus, I need more opinions from you guys about this before spending more time working on it.PS: This is not a complete work, just a rough draft and still needs much cleanup.