forked from rapidsai/cudf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
anyall.cpp
74 lines (63 loc) · 2.95 KB
/
anyall.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* 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.
* 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/benchmark_fixture.hpp>
#include <benchmarks/synchronization/synchronization.hpp>
#include <cudf/column/column_view.hpp>
#include <cudf/reduction.hpp>
#include <cudf/types.hpp>
#include <memory>
class Reduction : public cudf::benchmark {};
template <typename type>
void BM_reduction_anyall(benchmark::State& state,
std::unique_ptr<cudf::reduce_aggregation> const& agg)
{
cudf::size_type const column_size{static_cast<cudf::size_type>(state.range(0))};
auto const dtype = cudf::type_to_id<type>();
data_profile const profile = data_profile_builder().no_validity().distribution(
dtype, distribution_id::UNIFORM, 0, agg->kind == cudf::aggregation::ANY ? 0 : 100);
auto const values = create_random_column(dtype, row_count{column_size}, profile);
cudf::data_type output_dtype{cudf::type_id::BOOL8};
for (auto _ : state) {
cuda_event_timer timer(state, true);
auto result = cudf::reduce(*values, *agg, output_dtype);
}
}
#define concat(a, b, c) a##b##c
#define get_agg(op) concat(cudf::make_, op, _aggregation<cudf::reduce_aggregation>())
// TYPE, OP
#define RBM_BENCHMARK_DEFINE(name, type, aggregation) \
BENCHMARK_DEFINE_F(Reduction, name)(::benchmark::State & state) \
{ \
BM_reduction_anyall<type>(state, get_agg(aggregation)); \
} \
BENCHMARK_REGISTER_F(Reduction, name) \
->UseManualTime() \
->Arg(10000) /* 10k */ \
->Arg(100000) /* 100k */ \
->Arg(1000000) /* 1M */ \
->Arg(10000000) /* 10M */ \
->Arg(100000000); /* 100M */
#define REDUCE_BENCHMARK_DEFINE(type, aggregation) \
RBM_BENCHMARK_DEFINE(concat(type, _, aggregation), type, aggregation)
REDUCE_BENCHMARK_DEFINE(bool, all);
REDUCE_BENCHMARK_DEFINE(int8_t, all);
REDUCE_BENCHMARK_DEFINE(int32_t, all);
REDUCE_BENCHMARK_DEFINE(float, all);
REDUCE_BENCHMARK_DEFINE(bool, any);
REDUCE_BENCHMARK_DEFINE(int8_t, any);
REDUCE_BENCHMARK_DEFINE(int32_t, any);
REDUCE_BENCHMARK_DEFINE(float, any);