|
1 | 1 | /* |
2 | | - * SPDX-FileCopyrightText: Copyright (c) 2023, NVIDIA CORPORATION. |
| 2 | + * SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION. |
3 | 3 | * SPDX-License-Identifier: Apache-2.0 |
4 | 4 | */ |
5 | 5 |
|
6 | 6 | #pragma once |
7 | 7 |
|
8 | | -#include "generate_input.hpp" |
| 8 | +#include <cudf/table/table.hpp> |
| 9 | +#include <cudf/types.hpp> |
9 | 10 |
|
10 | | -#include <cudf_test/column_wrapper.hpp> |
11 | | - |
12 | | -// This error appears in GCC 11.3 and may be a compiler bug or nvbench bug. |
13 | | -#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" |
14 | 11 | #include <nvbench/nvbench.cuh> |
15 | | -#pragma GCC diagnostic pop |
16 | | - |
17 | | -#include <random> |
18 | | - |
19 | | -inline std::unique_ptr<cudf::table> create_lists_data(nvbench::state& state, |
20 | | - cudf::size_type const num_columns = 1, |
21 | | - cudf::size_type const min_val = 0, |
22 | | - cudf::size_type const max_val = 5) |
23 | | -{ |
24 | | - size_t const size_bytes(state.get_int64("size_bytes")); |
25 | | - cudf::size_type const depth{static_cast<cudf::size_type>(state.get_int64("depth"))}; |
26 | | - auto const null_frequency{state.get_float64("null_frequency")}; |
27 | | - |
28 | | - data_profile table_profile; |
29 | | - table_profile.set_distribution_params( |
30 | | - cudf::type_id::LIST, distribution_id::UNIFORM, min_val, max_val); |
31 | | - table_profile.set_list_depth(depth); |
32 | | - table_profile.set_null_probability(null_frequency); |
33 | | - return create_random_table(std::vector<cudf::type_id>(num_columns, cudf::type_id::LIST), |
34 | | - table_size_bytes{size_bytes}, |
35 | | - table_profile); |
36 | | -} |
37 | | - |
38 | | -inline std::unique_ptr<cudf::table> create_structs_data(nvbench::state& state, |
39 | | - cudf::size_type const n_cols = 1) |
40 | | -{ |
41 | | - using Type = int; |
42 | | - using column_wrapper = cudf::test::fixed_width_column_wrapper<Type>; |
43 | | - std::default_random_engine generator; |
44 | | - std::uniform_int_distribution<int> distribution(0, 100); |
45 | | - |
46 | | - cudf::size_type const n_rows{static_cast<cudf::size_type>(state.get_int64("NumRows"))}; |
47 | | - cudf::size_type const depth{static_cast<cudf::size_type>(state.get_int64("Depth"))}; |
48 | | - bool const nulls{static_cast<bool>(state.get_int64("Nulls"))}; |
49 | | - |
50 | | - // Create columns with values in the range [0,100) |
51 | | - std::vector<column_wrapper> columns; |
52 | | - columns.reserve(n_cols); |
53 | | - std::generate_n(std::back_inserter(columns), n_cols, [&]() { |
54 | | - auto const elements = cudf::detail::make_counting_transform_iterator( |
55 | | - 0, [&](auto row) { return distribution(generator); }); |
56 | | - if (!nulls) return column_wrapper(elements, elements + n_rows); |
57 | | - auto valids = |
58 | | - cudf::detail::make_counting_transform_iterator(0, [](auto i) { return i % 10 != 0; }); |
59 | | - return column_wrapper(elements, elements + n_rows, valids); |
60 | | - }); |
61 | | - |
62 | | - std::vector<std::unique_ptr<cudf::column>> cols; |
63 | | - std::transform(columns.begin(), columns.end(), std::back_inserter(cols), [](column_wrapper& col) { |
64 | | - return col.release(); |
65 | | - }); |
66 | 12 |
|
67 | | - std::vector<std::unique_ptr<cudf::column>> child_cols = std::move(cols); |
68 | | - // Nest the child columns in a struct, then nest that struct column inside another |
69 | | - // struct column up to the desired depth |
70 | | - for (int i = 0; i < depth; i++) { |
71 | | - std::vector<bool> struct_validity; |
72 | | - std::uniform_int_distribution<int> bool_distribution(0, 100 * (i + 1)); |
73 | | - std::generate_n( |
74 | | - std::back_inserter(struct_validity), n_rows, [&]() { return bool_distribution(generator); }); |
75 | | - cudf::test::structs_column_wrapper struct_col(std::move(child_cols), struct_validity); |
76 | | - child_cols = std::vector<std::unique_ptr<cudf::column>>{}; |
77 | | - child_cols.push_back(struct_col.release()); |
78 | | - } |
| 13 | +std::unique_ptr<cudf::table> create_lists_data(nvbench::state& state, |
| 14 | + cudf::size_type const num_columns = 1, |
| 15 | + cudf::size_type const min_val = 0, |
| 16 | + cudf::size_type const max_val = 5); |
79 | 17 |
|
80 | | - // Create table view |
81 | | - return std::make_unique<cudf::table>(std::move(child_cols)); |
82 | | -} |
| 18 | +std::unique_ptr<cudf::table> create_structs_data(nvbench::state& state, |
| 19 | + cudf::size_type const n_cols = 1); |
0 commit comments