Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix benchmarks coded in namespace cudf and using namespace cudf #12915

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions cpp/benchmarks/binaryop/compiled_binaryop.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2022, NVIDIA CORPORATION.
* Copyright (c) 2021-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.
Expand Down Expand Up @@ -66,8 +66,14 @@ void BM_compiled_binaryop(benchmark::State& state, cudf::binary_operator binop)
#define BINARYOP_BENCHMARK_DEFINE(lhs, rhs, bop, tout) \
BM_BINARYOP_BENCHMARK_DEFINE(build_name(bop, lhs, rhs, tout), lhs, rhs, bop, tout)

using namespace cudf;
using namespace numeric;
using cudf::duration_D;
using cudf::duration_ms;
using cudf::duration_ns;
using cudf::duration_s;
using cudf::timestamp_D;
using cudf::timestamp_ms;
using cudf::timestamp_s;
using numeric::decimal32;

// clang-format off
BINARYOP_BENCHMARK_DEFINE(float, int64_t, ADD, int32_t);
Expand Down
16 changes: 8 additions & 8 deletions cpp/benchmarks/groupby/group_rank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ template <cudf::rank_method method>
static void nvbench_groupby_rank(nvbench::state& state,
nvbench::type_list<nvbench::enum_type<method>>)
{
using namespace cudf;
constexpr auto dtype = type_to_id<int64_t>();
constexpr auto dtype = cudf::type_to_id<int64_t>();

bool const is_sorted = state.get_int64("is_sorted");
cudf::size_type const column_size = state.get_int64("data_size");
Expand All @@ -43,16 +42,17 @@ static void nvbench_groupby_rank(nvbench::state& state,
// values to be pre-sorted too for groupby rank
if (is_sorted) source_table = cudf::sort(*source_table);

table_view keys{{source_table->view().column(0)}};
column_view order_by{source_table->view().column(1)};
cudf::table_view keys{{source_table->view().column(0)}};
cudf::column_view order_by{source_table->view().column(1)};

auto agg = cudf::make_rank_aggregation<groupby_scan_aggregation>(method);
std::vector<groupby::scan_request> requests;
requests.emplace_back(groupby::scan_request());
auto agg = cudf::make_rank_aggregation<cudf::groupby_scan_aggregation>(method);
std::vector<cudf::groupby::scan_request> requests;
requests.emplace_back(cudf::groupby::scan_request());
requests[0].values = order_by;
requests[0].aggregations.push_back(std::move(agg));

groupby::groupby gb_obj(keys, null_policy::EXCLUDE, is_sorted ? sorted::YES : sorted::NO);
cudf::groupby::groupby gb_obj(
keys, cudf::null_policy::EXCLUDE, is_sorted ? cudf::sorted::YES : cudf::sorted::NO);

state.exec(nvbench::exec_tag::sync, [&](nvbench::launch& launch) {
rmm::cuda_stream_view stream_view{launch.get_stream()};
Expand Down
73 changes: 43 additions & 30 deletions cpp/benchmarks/lists/copying/scatter_lists.cu
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2022, NVIDIA CORPORATION.
* Copyright (c) 2021-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.
Expand Down Expand Up @@ -32,8 +32,6 @@

#include <cmath>

namespace cudf {

class ScatterLists : public cudf::benchmark {
};

Expand All @@ -43,72 +41,89 @@ void BM_lists_scatter(::benchmark::State& state)
auto stream = cudf::get_default_stream();
auto mr = rmm::mr::get_current_device_resource();

const size_type base_size{(size_type)state.range(0)};
const size_type num_elements_per_row{(size_type)state.range(1)};
const auto num_rows = (size_type)ceil(double(base_size) / num_elements_per_row);

auto source_base_col = make_fixed_width_column(
data_type{type_to_id<TypeParam>()}, base_size, mask_state::UNALLOCATED, stream, mr);
auto target_base_col = make_fixed_width_column(
data_type{type_to_id<TypeParam>()}, base_size, mask_state::UNALLOCATED, stream, mr);
const cudf::size_type base_size{(cudf::size_type)state.range(0)};
const cudf::size_type num_elements_per_row{(cudf::size_type)state.range(1)};
const auto num_rows = (cudf::size_type)ceil(double(base_size) / num_elements_per_row);
Comment on lines +44 to +46
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if it's in the guide, but I have seen libcudf devs using east-const by default. However, if it's a matter of personal preference then it's fine with me

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommend to change that too.


auto source_base_col = make_fixed_width_column(cudf::data_type{cudf::type_to_id<TypeParam>()},
base_size,
cudf::mask_state::UNALLOCATED,
stream,
mr);
auto target_base_col = make_fixed_width_column(cudf::data_type{cudf::type_to_id<TypeParam>()},
base_size,
cudf::mask_state::UNALLOCATED,
stream,
mr);
thrust::sequence(rmm::exec_policy(stream),
source_base_col->mutable_view().begin<TypeParam>(),
source_base_col->mutable_view().end<TypeParam>());
thrust::sequence(rmm::exec_policy(stream),
target_base_col->mutable_view().begin<TypeParam>(),
target_base_col->mutable_view().end<TypeParam>());

auto source_offsets = make_fixed_width_column(
data_type{type_to_id<offset_type>()}, num_rows + 1, mask_state::UNALLOCATED, stream, mr);
auto target_offsets = make_fixed_width_column(
data_type{type_to_id<offset_type>()}, num_rows + 1, mask_state::UNALLOCATED, stream, mr);
auto source_offsets =
make_fixed_width_column(cudf::data_type{cudf::type_to_id<cudf::offset_type>()},
num_rows + 1,
cudf::mask_state::UNALLOCATED,
stream,
mr);
auto target_offsets =
make_fixed_width_column(cudf::data_type{cudf::type_to_id<cudf::offset_type>()},
num_rows + 1,
cudf::mask_state::UNALLOCATED,
stream,
mr);

thrust::sequence(rmm::exec_policy(stream),
source_offsets->mutable_view().begin<offset_type>(),
source_offsets->mutable_view().end<offset_type>(),
source_offsets->mutable_view().begin<cudf::offset_type>(),
source_offsets->mutable_view().end<cudf::offset_type>(),
0,
num_elements_per_row);
thrust::sequence(rmm::exec_policy(stream),
target_offsets->mutable_view().begin<offset_type>(),
target_offsets->mutable_view().end<offset_type>(),
target_offsets->mutable_view().begin<cudf::offset_type>(),
target_offsets->mutable_view().end<cudf::offset_type>(),
0,
num_elements_per_row);

auto source = make_lists_column(num_rows,
std::move(source_offsets),
std::move(source_base_col),
0,
cudf::create_null_mask(num_rows, mask_state::UNALLOCATED),
cudf::create_null_mask(num_rows, cudf::mask_state::UNALLOCATED),
stream,
mr);
auto target = make_lists_column(num_rows,
std::move(target_offsets),
std::move(target_base_col),
0,
cudf::create_null_mask(num_rows, mask_state::UNALLOCATED),
cudf::create_null_mask(num_rows, cudf::mask_state::UNALLOCATED),
stream,
mr);

auto scatter_map = make_fixed_width_column(
data_type{type_to_id<size_type>()}, num_rows, mask_state::UNALLOCATED, stream, mr);
auto scatter_map = make_fixed_width_column(cudf::data_type{cudf::type_to_id<cudf::size_type>()},
num_rows,
cudf::mask_state::UNALLOCATED,
stream,
mr);
auto m_scatter_map = scatter_map->mutable_view();
thrust::sequence(rmm::exec_policy(stream),
m_scatter_map.begin<size_type>(),
m_scatter_map.end<size_type>(),
m_scatter_map.begin<cudf::size_type>(),
m_scatter_map.end<cudf::size_type>(),
num_rows - 1,
-1);

if (not coalesce) {
thrust::default_random_engine g;
thrust::shuffle(rmm::exec_policy(stream),
m_scatter_map.begin<size_type>(),
m_scatter_map.begin<size_type>(),
m_scatter_map.begin<cudf::size_type>(),
m_scatter_map.begin<cudf::size_type>(),
g);
}

for (auto _ : state) {
cuda_event_timer raii(state, true); // flush_l2_cache = true, stream = 0
scatter(table_view{{*source}}, *scatter_map, table_view{{*target}}, mr);
scatter(cudf::table_view{{*source}}, *scatter_map, cudf::table_view{{*target}}, mr);
}

state.SetBytesProcessed(static_cast<int64_t>(state.iterations()) * state.range(0) * 2 *
Expand All @@ -127,5 +142,3 @@ void BM_lists_scatter(::benchmark::State& state)

SBM_BENCHMARK_DEFINE(double_type_colesce_o, double, true);
SBM_BENCHMARK_DEFINE(double_type_colesce_x, double, false);

} // namespace cudf