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 bytes_per_second to shift benchmark #13950

Merged
20 changes: 16 additions & 4 deletions cpp/benchmarks/copying/shift.cu
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ static void BM_shift(benchmark::State& state)
cudf::size_type size = state.range(0);
cudf::size_type offset = size * (static_cast<double>(shift_factor) / 100.0);

auto const input_table =
create_sequence_table({cudf::type_to_id<int>()},
row_count{size},
use_validity ? std::optional<double>{1.0} : std::nullopt);
auto constexpr column_type_id = cudf::type_to_id<int>();
auto const input_table = create_sequence_table(
{column_type_id}, row_count{size}, use_validity ? std::optional<double>{1.0} : std::nullopt);
cudf::column_view input{input_table->get_column(0)};

auto fill = use_validity ? make_scalar<int>() : make_scalar<int>(777);
Blonck marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -68,6 +67,19 @@ static void BM_shift(benchmark::State& state)
cuda_event_timer raii(state, true);
auto output = cudf::shift(input, offset, *fill);
}

auto const elems_read = (size - offset);
auto const bytes_read = elems_read * sizeof(int);
Blonck marked this conversation as resolved.
Show resolved Hide resolved
Blonck marked this conversation as resolved.
Show resolved Hide resolved

// If 'use_validity' is false, the fill value is a number, and the entire column
// (excluding the null bitmask) needs to be written. On the other hand, if 'use_validity'
// is true, only the elements that can be shifted are written, along with the full null bitmask.
auto const elems_written = use_validity ? (size - offset) : size;
Blonck marked this conversation as resolved.
Show resolved Hide resolved
auto const bytes_written = elems_written * sizeof(cudf::id_to_type<column_type_id>);
Blonck marked this conversation as resolved.
Show resolved Hide resolved
auto const null_bytes = use_validity ? 2 * cudf::bitmask_allocation_size_bytes(size) : 0;

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

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