-
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.
Add gbenchmark for cudf::strings::to_lower (#7316)
Reference #5698 This creates a gbenchmark for the `cudf::strings::to_lower`. The device logic is the same for `cudf::strings::to_upper` and `cudf::strings::swapcase` so this a good measure for the 3 APIs. This PR is dependent on changes in PR #7292 These are mostly in the `generate_benchmark_input.cpp` The initial results were as follows: ``` -------------------------------------------------------------------------------------------------- Benchmark Time CPU Iterations UserCounters... -------------------------------------------------------------------------------------------------- StringCase/strings/4096/manual_time 0.278 ms 0.296 ms 2514 bytes_per_second=248.756M/s StringCase/strings/32768/manual_time 0.289 ms 0.307 ms 2421 bytes_per_second=1.86625G/s StringCase/strings/262144/manual_time 0.419 ms 0.438 ms 1662 bytes_per_second=10.2869G/s StringCase/strings/2097152/manual_time 2.59 ms 2.61 ms 269 bytes_per_second=13.3449G/s StringCase/strings/16777216/manual_time 25.9 ms 25.9 ms 27 bytes_per_second=10.6531G/s ``` The `convert_case` code here is a bit old. I changed it to use the more efficient `make_strings_children` utility and found the performance improved by 2x ``` -------------------------------------------------------------------------------------------------- Benchmark Time CPU Iterations UserCounters... -------------------------------------------------------------------------------------------------- StringCase/strings/4096/manual_time 0.117 ms 0.135 ms 5877 bytes_per_second=592.795M/s StringCase/strings/32768/manual_time 0.122 ms 0.140 ms 5641 bytes_per_second=4.42664G/s StringCase/strings/262144/manual_time 0.274 ms 0.292 ms 2535 bytes_per_second=15.768G/s StringCase/strings/2097152/manual_time 1.59 ms 1.61 ms 441 bytes_per_second=21.759G/s StringCase/strings/16777216/manual_time 12.1 ms 12.1 ms 58 bytes_per_second=22.8626G/s ``` So these changes are also included in this PR. Authors: - David (@davidwendt) Approvers: - Conor Hoekstra (@codereport) - Vukasin Milovanovic (@vuule) - Mark Harris (@harrism) URL: #7316
- Loading branch information
1 parent
74a7c76
commit f7b3f75
Showing
5 changed files
with
105 additions
and
88 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,51 @@ | ||
/* | ||
* Copyright (c) 2021, 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 <benchmark/benchmark.h> | ||
#include <benchmarks/common/generate_benchmark_input.hpp> | ||
#include <benchmarks/fixture/benchmark_fixture.hpp> | ||
#include <benchmarks/synchronization/synchronization.hpp> | ||
|
||
#include <cudf/strings/case.hpp> | ||
#include <cudf/strings/strings_column_view.hpp> | ||
|
||
class StringCase : public cudf::benchmark { | ||
}; | ||
|
||
static void BM_case(benchmark::State& state) | ||
{ | ||
cudf::size_type const n_rows{(cudf::size_type)state.range(0)}; | ||
auto const table = create_random_table({cudf::type_id::STRING}, 1, row_count{n_rows}); | ||
cudf::strings_column_view input(table->view().column(0)); | ||
|
||
for (auto _ : state) { | ||
cuda_event_timer raii(state, true, 0); | ||
cudf::strings::to_lower(input); | ||
} | ||
|
||
state.SetBytesProcessed(state.iterations() * input.chars_size()); | ||
} | ||
|
||
#define SORT_BENCHMARK_DEFINE(name) \ | ||
BENCHMARK_DEFINE_F(StringCase, name) \ | ||
(::benchmark::State & st) { BM_case(st); } \ | ||
BENCHMARK_REGISTER_F(StringCase, name) \ | ||
->RangeMultiplier(8) \ | ||
->Ranges({{1 << 12, 1 << 24}}) \ | ||
->UseManualTime() \ | ||
->Unit(benchmark::kMillisecond); | ||
|
||
SORT_BENCHMARK_DEFINE(to_lower) |
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
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