-
Notifications
You must be signed in to change notification settings - Fork 902
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 strings::concatenate (#7560)
Reference #5698 This creates a gbenchmark for `cudf::strings::concatenate` function. The benchmarks measures various sized rows as well as strings lengths. This PR also includes some changes to `combine.cu` for cleaning up the code and replacing `device_vector` usages with `device_uvector`. Authors: - David (@davidwendt) Approvers: - Nghia Truong (@ttnghia) - @nvdbaranec - Keith Kraus (@kkraus14) URL: #7560
- Loading branch information
1 parent
4723051
commit f5a4214
Showing
4 changed files
with
115 additions
and
40 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,72 @@ | ||
/* | ||
* 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 "string_bench_args.hpp" | ||
|
||
#include <benchmark/benchmark.h> | ||
#include <benchmarks/common/generate_benchmark_input.hpp> | ||
#include <benchmarks/fixture/benchmark_fixture.hpp> | ||
#include <benchmarks/synchronization/synchronization.hpp> | ||
|
||
#include <cudf/scalar/scalar.hpp> | ||
#include <cudf/strings/combine.hpp> | ||
#include <cudf/strings/strings_column_view.hpp> | ||
#include <cudf_test/column_wrapper.hpp> | ||
|
||
class StringCombine : public cudf::benchmark { | ||
}; | ||
|
||
static void BM_combine(benchmark::State& state) | ||
{ | ||
cudf::size_type const n_rows{static_cast<cudf::size_type>(state.range(0))}; | ||
cudf::size_type const max_str_length{static_cast<cudf::size_type>(state.range(1))}; | ||
data_profile table_profile; | ||
table_profile.set_distribution_params( | ||
cudf::type_id::STRING, distribution_id::NORMAL, 0, max_str_length); | ||
auto const table = | ||
create_random_table({cudf::type_id::STRING}, 2, row_count{n_rows}, table_profile); | ||
cudf::strings_column_view input1(table->view().column(0)); | ||
cudf::strings_column_view input2(table->view().column(1)); | ||
cudf::string_scalar separator("+"); | ||
|
||
for (auto _ : state) { | ||
cuda_event_timer raii(state, true, 0); | ||
cudf::strings::concatenate(table->view(), separator); | ||
} | ||
|
||
state.SetBytesProcessed(state.iterations() * (input1.chars_size() + input2.chars_size())); | ||
} | ||
|
||
static void generate_bench_args(benchmark::internal::Benchmark* b) | ||
{ | ||
int const min_rows = 1 << 12; | ||
int const max_rows = 1 << 24; | ||
int const row_mult = 8; | ||
int const min_rowlen = 1 << 4; | ||
int const max_rowlen = 1 << 11; | ||
int const len_mult = 4; | ||
generate_string_bench_args(b, min_rows, max_rows, row_mult, min_rowlen, max_rowlen, len_mult); | ||
} | ||
|
||
#define STRINGS_BENCHMARK_DEFINE(name) \ | ||
BENCHMARK_DEFINE_F(StringCombine, name) \ | ||
(::benchmark::State & st) { BM_combine(st); } \ | ||
BENCHMARK_REGISTER_F(StringCombine, name) \ | ||
->Apply(generate_bench_args) \ | ||
->UseManualTime() \ | ||
->Unit(benchmark::kMillisecond); | ||
|
||
STRINGS_BENCHMARK_DEFINE(concat) |
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