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

Use optional-iterator for copy-if-else kernel #9324

Merged
merged 21 commits into from
Oct 13, 2021

Conversation

davidwendt
Copy link
Contributor

@davidwendt davidwendt commented Sep 28, 2021

This PR changes the cudf::detail::copy_if_else utility functions to accept an optional-iterator instead of a pair-iterator. This improves the compile time of source files by generating 4x less kernels since the two input data arrays can each have nulls requiring 4 different pair-iterators to be created to call it. The optional-iterator allows the nulls check to occur at runtime instead of compile time.

The changes in this PR are for the callers of detail::copy_if_else to provide optional-iterators instead of pair-iterators. This PR is dependent on the changes in #9306

The benchmarks for the effected calling functions showed no significant change in runtime performance using the single optional-iterator over 4 unique pair-iterators. Two additional benchmarks are included cover non-null measurement which this PR impacts the most.

Also, the copy_tests.cu was renamed copy_tests.cpp and the test that launched to the internal cudf::detail::copy_if_else_kernel was replaced with one with a data-set large enough to require multiple blocks.

Related changes for the strings specific cudf::strings::detail::copy_if_else are in #9266

@davidwendt davidwendt added 2 - In Progress Currently a work in progress libcudf Affects libcudf (C++/CUDA) code. improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Sep 28, 2021
@davidwendt davidwendt self-assigned this Sep 28, 2021
@github-actions github-actions bot added the CMake CMake build issue label Sep 28, 2021
@davidwendt
Copy link
Contributor Author

Compile time improvements.

source file rank new rank time (s) new time (s)
copying/copy.cu 1 39 591 222
copying/segmented_shift.cu 61 107 147 84
replace/nans.cu 186 211 52 48

@jrhemstad
Copy link
Contributor

detail_copy_tests.cu to isolate the single test case which launches the cudf::detail::copy_if_else_kernel directly requiring nvcc to compile it.

This sounds fishy. We should strive for black box testing of public APIs and not be reaching into testing kernels directly.

@davidwendt
Copy link
Contributor Author

detail_copy_tests.cu to isolate the single test case which launches the cudf::detail::copy_if_else_kernel directly requiring nvcc to compile it.

This sounds fishy. We should strive for black box testing of public APIs and not be reaching into testing kernels directly.

I agree. I was not confident enough to just remove it. It appeared to be a valiant attempt to force a test that required executing with multiple blocks but without needing to create a large dataset. I'm certainly ok with removing it. Otherwise, I would welcome advice on how to replace it. Perhaps this merits a separate PR.

@codecov
Copy link

codecov bot commented Sep 29, 2021

Codecov Report

Merging #9324 (303b4b6) into branch-21.12 (ab4bfaa) will decrease coverage by 0.03%.
The diff coverage is 0.00%.

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

@@               Coverage Diff                @@
##           branch-21.12    #9324      +/-   ##
================================================
- Coverage         10.79%   10.75%   -0.04%     
================================================
  Files               116      116              
  Lines             18869    19483     +614     
================================================
+ Hits               2036     2096      +60     
- Misses            16833    17387     +554     
Impacted Files Coverage Δ
python/cudf/cudf/__init__.py 0.00% <0.00%> (ø)
python/cudf/cudf/_lib/__init__.py 0.00% <ø> (ø)
python/cudf/cudf/core/_base_index.py 0.00% <0.00%> (ø)
python/cudf/cudf/core/column/categorical.py 0.00% <0.00%> (ø)
python/cudf/cudf/core/column/column.py 0.00% <0.00%> (ø)
python/cudf/cudf/core/column/datetime.py 0.00% <0.00%> (ø)
python/cudf/cudf/core/column/lists.py 0.00% <0.00%> (ø)
python/cudf/cudf/core/column/numerical.py 0.00% <0.00%> (ø)
python/cudf/cudf/core/column/string.py 0.00% <0.00%> (ø)
python/cudf/cudf/core/column/struct.py 0.00% <0.00%> (ø)
... and 68 more

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 56eb91a...5fd512d. Read the comment docs.

@davidwendt
Copy link
Contributor Author

Removed the detail_copy_tests.cu and added a new gtest to the copy_tests.cpp with a data-set large enough to require multiple blocks.

@davidwendt davidwendt added 3 - Ready for Review Ready for review by team and removed 2 - In Progress Currently a work in progress labels Oct 6, 2021
@davidwendt davidwendt marked this pull request as ready for review October 6, 2021 18:40
@davidwendt davidwendt requested a review from a team as a code owner October 6, 2021 18:40
Copy link
Contributor

@bdice bdice left a comment

Choose a reason for hiding this comment

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

This looks great. Vastly cleaner!

cpp/benchmarks/copying/copy_if_else_benchmark.cpp Outdated Show resolved Hide resolved
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.

Also, the copy_tests.cu was renamed copy_tests.cpp

Nice!

@davidwendt
Copy link
Contributor Author

@gpucibot merge

@rapids-bot rapids-bot bot merged commit f9806ff into rapidsai:branch-21.12 Oct 13, 2021
@davidwendt davidwendt deleted the copy-cu-compile-time branch October 13, 2021 12:46
rapids-bot bot pushed a commit that referenced this pull request Oct 19, 2021
CUDA memcheck write error was introduced in #9324 (by me). The `has_nulls` handling had been reworked but a logic error allowed writing past the end of the output column. 

This PR also includes fixes to remove compile warnings in `group_correlation.cu` that only start to appear in nvcc 11.4.

Authors:
  - David Wendt (https://github.com/davidwendt)

Approvers:
  - https://github.com/nvdbaranec
  - Nghia Truong (https://github.com/ttnghia)

URL: #9467
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 - Ready for Review Ready for review by team CMake CMake build issue improvement Improvement / enhancement to an existing function libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants