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

Fix issue in slice() where columns with a positive offset were computing null counts incorrectly. #8738

Merged
merged 4 commits into from
Jul 19, 2021

Conversation

nvdbaranec
Copy link
Contributor

@nvdbaranec nvdbaranec commented Jul 13, 2021

slice() was passing the raw split indices to segmented_count_unset_bits(), resulting in the wrong ranges of validity bits being counted.

…ing a null count based on the wrong range of validity bits.
@nvdbaranec nvdbaranec added bug Something isn't working libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change labels Jul 13, 2021
@nvdbaranec nvdbaranec requested a review from a team as a code owner July 13, 2021 22:24
Comment on lines 45 to 48
std::transform(indices.begin(),
indices.end(),
std::back_inserter(shifted_indices),
[offset = input.offset()](size_type index) { return index + offset; });
Copy link
Contributor

Choose a reason for hiding this comment

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

slice() is supposed to be a relatively free operation (ignoring the bit counting), so materializing the shifted indices is a bummer.

I think it would be fairly easy to make segmented_count_unset_bits take an iterator for the segment offsets so you could instead pass a transform iterator in that adds the offset.

Copy link
Contributor

Choose a reason for hiding this comment

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

How about just invalidating the null count so the slice function will never do such counting? We don't know if the null count will be used later or not. If it is used later, it will be recomputed.

Copy link
Contributor

Choose a reason for hiding this comment

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

We used to do it that way, but we found that it was a better idea to compute all the null counts at once. Otherwise if you have many slices where you need the null count, you end up launching many kernels. This came up in the context of contiguous_split.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: slice.cpp will have to become slice.cu to do this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Couple things of note: A number of functions/kernels got moved from null_mask.cu to null_mask.cuh. Both segmented_count_unset_bits and segmented_count_set_bits have been refactored to take iterators, since unset is implemented through set. I had to change a device lambda in segmented_count_unset_bits into a functor (word_num_set_bits_functor) due to extended device lambda restrictions causing the compiler to complain about the iterators now being passed in.

@codecov
Copy link

codecov bot commented Jul 14, 2021

Codecov Report

❗ No coverage uploaded for pull request base (branch-21.08@8aaf8e6). Click here to learn what that means.
The diff coverage is n/a.

❗ Current head e532269 differs from pull request most recent head a109b03. Consider uploading reports for the commit a109b03 to get more accurate results
Impacted file tree graph

@@               Coverage Diff               @@
##             branch-21.08    #8738   +/-   ##
===============================================
  Coverage                ?   10.67%           
===============================================
  Files                   ?      109           
  Lines                   ?    18670           
  Branches                ?        0           
===============================================
  Hits                    ?     1993           
  Misses                  ?    16677           
  Partials                ?        0           

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 8aaf8e6...a109b03. Read the comment docs.

…egmented_count_set_bits() to take iterators for range indices.
@github-actions github-actions bot added the CMake CMake build issue label Jul 14, 2021
@nvdbaranec nvdbaranec requested a review from jrhemstad July 14, 2021 16:10
@nvdbaranec nvdbaranec requested a review from a team as a code owner July 14, 2021 16:32
Copy link
Contributor

@robertmaynard robertmaynard left a comment

Choose a reason for hiding this comment

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

CMake changes LGTM

@@ -141,6 +142,285 @@ void inplace_bitmask_binop(
stream.synchronize();
}

namespace {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@jrhemstad @nvdbaranec JFYI this PR looks like it got merged without addressing this. It's not a big deal but may be worth fixing in a follow-up to avoid the possibility of unexpected UB somewhere down the line.

@nvdbaranec
Copy link
Contributor Author

@gpucibot merge

@rapids-bot rapids-bot bot merged commit b011299 into rapidsai:branch-21.08 Jul 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working CMake CMake build issue libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants