From 916ce009ea088bafae083ababeaf080a81f565ce Mon Sep 17 00:00:00 2001 From: Karthikeyan Natarajan Date: Mon, 14 Feb 2022 21:48:41 +0530 Subject: [PATCH 01/24] rename generate_input.cpp to generate_input.cu --- cpp/benchmarks/CMakeLists.txt | 2 +- cpp/benchmarks/common/{generate_input.cpp => generate_input.cu} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename cpp/benchmarks/common/{generate_input.cpp => generate_input.cu} (100%) diff --git a/cpp/benchmarks/CMakeLists.txt b/cpp/benchmarks/CMakeLists.txt index 0704180bad0..e8b129c0c1c 100644 --- a/cpp/benchmarks/CMakeLists.txt +++ b/cpp/benchmarks/CMakeLists.txt @@ -14,7 +14,7 @@ find_package(Threads REQUIRED) -add_library(cudf_datagen STATIC common/generate_input.cpp) +add_library(cudf_datagen STATIC common/generate_input.cu) target_compile_features(cudf_datagen PUBLIC cxx_std_17 cuda_std_17) target_compile_options( diff --git a/cpp/benchmarks/common/generate_input.cpp b/cpp/benchmarks/common/generate_input.cu similarity index 100% rename from cpp/benchmarks/common/generate_input.cpp rename to cpp/benchmarks/common/generate_input.cu From d7f0f29f5d12c96ab5f4100c9ab076d00be6d135 Mon Sep 17 00:00:00 2001 From: Karthikeyan Natarajan Date: Tue, 15 Feb 2022 01:28:05 +0530 Subject: [PATCH 02/24] add create_sequence_table, create_random_null_mask --- cpp/benchmarks/common/generate_input.cu | 62 ++++++++++++++++++++++++ cpp/benchmarks/common/generate_input.hpp | 32 ++++++++++++ 2 files changed, 94 insertions(+) diff --git a/cpp/benchmarks/common/generate_input.cu b/cpp/benchmarks/common/generate_input.cu index 68eabd3f1cc..64b82fe421e 100644 --- a/cpp/benchmarks/common/generate_input.cu +++ b/cpp/benchmarks/common/generate_input.cu @@ -544,6 +544,35 @@ std::unique_ptr create_random_column(data_profile return list_column; // return the top-level column } +struct valid_generator { + thrust::minstd_rand engine; + thrust::uniform_real_distribution dist; + float valid_prob; + valid_generator(thrust::minstd_rand engine, float valid_probability) + : engine(engine), dist{0, 1}, valid_prob{valid_probability} + { + } + valid_generator(unsigned seed, float valid_probability) + : engine(seed), dist{0, 1}, valid_prob{valid_probability} + { + } + + __device__ bool operator()(size_t n) + { + engine.discard(n); + return dist(engine) < valid_prob; + } +}; + +std::pair create_random_null_mask(cudf::size_type size, + float null_probability, + unsigned seed) +{ + return cudf::detail::valid_if(thrust::make_counting_iterator(0), + thrust::make_counting_iterator(size), + valid_generator{seed, 1.0f - null_probability}); +}; + using columns_vector = std::vector>; /** @@ -642,6 +671,39 @@ std::unique_ptr create_random_table(std::vector cons return std::make_unique(std::move(output_columns)); } +std::unique_ptr create_sequence_table(std::vector const& dtype_ids, + cudf::size_type num_cols, + row_count num_rows, + float null_probability, + unsigned seed) +{ + auto const out_dtype_ids = repeat_dtypes(dtype_ids, num_cols); + auto columns = std::vector>(num_cols); + auto init = cudf::make_default_constructed_scalar(cudf::data_type{dtype_ids[0]}); + if (dtype_ids.size() == 1) { + std::generate_n(columns.begin(), num_cols, [&]() { + auto col = cudf::sequence(num_rows.count, *init); + if (null_probability >= 0.0) { + auto [mask, count] = create_random_null_mask(num_rows.count, null_probability, seed); + col->set_null_mask(std::move(mask), count); + } + return col; + }); + } else { + std::transform( + out_dtype_ids.begin(), out_dtype_ids.end(), columns.begin(), [num_rows](auto dtype) { + auto init = cudf::make_default_constructed_scalar(cudf::data_type{dtype}); + auto col = cudf::sequence(num_rows.count, *init); + if (null_probability >= 0.0) { + auto [mask, count] = create_random_null_mask(num_rows.count, null_probability, seed); + col->set_null_mask(std::move(mask), count); + } + return col; + }); + } + return std::make_unique(std::move(columns)); +} + std::vector get_type_or_group(int32_t id) { // identity transformation when passing a concrete type_id diff --git a/cpp/benchmarks/common/generate_input.hpp b/cpp/benchmarks/common/generate_input.hpp index 8261341ccfb..ec153993c4e 100644 --- a/cpp/benchmarks/common/generate_input.hpp +++ b/cpp/benchmarks/common/generate_input.hpp @@ -403,3 +403,35 @@ std::unique_ptr create_random_table(std::vector cons row_count num_rows, data_profile const& data_params = data_profile{}, unsigned seed = 1); + +/** + * @brief Generate sequence columns starting with value 0 in first row and increasing by 1 in + * subsequent rows. + * + * If the number of passed types is smaller than the number of requested column, the columns types + * with be repeated in round-robin order to fill the table. + * + * @param dtype_ids Vector of requested column types + * @param num_cols Number of columns in the output table + * @param num_rows Number of rows in the output table + * @param null_probability optional, probability of a null value, <0 implies no null mask. + * @param seed optional, seed for the pseudo-random engine + * @return A table with the sequence columns. + */ +std::unique_ptr create_sequence_table(std::vector const& dtype_ids, + cudf::size_type num_cols, + row_count num_rows, + float null_probability = -1.0, + unsigned seed = 1); + +/** + * @brief Create a random null mask object + * + * @param size number of rows + * @param null_probability probability of a null value + * @param seed optional, seed for the pseudo-random engine + * @return null mask device buffer with random null mask data + */ +rmm::device_buffer create_random_null_mask(cudf::size_type size, + float null_probability, + unsigned seed = 1); From bb74cc72bfe3bfaa612eaf6c873ef1a1cba68eac Mon Sep 17 00:00:00 2001 From: Karthikeyan Natarajan Date: Tue, 15 Feb 2022 23:06:24 +0530 Subject: [PATCH 03/24] fix includes, seed --- cpp/benchmarks/common/generate_input.cu | 38 ++++++++++++++---------- cpp/benchmarks/common/generate_input.hpp | 16 +++++----- 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/cpp/benchmarks/common/generate_input.cu b/cpp/benchmarks/common/generate_input.cu index 64b82fe421e..467435992e7 100644 --- a/cpp/benchmarks/common/generate_input.cu +++ b/cpp/benchmarks/common/generate_input.cu @@ -19,12 +19,17 @@ #include #include +#include +#include +#include #include #include #include #include +#include + #include #include #include @@ -564,9 +569,9 @@ struct valid_generator { } }; -std::pair create_random_null_mask(cudf::size_type size, - float null_probability, - unsigned seed) +std::pair create_random_null_mask(cudf::size_type size, + float null_probability, + unsigned seed) { return cudf::detail::valid_if(thrust::make_counting_iterator(0), thrust::make_counting_iterator(size), @@ -681,25 +686,28 @@ std::unique_ptr create_sequence_table(std::vector co auto columns = std::vector>(num_cols); auto init = cudf::make_default_constructed_scalar(cudf::data_type{dtype_ids[0]}); if (dtype_ids.size() == 1) { - std::generate_n(columns.begin(), num_cols, [&]() { + std::generate_n(columns.begin(), num_cols, [&]() mutable { auto col = cudf::sequence(num_rows.count, *init); if (null_probability >= 0.0) { - auto [mask, count] = create_random_null_mask(num_rows.count, null_probability, seed); + auto [mask, count] = create_random_null_mask(num_rows.count, null_probability, seed++); col->set_null_mask(std::move(mask), count); } return col; }); } else { - std::transform( - out_dtype_ids.begin(), out_dtype_ids.end(), columns.begin(), [num_rows](auto dtype) { - auto init = cudf::make_default_constructed_scalar(cudf::data_type{dtype}); - auto col = cudf::sequence(num_rows.count, *init); - if (null_probability >= 0.0) { - auto [mask, count] = create_random_null_mask(num_rows.count, null_probability, seed); - col->set_null_mask(std::move(mask), count); - } - return col; - }); + std::transform(out_dtype_ids.begin(), + out_dtype_ids.end(), + columns.begin(), + [num_rows, &seed, null_probability](auto dtype) mutable { + auto init = cudf::make_default_constructed_scalar(cudf::data_type{dtype}); + auto col = cudf::sequence(num_rows.count, *init); + if (null_probability >= 0.0) { + auto [mask, count] = + create_random_null_mask(num_rows.count, null_probability, seed++); + col->set_null_mask(std::move(mask), count); + } + return col; + }); } return std::make_unique(std::move(columns)); } diff --git a/cpp/benchmarks/common/generate_input.hpp b/cpp/benchmarks/common/generate_input.hpp index ec153993c4e..46928e8b7fb 100644 --- a/cpp/benchmarks/common/generate_input.hpp +++ b/cpp/benchmarks/common/generate_input.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -224,9 +224,9 @@ class data_profile { cudf::size_type avg_run_length = 4; public: - template < - typename T, - typename std::enable_if_t && std::is_integral::value, T>* = nullptr> + template && cuda::std::is_integral_v, T>* = + nullptr> distribution_params get_distribution_params() const { auto it = int_params.find(cudf::type_to_id()); @@ -307,7 +307,7 @@ class data_profile { // discrete distributions (integers, strings, lists). Otherwise the call with have no effect. template ::value, T>* = nullptr> + typename std::enable_if_t, T>* = nullptr> void set_distribution_params(Type_enum type_or_group, distribution_id dist, T lower_bound, @@ -432,6 +432,6 @@ std::unique_ptr create_sequence_table(std::vector co * @param seed optional, seed for the pseudo-random engine * @return null mask device buffer with random null mask data */ -rmm::device_buffer create_random_null_mask(cudf::size_type size, - float null_probability, - unsigned seed = 1); +std::pair create_random_null_mask(cudf::size_type size, + float null_probability, + unsigned seed = 1); From 0ea4f60864b43826599aa9ffcf56285a130bc18b Mon Sep 17 00:00:00 2001 From: Karthikeyan Natarajan Date: Tue, 15 Feb 2022 23:07:03 +0530 Subject: [PATCH 04/24] use cuda::std to include int128 --- cpp/benchmarks/common/random_distribution_factory.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cpp/benchmarks/common/random_distribution_factory.hpp b/cpp/benchmarks/common/random_distribution_factory.hpp index 48e6855c39a..c1b0209e638 100644 --- a/cpp/benchmarks/common/random_distribution_factory.hpp +++ b/cpp/benchmarks/common/random_distribution_factory.hpp @@ -24,7 +24,7 @@ /** * @brief Generates a normal(binomial) distribution between zero and upper_bound. */ -template ::value, T>* = nullptr> +template , T>* = nullptr> auto make_normal_dist(T upper_bound) { using uT = typename std::make_unsigned::type; @@ -42,7 +42,7 @@ auto make_normal_dist(T upper_bound) return std::normal_distribution(mean, stddev); } -template ::value, T>* = nullptr> +template , T>* = nullptr> auto make_uniform_dist(T range_start, T range_end) { return std::uniform_int_distribution(range_start, range_end); @@ -62,7 +62,7 @@ double geometric_dist_p(T range_size) return p ? p : std::numeric_limits::epsilon(); } -template ::value, T>* = nullptr> +template , T>* = nullptr> auto make_geometric_dist(T range_start, T range_end) { using uT = typename std::make_unsigned::type; @@ -82,7 +82,7 @@ auto make_geometric_dist(T range_start, T range_end) template using distribution_fn = std::function; -template ::value, T>* = nullptr> +template , T>* = nullptr> distribution_fn make_distribution(distribution_id did, T lower_bound, T upper_bound) { switch (did) { From a25241e5b6ea6c322a28eb1503f97006b2d4ce5d Mon Sep 17 00:00:00 2001 From: Karthikeyan Natarajan Date: Tue, 15 Feb 2022 23:07:27 +0530 Subject: [PATCH 05/24] use -std=gnu++17 for generate_input.cu for int128 support --- cpp/benchmarks/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cpp/benchmarks/CMakeLists.txt b/cpp/benchmarks/CMakeLists.txt index e8b129c0c1c..f28e5efd3e1 100644 --- a/cpp/benchmarks/CMakeLists.txt +++ b/cpp/benchmarks/CMakeLists.txt @@ -15,6 +15,11 @@ find_package(Threads REQUIRED) add_library(cudf_datagen STATIC common/generate_input.cu) +set_property( + SOURCE common/generate_input.cu + APPEND + PROPERTY COMPILE_FLAGS "-Xcompiler=-std=gnu++17" +) target_compile_features(cudf_datagen PUBLIC cxx_std_17 cuda_std_17) target_compile_options( From dfd33f28f085d181af4ffe27dc1c0c4ff8a39d35 Mon Sep 17 00:00:00 2001 From: Karthikeyan Natarajan Date: Tue, 15 Feb 2022 23:23:36 +0530 Subject: [PATCH 06/24] go back to using BENCHMARK_TEMPLATE_DEFINE_F --- cpp/benchmarks/ast/transform.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/cpp/benchmarks/ast/transform.cpp b/cpp/benchmarks/ast/transform.cpp index c17c288a6d3..845fe47c7cf 100644 --- a/cpp/benchmarks/ast/transform.cpp +++ b/cpp/benchmarks/ast/transform.cpp @@ -41,6 +41,7 @@ enum class TreeType { // child column reference }; +template class AST : public cudf::benchmark { }; @@ -138,10 +139,15 @@ static void CustomRanges(benchmark::internal::Benchmark* b) } } -#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) \ +#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); \ + } \ + BENCHMARK_REGISTER_F(AST, name) \ + ->Apply(CustomRanges) \ + ->Unit(benchmark::kMillisecond) \ ->UseManualTime(); AST_TRANSFORM_BENCHMARK_DEFINE( From f9f3eec0134eb62392e6feac7e3eecbff7806166 Mon Sep 17 00:00:00 2001 From: Karthikeyan Natarajan Date: Tue, 15 Feb 2022 23:24:27 +0530 Subject: [PATCH 07/24] use create_sequence_table in ast bench --- cpp/benchmarks/ast/transform.cpp | 53 ++++++-------------------------- 1 file changed, 10 insertions(+), 43 deletions(-) diff --git a/cpp/benchmarks/ast/transform.cpp b/cpp/benchmarks/ast/transform.cpp index 845fe47c7cf..d2ce2204e13 100644 --- a/cpp/benchmarks/ast/transform.cpp +++ b/cpp/benchmarks/ast/transform.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,26 +14,18 @@ * limitations under the License. */ -#include -#include -#include +#include +#include +#include + #include #include -#include - -#include - -#include -#include -#include -#include #include #include #include -#include -#include +#include #include enum class TreeType { @@ -52,35 +44,10 @@ static void BM_ast_transform(benchmark::State& state) const cudf::size_type tree_levels = (cudf::size_type)state.range(1); // Create table data - auto n_cols = reuse_columns ? 1 : tree_levels + 1; - auto column_wrappers = std::vector>(n_cols); - auto columns = std::vector(n_cols); - - auto data_iterator = thrust::make_counting_iterator(0); - - if constexpr (Nullable) { - auto validities = std::vector(table_size); - std::random_device rd; - std::mt19937 gen(rd()); - - std::generate( - validities.begin(), validities.end(), [&]() { return gen() > (0.5 * gen.max()); }); - std::generate_n(column_wrappers.begin(), n_cols, [=]() { - return cudf::test::fixed_width_column_wrapper( - data_iterator, data_iterator + table_size, validities.begin()); - }); - } else { - std::generate_n(column_wrappers.begin(), n_cols, [=]() { - return cudf::test::fixed_width_column_wrapper(data_iterator, - data_iterator + table_size); - }); - } - std::transform( - column_wrappers.begin(), column_wrappers.end(), columns.begin(), [](auto const& col) { - return static_cast(col); - }); - - cudf::table_view table{columns}; + auto n_cols = reuse_columns ? 1 : tree_levels + 1; + auto source_table = create_sequence_table( + {cudf::type_to_id()}, n_cols, row_count{table_size}, Nullable ? 0.5 : -1.0); + auto table = source_table->view(); // Create column references auto column_refs = std::vector(); From 81ac53a3631662c769bb5fe2ad29113469f78ade Mon Sep 17 00:00:00 2001 From: Karthikeyan Natarajan Date: Tue, 15 Feb 2022 23:25:05 +0530 Subject: [PATCH 08/24] use create_sequence_table in binops bench --- cpp/benchmarks/binaryop/binaryop.cpp | 45 ++++++------------- cpp/benchmarks/binaryop/compiled_binaryop.cpp | 19 +++----- 2 files changed, 20 insertions(+), 44 deletions(-) diff --git a/cpp/benchmarks/binaryop/binaryop.cpp b/cpp/benchmarks/binaryop/binaryop.cpp index 314d657679b..1f5823cf842 100644 --- a/cpp/benchmarks/binaryop/binaryop.cpp +++ b/cpp/benchmarks/binaryop/binaryop.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,23 +14,15 @@ * limitations under the License. */ +#include +#include +#include + #include -#include -#include #include #include -#include - -#include - -#include -#include -#include - -#include #include -#include #include // This set of benchmarks is designed to be a comparison for the AST benchmarks @@ -51,21 +43,10 @@ static void BM_binaryop_transform(benchmark::State& state) const cudf::size_type tree_levels = (cudf::size_type)state.range(1); // Create table data - auto n_cols = reuse_columns ? 1 : tree_levels + 1; - auto column_wrappers = std::vector>(); - auto columns = std::vector(n_cols); - - auto data_iterator = thrust::make_counting_iterator(0); - std::generate_n(std::back_inserter(column_wrappers), n_cols, [=]() { - return cudf::test::fixed_width_column_wrapper(data_iterator, - data_iterator + table_size); - }); - std::transform( - column_wrappers.begin(), column_wrappers.end(), columns.begin(), [](auto const& col) { - return static_cast(col); - }); - - cudf::table_view table{columns}; + auto n_cols = reuse_columns ? 1 : tree_levels + 1; + auto source_table = + create_sequence_table({cudf::type_to_id()}, n_cols, row_count{table_size}); + cudf::table_view table{*source_table}; // Execute benchmark for (auto _ : state) { @@ -74,13 +55,13 @@ static void BM_binaryop_transform(benchmark::State& state) auto const op = cudf::binary_operator::ADD; auto result_data_type = cudf::data_type(cudf::type_to_id()); if (reuse_columns) { - auto result = cudf::binary_operation(columns.at(0), columns.at(0), op, result_data_type); + auto result = cudf::binary_operation(table.column(0), table.column(0), op, result_data_type); for (cudf::size_type i = 0; i < tree_levels - 1; i++) { - result = cudf::binary_operation(result->view(), columns.at(0), op, result_data_type); + result = cudf::binary_operation(result->view(), table.column(0), op, result_data_type); } } else { - auto result = cudf::binary_operation(columns.at(0), columns.at(1), op, result_data_type); - std::for_each(std::next(columns.cbegin(), 2), columns.cend(), [&](auto const& col) { + auto result = cudf::binary_operation(table.column(0), table.column(1), op, result_data_type); + std::for_each(std::next(table.begin(), 2), table.end(), [&](auto const& col) { result = cudf::binary_operation(result->view(), col, op, result_data_type); }); } diff --git a/cpp/benchmarks/binaryop/compiled_binaryop.cpp b/cpp/benchmarks/binaryop/compiled_binaryop.cpp index f8226c7387a..f572c12d9ec 100644 --- a/cpp/benchmarks/binaryop/compiled_binaryop.cpp +++ b/cpp/benchmarks/binaryop/compiled_binaryop.cpp @@ -14,16 +14,12 @@ * limitations under the License. */ -#include -#include -#include - -#include +#include +#include +#include #include -#include - class COMPILED_BINARYOP : public cudf::benchmark { }; @@ -32,12 +28,11 @@ void BM_compiled_binaryop(benchmark::State& state, cudf::binary_operator binop) { const cudf::size_type column_size{(cudf::size_type)state.range(0)}; - auto data_it = thrust::make_counting_iterator(0); - cudf::test::fixed_width_column_wrapper input1(data_it, data_it + column_size); - cudf::test::fixed_width_column_wrapper input2(data_it, data_it + column_size); + auto source_table = create_sequence_table( + {cudf::type_to_id(), cudf::type_to_id()}, 2, row_count{column_size}); - auto lhs = cudf::column_view(input1); - auto rhs = cudf::column_view(input2); + auto lhs = cudf::column_view(source_table->get_column(0)); + auto rhs = cudf::column_view(source_table->get_column(1)); auto output_dtype = cudf::data_type(cudf::type_to_id()); // Call once for hot cache. From 6c659d459b1959f531c9d8545357dfba665ca7d8 Mon Sep 17 00:00:00 2001 From: Karthikeyan Natarajan Date: Tue, 15 Feb 2022 23:26:01 +0530 Subject: [PATCH 09/24] use create_sequence_table, thrust::shuffle in scatter bench --- cpp/benchmarks/copying/scatter.cu | 72 ++++++++++--------------------- 1 file changed, 23 insertions(+), 49 deletions(-) diff --git a/cpp/benchmarks/copying/scatter.cu b/cpp/benchmarks/copying/scatter.cu index a9ab376c8c3..d682b433ce9 100644 --- a/cpp/benchmarks/copying/scatter.cu +++ b/cpp/benchmarks/copying/scatter.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, NVIDIA CORPORATION. + * Copyright (c) 2019-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,24 +14,17 @@ * limitations under the License. */ -#include +#include +#include +#include #include - -#include -#include -// #include -#include -#include -#include - #include -#include -#include +#include +#include -#include "../fixture/benchmark_fixture.hpp" -#include "../synchronization/synchronization.hpp" +#include class Scatter : public cudf::benchmark { }; @@ -42,50 +35,31 @@ void BM_scatter(benchmark::State& state) const cudf::size_type source_size{(cudf::size_type)state.range(0)}; const auto n_cols = (cudf::size_type)state.range(1); - // Every element is valid - auto data = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return i; }); - // Gather indices - std::vector host_map_data(source_size); - std::iota(host_map_data.begin(), host_map_data.end(), 0); + auto scatter_map_table = + create_sequence_table({cudf::type_to_id()}, 1, row_count{source_size}); + auto scatter_map = scatter_map_table->get_column(0).mutable_view(); if (coalesce) { - std::reverse(host_map_data.begin(), host_map_data.end()); + thrust::reverse(thrust::device, + scatter_map.begin(), + scatter_map.end()); } else { - std::random_shuffle(host_map_data.begin(), host_map_data.end()); + thrust::shuffle(thrust::device, + scatter_map.begin(), + scatter_map.end(), + thrust::default_random_engine()); } - cudf::test::fixed_width_column_wrapper scatter_map(host_map_data.begin(), - host_map_data.end()); - - std::vector> source_column_wrappers; - std::vector source_columns(n_cols); - - std::vector> target_column_wrappers; - std::vector target_columns(n_cols); - - std::generate_n(std::back_inserter(source_column_wrappers), n_cols, [=]() { - return cudf::test::fixed_width_column_wrapper(data, data + source_size); - }); - std::transform(source_column_wrappers.begin(), - source_column_wrappers.end(), - source_columns.begin(), - [](auto const& col) { return static_cast(col); }); - - std::generate_n(std::back_inserter(target_column_wrappers), n_cols, [=]() { - return cudf::test::fixed_width_column_wrapper(data, data + source_size); - }); - std::transform(target_column_wrappers.begin(), - target_column_wrappers.end(), - target_columns.begin(), - [](auto const& col) { return static_cast(col); }); - - cudf::table_view source_table{source_columns}; - cudf::table_view target_table{target_columns}; + // Every element is valid + auto source_table = + create_sequence_table({cudf::type_to_id()}, n_cols, row_count{source_size}); + auto target_table = + create_sequence_table({cudf::type_to_id()}, n_cols, row_count{source_size}); for (auto _ : state) { cuda_event_timer raii(state, true); // flush_l2_cache = true, stream = 0 - cudf::scatter(source_table, scatter_map, target_table); + cudf::scatter(*source_table, scatter_map, *target_table); } state.SetBytesProcessed(static_cast(state.iterations()) * state.range(0) * n_cols * 2 * From 9f5c5baa8523a6dd9a34a00828f30ff20676be42 Mon Sep 17 00:00:00 2001 From: Karthikeyan Natarajan Date: Tue, 15 Feb 2022 23:26:52 +0530 Subject: [PATCH 10/24] use cudf::sequence, create_random_null_mask in search bench --- cpp/benchmarks/search/search.cpp | 86 +++++++++++--------------------- 1 file changed, 30 insertions(+), 56 deletions(-) diff --git a/cpp/benchmarks/search/search.cpp b/cpp/benchmarks/search/search.cpp index c3529c7e79c..979b5f86c0c 100644 --- a/cpp/benchmarks/search/search.cpp +++ b/cpp/benchmarks/search/search.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,63 +14,45 @@ * limitations under the License. */ +#include +#include +#include + +#include #include +#include +#include #include #include #include -#include - #include -#include -#include -#include - class Search : public cudf::benchmark { }; -auto make_validity_iter() -{ - static constexpr int r_min = 1; - static constexpr int r_max = 10; - - cudf::test::UniformRandomGenerator rand_gen(r_min, r_max); - uint8_t mod_base = rand_gen.generate(); - return cudf::detail::make_counting_transform_iterator( - 0, [mod_base](auto row) { return (row % mod_base) > 0; }); -} - void BM_column(benchmark::State& state, bool nulls) { const cudf::size_type column_size{(cudf::size_type)state.range(0)}; const cudf::size_type values_size = column_size; - auto col_data_it = cudf::detail::make_counting_transform_iterator( - 0, [=](cudf::size_type row) { return static_cast(row); }); - auto val_data_it = cudf::detail::make_counting_transform_iterator( - 0, [=](cudf::size_type row) { return static_cast(values_size - row); }); - - auto column = [&]() { - return nulls ? cudf::test::fixed_width_column_wrapper( - col_data_it, col_data_it + column_size, make_validity_iter()) - : cudf::test::fixed_width_column_wrapper(col_data_it, - col_data_it + column_size); - }(); - auto values = [&]() { - return nulls ? cudf::test::fixed_width_column_wrapper( - val_data_it, val_data_it + values_size, make_validity_iter()) - : cudf::test::fixed_width_column_wrapper(val_data_it, - val_data_it + values_size); - }(); - - auto data_table = cudf::sort(cudf::table_view({column})); + auto init_data = cudf::make_fixed_width_scalar(static_cast(0)); + auto init_value = cudf::make_fixed_width_scalar(static_cast(values_size)); + auto step = cudf::make_fixed_width_scalar(static_cast(-1)); + auto column = cudf::sequence(column_size, *init_data); + auto values = cudf::sequence(values_size, *init_value, *step); + if (nulls) { + column->set_null_mask(create_random_null_mask(column->size(), 0.1, 1).first); + values->set_null_mask(create_random_null_mask(values->size(), 0.1, 2).first); + } + + auto data_table = cudf::sort(cudf::table_view({*column})); for (auto _ : state) { cuda_event_timer timer(state, true); auto col = cudf::upper_bound(data_table->view(), - cudf::table_view({values}), + cudf::table_view({*values}), {cudf::order::ASCENDING}, {cudf::null_order::BEFORE}); } @@ -145,27 +127,19 @@ void BM_contains(benchmark::State& state, bool nulls) const cudf::size_type column_size{(cudf::size_type)state.range(0)}; const cudf::size_type values_size = column_size; - auto col_data_it = cudf::detail::make_counting_transform_iterator( - 0, [=](cudf::size_type row) { return static_cast(row); }); - auto val_data_it = cudf::detail::make_counting_transform_iterator( - 0, [=](cudf::size_type row) { return static_cast(values_size - row); }); - - auto column = [&]() { - return nulls ? cudf::test::fixed_width_column_wrapper( - col_data_it, col_data_it + column_size, make_validity_iter()) - : cudf::test::fixed_width_column_wrapper(col_data_it, - col_data_it + column_size); - }(); - auto values = [&]() { - return nulls ? cudf::test::fixed_width_column_wrapper( - val_data_it, val_data_it + values_size, make_validity_iter()) - : cudf::test::fixed_width_column_wrapper(val_data_it, - val_data_it + values_size); - }(); + auto init_data = cudf::make_fixed_width_scalar(static_cast(0)); + auto init_value = cudf::make_fixed_width_scalar(static_cast(values_size)); + auto step = cudf::make_fixed_width_scalar(static_cast(-1)); + auto column = cudf::sequence(column_size, *init_data); + auto values = cudf::sequence(values_size, *init_value, *step); + if (nulls) { + column->set_null_mask(create_random_null_mask(column->size(), 0.1, 1).first); + values->set_null_mask(create_random_null_mask(values->size(), 0.1, 2).first); + } for (auto _ : state) { cuda_event_timer timer(state, true); - auto col = cudf::contains(column, values); + auto col = cudf::contains(*column, *values); } } From 67580959ad62705b5506878fe9d717a253dc2d1a Mon Sep 17 00:00:00 2001 From: Karthikeyan Natarajan Date: Tue, 15 Feb 2022 23:31:36 +0530 Subject: [PATCH 11/24] update copyright year --- cpp/benchmarks/common/random_distribution_factory.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/benchmarks/common/random_distribution_factory.hpp b/cpp/benchmarks/common/random_distribution_factory.hpp index c1b0209e638..df2b6e0a754 100644 --- a/cpp/benchmarks/common/random_distribution_factory.hpp +++ b/cpp/benchmarks/common/random_distribution_factory.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 718e269eefcefb57e093c8113e149a3bdf9dd24d Mon Sep 17 00:00:00 2001 From: Karthikeyan Natarajan Date: Tue, 15 Feb 2022 23:57:17 +0530 Subject: [PATCH 12/24] style fix clang format --- cpp/benchmarks/copying/scatter.cu | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cpp/benchmarks/copying/scatter.cu b/cpp/benchmarks/copying/scatter.cu index d682b433ce9..1d423902fd1 100644 --- a/cpp/benchmarks/copying/scatter.cu +++ b/cpp/benchmarks/copying/scatter.cu @@ -41,9 +41,8 @@ void BM_scatter(benchmark::State& state) auto scatter_map = scatter_map_table->get_column(0).mutable_view(); if (coalesce) { - thrust::reverse(thrust::device, - scatter_map.begin(), - scatter_map.end()); + thrust::reverse( + thrust::device, scatter_map.begin(), scatter_map.end()); } else { thrust::shuffle(thrust::device, scatter_map.begin(), From 0ad778edf95c66ae2568a8dc6e69e8de04649207 Mon Sep 17 00:00:00 2001 From: Karthikeyan Natarajan Date: Thu, 17 Feb 2022 18:55:28 +0530 Subject: [PATCH 13/24] address review comments --- cpp/benchmarks/ast/transform.cpp | 6 ++-- cpp/benchmarks/binaryop/binaryop.cpp | 10 +++---- cpp/benchmarks/binaryop/compiled_binaryop.cpp | 2 +- cpp/benchmarks/common/generate_input.cu | 30 +++++++++++-------- cpp/benchmarks/common/generate_input.hpp | 10 ++++--- cpp/benchmarks/copying/scatter.cu | 6 ++-- cpp/benchmarks/search/search.cpp | 14 ++++----- 7 files changed, 41 insertions(+), 37 deletions(-) diff --git a/cpp/benchmarks/ast/transform.cpp b/cpp/benchmarks/ast/transform.cpp index d2ce2204e13..336872a1745 100644 --- a/cpp/benchmarks/ast/transform.cpp +++ b/cpp/benchmarks/ast/transform.cpp @@ -40,11 +40,11 @@ class AST : public cudf::benchmark { template static void BM_ast_transform(benchmark::State& state) { - const cudf::size_type table_size{(cudf::size_type)state.range(0)}; - const cudf::size_type tree_levels = (cudf::size_type)state.range(1); + const auto table_size{static_cast(state.range(0))}; + const auto tree_levels{static_cast(state.range(1))}; // Create table data - auto n_cols = reuse_columns ? 1 : tree_levels + 1; + auto const n_cols = reuse_columns ? 1 : tree_levels + 1; auto source_table = create_sequence_table( {cudf::type_to_id()}, n_cols, row_count{table_size}, Nullable ? 0.5 : -1.0); auto table = source_table->view(); diff --git a/cpp/benchmarks/binaryop/binaryop.cpp b/cpp/benchmarks/binaryop/binaryop.cpp index 1f5823cf842..f0ea6fdb076 100644 --- a/cpp/benchmarks/binaryop/binaryop.cpp +++ b/cpp/benchmarks/binaryop/binaryop.cpp @@ -39,11 +39,11 @@ class BINARYOP : public cudf::benchmark { template static void BM_binaryop_transform(benchmark::State& state) { - const cudf::size_type table_size{(cudf::size_type)state.range(0)}; - const cudf::size_type tree_levels = (cudf::size_type)state.range(1); + const cudf::size_type table_size{static_cast(state.range(0))}; + const cudf::size_type tree_levels{static_cast(state.range(1))}; // Create table data - auto n_cols = reuse_columns ? 1 : tree_levels + 1; + auto const n_cols = reuse_columns ? 1 : tree_levels + 1; auto source_table = create_sequence_table({cudf::type_to_id()}, n_cols, row_count{table_size}); cudf::table_view table{*source_table}; @@ -52,8 +52,8 @@ static void BM_binaryop_transform(benchmark::State& state) for (auto _ : state) { cuda_event_timer raii(state, true); // flush_l2_cache = true, stream = 0 // Execute tree that chains additions like (((a + b) + c) + d) - auto const op = cudf::binary_operator::ADD; - auto result_data_type = cudf::data_type(cudf::type_to_id()); + auto const op = cudf::binary_operator::ADD; + auto const result_data_type = cudf::data_type(cudf::type_to_id()); if (reuse_columns) { auto result = cudf::binary_operation(table.column(0), table.column(0), op, result_data_type); for (cudf::size_type i = 0; i < tree_levels - 1; i++) { diff --git a/cpp/benchmarks/binaryop/compiled_binaryop.cpp b/cpp/benchmarks/binaryop/compiled_binaryop.cpp index f572c12d9ec..4422351483a 100644 --- a/cpp/benchmarks/binaryop/compiled_binaryop.cpp +++ b/cpp/benchmarks/binaryop/compiled_binaryop.cpp @@ -26,7 +26,7 @@ class COMPILED_BINARYOP : public cudf::benchmark { template void BM_compiled_binaryop(benchmark::State& state, cudf::binary_operator binop) { - const cudf::size_type column_size{(cudf::size_type)state.range(0)}; + const auto column_size{static_cast(state.range(0))}; auto source_table = create_sequence_table( {cudf::type_to_id(), cudf::type_to_id()}, 2, row_count{column_size}); diff --git a/cpp/benchmarks/common/generate_input.cu b/cpp/benchmarks/common/generate_input.cu index 467435992e7..4c39b6f2734 100644 --- a/cpp/benchmarks/common/generate_input.cu +++ b/cpp/benchmarks/common/generate_input.cu @@ -573,9 +573,17 @@ std::pair create_random_null_mask(cudf::siz float null_probability, unsigned seed) { - return cudf::detail::valid_if(thrust::make_counting_iterator(0), - thrust::make_counting_iterator(size), - valid_generator{seed, 1.0f - null_probability}); + if (null_probability < 0.0f) { + return {rmm::device_buffer{}, 0}; + } else if (null_probability >= 1.0f or null_probability == 0.0f) { + rmm::device_uvector mask(null_mask_size(size), rmm::cuda_stream_default); + thrust::fill(thrust::device, mask.begin(), mask.end(), null_probability >= 1.0f ? 0 : ~0); + return {mask.release(), size}; + } else { + return cudf::detail::valid_if(thrust::make_counting_iterator(0), + thrust::make_counting_iterator(size), + valid_generator{seed, 1.0f - null_probability}); + } }; using columns_vector = std::vector>; @@ -687,11 +695,9 @@ std::unique_ptr create_sequence_table(std::vector co auto init = cudf::make_default_constructed_scalar(cudf::data_type{dtype_ids[0]}); if (dtype_ids.size() == 1) { std::generate_n(columns.begin(), num_cols, [&]() mutable { - auto col = cudf::sequence(num_rows.count, *init); - if (null_probability >= 0.0) { - auto [mask, count] = create_random_null_mask(num_rows.count, null_probability, seed++); - col->set_null_mask(std::move(mask), count); - } + auto col = cudf::sequence(num_rows.count, *init); + auto [mask, count] = create_random_null_mask(num_rows.count, null_probability, seed++); + col->set_null_mask(std::move(mask), count); return col; }); } else { @@ -701,11 +707,9 @@ std::unique_ptr create_sequence_table(std::vector co [num_rows, &seed, null_probability](auto dtype) mutable { auto init = cudf::make_default_constructed_scalar(cudf::data_type{dtype}); auto col = cudf::sequence(num_rows.count, *init); - if (null_probability >= 0.0) { - auto [mask, count] = - create_random_null_mask(num_rows.count, null_probability, seed++); - col->set_null_mask(std::move(mask), count); - } + auto [mask, count] = + create_random_null_mask(num_rows.count, null_probability, seed++); + col->set_null_mask(std::move(mask), count); return col; }); } diff --git a/cpp/benchmarks/common/generate_input.hpp b/cpp/benchmarks/common/generate_input.hpp index 46928e8b7fb..daebc9fef6a 100644 --- a/cpp/benchmarks/common/generate_input.hpp +++ b/cpp/benchmarks/common/generate_input.hpp @@ -408,13 +408,14 @@ std::unique_ptr create_random_table(std::vector cons * @brief Generate sequence columns starting with value 0 in first row and increasing by 1 in * subsequent rows. * - * If the number of passed types is smaller than the number of requested column, the columns types - * with be repeated in round-robin order to fill the table. + * If the number of passed types is smaller than the number of requested columns, the types + * will be repeated cyclically to fill the number of requested columns. * * @param dtype_ids Vector of requested column types * @param num_cols Number of columns in the output table * @param num_rows Number of rows in the output table - * @param null_probability optional, probability of a null value, <0 implies no null mask. + * @param null_probability optional, probability of a null value + <0 implies no null mask, =0 implies all valids, >=1 implies all nulls * @param seed optional, seed for the pseudo-random engine * @return A table with the sequence columns. */ @@ -429,8 +430,9 @@ std::unique_ptr create_sequence_table(std::vector co * * @param size number of rows * @param null_probability probability of a null value + <0 implies no null mask, =0 implies all valids, >=1 implies all nulls * @param seed optional, seed for the pseudo-random engine - * @return null mask device buffer with random null mask data + * @return null mask device buffer with random null mask data and null count */ std::pair create_random_null_mask(cudf::size_type size, float null_probability, diff --git a/cpp/benchmarks/copying/scatter.cu b/cpp/benchmarks/copying/scatter.cu index 1d423902fd1..08acdf8b924 100644 --- a/cpp/benchmarks/copying/scatter.cu +++ b/cpp/benchmarks/copying/scatter.cu @@ -24,16 +24,14 @@ #include #include -#include - class Scatter : public cudf::benchmark { }; template void BM_scatter(benchmark::State& state) { - const cudf::size_type source_size{(cudf::size_type)state.range(0)}; - const auto n_cols = (cudf::size_type)state.range(1); + auto const source_size{static_cast(state.range(0))}; + auto const n_cols{static_cast(state.range(1))}; // Gather indices auto scatter_map_table = diff --git a/cpp/benchmarks/search/search.cpp b/cpp/benchmarks/search/search.cpp index 979b5f86c0c..d8d5700c94a 100644 --- a/cpp/benchmarks/search/search.cpp +++ b/cpp/benchmarks/search/search.cpp @@ -34,8 +34,8 @@ class Search : public cudf::benchmark { void BM_column(benchmark::State& state, bool nulls) { - const cudf::size_type column_size{(cudf::size_type)state.range(0)}; - const cudf::size_type values_size = column_size; + const auto column_size{static_cast(state.range(0))}; + const auto values_size = column_size; auto init_data = cudf::make_fixed_width_scalar(static_cast(0)); auto init_value = cudf::make_fixed_width_scalar(static_cast(values_size)); @@ -75,9 +75,9 @@ void BM_table(benchmark::State& state) { using wrapper = cudf::test::fixed_width_column_wrapper; - const cudf::size_type num_columns{(cudf::size_type)state.range(0)}; - const cudf::size_type column_size{(cudf::size_type)state.range(1)}; - const cudf::size_type values_size = column_size; + const auto num_columns{static_cast(state.range(0))}; + const auto column_size{static_cast(state.range(1))}; + const auto values_size = column_size; auto make_table = [&](cudf::size_type col_size) { cudf::test::UniformRandomGenerator random_gen(0, 100); @@ -124,8 +124,8 @@ BENCHMARK_REGISTER_F(Search, Table) void BM_contains(benchmark::State& state, bool nulls) { - const cudf::size_type column_size{(cudf::size_type)state.range(0)}; - const cudf::size_type values_size = column_size; + auto const column_size{static_cast(state.range(0))}; + auto const values_size = column_size; auto init_data = cudf::make_fixed_width_scalar(static_cast(0)); auto init_value = cudf::make_fixed_width_scalar(static_cast(values_size)); From bda1f6c9d2b7065c951481d7213dc05d9388363b Mon Sep 17 00:00:00 2001 From: Karthikeyan Natarajan Date: Sat, 19 Feb 2022 05:52:23 +0530 Subject: [PATCH 14/24] const auto to auto const --- cpp/benchmarks/ast/transform.cpp | 8 ++++---- cpp/benchmarks/binaryop/binaryop.cpp | 6 +++--- cpp/benchmarks/binaryop/compiled_binaryop.cpp | 4 ++-- cpp/benchmarks/join/join_common.hpp | 4 ++-- cpp/benchmarks/search/search.cpp | 10 +++++----- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/cpp/benchmarks/ast/transform.cpp b/cpp/benchmarks/ast/transform.cpp index 336872a1745..55292f41fa7 100644 --- a/cpp/benchmarks/ast/transform.cpp +++ b/cpp/benchmarks/ast/transform.cpp @@ -40,12 +40,12 @@ class AST : public cudf::benchmark { template static void BM_ast_transform(benchmark::State& state) { - const auto table_size{static_cast(state.range(0))}; - const auto tree_levels{static_cast(state.range(1))}; + auto const table_size{static_cast(state.range(0))}; + auto const tree_levels{static_cast(state.range(1))}; // Create table data - auto const n_cols = reuse_columns ? 1 : tree_levels + 1; - auto source_table = create_sequence_table( + auto const n_cols = reuse_columns ? 1 : tree_levels + 1; + auto const source_table = create_sequence_table( {cudf::type_to_id()}, n_cols, row_count{table_size}, Nullable ? 0.5 : -1.0); auto table = source_table->view(); diff --git a/cpp/benchmarks/binaryop/binaryop.cpp b/cpp/benchmarks/binaryop/binaryop.cpp index f0ea6fdb076..94b3c1ea964 100644 --- a/cpp/benchmarks/binaryop/binaryop.cpp +++ b/cpp/benchmarks/binaryop/binaryop.cpp @@ -39,12 +39,12 @@ class BINARYOP : public cudf::benchmark { template static void BM_binaryop_transform(benchmark::State& state) { - const cudf::size_type table_size{static_cast(state.range(0))}; - const cudf::size_type tree_levels{static_cast(state.range(1))}; + auto const table_size{static_cast(state.range(0))}; + auto const tree_levels{static_cast(state.range(1))}; // Create table data auto const n_cols = reuse_columns ? 1 : tree_levels + 1; - auto source_table = + auto const source_table = create_sequence_table({cudf::type_to_id()}, n_cols, row_count{table_size}); cudf::table_view table{*source_table}; diff --git a/cpp/benchmarks/binaryop/compiled_binaryop.cpp b/cpp/benchmarks/binaryop/compiled_binaryop.cpp index 4422351483a..5703b29d7db 100644 --- a/cpp/benchmarks/binaryop/compiled_binaryop.cpp +++ b/cpp/benchmarks/binaryop/compiled_binaryop.cpp @@ -26,9 +26,9 @@ class COMPILED_BINARYOP : public cudf::benchmark { template void BM_compiled_binaryop(benchmark::State& state, cudf::binary_operator binop) { - const auto column_size{static_cast(state.range(0))}; + auto const column_size{static_cast(state.range(0))}; - auto source_table = create_sequence_table( + auto const source_table = create_sequence_table( {cudf::type_to_id(), cudf::type_to_id()}, 2, row_count{column_size}); auto lhs = cudf::column_view(source_table->get_column(0)); diff --git a/cpp/benchmarks/join/join_common.hpp b/cpp/benchmarks/join/join_common.hpp index f2b9cb1bdb9..c1957db7929 100644 --- a/cpp/benchmarks/join/join_common.hpp +++ b/cpp/benchmarks/join/join_common.hpp @@ -147,8 +147,8 @@ static void BM_join(state_type& state, Join JoinFunc) // Benchmark conditional join if constexpr (std::is_same_v and is_conditional) { // Common column references. - const auto col_ref_left_0 = cudf::ast::column_reference(0); - const auto col_ref_right_0 = cudf::ast::column_reference(0, cudf::ast::table_reference::RIGHT); + auto const col_ref_left_0 = cudf::ast::column_reference(0); + auto const col_ref_right_0 = cudf::ast::column_reference(0, cudf::ast::table_reference::RIGHT); auto left_zero_eq_right_zero = cudf::ast::operation(cudf::ast::ast_operator::EQUAL, col_ref_left_0, col_ref_right_0); diff --git a/cpp/benchmarks/search/search.cpp b/cpp/benchmarks/search/search.cpp index d8d5700c94a..ed3114a64a8 100644 --- a/cpp/benchmarks/search/search.cpp +++ b/cpp/benchmarks/search/search.cpp @@ -34,8 +34,8 @@ class Search : public cudf::benchmark { void BM_column(benchmark::State& state, bool nulls) { - const auto column_size{static_cast(state.range(0))}; - const auto values_size = column_size; + auto const column_size{static_cast(state.range(0))}; + auto const values_size = column_size; auto init_data = cudf::make_fixed_width_scalar(static_cast(0)); auto init_value = cudf::make_fixed_width_scalar(static_cast(values_size)); @@ -75,9 +75,9 @@ void BM_table(benchmark::State& state) { using wrapper = cudf::test::fixed_width_column_wrapper; - const auto num_columns{static_cast(state.range(0))}; - const auto column_size{static_cast(state.range(1))}; - const auto values_size = column_size; + auto const num_columns{static_cast(state.range(0))}; + auto const column_size{static_cast(state.range(1))}; + auto const values_size = column_size; auto make_table = [&](cudf::size_type col_size) { cudf::test::UniformRandomGenerator random_gen(0, 100); From d568d09ff116a6f0ec9c109da80ce9d6f6a59ae8 Mon Sep 17 00:00:00 2001 From: Karthikeyan Natarajan Date: Sat, 19 Feb 2022 06:05:56 +0530 Subject: [PATCH 15/24] address review comments --- cpp/benchmarks/common/generate_input.cu | 8 +++++--- cpp/benchmarks/common/generate_input.hpp | 9 +++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/cpp/benchmarks/common/generate_input.cu b/cpp/benchmarks/common/generate_input.cu index 4c39b6f2734..2275fde6b35 100644 --- a/cpp/benchmarks/common/generate_input.cu +++ b/cpp/benchmarks/common/generate_input.cu @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -576,9 +577,10 @@ std::pair create_random_null_mask(cudf::siz if (null_probability < 0.0f) { return {rmm::device_buffer{}, 0}; } else if (null_probability >= 1.0f or null_probability == 0.0f) { - rmm::device_uvector mask(null_mask_size(size), rmm::cuda_stream_default); - thrust::fill(thrust::device, mask.begin(), mask.end(), null_probability >= 1.0f ? 0 : ~0); - return {mask.release(), size}; + return { + cudf::create_null_mask( + size, null_probability >= 1.0f ? cudf::mask_state::ALL_VALID : cudf::mask_state::ALL_NULL), + null_probability >= 1.0f ? size : 0}; } else { return cudf::detail::valid_if(thrust::make_counting_iterator(0), thrust::make_counting_iterator(size), diff --git a/cpp/benchmarks/common/generate_input.hpp b/cpp/benchmarks/common/generate_input.hpp index daebc9fef6a..61e4746bc9b 100644 --- a/cpp/benchmarks/common/generate_input.hpp +++ b/cpp/benchmarks/common/generate_input.hpp @@ -19,6 +19,7 @@ #include #include +#include #include /** @@ -411,15 +412,15 @@ std::unique_ptr create_random_table(std::vector cons * If the number of passed types is smaller than the number of requested columns, the types * will be repeated cyclically to fill the number of requested columns. * - * @param dtype_ids Vector of requested column types + * @param dtype_ids Span of requested column types * @param num_cols Number of columns in the output table * @param num_rows Number of rows in the output table * @param null_probability optional, probability of a null value - <0 implies no null mask, =0 implies all valids, >=1 implies all nulls + * <0 implies no null mask, =0 implies all valids, >=1 implies all nulls * @param seed optional, seed for the pseudo-random engine * @return A table with the sequence columns. */ -std::unique_ptr create_sequence_table(std::vector const& dtype_ids, +std::unique_ptr create_sequence_table(cudf::host_span const& dtype_ids, cudf::size_type num_cols, row_count num_rows, float null_probability = -1.0, @@ -430,7 +431,7 @@ std::unique_ptr create_sequence_table(std::vector co * * @param size number of rows * @param null_probability probability of a null value - <0 implies no null mask, =0 implies all valids, >=1 implies all nulls + * <0 implies no null mask, =0 implies all valids, >=1 implies all nulls * @param seed optional, seed for the pseudo-random engine * @return null mask device buffer with random null mask data and null count */ From 993c85dc2f60fe9197c85872f7a3e385bb163685 Mon Sep 17 00:00:00 2001 From: Karthikeyan Natarajan Date: Mon, 21 Feb 2022 19:46:08 +0530 Subject: [PATCH 16/24] reduce code duplication --- cpp/benchmarks/common/generate_input.cu | 36 +++++++++++------------- cpp/benchmarks/common/generate_input.hpp | 2 +- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/cpp/benchmarks/common/generate_input.cu b/cpp/benchmarks/common/generate_input.cu index 2275fde6b35..892a433dfbe 100644 --- a/cpp/benchmarks/common/generate_input.cu +++ b/cpp/benchmarks/common/generate_input.cu @@ -692,28 +692,24 @@ std::unique_ptr create_sequence_table(std::vector co float null_probability, unsigned seed) { - auto const out_dtype_ids = repeat_dtypes(dtype_ids, num_cols); - auto columns = std::vector>(num_cols); - auto init = cudf::make_default_constructed_scalar(cudf::data_type{dtype_ids[0]}); + auto const out_dtype_ids = repeat_dtypes(dtype_ids, num_cols); + auto columns = std::vector>(num_cols); + auto create_sequence_column = [&](auto const& init) mutable { + auto col = cudf::sequence(num_rows.count, init); + auto [mask, count] = create_random_null_mask(num_rows.count, null_probability, seed++); + col->set_null_mask(std::move(mask), count); + return col; + }; if (dtype_ids.size() == 1) { - std::generate_n(columns.begin(), num_cols, [&]() mutable { - auto col = cudf::sequence(num_rows.count, *init); - auto [mask, count] = create_random_null_mask(num_rows.count, null_probability, seed++); - col->set_null_mask(std::move(mask), count); - return col; - }); + auto init = cudf::make_default_constructed_scalar(cudf::data_type{dtype_ids[0]}); + std::generate_n( + columns.begin(), num_cols, [&]() mutable { return create_sequence_column(*init); }); } else { - std::transform(out_dtype_ids.begin(), - out_dtype_ids.end(), - columns.begin(), - [num_rows, &seed, null_probability](auto dtype) mutable { - auto init = cudf::make_default_constructed_scalar(cudf::data_type{dtype}); - auto col = cudf::sequence(num_rows.count, *init); - auto [mask, count] = - create_random_null_mask(num_rows.count, null_probability, seed++); - col->set_null_mask(std::move(mask), count); - return col; - }); + std::transform( + out_dtype_ids.begin(), out_dtype_ids.end(), columns.begin(), [&](auto dtype) mutable { + auto init = cudf::make_default_constructed_scalar(cudf::data_type{dtype}); + return create_sequence_column(*init); + }); } return std::make_unique(std::move(columns)); } diff --git a/cpp/benchmarks/common/generate_input.hpp b/cpp/benchmarks/common/generate_input.hpp index 61e4746bc9b..f2127807200 100644 --- a/cpp/benchmarks/common/generate_input.hpp +++ b/cpp/benchmarks/common/generate_input.hpp @@ -420,7 +420,7 @@ std::unique_ptr create_random_table(std::vector cons * @param seed optional, seed for the pseudo-random engine * @return A table with the sequence columns. */ -std::unique_ptr create_sequence_table(cudf::host_span const& dtype_ids, +std::unique_ptr create_sequence_table(std::vector const& dtype_ids, cudf::size_type num_cols, row_count num_rows, float null_probability = -1.0, From 02ef0d278f60f6521997dc01460ed78c990fbd29 Mon Sep 17 00:00:00 2001 From: Karthikeyan Natarajan Date: Wed, 23 Feb 2022 01:30:57 +0530 Subject: [PATCH 17/24] Revert "rename generate_input.cpp to generate_input.cu" seperate nullmask generator code This reverts commit 916ce009ea088bafae083ababeaf080a81f565ce. --- cpp/benchmarks/CMakeLists.txt | 7 +- .../{generate_input.cu => generate_input.cpp} | 42 ------------ cpp/benchmarks/common/generate_nullmask.cu | 64 +++++++++++++++++++ 3 files changed, 65 insertions(+), 48 deletions(-) rename cpp/benchmarks/common/{generate_input.cu => generate_input.cpp} (95%) create mode 100644 cpp/benchmarks/common/generate_nullmask.cu diff --git a/cpp/benchmarks/CMakeLists.txt b/cpp/benchmarks/CMakeLists.txt index d010ca3f20d..99aeff0df93 100644 --- a/cpp/benchmarks/CMakeLists.txt +++ b/cpp/benchmarks/CMakeLists.txt @@ -14,12 +14,7 @@ find_package(Threads REQUIRED) -add_library(cudf_datagen STATIC common/generate_input.cu) -set_property( - SOURCE common/generate_input.cu - APPEND - PROPERTY COMPILE_FLAGS "-Xcompiler=-std=gnu++17" -) +add_library(cudf_datagen STATIC common/generate_input.cpp common/generate_nullmask.cu) target_compile_features(cudf_datagen PUBLIC cxx_std_17 cuda_std_17) target_compile_options( diff --git a/cpp/benchmarks/common/generate_input.cu b/cpp/benchmarks/common/generate_input.cpp similarity index 95% rename from cpp/benchmarks/common/generate_input.cu rename to cpp/benchmarks/common/generate_input.cpp index 892a433dfbe..e2c9fc38e28 100644 --- a/cpp/benchmarks/common/generate_input.cu +++ b/cpp/benchmarks/common/generate_input.cpp @@ -19,9 +19,7 @@ #include #include -#include #include -#include #include #include #include @@ -29,8 +27,6 @@ #include #include -#include - #include #include #include @@ -550,44 +546,6 @@ std::unique_ptr create_random_column(data_profile return list_column; // return the top-level column } -struct valid_generator { - thrust::minstd_rand engine; - thrust::uniform_real_distribution dist; - float valid_prob; - valid_generator(thrust::minstd_rand engine, float valid_probability) - : engine(engine), dist{0, 1}, valid_prob{valid_probability} - { - } - valid_generator(unsigned seed, float valid_probability) - : engine(seed), dist{0, 1}, valid_prob{valid_probability} - { - } - - __device__ bool operator()(size_t n) - { - engine.discard(n); - return dist(engine) < valid_prob; - } -}; - -std::pair create_random_null_mask(cudf::size_type size, - float null_probability, - unsigned seed) -{ - if (null_probability < 0.0f) { - return {rmm::device_buffer{}, 0}; - } else if (null_probability >= 1.0f or null_probability == 0.0f) { - return { - cudf::create_null_mask( - size, null_probability >= 1.0f ? cudf::mask_state::ALL_VALID : cudf::mask_state::ALL_NULL), - null_probability >= 1.0f ? size : 0}; - } else { - return cudf::detail::valid_if(thrust::make_counting_iterator(0), - thrust::make_counting_iterator(size), - valid_generator{seed, 1.0f - null_probability}); - } -}; - using columns_vector = std::vector>; /** diff --git a/cpp/benchmarks/common/generate_nullmask.cu b/cpp/benchmarks/common/generate_nullmask.cu new file mode 100644 index 00000000000..6fef3c8d6ba --- /dev/null +++ b/cpp/benchmarks/common/generate_nullmask.cu @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2022, 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 "generate_input.hpp" + +#include +#include + +#include + +/** + * @brief valid bit generator with given probability [0.0 - 1.0] + * + */ +struct valid_generator { + thrust::minstd_rand engine; + thrust::uniform_real_distribution dist; + float valid_prob; + valid_generator(thrust::minstd_rand engine, float valid_probability) + : engine(engine), dist{0, 1}, valid_prob{valid_probability} + { + } + valid_generator(unsigned seed, float valid_probability) + : engine(seed), dist{0, 1}, valid_prob{valid_probability} + { + } + + __device__ bool operator()(size_t n) + { + engine.discard(n); + return dist(engine) < valid_prob; + } +}; + +std::pair create_random_null_mask(cudf::size_type size, + float null_probability, + unsigned seed) +{ + if (null_probability < 0.0f) { + return {rmm::device_buffer{}, 0}; + } else if (null_probability >= 1.0f or null_probability == 0.0f) { + return { + cudf::create_null_mask( + size, null_probability >= 1.0f ? cudf::mask_state::ALL_VALID : cudf::mask_state::ALL_NULL), + null_probability >= 1.0f ? size : 0}; + } else { + return cudf::detail::valid_if(thrust::make_counting_iterator(0), + thrust::make_counting_iterator(size), + valid_generator{seed, 1.0f - null_probability}); + } +}; From 820b417991f9972f5632b857a6a9562a7ff586d7 Mon Sep 17 00:00:00 2001 From: Karthikeyan Natarajan Date: Thu, 24 Feb 2022 21:10:28 +0530 Subject: [PATCH 18/24] rename generator functor --- cpp/benchmarks/common/generate_nullmask.cu | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/cpp/benchmarks/common/generate_nullmask.cu b/cpp/benchmarks/common/generate_nullmask.cu index 6fef3c8d6ba..d507abb9245 100644 --- a/cpp/benchmarks/common/generate_nullmask.cu +++ b/cpp/benchmarks/common/generate_nullmask.cu @@ -22,26 +22,26 @@ #include /** - * @brief valid bit generator with given probability [0.0 - 1.0] + * @brief bool generator with given probability [0.0 - 1.0] of returning true. * */ -struct valid_generator { +struct bool_generator { thrust::minstd_rand engine; thrust::uniform_real_distribution dist; - float valid_prob; - valid_generator(thrust::minstd_rand engine, float valid_probability) - : engine(engine), dist{0, 1}, valid_prob{valid_probability} + float probability_true; + bool_generator(thrust::minstd_rand engine, float probability_true) + : engine(engine), dist{0, 1}, probability_true{probability_true} { } - valid_generator(unsigned seed, float valid_probability) - : engine(seed), dist{0, 1}, valid_prob{valid_probability} + bool_generator(unsigned seed, float valid_probability) + : engine(seed), dist{0, 1}, probability_true{valid_probability} { } __device__ bool operator()(size_t n) { engine.discard(n); - return dist(engine) < valid_prob; + return dist(engine) < probability_true; } }; @@ -59,6 +59,6 @@ std::pair create_random_null_mask(cudf::siz } else { return cudf::detail::valid_if(thrust::make_counting_iterator(0), thrust::make_counting_iterator(size), - valid_generator{seed, 1.0f - null_probability}); + bool_generator{seed, 1.0f - null_probability}); } }; From 9028a80cd9247161bdc2e2df18cd92eff11d9f15 Mon Sep 17 00:00:00 2001 From: Karthikeyan Natarajan Date: Thu, 24 Feb 2022 22:26:03 +0530 Subject: [PATCH 19/24] simplify create null mask --- cpp/benchmarks/common/generate_nullmask.cu | 9 ++++----- cpp/benchmarks/search/search.cpp | 6 ++++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cpp/benchmarks/common/generate_nullmask.cu b/cpp/benchmarks/common/generate_nullmask.cu index d507abb9245..5b343c47e80 100644 --- a/cpp/benchmarks/common/generate_nullmask.cu +++ b/cpp/benchmarks/common/generate_nullmask.cu @@ -51,11 +51,10 @@ std::pair create_random_null_mask(cudf::siz { if (null_probability < 0.0f) { return {rmm::device_buffer{}, 0}; - } else if (null_probability >= 1.0f or null_probability == 0.0f) { - return { - cudf::create_null_mask( - size, null_probability >= 1.0f ? cudf::mask_state::ALL_VALID : cudf::mask_state::ALL_NULL), - null_probability >= 1.0f ? size : 0}; + } else if (null_probability == 0.0f) { + return {cudf::create_null_mask(size, cudf::mask_state::ALL_NULL), size}; + } else if (null_probability >= 1.0f) { + return {cudf::create_null_mask(size, cudf::mask_state::ALL_VALID), 0}; } else { return cudf::detail::valid_if(thrust::make_counting_iterator(0), thrust::make_counting_iterator(size), diff --git a/cpp/benchmarks/search/search.cpp b/cpp/benchmarks/search/search.cpp index ed3114a64a8..c2288c621dd 100644 --- a/cpp/benchmarks/search/search.cpp +++ b/cpp/benchmarks/search/search.cpp @@ -43,8 +43,10 @@ void BM_column(benchmark::State& state, bool nulls) auto column = cudf::sequence(column_size, *init_data); auto values = cudf::sequence(values_size, *init_value, *step); if (nulls) { - column->set_null_mask(create_random_null_mask(column->size(), 0.1, 1).first); - values->set_null_mask(create_random_null_mask(values->size(), 0.1, 2).first); + auto [column_null_mask, column_null_count] = create_random_null_mask(column->size(), 0.1, 1); + column->set_null_mask(std::move(column_null_mask), column_null_count); + auto [values_null_mask, values_null_count] = create_random_null_mask(values->size(), 0.1, 2); + values->set_null_mask(std::move(values_null_mask), values_null_count); } auto data_table = cudf::sort(cudf::table_view({*column})); From 4f1f3e8f85c007f1b724db78313db9081863b47c Mon Sep 17 00:00:00 2001 From: Karthikeyan Natarajan Date: Thu, 24 Feb 2022 22:39:52 +0530 Subject: [PATCH 20/24] rename repeat_dtypes to cycle_dtypes --- cpp/benchmarks/common/generate_input.cpp | 12 ++++++------ cpp/benchmarks/common/generate_input.hpp | 10 ++++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/cpp/benchmarks/common/generate_input.cpp b/cpp/benchmarks/common/generate_input.cpp index e2c9fc38e28..9cefec96109 100644 --- a/cpp/benchmarks/common/generate_input.cpp +++ b/cpp/benchmarks/common/generate_input.cpp @@ -573,11 +573,11 @@ columns_vector create_random_columns(data_profile const& profile, } /** - * @brief Repeats the input data types in round-robin order to fill a vector of @ref num_cols + * @brief Repeats the input data types cyclically order to fill a vector of @ref num_cols * elements. */ -std::vector repeat_dtypes(std::vector const& dtype_ids, - cudf::size_type num_cols) +std::vector cycle_dtypes(std::vector const& dtype_ids, + cudf::size_type num_cols) { if (dtype_ids.size() == static_cast(num_cols)) { return dtype_ids; } std::vector out_dtypes; @@ -593,7 +593,7 @@ std::unique_ptr create_random_table(std::vector cons data_profile const& profile, unsigned seed) { - auto const out_dtype_ids = repeat_dtypes(dtype_ids, num_cols); + auto const out_dtype_ids = cycle_dtypes(dtype_ids, num_cols); size_t const avg_row_bytes = std::accumulate(out_dtype_ids.begin(), out_dtype_ids.end(), 0ul, [&](size_t sum, auto tid) { return sum + avg_element_size(profile, cudf::data_type(tid)); @@ -609,7 +609,7 @@ std::unique_ptr create_random_table(std::vector cons data_profile const& profile, unsigned seed) { - auto const out_dtype_ids = repeat_dtypes(dtype_ids, num_cols); + auto const out_dtype_ids = cycle_dtypes(dtype_ids, num_cols); auto seed_engine = deterministic_engine(seed); auto const processor_count = std::thread::hardware_concurrency(); @@ -650,7 +650,7 @@ std::unique_ptr create_sequence_table(std::vector co float null_probability, unsigned seed) { - auto const out_dtype_ids = repeat_dtypes(dtype_ids, num_cols); + auto const out_dtype_ids = cycle_dtypes(dtype_ids, num_cols); auto columns = std::vector>(num_cols); auto create_sequence_column = [&](auto const& init) mutable { auto col = cudf::sequence(num_rows.count, init); diff --git a/cpp/benchmarks/common/generate_input.hpp b/cpp/benchmarks/common/generate_input.hpp index 9e4436546db..176b9cf1fdd 100644 --- a/cpp/benchmarks/common/generate_input.hpp +++ b/cpp/benchmarks/common/generate_input.hpp @@ -425,6 +425,16 @@ std::unique_ptr create_sequence_table(std::vector co float null_probability = -1.0, unsigned seed = 1); +/** + * @brief Repeats the input data types cyclically to fill a vector of @ref num_cols + * elements. + * + * @param dtype_ids Vector of requested column types + * @param num_cols Number of types in the output vector + * @return A vector of type_ids + */ +std::vector cycle_dtypes(std::vector const& dtype_ids, + cudf::size_type num_cols); /** * @brief Create a random null mask object * From b31de3ab8869156a5b86bc22da92f8e53315c6bc Mon Sep 17 00:00:00 2001 From: Karthikeyan Natarajan Date: Thu, 24 Feb 2022 23:11:25 +0530 Subject: [PATCH 21/24] move cycle_dtypes out for create_sequence_table --- cpp/benchmarks/ast/transform.cpp | 8 ++++--- cpp/benchmarks/binaryop/binaryop.cpp | 6 ++--- cpp/benchmarks/binaryop/compiled_binaryop.cpp | 2 +- cpp/benchmarks/common/generate_input.cpp | 22 +++++-------------- cpp/benchmarks/common/generate_input.hpp | 7 +----- cpp/benchmarks/copying/scatter.cu | 10 ++++----- 6 files changed, 20 insertions(+), 35 deletions(-) diff --git a/cpp/benchmarks/ast/transform.cpp b/cpp/benchmarks/ast/transform.cpp index 55292f41fa7..de0429f74ad 100644 --- a/cpp/benchmarks/ast/transform.cpp +++ b/cpp/benchmarks/ast/transform.cpp @@ -44,9 +44,11 @@ static void BM_ast_transform(benchmark::State& state) auto const tree_levels{static_cast(state.range(1))}; // Create table data - auto const n_cols = reuse_columns ? 1 : tree_levels + 1; - auto const source_table = create_sequence_table( - {cudf::type_to_id()}, n_cols, row_count{table_size}, Nullable ? 0.5 : -1.0); + auto const n_cols = reuse_columns ? 1 : tree_levels + 1; + auto const source_table = + create_sequence_table(cycle_dtypes({cudf::type_to_id()}, n_cols), + row_count{table_size}, + Nullable ? 0.5 : -1.0); auto table = source_table->view(); // Create column references diff --git a/cpp/benchmarks/binaryop/binaryop.cpp b/cpp/benchmarks/binaryop/binaryop.cpp index 94b3c1ea964..e5bde94f1f9 100644 --- a/cpp/benchmarks/binaryop/binaryop.cpp +++ b/cpp/benchmarks/binaryop/binaryop.cpp @@ -43,9 +43,9 @@ static void BM_binaryop_transform(benchmark::State& state) auto const tree_levels{static_cast(state.range(1))}; // Create table data - auto const n_cols = reuse_columns ? 1 : tree_levels + 1; - auto const source_table = - create_sequence_table({cudf::type_to_id()}, n_cols, row_count{table_size}); + auto const n_cols = reuse_columns ? 1 : tree_levels + 1; + auto const source_table = create_sequence_table( + cycle_dtypes({cudf::type_to_id()}, n_cols), row_count{table_size}); cudf::table_view table{*source_table}; // Execute benchmark diff --git a/cpp/benchmarks/binaryop/compiled_binaryop.cpp b/cpp/benchmarks/binaryop/compiled_binaryop.cpp index 5703b29d7db..50cd0b7b8d5 100644 --- a/cpp/benchmarks/binaryop/compiled_binaryop.cpp +++ b/cpp/benchmarks/binaryop/compiled_binaryop.cpp @@ -29,7 +29,7 @@ void BM_compiled_binaryop(benchmark::State& state, cudf::binary_operator binop) auto const column_size{static_cast(state.range(0))}; auto const source_table = create_sequence_table( - {cudf::type_to_id(), cudf::type_to_id()}, 2, row_count{column_size}); + {cudf::type_to_id(), cudf::type_to_id()}, row_count{column_size}); auto lhs = cudf::column_view(source_table->get_column(0)); auto rhs = cudf::column_view(source_table->get_column(1)); diff --git a/cpp/benchmarks/common/generate_input.cpp b/cpp/benchmarks/common/generate_input.cpp index 9cefec96109..a22a19163d9 100644 --- a/cpp/benchmarks/common/generate_input.cpp +++ b/cpp/benchmarks/common/generate_input.cpp @@ -645,30 +645,18 @@ std::unique_ptr create_random_table(std::vector cons } std::unique_ptr create_sequence_table(std::vector const& dtype_ids, - cudf::size_type num_cols, row_count num_rows, float null_probability, unsigned seed) { - auto const out_dtype_ids = cycle_dtypes(dtype_ids, num_cols); - auto columns = std::vector>(num_cols); - auto create_sequence_column = [&](auto const& init) mutable { - auto col = cudf::sequence(num_rows.count, init); + auto columns = std::vector>(dtype_ids.size()); + std::transform(dtype_ids.begin(), dtype_ids.end(), columns.begin(), [&](auto dtype) mutable { + auto init = cudf::make_default_constructed_scalar(cudf::data_type{dtype}); + auto col = cudf::sequence(num_rows.count, *init); auto [mask, count] = create_random_null_mask(num_rows.count, null_probability, seed++); col->set_null_mask(std::move(mask), count); return col; - }; - if (dtype_ids.size() == 1) { - auto init = cudf::make_default_constructed_scalar(cudf::data_type{dtype_ids[0]}); - std::generate_n( - columns.begin(), num_cols, [&]() mutable { return create_sequence_column(*init); }); - } else { - std::transform( - out_dtype_ids.begin(), out_dtype_ids.end(), columns.begin(), [&](auto dtype) mutable { - auto init = cudf::make_default_constructed_scalar(cudf::data_type{dtype}); - return create_sequence_column(*init); - }); - } + }); return std::make_unique(std::move(columns)); } diff --git a/cpp/benchmarks/common/generate_input.hpp b/cpp/benchmarks/common/generate_input.hpp index 176b9cf1fdd..4825713ba76 100644 --- a/cpp/benchmarks/common/generate_input.hpp +++ b/cpp/benchmarks/common/generate_input.hpp @@ -408,11 +408,7 @@ std::unique_ptr create_random_table(std::vector cons * @brief Generate sequence columns starting with value 0 in first row and increasing by 1 in * subsequent rows. * - * If the number of passed types is smaller than the number of requested columns, the types - * will be repeated cyclically to fill the number of requested columns. - * - * @param dtype_ids Span of requested column types - * @param num_cols Number of columns in the output table + * @param dtype_ids Vector of requested column types * @param num_rows Number of rows in the output table * @param null_probability optional, probability of a null value * <0 implies no null mask, =0 implies all valids, >=1 implies all nulls @@ -420,7 +416,6 @@ std::unique_ptr create_random_table(std::vector cons * @return A table with the sequence columns. */ std::unique_ptr create_sequence_table(std::vector const& dtype_ids, - cudf::size_type num_cols, row_count num_rows, float null_probability = -1.0, unsigned seed = 1); diff --git a/cpp/benchmarks/copying/scatter.cu b/cpp/benchmarks/copying/scatter.cu index 08acdf8b924..977937beaa2 100644 --- a/cpp/benchmarks/copying/scatter.cu +++ b/cpp/benchmarks/copying/scatter.cu @@ -35,7 +35,7 @@ void BM_scatter(benchmark::State& state) // Gather indices auto scatter_map_table = - create_sequence_table({cudf::type_to_id()}, 1, row_count{source_size}); + create_sequence_table({cudf::type_to_id()}, row_count{source_size}); auto scatter_map = scatter_map_table->get_column(0).mutable_view(); if (coalesce) { @@ -49,10 +49,10 @@ void BM_scatter(benchmark::State& state) } // Every element is valid - auto source_table = - create_sequence_table({cudf::type_to_id()}, n_cols, row_count{source_size}); - auto target_table = - create_sequence_table({cudf::type_to_id()}, n_cols, row_count{source_size}); + auto source_table = create_sequence_table(cycle_dtypes({cudf::type_to_id()}, n_cols), + row_count{source_size}); + auto target_table = create_sequence_table(cycle_dtypes({cudf::type_to_id()}, n_cols), + row_count{source_size}); for (auto _ : state) { cuda_event_timer raii(state, true); // flush_l2_cache = true, stream = 0 From 1d4d57a8f4e7a869f9c6cefa2d6e04a464edb2d2 Mon Sep 17 00:00:00 2001 From: Karthikeyan Natarajan Date: Thu, 24 Feb 2022 23:57:13 +0530 Subject: [PATCH 22/24] move cycle_dtypes out of create_random_table --- cpp/benchmarks/common/generate_input.cpp | 15 ++++++--------- cpp/benchmarks/common/generate_input.hpp | 10 ---------- cpp/benchmarks/copying/copy_if_else.cpp | 4 ++-- cpp/benchmarks/groupby/group_struct.cu | 17 +++++------------ cpp/benchmarks/hashing/hash.cpp | 4 ++-- cpp/benchmarks/io/csv/csv_reader.cpp | 7 ++++--- cpp/benchmarks/io/csv/csv_writer.cpp | 7 ++++--- cpp/benchmarks/io/orc/orc_reader.cpp | 8 ++++---- cpp/benchmarks/io/orc/orc_writer.cpp | 6 +++--- cpp/benchmarks/io/parquet/parquet_reader.cpp | 8 ++++---- cpp/benchmarks/io/parquet/parquet_writer.cpp | 8 ++++---- .../io/parquet/parquet_writer_chunks.cpp | 9 +++++---- cpp/benchmarks/io/text/multibyte_split.cpp | 1 - cpp/benchmarks/reduction/scan.cpp | 4 ++-- cpp/benchmarks/replace/clamp.cpp | 4 ++-- cpp/benchmarks/replace/nans.cpp | 4 ++-- cpp/benchmarks/sort/sort_strings.cpp | 4 ++-- cpp/benchmarks/string/case.cpp | 4 ++-- cpp/benchmarks/string/combine.cpp | 6 +++--- cpp/benchmarks/string/contains.cpp | 4 ++-- cpp/benchmarks/string/convert_datetime.cpp | 4 ++-- cpp/benchmarks/string/convert_fixed_point.cpp | 4 ++-- cpp/benchmarks/string/convert_numerics.cpp | 4 ++-- cpp/benchmarks/string/copy.cu | 4 ++-- cpp/benchmarks/string/factory.cu | 7 +++---- cpp/benchmarks/string/filter.cpp | 5 ++--- cpp/benchmarks/string/find.cpp | 5 ++--- cpp/benchmarks/string/repeat_strings.cpp | 4 ++-- cpp/benchmarks/string/replace.cpp | 5 ++--- cpp/benchmarks/string/replace_re.cpp | 5 ++--- cpp/benchmarks/string/split.cpp | 5 ++--- cpp/benchmarks/string/substring.cpp | 5 ++--- cpp/benchmarks/string/translate.cpp | 5 ++--- cpp/benchmarks/text/ngrams.cpp | 5 ++--- cpp/benchmarks/text/normalize.cpp | 5 ++--- cpp/benchmarks/text/normalize_spaces.cpp | 5 ++--- cpp/benchmarks/text/tokenize.cpp | 5 ++--- 37 files changed, 93 insertions(+), 123 deletions(-) diff --git a/cpp/benchmarks/common/generate_input.cpp b/cpp/benchmarks/common/generate_input.cpp index a22a19163d9..d6564428a2e 100644 --- a/cpp/benchmarks/common/generate_input.cpp +++ b/cpp/benchmarks/common/generate_input.cpp @@ -588,29 +588,26 @@ std::vector cycle_dtypes(std::vector const& dtype_ } std::unique_ptr create_random_table(std::vector const& dtype_ids, - cudf::size_type num_cols, table_size_bytes table_bytes, data_profile const& profile, unsigned seed) { - auto const out_dtype_ids = cycle_dtypes(dtype_ids, num_cols); size_t const avg_row_bytes = - std::accumulate(out_dtype_ids.begin(), out_dtype_ids.end(), 0ul, [&](size_t sum, auto tid) { + std::accumulate(dtype_ids.begin(), dtype_ids.end(), 0ul, [&](size_t sum, auto tid) { return sum + avg_element_size(profile, cudf::data_type(tid)); }); cudf::size_type const num_rows = table_bytes.size / avg_row_bytes; - return create_random_table(out_dtype_ids, num_cols, row_count{num_rows}, profile, seed); + return create_random_table(dtype_ids, row_count{num_rows}, profile, seed); } std::unique_ptr create_random_table(std::vector const& dtype_ids, - cudf::size_type num_cols, row_count num_rows, data_profile const& profile, unsigned seed) { - auto const out_dtype_ids = cycle_dtypes(dtype_ids, num_cols); - auto seed_engine = deterministic_engine(seed); + cudf::size_type const num_cols = dtype_ids.size(); + auto seed_engine = deterministic_engine(seed); auto const processor_count = std::thread::hardware_concurrency(); cudf::size_type const cols_per_thread = (num_cols + processor_count - 1) / processor_count; @@ -621,8 +618,8 @@ std::unique_ptr create_random_table(std::vector cons for (unsigned int i = 0; i < processor_count && next_col < num_cols; ++i) { auto thread_engine = deterministic_engine(seed_dist(seed_engine)); auto const thread_num_cols = std::min(num_cols - next_col, cols_per_thread); - std::vector thread_types(out_dtype_ids.begin() + next_col, - out_dtype_ids.begin() + next_col + thread_num_cols); + std::vector thread_types(dtype_ids.begin() + next_col, + dtype_ids.begin() + next_col + thread_num_cols); col_futures.emplace_back(std::async(std::launch::async, create_random_columns, std::cref(profile), diff --git a/cpp/benchmarks/common/generate_input.hpp b/cpp/benchmarks/common/generate_input.hpp index 4825713ba76..17bd650e722 100644 --- a/cpp/benchmarks/common/generate_input.hpp +++ b/cpp/benchmarks/common/generate_input.hpp @@ -370,18 +370,13 @@ struct row_count { /** * @brief Deterministically generates a table filled with data with the given parameters. * - * If the number of passed types is smaller than the number of requested column, the columns types - * with be repeated in round-robin order to fill the table. - * * @param dtype_ids Vector of requested column types - * @param num_cols Number of columns in the output table * @param table_bytes Target size of the output table, in bytes. Some type may not produce columns * of exact size * @param data_params optional, set of data parameters describing the data profile for each type * @param seed optional, seed for the pseudo-random engine */ std::unique_ptr create_random_table(std::vector const& dtype_ids, - cudf::size_type num_cols, table_size_bytes table_bytes, data_profile const& data_params = data_profile{}, unsigned seed = 1); @@ -389,17 +384,12 @@ std::unique_ptr create_random_table(std::vector cons /** * @brief Deterministically generates a table filled with data with the given parameters. * - * If the number of passed types is smaller than the number of requested column, the columns types - * with be repeated in round-robin order to fill the table. - * * @param dtype_ids Vector of requested column types - * @param num_cols Number of columns in the output table * @param num_rows Number of rows in the output table * @param data_params optional, set of data parameters describing the data profile for each type * @param seed optional, seed for the pseudo-random engine */ std::unique_ptr create_random_table(std::vector const& dtype_ids, - cudf::size_type num_cols, row_count num_rows, data_profile const& data_params = data_profile{}, unsigned seed = 1); diff --git a/cpp/benchmarks/copying/copy_if_else.cpp b/cpp/benchmarks/copying/copy_if_else.cpp index 6f3ba34e373..6f094aba680 100644 --- a/cpp/benchmarks/copying/copy_if_else.cpp +++ b/cpp/benchmarks/copying/copy_if_else.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +32,7 @@ static void BM_copy_if_else(benchmark::State& state, bool nulls) cudf::size_type const n_rows{(cudf::size_type)state.range(0)}; auto input_type = cudf::type_to_id(); auto bool_type = cudf::type_id::BOOL8; - auto const input = create_random_table({input_type, input_type, bool_type}, 3, row_count{n_rows}); + auto const input = create_random_table({input_type, input_type, bool_type}, row_count{n_rows}); if (!nulls) { input->get_column(2).set_null_mask(rmm::device_buffer{}, 0); diff --git a/cpp/benchmarks/groupby/group_struct.cu b/cpp/benchmarks/groupby/group_struct.cu index 355c7cbab6c..34f2d1adc75 100644 --- a/cpp/benchmarks/groupby/group_struct.cu +++ b/cpp/benchmarks/groupby/group_struct.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,18 +41,11 @@ static auto create_data_table(cudf::size_type n_rows) // The first two struct members are int32 and string. // The first column is also used as keys in groupby. - auto col_ids = std::vector{cudf::type_id::INT32, cudf::type_id::STRING}; - // The subsequent struct members are int32 and string again. - for (cudf::size_type i = 3; i <= num_struct_members; ++i) { - if (i % 2) { - col_ids.push_back(cudf::type_id::INT32); - } else { - col_ids.push_back(cudf::type_id::STRING); - } - } - - return create_random_table(col_ids, num_struct_members, row_count{n_rows}, table_profile); + return create_random_table( + cycle_dtypes({cudf::type_id::INT32, cudf::type_id::STRING}, num_struct_members), + row_count{n_rows}, + table_profile); } // Max aggregation/scan technically has the same performance as min. diff --git a/cpp/benchmarks/hashing/hash.cpp b/cpp/benchmarks/hashing/hash.cpp index e2ad38230a2..fe22795bb6b 100644 --- a/cpp/benchmarks/hashing/hash.cpp +++ b/cpp/benchmarks/hashing/hash.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ enum contains_nulls { no_nulls, nulls }; static void BM_hash(benchmark::State& state, cudf::hash_id hid, contains_nulls has_nulls) { cudf::size_type const n_rows{(cudf::size_type)state.range(0)}; - auto const data = create_random_table({cudf::type_id::INT64}, 1, row_count{n_rows}); + auto const data = create_random_table({cudf::type_id::INT64}, row_count{n_rows}); if (has_nulls == contains_nulls::no_nulls) data->get_column(0).set_null_mask(rmm::device_buffer{}, 0); diff --git a/cpp/benchmarks/io/csv/csv_reader.cpp b/cpp/benchmarks/io/csv/csv_reader.cpp index 241ba4d5954..c50f5220200 100644 --- a/cpp/benchmarks/io/csv/csv_reader.cpp +++ b/cpp/benchmarks/io/csv/csv_reader.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,8 @@ void BM_csv_read_varying_input(benchmark::State& state) auto const data_types = get_type_or_group(state.range(0)); auto const source_type = static_cast(state.range(1)); - auto const tbl = create_random_table(data_types, num_cols, table_size_bytes{data_size}); + auto const tbl = + create_random_table(cycle_dtypes(data_types, num_cols), table_size_bytes{data_size}); auto const view = tbl->view(); cuio_source_sink_pair source_sink(source_type); @@ -75,7 +76,7 @@ void BM_csv_read_varying_options(benchmark::State& state) col_sel); auto const cols_to_read = select_column_indexes(data_types.size(), col_sel); - auto const tbl = create_random_table(data_types, data_types.size(), table_size_bytes{data_size}); + auto const tbl = create_random_table(data_types, table_size_bytes{data_size}); auto const view = tbl->view(); cuio_source_sink_pair source_sink(io_type::HOST_BUFFER); diff --git a/cpp/benchmarks/io/csv/csv_writer.cpp b/cpp/benchmarks/io/csv/csv_writer.cpp index 413a269bcb2..65aa31c68dc 100644 --- a/cpp/benchmarks/io/csv/csv_writer.cpp +++ b/cpp/benchmarks/io/csv/csv_writer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,8 @@ void BM_csv_write_varying_inout(benchmark::State& state) auto const data_types = get_type_or_group(state.range(0)); auto const sink_type = static_cast(state.range(1)); - auto const tbl = create_random_table(data_types, num_cols, table_size_bytes{data_size}); + auto const tbl = + create_random_table(cycle_dtypes(data_types, num_cols), table_size_bytes{data_size}); auto const view = tbl->view(); cuio_source_sink_pair source_sink(sink_type); @@ -66,7 +67,7 @@ void BM_csv_write_varying_options(benchmark::State& state) int32_t(type_group_id::TIMESTAMP), int32_t(cudf::type_id::STRING)}); - auto const tbl = create_random_table(data_types, data_types.size(), table_size_bytes{data_size}); + auto const tbl = create_random_table(data_types, table_size_bytes{data_size}); auto const view = tbl->view(); std::string const na_per(na_per_len, '#'); diff --git a/cpp/benchmarks/io/orc/orc_reader.cpp b/cpp/benchmarks/io/orc/orc_reader.cpp index e15513275ee..29d4860a0e5 100644 --- a/cpp/benchmarks/io/orc/orc_reader.cpp +++ b/cpp/benchmarks/io/orc/orc_reader.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,8 +45,8 @@ void BM_orc_read_varying_input(benchmark::State& state) data_profile table_data_profile; table_data_profile.set_cardinality(cardinality); table_data_profile.set_avg_run_length(run_length); - auto const tbl = - create_random_table(data_types, num_cols, table_size_bytes{data_size}, table_data_profile); + auto const tbl = create_random_table( + cycle_dtypes(data_types, num_cols), table_size_bytes{data_size}, table_data_profile); auto const view = tbl->view(); cuio_source_sink_pair source_sink(source_type); @@ -96,7 +96,7 @@ void BM_orc_read_varying_options(benchmark::State& state) int32_t(type_group_id::TIMESTAMP), int32_t(cudf::type_id::STRING)}), col_sel); - auto const tbl = create_random_table(data_types, data_types.size(), table_size_bytes{data_size}); + auto const tbl = create_random_table(data_types, table_size_bytes{data_size}); auto const view = tbl->view(); cuio_source_sink_pair source_sink(io_type::HOST_BUFFER); diff --git a/cpp/benchmarks/io/orc/orc_writer.cpp b/cpp/benchmarks/io/orc/orc_writer.cpp index 50ae76e867c..e24ca7f749d 100644 --- a/cpp/benchmarks/io/orc/orc_writer.cpp +++ b/cpp/benchmarks/io/orc/orc_writer.cpp @@ -46,8 +46,8 @@ void BM_orc_write_varying_inout(benchmark::State& state) data_profile table_data_profile; table_data_profile.set_cardinality(cardinality); table_data_profile.set_avg_run_length(run_length); - auto const tbl = - create_random_table(data_types, num_cols, table_size_bytes{data_size}, table_data_profile); + auto const tbl = create_random_table( + cycle_dtypes(data_types, num_cols), table_size_bytes{data_size}, table_data_profile); auto const view = tbl->view(); cuio_source_sink_pair source_sink(sink_type); @@ -83,7 +83,7 @@ void BM_orc_write_varying_options(benchmark::State& state) int32_t(cudf::type_id::STRING), int32_t(cudf::type_id::LIST)}); - auto const tbl = create_random_table(data_types, data_types.size(), table_size_bytes{data_size}); + auto const tbl = create_random_table(data_types, table_size_bytes{data_size}); auto const view = tbl->view(); cuio_source_sink_pair source_sink(io_type::FILEPATH); diff --git a/cpp/benchmarks/io/parquet/parquet_reader.cpp b/cpp/benchmarks/io/parquet/parquet_reader.cpp index 09194931498..74613e50158 100644 --- a/cpp/benchmarks/io/parquet/parquet_reader.cpp +++ b/cpp/benchmarks/io/parquet/parquet_reader.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,8 +45,8 @@ void BM_parq_read_varying_input(benchmark::State& state) data_profile table_data_profile; table_data_profile.set_cardinality(cardinality); table_data_profile.set_avg_run_length(run_length); - auto const tbl = - create_random_table(data_types, num_cols, table_size_bytes{data_size}, table_data_profile); + auto const tbl = create_random_table( + cycle_dtypes(data_types, num_cols), table_size_bytes{data_size}, table_data_profile); auto const view = tbl->view(); cuio_source_sink_pair source_sink(source_type); @@ -96,7 +96,7 @@ void BM_parq_read_varying_options(benchmark::State& state) static_cast(type_group_id::TIMESTAMP), static_cast(cudf::type_id::STRING)}), col_sel); - auto const tbl = create_random_table(data_types, data_types.size(), table_size_bytes{data_size}); + auto const tbl = create_random_table(data_types, table_size_bytes{data_size}); auto const view = tbl->view(); cuio_source_sink_pair source_sink(io_type::HOST_BUFFER); diff --git a/cpp/benchmarks/io/parquet/parquet_writer.cpp b/cpp/benchmarks/io/parquet/parquet_writer.cpp index 8287c27f804..d203f0d27c8 100644 --- a/cpp/benchmarks/io/parquet/parquet_writer.cpp +++ b/cpp/benchmarks/io/parquet/parquet_writer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,8 +45,8 @@ void BM_parq_write_varying_inout(benchmark::State& state) data_profile table_data_profile; table_data_profile.set_cardinality(cardinality); table_data_profile.set_avg_run_length(run_length); - auto const tbl = - create_random_table(data_types, num_cols, table_size_bytes{data_size}, table_data_profile); + auto const tbl = create_random_table( + cycle_dtypes(data_types, num_cols), table_size_bytes{data_size}, table_data_profile); auto const view = tbl->view(); cuio_source_sink_pair source_sink(sink_type); @@ -77,7 +77,7 @@ void BM_parq_write_varying_options(benchmark::State& state) int32_t(cudf::type_id::STRING), int32_t(cudf::type_id::LIST)}); - auto const tbl = create_random_table(data_types, data_types.size(), table_size_bytes{data_size}); + auto const tbl = create_random_table(data_types, table_size_bytes{data_size}); auto const view = tbl->view(); cuio_source_sink_pair source_sink(io_type::FILEPATH); diff --git a/cpp/benchmarks/io/parquet/parquet_writer_chunks.cpp b/cpp/benchmarks/io/parquet/parquet_writer_chunks.cpp index 98eaba213e5..30ed245ed9a 100644 --- a/cpp/benchmarks/io/parquet/parquet_writer_chunks.cpp +++ b/cpp/benchmarks/io/parquet/parquet_writer_chunks.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +45,8 @@ void PQ_write(benchmark::State& state) { cudf::size_type num_cols = state.range(0); - auto tbl = create_random_table({cudf::type_id::INT32}, num_cols, table_size_bytes{data_size}); + auto tbl = create_random_table(cycle_dtypes({cudf::type_id::INT32}, num_cols), + table_size_bytes{data_size}); cudf::table_view view = tbl->view(); auto mem_stats_logger = cudf::memory_stats_logger(); @@ -69,8 +70,8 @@ void PQ_write_chunked(benchmark::State& state) std::vector> tables; for (cudf::size_type idx = 0; idx < num_tables; idx++) { - tables.push_back(create_random_table( - {cudf::type_id::INT32}, num_cols, table_size_bytes{size_t(data_size / num_tables)})); + tables.push_back(create_random_table(cycle_dtypes({cudf::type_id::INT32}, num_cols), + table_size_bytes{size_t(data_size / num_tables)})); } auto mem_stats_logger = cudf::memory_stats_logger(); diff --git a/cpp/benchmarks/io/text/multibyte_split.cpp b/cpp/benchmarks/io/text/multibyte_split.cpp index b13835c15bb..8c4b10d928d 100644 --- a/cpp/benchmarks/io/text/multibyte_split.cpp +++ b/cpp/benchmarks/io/text/multibyte_split.cpp @@ -70,7 +70,6 @@ static cudf::string_scalar create_random_input(int32_t num_chars, auto const values_table = create_random_table( // {cudf::type_id::STRING}, - 1, row_count{num_rows}, table_profile); diff --git a/cpp/benchmarks/reduction/scan.cpp b/cpp/benchmarks/reduction/scan.cpp index 05c15a4fcb5..7a0d3f9515f 100644 --- a/cpp/benchmarks/reduction/scan.cpp +++ b/cpp/benchmarks/reduction/scan.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ static void BM_reduction_scan(benchmark::State& state, bool include_nulls) { cudf::size_type const n_rows{(cudf::size_type)state.range(0)}; auto const dtype = cudf::type_to_id(); - auto const table = create_random_table({dtype}, 1, row_count{n_rows}); + auto const table = create_random_table({dtype}, row_count{n_rows}); if (!include_nulls) table->get_column(0).set_null_mask(rmm::device_buffer{}, 0); cudf::column_view input(table->view().column(0)); diff --git a/cpp/benchmarks/replace/clamp.cpp b/cpp/benchmarks/replace/clamp.cpp index dd8b06227bc..d3a7415a478 100644 --- a/cpp/benchmarks/replace/clamp.cpp +++ b/cpp/benchmarks/replace/clamp.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ static void BM_clamp(benchmark::State& state, bool include_nulls) { cudf::size_type const n_rows{(cudf::size_type)state.range(0)}; auto const dtype = cudf::type_to_id(); - auto const table = create_random_table({dtype}, 1, row_count{n_rows}); + auto const table = create_random_table({dtype}, row_count{n_rows}); if (!include_nulls) { table->get_column(0).set_null_mask(rmm::device_buffer{}, 0); } cudf::column_view input(table->view().column(0)); diff --git a/cpp/benchmarks/replace/nans.cpp b/cpp/benchmarks/replace/nans.cpp index 3faf217956b..e1b05bbc337 100644 --- a/cpp/benchmarks/replace/nans.cpp +++ b/cpp/benchmarks/replace/nans.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ static void BM_replace_nans(benchmark::State& state, bool include_nulls) { cudf::size_type const n_rows{(cudf::size_type)state.range(0)}; auto const dtype = cudf::type_to_id(); - auto const table = create_random_table({dtype}, 1, row_count{n_rows}); + auto const table = create_random_table({dtype}, row_count{n_rows}); if (!include_nulls) { table->get_column(0).set_null_mask(rmm::device_buffer{}, 0); } cudf::column_view input(table->view().column(0)); diff --git a/cpp/benchmarks/sort/sort_strings.cpp b/cpp/benchmarks/sort/sort_strings.cpp index 8adeef21a79..30a7aee043b 100644 --- a/cpp/benchmarks/sort/sort_strings.cpp +++ b/cpp/benchmarks/sort/sort_strings.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ static void BM_sort(benchmark::State& state) { cudf::size_type const n_rows{(cudf::size_type)state.range(0)}; - auto const table = create_random_table({cudf::type_id::STRING}, 1, row_count{n_rows}); + auto const table = create_random_table({cudf::type_id::STRING}, row_count{n_rows}); for (auto _ : state) { cuda_event_timer raii(state, true, rmm::cuda_stream_default); diff --git a/cpp/benchmarks/string/case.cpp b/cpp/benchmarks/string/case.cpp index 0f1653af2c6..0d74d0a6b7c 100644 --- a/cpp/benchmarks/string/case.cpp +++ b/cpp/benchmarks/string/case.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,7 @@ class StringCase : public cudf::benchmark { static void BM_case(benchmark::State& state) { cudf::size_type const n_rows{(cudf::size_type)state.range(0)}; - auto const table = create_random_table({cudf::type_id::STRING}, 1, row_count{n_rows}); + auto const table = create_random_table({cudf::type_id::STRING}, row_count{n_rows}); cudf::strings_column_view input(table->view().column(0)); for (auto _ : state) { diff --git a/cpp/benchmarks/string/combine.cpp b/cpp/benchmarks/string/combine.cpp index 8983646b6f1..a0cfcd15fe8 100644 --- a/cpp/benchmarks/string/combine.cpp +++ b/cpp/benchmarks/string/combine.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,8 +36,8 @@ static void BM_combine(benchmark::State& state) data_profile table_profile; table_profile.set_distribution_params( cudf::type_id::STRING, distribution_id::NORMAL, 0, max_str_length); - auto const table = - create_random_table({cudf::type_id::STRING}, 2, row_count{n_rows}, table_profile); + auto const table = create_random_table( + {cudf::type_id::STRING, cudf::type_id::STRING}, row_count{n_rows}, table_profile); cudf::strings_column_view input1(table->view().column(0)); cudf::strings_column_view input2(table->view().column(1)); cudf::string_scalar separator("+"); diff --git a/cpp/benchmarks/string/contains.cpp b/cpp/benchmarks/string/contains.cpp index fbcfabb4532..8c536372359 100644 --- a/cpp/benchmarks/string/contains.cpp +++ b/cpp/benchmarks/string/contains.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ enum contains_type { contains, count, findall }; static void BM_contains(benchmark::State& state, contains_type ct) { cudf::size_type const n_rows{(cudf::size_type)state.range(0)}; - auto const table = create_random_table({cudf::type_id::STRING}, 1, row_count{n_rows}); + auto const table = create_random_table({cudf::type_id::STRING}, row_count{n_rows}); cudf::strings_column_view input(table->view().column(0)); for (auto _ : state) { diff --git a/cpp/benchmarks/string/convert_datetime.cpp b/cpp/benchmarks/string/convert_datetime.cpp index af51b504ee8..3782fea1e36 100644 --- a/cpp/benchmarks/string/convert_datetime.cpp +++ b/cpp/benchmarks/string/convert_datetime.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ void BM_convert_datetime(benchmark::State& state, direction dir) auto const n_rows = static_cast(state.range(0)); auto const data_type = cudf::data_type(cudf::type_to_id()); - auto const table = create_random_table({data_type.id()}, 1, row_count{n_rows}); + auto const table = create_random_table({data_type.id()}, row_count{n_rows}); cudf::column_view input(table->view().column(0)); auto source = dir == direction::to ? cudf::strings::from_timestamps(input, "%Y-%m-%d %H:%M:%S") diff --git a/cpp/benchmarks/string/convert_fixed_point.cpp b/cpp/benchmarks/string/convert_fixed_point.cpp index 5c050592c7b..05b87906eca 100644 --- a/cpp/benchmarks/string/convert_fixed_point.cpp +++ b/cpp/benchmarks/string/convert_fixed_point.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ namespace { std::unique_ptr get_strings_column(cudf::size_type rows) { std::unique_ptr result = - create_random_table({cudf::type_id::FLOAT32}, 1, row_count{static_cast(rows)}); + create_random_table({cudf::type_id::FLOAT32}, row_count{static_cast(rows)}); return cudf::strings::from_floats(result->release().front()->view()); } diff --git a/cpp/benchmarks/string/convert_numerics.cpp b/cpp/benchmarks/string/convert_numerics.cpp index 02ccb17e74a..71a23c76829 100644 --- a/cpp/benchmarks/string/convert_numerics.cpp +++ b/cpp/benchmarks/string/convert_numerics.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ template std::unique_ptr get_numerics_column(cudf::size_type rows) { std::unique_ptr result = - create_random_table({cudf::type_to_id()}, 1, row_count{rows}); + create_random_table({cudf::type_to_id()}, row_count{rows}); return std::move(result->release().front()); } diff --git a/cpp/benchmarks/string/copy.cu b/cpp/benchmarks/string/copy.cu index 2f064e71c44..00eb818256c 100644 --- a/cpp/benchmarks/string/copy.cu +++ b/cpp/benchmarks/string/copy.cu @@ -40,9 +40,9 @@ static void BM_copy(benchmark::State& state, copy_type ct) cudf::type_id::STRING, distribution_id::NORMAL, 0, max_str_length); auto const source = - create_random_table({cudf::type_id::STRING}, 1, row_count{n_rows}, table_profile); + create_random_table({cudf::type_id::STRING}, row_count{n_rows}, table_profile); auto const target = - create_random_table({cudf::type_id::STRING}, 1, row_count{n_rows}, table_profile); + create_random_table({cudf::type_id::STRING}, row_count{n_rows}, table_profile); // scatter indices auto index_map_col = make_numeric_column( diff --git a/cpp/benchmarks/string/factory.cu b/cpp/benchmarks/string/factory.cu index 2a88def1871..47356af129e 100644 --- a/cpp/benchmarks/string/factory.cu +++ b/cpp/benchmarks/string/factory.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,9 +53,8 @@ static void BM_factory(benchmark::State& state) data_profile table_profile; table_profile.set_distribution_params( cudf::type_id::STRING, distribution_id::NORMAL, 0, max_str_length); - auto const table = - create_random_table({cudf::type_id::STRING}, 1, row_count{n_rows}, table_profile); - auto d_column = cudf::column_device_view::create(table->view().column(0)); + auto const table = create_random_table({cudf::type_id::STRING}, row_count{n_rows}, table_profile); + auto d_column = cudf::column_device_view::create(table->view().column(0)); rmm::device_uvector pairs(d_column->size(), rmm::cuda_stream_default); thrust::transform(thrust::device, d_column->pair_begin(), diff --git a/cpp/benchmarks/string/filter.cpp b/cpp/benchmarks/string/filter.cpp index fb030c2ccc2..b39cf25bc91 100644 --- a/cpp/benchmarks/string/filter.cpp +++ b/cpp/benchmarks/string/filter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,8 +41,7 @@ static void BM_filter_chars(benchmark::State& state, FilterAPI api) data_profile table_profile; table_profile.set_distribution_params( cudf::type_id::STRING, distribution_id::NORMAL, 0, max_str_length); - auto const table = - create_random_table({cudf::type_id::STRING}, 1, row_count{n_rows}, table_profile); + auto const table = create_random_table({cudf::type_id::STRING}, row_count{n_rows}, table_profile); cudf::strings_column_view input(table->view().column(0)); auto const types = cudf::strings::string_character_types::SPACE; diff --git a/cpp/benchmarks/string/find.cpp b/cpp/benchmarks/string/find.cpp index 167e9bc1348..55eb52c9b30 100644 --- a/cpp/benchmarks/string/find.cpp +++ b/cpp/benchmarks/string/find.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,8 +39,7 @@ static void BM_find_scalar(benchmark::State& state, FindAPI find_api) data_profile table_profile; table_profile.set_distribution_params( cudf::type_id::STRING, distribution_id::NORMAL, 0, max_str_length); - auto const table = - create_random_table({cudf::type_id::STRING}, 1, row_count{n_rows}, table_profile); + auto const table = create_random_table({cudf::type_id::STRING}, row_count{n_rows}, table_profile); cudf::strings_column_view input(table->view().column(0)); cudf::string_scalar target("+"); cudf::test::strings_column_wrapper targets({"+", "-"}); diff --git a/cpp/benchmarks/string/repeat_strings.cpp b/cpp/benchmarks/string/repeat_strings.cpp index 86b8525023f..9044db18522 100644 --- a/cpp/benchmarks/string/repeat_strings.cpp +++ b/cpp/benchmarks/string/repeat_strings.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +45,7 @@ static std::unique_ptr create_data_table(cudf::size_type n_cols, cudf::type_id::INT32, distribution_id::NORMAL, min_repeat_times, max_repeat_times); } - return create_random_table(dtype_ids, n_cols, row_count{n_rows}, table_profile); + return create_random_table(dtype_ids, row_count{n_rows}, table_profile); } static void BM_repeat_strings_scalar_times(benchmark::State& state) diff --git a/cpp/benchmarks/string/replace.cpp b/cpp/benchmarks/string/replace.cpp index 9be2e3a8627..0a3607c64f0 100644 --- a/cpp/benchmarks/string/replace.cpp +++ b/cpp/benchmarks/string/replace.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,8 +40,7 @@ static void BM_replace(benchmark::State& state, replace_type rt) data_profile table_profile; table_profile.set_distribution_params( cudf::type_id::STRING, distribution_id::NORMAL, 0, max_str_length); - auto const table = - create_random_table({cudf::type_id::STRING}, 1, row_count{n_rows}, table_profile); + auto const table = create_random_table({cudf::type_id::STRING}, row_count{n_rows}, table_profile); cudf::strings_column_view input(table->view().column(0)); cudf::string_scalar target("+"); cudf::string_scalar repl(""); diff --git a/cpp/benchmarks/string/replace_re.cpp b/cpp/benchmarks/string/replace_re.cpp index c106953bf69..b9d04630837 100644 --- a/cpp/benchmarks/string/replace_re.cpp +++ b/cpp/benchmarks/string/replace_re.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,8 +37,7 @@ static void BM_replace(benchmark::State& state, replace_type rt) data_profile table_profile; table_profile.set_distribution_params( cudf::type_id::STRING, distribution_id::NORMAL, 0, max_str_length); - auto const table = - create_random_table({cudf::type_id::STRING}, 1, row_count{n_rows}, table_profile); + auto const table = create_random_table({cudf::type_id::STRING}, row_count{n_rows}, table_profile); cudf::strings_column_view input(table->view().column(0)); cudf::test::strings_column_wrapper repls({"#", ""}); diff --git a/cpp/benchmarks/string/split.cpp b/cpp/benchmarks/string/split.cpp index fc879d1d0eb..ad25cfe54de 100644 --- a/cpp/benchmarks/string/split.cpp +++ b/cpp/benchmarks/string/split.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,8 +38,7 @@ static void BM_split(benchmark::State& state, split_type rt) data_profile table_profile; table_profile.set_distribution_params( cudf::type_id::STRING, distribution_id::NORMAL, 0, max_str_length); - auto const table = - create_random_table({cudf::type_id::STRING}, 1, row_count{n_rows}, table_profile); + auto const table = create_random_table({cudf::type_id::STRING}, row_count{n_rows}, table_profile); cudf::strings_column_view input(table->view().column(0)); cudf::string_scalar target("+"); diff --git a/cpp/benchmarks/string/substring.cpp b/cpp/benchmarks/string/substring.cpp index 8864fffc40b..2195cc56515 100644 --- a/cpp/benchmarks/string/substring.cpp +++ b/cpp/benchmarks/string/substring.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,8 +43,7 @@ static void BM_substring(benchmark::State& state, substring_type rt) data_profile table_profile; table_profile.set_distribution_params( cudf::type_id::STRING, distribution_id::NORMAL, 0, max_str_length); - auto const table = - create_random_table({cudf::type_id::STRING}, 1, row_count{n_rows}, table_profile); + auto const table = create_random_table({cudf::type_id::STRING}, row_count{n_rows}, table_profile); cudf::strings_column_view input(table->view().column(0)); auto starts_itr = thrust::constant_iterator(1); auto stops_itr = thrust::constant_iterator(max_str_length / 2); diff --git a/cpp/benchmarks/string/translate.cpp b/cpp/benchmarks/string/translate.cpp index 98688fa14fc..38c6ff9c701 100644 --- a/cpp/benchmarks/string/translate.cpp +++ b/cpp/benchmarks/string/translate.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,8 +41,7 @@ static void BM_translate(benchmark::State& state, int entry_count) data_profile table_profile; table_profile.set_distribution_params( cudf::type_id::STRING, distribution_id::NORMAL, 0, max_str_length); - auto const table = - create_random_table({cudf::type_id::STRING}, 1, row_count{n_rows}, table_profile); + auto const table = create_random_table({cudf::type_id::STRING}, row_count{n_rows}, table_profile); cudf::strings_column_view input(table->view().column(0)); std::vector entries(entry_count); diff --git a/cpp/benchmarks/text/ngrams.cpp b/cpp/benchmarks/text/ngrams.cpp index 7c39ebbb1bb..157c27ae48a 100644 --- a/cpp/benchmarks/text/ngrams.cpp +++ b/cpp/benchmarks/text/ngrams.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,8 +38,7 @@ static void BM_ngrams(benchmark::State& state, ngrams_type nt) data_profile table_profile; table_profile.set_distribution_params( cudf::type_id::STRING, distribution_id::NORMAL, 0, max_str_length); - auto const table = - create_random_table({cudf::type_id::STRING}, 1, row_count{n_rows}, table_profile); + auto const table = create_random_table({cudf::type_id::STRING}, row_count{n_rows}, table_profile); cudf::strings_column_view input(table->view().column(0)); for (auto _ : state) { diff --git a/cpp/benchmarks/text/normalize.cpp b/cpp/benchmarks/text/normalize.cpp index ac8e92b3376..2cc083f4ae8 100644 --- a/cpp/benchmarks/text/normalize.cpp +++ b/cpp/benchmarks/text/normalize.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,8 +36,7 @@ static void BM_normalize(benchmark::State& state, bool to_lower) data_profile table_profile; table_profile.set_distribution_params( cudf::type_id::STRING, distribution_id::NORMAL, 0, max_str_length); - auto const table = - create_random_table({cudf::type_id::STRING}, 1, row_count{n_rows}, table_profile); + auto const table = create_random_table({cudf::type_id::STRING}, row_count{n_rows}, table_profile); cudf::strings_column_view input(table->view().column(0)); for (auto _ : state) { diff --git a/cpp/benchmarks/text/normalize_spaces.cpp b/cpp/benchmarks/text/normalize_spaces.cpp index 34749b579b9..3bd636d4aa9 100644 --- a/cpp/benchmarks/text/normalize_spaces.cpp +++ b/cpp/benchmarks/text/normalize_spaces.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,8 +37,7 @@ static void BM_normalize(benchmark::State& state) data_profile table_profile; table_profile.set_distribution_params( cudf::type_id::STRING, distribution_id::NORMAL, 0, max_str_length); - auto const table = - create_random_table({cudf::type_id::STRING}, 1, row_count{n_rows}, table_profile); + auto const table = create_random_table({cudf::type_id::STRING}, row_count{n_rows}, table_profile); cudf::strings_column_view input(table->view().column(0)); for (auto _ : state) { diff --git a/cpp/benchmarks/text/tokenize.cpp b/cpp/benchmarks/text/tokenize.cpp index fa3f816db59..4cb9c9e5271 100644 --- a/cpp/benchmarks/text/tokenize.cpp +++ b/cpp/benchmarks/text/tokenize.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,8 +40,7 @@ static void BM_tokenize(benchmark::State& state, tokenize_type tt) data_profile table_profile; table_profile.set_distribution_params( cudf::type_id::STRING, distribution_id::NORMAL, 0, max_str_length); - auto const table = - create_random_table({cudf::type_id::STRING}, 1, row_count{n_rows}, table_profile); + auto const table = create_random_table({cudf::type_id::STRING}, row_count{n_rows}, table_profile); cudf::strings_column_view input(table->view().column(0)); cudf::test::strings_column_wrapper delimiters({" ", "+", "-"}); From 581e4b881517a817f9d1875d537b583c53b0076e Mon Sep 17 00:00:00 2001 From: Karthikeyan Natarajan Date: Fri, 25 Feb 2022 00:00:36 +0530 Subject: [PATCH 23/24] fix null mask null_count --- cpp/benchmarks/search/search.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cpp/benchmarks/search/search.cpp b/cpp/benchmarks/search/search.cpp index c2288c621dd..0bccbbaff54 100644 --- a/cpp/benchmarks/search/search.cpp +++ b/cpp/benchmarks/search/search.cpp @@ -135,8 +135,10 @@ void BM_contains(benchmark::State& state, bool nulls) auto column = cudf::sequence(column_size, *init_data); auto values = cudf::sequence(values_size, *init_value, *step); if (nulls) { - column->set_null_mask(create_random_null_mask(column->size(), 0.1, 1).first); - values->set_null_mask(create_random_null_mask(values->size(), 0.1, 2).first); + auto [column_null_mask, column_null_count] = create_random_null_mask(column->size(), 0.1, 1); + column->set_null_mask(std::move(column_null_mask), column_null_count); + auto [values_null_mask, values_null_count] = create_random_null_mask(values->size(), 0.1, 2); + values->set_null_mask(std::move(values_null_mask), values_null_count); } for (auto _ : state) { From fbd57085a560b3dd703ef5a8ff57cce55fec92dc Mon Sep 17 00:00:00 2001 From: Karthikeyan <6488848+karthikeyann@users.noreply.github.com> Date: Fri, 25 Feb 2022 02:33:24 +0530 Subject: [PATCH 24/24] address review comments --- cpp/benchmarks/common/generate_nullmask.cu | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/cpp/benchmarks/common/generate_nullmask.cu b/cpp/benchmarks/common/generate_nullmask.cu index 5b343c47e80..502af95a971 100644 --- a/cpp/benchmarks/common/generate_nullmask.cu +++ b/cpp/benchmarks/common/generate_nullmask.cu @@ -29,12 +29,8 @@ struct bool_generator { thrust::minstd_rand engine; thrust::uniform_real_distribution dist; float probability_true; - bool_generator(thrust::minstd_rand engine, float probability_true) - : engine(engine), dist{0, 1}, probability_true{probability_true} - { - } - bool_generator(unsigned seed, float valid_probability) - : engine(seed), dist{0, 1}, probability_true{valid_probability} + bool_generator(unsigned seed, float probability_true) + : engine(seed), dist{0, 1}, probability_true{probability_true} { }