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

Add groupby max aggregation benchmark #11464

Merged
merged 20 commits into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from 19 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
4 changes: 3 additions & 1 deletion cpp/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ ConfigureBench(
groupby/group_struct_values.cpp groupby/group_no_requests.cpp groupby/group_scan.cpp
)

ConfigureNVBench(GROUPBY_NVBENCH groupby/group_rank.cpp groupby/group_struct_keys.cpp)
ConfigureNVBench(
GROUPBY_NVBENCH groupby/group_max.cpp groupby/group_rank.cpp groupby/group_struct_keys.cpp
)

# ##################################################################################################
# * hashing benchmark -----------------------------------------------------------------------------
Expand Down
63 changes: 63 additions & 0 deletions cpp/benchmarks/groupby/group_max.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright (c) 2022, 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 <benchmarks/fixture/rmm_pool_raii.hpp>

#include <cudf/groupby.hpp>

#include <nvbench/nvbench.cuh>

template <typename Type>
void bench_groupby_max(nvbench::state& state, nvbench::type_list<Type>)
{
cudf::rmm_pool_raii pool_raii;

auto const input_table = [&] {
data_profile profile;
profile.set_null_frequency(std::nullopt);
Copy link
Contributor

Choose a reason for hiding this comment

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

I would be curious to know the performance impact when including nulls.
Could this be added as a state parameter?
Perhaps just a single value like 10% or less would be enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added nulls for the values column.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, that makes sense.

profile.set_cardinality(0);
profile.set_distribution_params<int32_t>(
cudf::type_to_id<int32_t>(), distribution_id::UNIFORM, 0, 100);
profile.set_distribution_params<Type>(cudf::type_to_id<Type>(),
distribution_id::UNIFORM,
static_cast<Type>(0),
static_cast<Type>(1000));

const auto size = static_cast<cudf::size_type>(state.get_int64("NumRows"));
return create_random_table(
{cudf::type_to_id<int32_t>(), cudf::type_to_id<Type>()}, row_count{size}, profile);
}();

auto const& keys = input_table->get_column(0);
auto const& vals = input_table->get_column(1);

auto gb_obj = cudf::groupby::groupby(cudf::table_view({keys, keys, keys}));

std::vector<cudf::groupby::aggregation_request> requests;
requests.emplace_back(cudf::groupby::aggregation_request());
requests[0].values = vals;
requests[0].aggregations.push_back(cudf::make_max_aggregation<cudf::groupby_aggregation>());

state.set_cuda_stream(nvbench::make_cuda_stream_view(cudf::default_stream_value.value()));
state.exec(nvbench::exec_tag::sync,
[&](nvbench::launch& launch) { auto const result = gb_obj.aggregate(requests); });
}

NVBENCH_BENCH_TYPES(bench_groupby_max,
NVBENCH_TYPE_AXES(nvbench::type_list<int16_t, int32_t, int64_t, float, double>))
.set_name("groupby_max")
.add_int64_power_of_two_axis("NumRows", {12, 16, 20, 24});