-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Improve performance for cudf::contains when searching for a scalar
#11202
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
Merged
Merged
Changes from 17 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
0d4747e
Fix warnings
ttnghia 9c5709c
Extract `create_table_data` function
ttnghia a09154a
Run benchmark using random data
ttnghia fb32f2d
Use macro in benchmark
ttnghia 4b43d6d
Add more benchmark
ttnghia 1debe3b
Change benchmark range
ttnghia b4b4847
Use `count_if` instead of `find`
ttnghia 7528ea0
Change float to size_type for benchmark
ttnghia 9da73de
Remove `[[maybe_unused]]`
ttnghia b8dc84a
Remove separator
ttnghia 19c73d3
MISC
ttnghia d4d063b
Change `seed` from static into dynamic, and add back `[[maybe_unused]]`
ttnghia 75d5584
Reverse benchmark
ttnghia 61cd767
Avoid memory round trip
ttnghia 0ea3794
Fix typo
ttnghia fc9d7bb
Add benchmark
ttnghia 0223ec7
Add `tparam`
ttnghia 3d5acaf
Fix null frequency
ttnghia 3d82ba4
Remove random seed
ttnghia fdfa9f7
Simplify code
ttnghia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| /* | ||
| * Copyright (c) 2022, NVIDIA CORPORATION. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| #include <benchmarks/common/generate_input.hpp> | ||
| #include <benchmarks/fixture/rmm_pool_raii.hpp> | ||
|
|
||
| #include <cudf/detail/search.hpp> | ||
| #include <cudf/scalar/scalar_factories.hpp> | ||
| #include <cudf/types.hpp> | ||
|
|
||
| #include <nvbench/nvbench.cuh> | ||
|
|
||
| namespace { | ||
| template <typename Type> | ||
| std::unique_ptr<cudf::table> create_table_data(cudf::size_type n_rows, | ||
| cudf::size_type n_cols, | ||
| bool has_nulls = false) | ||
| { | ||
| data_profile profile; | ||
| profile.set_cardinality(0); | ||
| profile.set_null_frequency(has_nulls ? 0.1 : 0.0); | ||
| profile.set_distribution_params<Type>( | ||
| cudf::type_to_id<Type>(), distribution_id::UNIFORM, Type{0}, Type{1000}); | ||
|
|
||
| auto const seed = static_cast<uint32_t>(time(nullptr)); | ||
|
karthikeyann marked this conversation as resolved.
Outdated
|
||
| return create_random_table( | ||
| cycle_dtypes({cudf::type_to_id<Type>()}, n_cols), row_count{n_rows}, profile, seed); | ||
| } | ||
|
|
||
| template <typename Type> | ||
| std::unique_ptr<cudf::column> create_column_data(cudf::size_type n_rows, bool has_nulls = false) | ||
| { | ||
| return std::move(create_table_data<Type>(n_rows, 1, has_nulls)->release().front()); | ||
| } | ||
|
|
||
| } // namespace | ||
|
|
||
| static void nvbench_contains_scalar(nvbench::state& state) | ||
| { | ||
| cudf::rmm_pool_raii pool_raii; | ||
| using Type = int; | ||
|
|
||
| auto const has_nulls = static_cast<bool>(state.get_int64("has_nulls")); | ||
| auto const size = state.get_int64("data_size"); | ||
|
|
||
| auto const haystack = create_column_data<Type>(size, has_nulls); | ||
| auto const needle = cudf::make_fixed_width_scalar<Type>(size / 2); | ||
|
|
||
| state.exec(nvbench::exec_tag::sync, [&](nvbench::launch& launch) { | ||
| auto const stream_view = rmm::cuda_stream_view{launch.get_stream()}; | ||
| [[maybe_unused]] auto const result = cudf::detail::contains(*haystack, *needle, stream_view); | ||
| }); | ||
| } | ||
|
|
||
| NVBENCH_BENCH(nvbench_contains_scalar) | ||
| .set_name("contains_scalar") | ||
| .add_int64_power_of_two_axis("data_size", {10, 12, 14, 16, 18, 20, 22, 24, 26}) | ||
| .add_int64_axis("has_nulls", {0, 1}); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.