Skip to content

Commit

Permalink
Add bytes_per_second to transpose benchmark (#14170)
Browse files Browse the repository at this point in the history
This patch relates to #13735.

Benchmark: [transpose_benchmark.txt](https://github.com/rapidsai/cudf/files/12699834/transpose_benchmark.txt)

Authors:
  - Martin Marenz (https://github.com/Blonck)
  - Mark Harris (https://github.com/harrism)

Approvers:
  - Mark Harris (https://github.com/harrism)
  - Yunsong Wang (https://github.com/PointKernel)

URL: #14170
  • Loading branch information
Blonck authored Oct 10, 2023
1 parent 5039d04 commit c0c7ed8
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions cpp/benchmarks/transpose/transpose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,19 @@
#include <cudf/column/column_factories.hpp>
#include <cudf/table/table.hpp>
#include <cudf/transpose.hpp>
#include <cudf/types.hpp>

#include <thrust/iterator/counting_iterator.h>
#include <thrust/iterator/transform_iterator.h>

static void BM_transpose(benchmark::State& state)
{
auto count = state.range(0);
auto count = state.range(0);
constexpr auto column_type_id = cudf::type_id::INT32;
auto int_column_generator =
thrust::make_transform_iterator(thrust::counting_iterator(0), [count](int i) {
return cudf::make_numeric_column(
cudf::data_type{cudf::type_id::INT32}, count, cudf::mask_state::ALL_VALID);
cudf::data_type{column_type_id}, count, cudf::mask_state::ALL_VALID);
});

auto input_table = cudf::table(std::vector(int_column_generator, int_column_generator + count));
Expand All @@ -40,6 +42,17 @@ static void BM_transpose(benchmark::State& state)
cuda_event_timer raii(state, true);
auto output = cudf::transpose(input);
}

// Collect memory statistics.
auto const bytes_read = static_cast<uint64_t>(input.num_columns()) * input.num_rows() *
sizeof(cudf::id_to_type<column_type_id>);
auto const bytes_written = bytes_read;
// Account for nullability in input and output.
auto const null_bytes = 2 * static_cast<uint64_t>(input.num_columns()) *
cudf::bitmask_allocation_size_bytes(input.num_rows());

state.SetBytesProcessed(static_cast<int64_t>(state.iterations()) *
(bytes_read + bytes_written + null_bytes));
}

class Transpose : public cudf::benchmark {};
Expand Down

0 comments on commit c0c7ed8

Please sign in to comment.