Skip to content

Commit 3e418dd

Browse files
authoredDec 2, 2024··
Move make_strings_column benchmark to nvbench (#17340)
Moves the `cpp/benchmarks/string/factory.cu` implementation from google-bench to nvbench. Also renames to `.cpp` by recoding without device code. Authors: - David Wendt (https://github.com/davidwendt) Approvers: - Bradley Dice (https://github.com/bdice) - Vyas Ramasubramani (https://github.com/vyasr) URL: #17340
1 parent 4b2dc33 commit 3e418dd

File tree

3 files changed

+61
-94
lines changed

3 files changed

+61
-94
lines changed
 

‎cpp/benchmarks/CMakeLists.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,6 @@ ConfigureNVBench(
360360

361361
# ##################################################################################################
362362
# * strings benchmark -------------------------------------------------------------------
363-
ConfigureBench(STRINGS_BENCH string/factory.cu)
364-
365363
ConfigureNVBench(
366364
STRINGS_NVBENCH
367365
string/case.cpp
@@ -377,6 +375,7 @@ ConfigureNVBench(
377375
string/copy_range.cpp
378376
string/count.cpp
379377
string/extract.cpp
378+
string/factory.cpp
380379
string/filter.cpp
381380
string/find.cpp
382381
string/find_multiple.cpp

‎cpp/benchmarks/string/factory.cpp

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Copyright (c) 2021-2024, NVIDIA CORPORATION.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#include <benchmarks/common/generate_input.hpp>
18+
19+
#include <cudf/column/column_factories.hpp>
20+
#include <cudf/strings/detail/utilities.hpp>
21+
#include <cudf/strings/string_view.cuh>
22+
#include <cudf/strings/strings_column_view.hpp>
23+
#include <cudf/utilities/default_stream.hpp>
24+
25+
#include <rmm/device_uvector.hpp>
26+
27+
#include <nvbench/nvbench.cuh>
28+
29+
#include <limits>
30+
31+
static void bench_factory(nvbench::state& state)
32+
{
33+
auto const num_rows = static_cast<cudf::size_type>(state.get_int64("num_rows"));
34+
auto const min_width = static_cast<cudf::size_type>(state.get_int64("min_width"));
35+
auto const max_width = static_cast<cudf::size_type>(state.get_int64("max_width"));
36+
37+
data_profile const profile = data_profile_builder().distribution(
38+
cudf::type_id::STRING, distribution_id::NORMAL, min_width, max_width);
39+
auto const column = create_random_column(cudf::type_id::STRING, row_count{num_rows}, profile);
40+
auto const sv = cudf::strings_column_view(column->view());
41+
42+
auto stream = cudf::get_default_stream();
43+
auto mr = cudf::get_current_device_resource_ref();
44+
auto d_strings = cudf::strings::detail::create_string_vector_from_column(sv, stream, mr);
45+
46+
state.set_cuda_stream(nvbench::make_cuda_stream_view(stream.value()));
47+
auto chars_size = sv.chars_size(stream);
48+
state.add_global_memory_reads<nvbench::int8_t>(chars_size);
49+
state.add_global_memory_writes<nvbench::int8_t>(chars_size);
50+
51+
state.exec(nvbench::exec_tag::sync, [&](nvbench::launch& launch) {
52+
cudf::make_strings_column(d_strings, cudf::string_view{nullptr, 0});
53+
});
54+
}
55+
56+
NVBENCH_BENCH(bench_factory)
57+
.set_name("factory")
58+
.add_int64_axis("min_width", {0})
59+
.add_int64_axis("max_width", {32, 64, 128, 256})
60+
.add_int64_axis("num_rows", {32768, 262144, 2097152});

‎cpp/benchmarks/string/factory.cu

-92
This file was deleted.

0 commit comments

Comments
 (0)