Skip to content

Commit

Permalink
Move make_strings_column benchmark to nvbench (#17340)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
davidwendt authored Dec 2, 2024
1 parent 4b2dc33 commit 3e418dd
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 94 deletions.
3 changes: 1 addition & 2 deletions cpp/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,6 @@ ConfigureNVBench(

# ##################################################################################################
# * strings benchmark -------------------------------------------------------------------
ConfigureBench(STRINGS_BENCH string/factory.cu)

ConfigureNVBench(
STRINGS_NVBENCH
string/case.cpp
Expand All @@ -377,6 +375,7 @@ ConfigureNVBench(
string/copy_range.cpp
string/count.cpp
string/extract.cpp
string/factory.cpp
string/filter.cpp
string/find.cpp
string/find_multiple.cpp
Expand Down
60 changes: 60 additions & 0 deletions cpp/benchmarks/string/factory.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright (c) 2021-2024, 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 <cudf/column/column_factories.hpp>
#include <cudf/strings/detail/utilities.hpp>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/utilities/default_stream.hpp>

#include <rmm/device_uvector.hpp>

#include <nvbench/nvbench.cuh>

#include <limits>

static void bench_factory(nvbench::state& state)
{
auto const num_rows = static_cast<cudf::size_type>(state.get_int64("num_rows"));
auto const min_width = static_cast<cudf::size_type>(state.get_int64("min_width"));
auto const max_width = static_cast<cudf::size_type>(state.get_int64("max_width"));

data_profile const profile = data_profile_builder().distribution(
cudf::type_id::STRING, distribution_id::NORMAL, min_width, max_width);
auto const column = create_random_column(cudf::type_id::STRING, row_count{num_rows}, profile);
auto const sv = cudf::strings_column_view(column->view());

auto stream = cudf::get_default_stream();
auto mr = cudf::get_current_device_resource_ref();
auto d_strings = cudf::strings::detail::create_string_vector_from_column(sv, stream, mr);

state.set_cuda_stream(nvbench::make_cuda_stream_view(stream.value()));
auto chars_size = sv.chars_size(stream);
state.add_global_memory_reads<nvbench::int8_t>(chars_size);
state.add_global_memory_writes<nvbench::int8_t>(chars_size);

state.exec(nvbench::exec_tag::sync, [&](nvbench::launch& launch) {
cudf::make_strings_column(d_strings, cudf::string_view{nullptr, 0});
});
}

NVBENCH_BENCH(bench_factory)
.set_name("factory")
.add_int64_axis("min_width", {0})
.add_int64_axis("max_width", {32, 64, 128, 256})
.add_int64_axis("num_rows", {32768, 262144, 2097152});
92 changes: 0 additions & 92 deletions cpp/benchmarks/string/factory.cu

This file was deleted.

0 comments on commit 3e418dd

Please sign in to comment.