Skip to content

Commit

Permalink
Clean up distinct_count benchmark (#13321)
Browse files Browse the repository at this point in the history
This PR moves the `distinct_count` benchmark to the `stream_compaction` folder. It also adds peak memory usage information and targets the public API for performance evaluation.

Authors:
  - Yunsong Wang (https://github.com/PointKernel)

Approvers:
  - Nghia Truong (https://github.com/ttnghia)
  - Karthikeyan (https://github.com/karthikeyann)

URL: #13321
  • Loading branch information
PointKernel authored May 11, 2023
1 parent e4e65a9 commit 8a5a1f4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
7 changes: 3 additions & 4 deletions cpp/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ ConfigureBench(APPLY_BOOLEAN_MASK_BENCH stream_compaction/apply_boolean_mask.cpp
# ##################################################################################################
# * stream_compaction benchmark -------------------------------------------------------------------
ConfigureNVBench(
STREAM_COMPACTION_NVBENCH stream_compaction/distinct.cpp stream_compaction/unique.cpp
stream_compaction/unique_count.cpp
STREAM_COMPACTION_NVBENCH stream_compaction/distinct.cpp stream_compaction/distinct_count.cpp
stream_compaction/unique.cpp stream_compaction/unique_count.cpp
)

# ##################################################################################################
Expand Down Expand Up @@ -195,8 +195,7 @@ ConfigureBench(
reduction/reduce.cpp reduction/scan.cpp
)
ConfigureNVBench(
REDUCTION_NVBENCH reduction/distinct_count.cpp reduction/rank.cpp reduction/scan_structs.cpp
reduction/segmented_reduce.cpp
REDUCTION_NVBENCH reduction/rank.cpp reduction/scan_structs.cpp reduction/segmented_reduce.cpp
)

# ##################################################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
*/

#include <benchmarks/common/generate_input.hpp>
#include <benchmarks/fixture/rmm_pool_raii.hpp>
#include <benchmarks/fixture/benchmark_fixture.hpp>

#include <cudf/detail/stream_compaction.hpp>
#include <cudf/stream_compaction.hpp>

#include <nvbench/nvbench.cuh>

template <typename Type>
static void bench_reduction_distinct_count(nvbench::state& state, nvbench::type_list<Type>)
static void bench_distinct_count(nvbench::state& state, nvbench::type_list<Type>)
{
auto const dtype = cudf::type_to_id<Type>();
auto const size = static_cast<cudf::size_type>(state.get_int64("num_rows"));
Expand All @@ -40,16 +40,19 @@ static void bench_reduction_distinct_count(nvbench::state& state, nvbench::type_
auto const& data_column = data_table->get_column(0);
auto const input_table = cudf::table_view{{data_column, data_column, data_column}};

auto mem_stats_logger = cudf::memory_stats_logger(); // init stats logger
state.set_cuda_stream(nvbench::make_cuda_stream_view(cudf::get_default_stream().value()));
state.exec(nvbench::exec_tag::sync, [&](nvbench::launch& launch) {
rmm::cuda_stream_view stream{launch.get_stream()};
cudf::detail::distinct_count(input_table, cudf::null_equality::EQUAL, stream);
cudf::distinct_count(input_table, cudf::null_equality::EQUAL);
});
state.add_buffer_size(
mem_stats_logger.peak_memory_usage(), "peak_memory_usage", "peak_memory_usage");
}

using data_type = nvbench::type_list<int32_t, int64_t, float, double>;

NVBENCH_BENCH_TYPES(bench_reduction_distinct_count, NVBENCH_TYPE_AXES(data_type))
.set_name("reduction_distinct_count")
NVBENCH_BENCH_TYPES(bench_distinct_count, NVBENCH_TYPE_AXES(data_type))
.set_name("distinct_count")
.add_int64_axis("num_rows",
{
10000, // 10k
Expand Down

0 comments on commit 8a5a1f4

Please sign in to comment.