diff --git a/cpp/benchmarks/ast/transform_benchmark.cpp b/cpp/benchmarks/ast/transform_benchmark.cpp index fd0a0f7d2c8..c17c288a6d3 100644 --- a/cpp/benchmarks/ast/transform_benchmark.cpp +++ b/cpp/benchmarks/ast/transform_benchmark.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -40,7 +41,6 @@ enum class TreeType { // child column reference }; -template class AST : public cudf::benchmark { }; @@ -127,9 +127,22 @@ static void BM_ast_transform(benchmark::State& state) (tree_levels + 1) * sizeof(key_type)); } -#define AST_TRANSFORM_BENCHMARK_DEFINE(name, key_type, tree_type, reuse_columns, nullable) \ - BENCHMARK_TEMPLATE_DEFINE_F(AST, name, key_type, tree_type, reuse_columns, nullable) \ - (::benchmark::State & st) { BM_ast_transform(st); } +static void CustomRanges(benchmark::internal::Benchmark* b) +{ + auto row_counts = std::vector{100'000, 1'000'000, 10'000'000, 100'000'000}; + auto operation_counts = std::vector{1, 5, 10}; + for (auto const& row_count : row_counts) { + for (auto const& operation_count : operation_counts) { + b->Args({row_count, operation_count}); + } + } +} + +#define AST_TRANSFORM_BENCHMARK_DEFINE(name, key_type, tree_type, reuse_columns, nullable) \ + TEMPLATED_BENCHMARK_F(AST, BM_ast_transform, key_type, tree_type, reuse_columns, nullable) \ + ->Apply(CustomRanges) \ + ->Unit(benchmark::kMillisecond) \ + ->UseManualTime(); AST_TRANSFORM_BENCHMARK_DEFINE( ast_int32_imbalanced_unique, int32_t, TreeType::IMBALANCED_LEFT, false, false); @@ -144,44 +157,3 @@ AST_TRANSFORM_BENCHMARK_DEFINE( ast_int32_imbalanced_reuse_nulls, int32_t, TreeType::IMBALANCED_LEFT, true, true); AST_TRANSFORM_BENCHMARK_DEFINE( ast_double_imbalanced_unique_nulls, double, TreeType::IMBALANCED_LEFT, false, true); - -static void CustomRanges(benchmark::internal::Benchmark* b) -{ - auto row_counts = std::vector{100'000, 1'000'000, 10'000'000, 100'000'000}; - auto operation_counts = std::vector{1, 5, 10}; - for (auto const& row_count : row_counts) { - for (auto const& operation_count : operation_counts) { - b->Args({row_count, operation_count}); - } - } -} - -BENCHMARK_REGISTER_F(AST, ast_int32_imbalanced_unique) - ->Apply(CustomRanges) - ->Unit(benchmark::kMillisecond) - ->UseManualTime(); - -BENCHMARK_REGISTER_F(AST, ast_int32_imbalanced_reuse) - ->Apply(CustomRanges) - ->Unit(benchmark::kMillisecond) - ->UseManualTime(); - -BENCHMARK_REGISTER_F(AST, ast_double_imbalanced_unique) - ->Apply(CustomRanges) - ->Unit(benchmark::kMillisecond) - ->UseManualTime(); - -BENCHMARK_REGISTER_F(AST, ast_int32_imbalanced_unique_nulls) - ->Apply(CustomRanges) - ->Unit(benchmark::kMillisecond) - ->UseManualTime(); - -BENCHMARK_REGISTER_F(AST, ast_int32_imbalanced_reuse_nulls) - ->Apply(CustomRanges) - ->Unit(benchmark::kMillisecond) - ->UseManualTime(); - -BENCHMARK_REGISTER_F(AST, ast_double_imbalanced_unique_nulls) - ->Apply(CustomRanges) - ->Unit(benchmark::kMillisecond) - ->UseManualTime(); diff --git a/cpp/benchmarks/column/concatenate_benchmark.cpp b/cpp/benchmarks/column/concatenate_benchmark.cpp index 3634b2f08a2..abca4b4e0f5 100644 --- a/cpp/benchmarks/column/concatenate_benchmark.cpp +++ b/cpp/benchmarks/column/concatenate_benchmark.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -26,7 +27,6 @@ #include #include -template class Concatenate : public cudf::benchmark { }; @@ -69,17 +69,15 @@ static void BM_concatenate(benchmark::State& state) state.SetBytesProcessed(state.iterations() * num_cols * num_rows * sizeof(T)); } -#define CONCAT_BENCHMARK_DEFINE(name, type, nullable) \ - BENCHMARK_TEMPLATE_DEFINE_F(Concatenate, name, type, nullable) \ - (::benchmark::State & state) { BM_concatenate(state); } \ - BENCHMARK_REGISTER_F(Concatenate, name) \ - ->RangeMultiplier(8) \ - ->Ranges({{1 << 6, 1 << 18}, {2, 1024}}) \ - ->Unit(benchmark::kMillisecond) \ +#define CONCAT_BENCHMARK_DEFINE(type, nullable) \ + TEMPLATED_BENCHMARK_F(Concatenate, BM_concatenate, type, nullable) \ + ->RangeMultiplier(8) \ + ->Ranges({{1 << 6, 1 << 18}, {2, 1024}}) \ + ->Unit(benchmark::kMillisecond) \ ->UseManualTime(); -CONCAT_BENCHMARK_DEFINE(concat_columns_int64_non_null, int64_t, false) -CONCAT_BENCHMARK_DEFINE(concat_columns_int64_nullable, int64_t, true) +CONCAT_BENCHMARK_DEFINE(int64_t, false) +CONCAT_BENCHMARK_DEFINE(int64_t, true) template static void BM_concatenate_tables(benchmark::State& state) @@ -131,19 +129,16 @@ static void BM_concatenate_tables(benchmark::State& state) state.SetBytesProcessed(state.iterations() * num_cols * num_rows * num_tables * sizeof(T)); } -#define CONCAT_TABLES_BENCHMARK_DEFINE(name, type, nullable) \ - BENCHMARK_TEMPLATE_DEFINE_F(Concatenate, name, type, nullable) \ - (::benchmark::State & state) { BM_concatenate_tables(state); } \ - BENCHMARK_REGISTER_F(Concatenate, name) \ - ->RangeMultiplier(8) \ - ->Ranges({{1 << 8, 1 << 12}, {2, 32}, {2, 128}}) \ - ->Unit(benchmark::kMillisecond) \ +#define CONCAT_TABLES_BENCHMARK_DEFINE(type, nullable) \ + TEMPLATED_BENCHMARK_F(Concatenate, BM_concatenate_tables, type, nullable) \ + ->RangeMultiplier(8) \ + ->Ranges({{1 << 8, 1 << 12}, {2, 32}, {2, 128}}) \ + ->Unit(benchmark::kMillisecond) \ ->UseManualTime(); -CONCAT_TABLES_BENCHMARK_DEFINE(concat_tables_int64_non_null, int64_t, false) -CONCAT_TABLES_BENCHMARK_DEFINE(concat_tables_int64_nullable, int64_t, true) +CONCAT_TABLES_BENCHMARK_DEFINE(int64_t, false) +CONCAT_TABLES_BENCHMARK_DEFINE(int64_t, true) -template class ConcatenateStrings : public cudf::benchmark { }; @@ -192,14 +187,12 @@ static void BM_concatenate_strings(benchmark::State& state) (sizeof(int32_t) + num_chars)); // offset + chars } -#define CONCAT_STRINGS_BENCHMARK_DEFINE(name, nullable) \ - BENCHMARK_TEMPLATE_DEFINE_F(ConcatenateStrings, name, nullable) \ - (::benchmark::State & state) { BM_concatenate_strings(state); } \ - BENCHMARK_REGISTER_F(ConcatenateStrings, name) \ - ->RangeMultiplier(8) \ - ->Ranges({{1 << 8, 1 << 14}, {8, 128}, {2, 256}}) \ - ->Unit(benchmark::kMillisecond) \ +#define CONCAT_STRINGS_BENCHMARK_DEFINE(nullable) \ + TEMPLATED_BENCHMARK_F(ConcatenateStrings, BM_concatenate_strings, nullable) \ + ->RangeMultiplier(8) \ + ->Ranges({{1 << 8, 1 << 14}, {8, 128}, {2, 256}}) \ + ->Unit(benchmark::kMillisecond) \ ->UseManualTime(); -CONCAT_STRINGS_BENCHMARK_DEFINE(concat_string_columns_non_null, false) -CONCAT_STRINGS_BENCHMARK_DEFINE(concat_string_columns_nullable, true) +CONCAT_STRINGS_BENCHMARK_DEFINE(false) +CONCAT_STRINGS_BENCHMARK_DEFINE(true) diff --git a/cpp/benchmarks/string/url_decode_benchmark.cpp b/cpp/benchmarks/string/url_decode_benchmark.cpp index 9cfaaf27286..4dc77cffa1a 100644 --- a/cpp/benchmarks/string/url_decode_benchmark.cpp +++ b/cpp/benchmarks/string/url_decode_benchmark.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -66,7 +67,6 @@ cudf::test::strings_column_wrapper generate_column(cudf::size_type num_rows, return cudf::test::strings_column_wrapper(strings.begin(), strings.end()); } -template class UrlDecode : public cudf::benchmark { }; @@ -88,15 +88,13 @@ void BM_url_decode(benchmark::State& state) (chars_per_row + sizeof(cudf::size_type))); } -#define URLD_BENCHMARK_DEFINE(name, esc_seq_pct) \ - BENCHMARK_TEMPLATE_DEFINE_F(UrlDecode, name, esc_seq_pct) \ - (::benchmark::State & state) { BM_url_decode(state); } \ - BENCHMARK_REGISTER_F(UrlDecode, name) \ - ->Args({100000000, 10}) \ - ->Args({10000000, 100}) \ - ->Args({1000000, 1000}) \ - ->Unit(benchmark::kMillisecond) \ +#define URLD_BENCHMARK_DEFINE(esc_seq_pct) \ + TEMPLATED_BENCHMARK_F(UrlDecode, BM_url_decode, esc_seq_pct) \ + ->Args({100000000, 10}) \ + ->Args({10000000, 100}) \ + ->Args({1000000, 1000}) \ + ->Unit(benchmark::kMillisecond) \ ->UseManualTime(); -URLD_BENCHMARK_DEFINE(url_decode_10pct, 10) -URLD_BENCHMARK_DEFINE(url_decode_50pct, 50) +URLD_BENCHMARK_DEFINE(10) +URLD_BENCHMARK_DEFINE(50)