-
Notifications
You must be signed in to change notification settings - Fork 915
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve performance for cudf::strings::count_characters for long stri…
…ngs (#12779) Adds more efficient counting algorithm specifically for columns with long strings--greater than 64 bytes on average. The internal detail method will be used to help improve performance in other strings functions. Authors: - David Wendt (https://github.com/davidwendt) - Bradley Dice (https://github.com/bdice) Approvers: - Nghia Truong (https://github.com/ttnghia) - Bradley Dice (https://github.com/bdice) URL: #12779
- Loading branch information
1 parent
ac1cac6
commit 2025783
Showing
4 changed files
with
160 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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 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,56 @@ | ||
/* | ||
* Copyright (c) 2023, 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/strings/attributes.hpp> | ||
#include <cudf/strings/strings_column_view.hpp> | ||
#include <cudf/utilities/default_stream.hpp> | ||
|
||
#include <nvbench/nvbench.cuh> | ||
|
||
static void bench_lengths(nvbench::state& state) | ||
{ | ||
auto const num_rows = static_cast<cudf::size_type>(state.get_int64("num_rows")); | ||
auto const row_width = static_cast<cudf::size_type>(state.get_int64("row_width")); | ||
|
||
if (static_cast<std::size_t>(num_rows) * static_cast<std::size_t>(row_width) >= | ||
static_cast<std::size_t>(std::numeric_limits<cudf::size_type>::max())) { | ||
state.skip("Skip benchmarks greater than size_type limit"); | ||
} | ||
|
||
data_profile const table_profile = data_profile_builder().distribution( | ||
cudf::type_id::STRING, distribution_id::NORMAL, 0, row_width); | ||
auto const table = | ||
create_random_table({cudf::type_id::STRING}, row_count{num_rows}, table_profile); | ||
cudf::strings_column_view input(table->view().column(0)); | ||
|
||
state.set_cuda_stream(nvbench::make_cuda_stream_view(cudf::get_default_stream().value())); | ||
// gather some throughput statistics as well | ||
auto chars_size = input.chars_size(); | ||
state.add_global_memory_reads<nvbench::int8_t>(chars_size); // all bytes are read; | ||
state.add_global_memory_writes<nvbench::int32_t>(num_rows); // output is an integer per row | ||
|
||
state.exec(nvbench::exec_tag::sync, [&](nvbench::launch& launch) { | ||
auto result = cudf::strings::count_characters(input); | ||
}); | ||
} | ||
|
||
NVBENCH_BENCH(bench_lengths) | ||
.set_name("strings_lengths") | ||
.add_int64_axis("num_rows", {4096, 32768, 262144, 2097152, 16777216}) | ||
.add_int64_axis("row_width", {32, 64, 128, 256, 512, 1024, 2048, 4096}); |
This file contains 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 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