Skip to content
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

[REVIEW] Port scatter to libcudf++ #3354

Merged
merged 50 commits into from
Nov 25, 2019

Conversation

trevorsm7
Copy link
Contributor

@trevorsm7 trevorsm7 commented Nov 12, 2019

Part of #2934, taken over from #3296

Merge after:

@trevorsm7 trevorsm7 added 2 - In Progress Currently a work in progress libcudf++ labels Nov 12, 2019
@trevorsm7 trevorsm7 self-assigned this Nov 12, 2019
@codecov
Copy link

codecov bot commented Nov 12, 2019

Codecov Report

Merging #3354 into branch-0.11 will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##           branch-0.11    #3354   +/-   ##
============================================
  Coverage        87.36%   87.36%           
============================================
  Files               49       49           
  Lines             9295     9295           
============================================
  Hits              8121     8121           
  Misses            1174     1174

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ee739fb...33b3cc4. Read the comment docs.

@harrism
Copy link
Member

harrism commented Nov 22, 2019

@cwharris How would you implement repeat using scatter?

@cwharris
Copy link
Contributor

@harrism I keep forgetting C++ iterators are simpler than enumerators from other languages. It would be possible if we used something more complex than a size_type, I think, but scatter would have to support it.

@cwharris
Copy link
Contributor

For instance, if we have a composite type contains the values we’re already iterating over and a counter, we could then make the end iterator hold the last composite value. scatter wouldn’t use the counter portion, thats just for iterator comparison.

@cwharris
Copy link
Contributor

I am probably wrong about this again. I need to search through the scatter code to see if what I’m talking about makes sense.

@cwharris
Copy link
Contributor

cwharris commented Nov 22, 2019

I was confusing scatter and gather. I'm sorry. A simple iterator is still useful for when you need to scatter values using a stride, though.

@harrism
Copy link
Member

harrism commented Nov 22, 2019

I agree iterators are useful for scatter/gather maps. Just didn't think scatter would be useful for repeat since each input element can only have a single destination in the scatter map. Gather would work.

Copy link
Member

@harrism harrism left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really good. Couple small comments.

cpp/src/copying/scatter.cu Outdated Show resolved Hide resolved
cpp/src/copying/scatter.cu Show resolved Hide resolved
Copy link
Member

@harrism harrism left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the changelog to match the rest of the libcudf++ PRs (they don't mention "libcudf++" since readers won't know what that is). But otherwise I approve!

CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@trevorsm7 trevorsm7 added 5 - Ready to Merge Testing and reviews complete, ready to merge and removed 3 - Ready for Review Ready for review by team labels Nov 25, 2019
@harrism harrism merged commit 5cde46d into rapidsai:branch-0.11 Nov 25, 2019
Copy link
Contributor

@jrhemstad jrhemstad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's ample opportunity to reduce redundancy between the scalar/column scatter code paths by updating the detail::scatter implementation to accept iterators for the inputs. Probably something where you expect the input to be a tuple<T,bool> like from make_pair_iterator.

auto const begin = -target.num_rows();
auto const end = target.num_rows();
auto bounds = bounds_checker<T>{begin, end};
CUDF_EXPECTS(thrust::all_of(rmm::exec_policy(stream)->on(stream),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use thrust::all_of, it's slow: https://github.com/thrust/thrust/issues/1016

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shoot, that explains why the old code I ported from was using count_if...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll replace all_of with count_if in #3448

template <typename MapIterator>
void scatter_scalar_bitmask(std::vector<std::unique_ptr<scalar>> const& source,
MapIterator scatter_map, size_type num_scatter_rows,
std::vector<std::unique_ptr<column>>& target,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it should be a table or mutable_table_view.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I needed to be able to set the null count, which can't be done with a view. It could be a table. I thought it was easier to just work with the vector of columns and only move the vector into a new table as the last step. Being able to iterate over columns in the table (not just get_column(i)) would make the table a little easier to work with

size_type const output_row = scatter_map[row];

if (mark_true){
destination.set_valid(output_row);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes, this is going to be slow. I thought the gather_bitmask_kernel was being used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's being used for the regular scatter, but it needed significant changes to make it work with the scalar variant (no source bitmask, just a single valid flag). I just ported the existing scatter scalar as-is, even though it did look like it could be improved. The changes @cwharris is making for gather_bitmask_kernel to take a selector for the source validity could fix this

@harrism
Copy link
Member

harrism commented Nov 26, 2019

@jrhemstad please file issues after PRs are merged or the review may get lost.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5 - Ready to Merge Testing and reviews complete, ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants