Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Precompute AST arity #17234

Open
wants to merge 21 commits into
base: branch-25.02
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
3062e8c
Precompute AST arity
bdice Nov 1, 2024
a6e2b58
Make ast_operator_arity host-only.
bdice Nov 1, 2024
b69dfc2
Start moving code to operators.cpp.
bdice Nov 4, 2024
5598f68
Move more code to operators.cpp, make dispatch machinery return non-v…
bdice Nov 13, 2024
3f18172
Merge branch 'branch-24.12' into ast-precompute-arity
bdice Nov 13, 2024
3270c10
Go back to void dispatching for arity and return type.
bdice Nov 13, 2024
ea35ca3
Merge remote-tracking branch 'upstream/branch-24.12' into ast-precomp…
bdice Nov 13, 2024
a889380
Merge branch 'branch-24.12' into ast-precompute-arity
lamarrr Nov 13, 2024
68213c6
Use cudf::size_type for operator arities.
bdice Nov 20, 2024
5248b2d
Merge branch 'ast-precompute-arity' of github.com:bdice/cudf into ast…
bdice Nov 20, 2024
e57d90d
Merge remote-tracking branch 'upstream/branch-25.02' into ast-precomp…
bdice Nov 20, 2024
48e33c3
Merge branch 'branch-25.02' into ast-precompute-arity
lamarrr Nov 21, 2024
f7dfb54
Merge remote-tracking branch 'upstream/branch-25.02' into ast-precomp…
bdice Nov 21, 2024
4d58e9f
Merge branch 'branch-25.02' into ast-precompute-arity
lamarrr Nov 26, 2024
1d9c665
fixed ast program's buffer alignment and sizing
lamarrr Dec 10, 2024
4b32284
Merge pull request #5 from lamarrr/ast-precompute-buffer-fix
bdice Dec 24, 2024
c8c6cb7
Merge branch 'branch-25.02' into ast-precompute-arity
lamarrr Jan 2, 2025
a729188
Merge branch 'branch-25.02' into ast-precompute-arity
lamarrr Jan 6, 2025
fb17b71
Merge branch 'branch-25.02' into ast-precompute-arity
lamarrr Jan 8, 2025
814aaed
Merge branch 'branch-25.02' into ast-precompute-arity
bdice Jan 8, 2025
f6c087d
updated copyright year
lamarrr Jan 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ add_library(
src/aggregation/result_cache.cpp
src/ast/expression_parser.cpp
src/ast/expressions.cpp
src/ast/operators.cpp
src/binaryop/binaryop.cpp
src/binaryop/compiled/ATan2.cu
src/binaryop/compiled/Add.cu
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/cudf/ast/detail/expression_evaluator.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ struct expression_evaluator {
++operator_index) {
// Execute operator
auto const op = plan.operators[operator_index];
auto const arity = ast_operator_arity(op);
auto const arity = plan.operator_arities[operator_index];
if (arity == 1) {
// Unary operator
auto const& input =
Expand Down
15 changes: 13 additions & 2 deletions cpp/include/cudf/ast/detail/expression_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <cudf/ast/detail/operators.hpp>
#include <cudf/ast/expressions.hpp>
#include <cudf/detail/utilities/integer_utils.hpp>
#include <cudf/table/table_view.hpp>
#include <cudf/types.hpp>
#include <cudf/utilities/memory_resource.hpp>
Expand Down Expand Up @@ -88,6 +89,7 @@ struct expression_device_view {
device_span<detail::device_data_reference const> data_references;
device_span<generic_scalar_device_view const> literals;
device_span<ast_operator const> operators;
device_span<int8_t const> operator_arities;
device_span<cudf::size_type const> operator_source_indices;
cudf::size_type num_intermediates;
};
Expand Down Expand Up @@ -248,12 +250,17 @@ class expression_parser {
extract_size_and_pointer(_data_references, sizes, data_pointers);
extract_size_and_pointer(_literals, sizes, data_pointers);
extract_size_and_pointer(_operators, sizes, data_pointers);
extract_size_and_pointer(_operator_arities, sizes, data_pointers);
extract_size_and_pointer(_operator_source_indices, sizes, data_pointers);

// Create device buffer
auto const buffer_size = std::accumulate(sizes.cbegin(), sizes.cend(), 0);
auto buffer_offsets = std::vector<int>(sizes.size());
thrust::exclusive_scan(sizes.cbegin(), sizes.cend(), buffer_offsets.begin(), 0);
thrust::exclusive_scan(
sizes.cbegin(), sizes.cend(), buffer_offsets.begin(), 0, [](auto a, auto b) {
// Must align each part of the AST program on 4-byte addresses
lamarrr marked this conversation as resolved.
Show resolved Hide resolved
return a + cudf::util::round_up_safe(b, 4);
});

auto h_data_buffer = std::vector<char>(buffer_size);
for (unsigned int i = 0; i < data_pointers.size(); ++i) {
Expand All @@ -277,8 +284,11 @@ class expression_parser {
device_expression_data.operators = device_span<ast_operator const>(
reinterpret_cast<ast_operator const*>(device_data_buffer_ptr + buffer_offsets[2]),
_operators.size());
device_expression_data.operator_arities = device_span<int8_t const>(
reinterpret_cast<int8_t const*>(device_data_buffer_ptr + buffer_offsets[3]),
_operators.size());
device_expression_data.operator_source_indices = device_span<cudf::size_type const>(
reinterpret_cast<cudf::size_type const*>(device_data_buffer_ptr + buffer_offsets[3]),
reinterpret_cast<cudf::size_type const*>(device_data_buffer_ptr + buffer_offsets[4]),
_operator_source_indices.size());
device_expression_data.num_intermediates = _intermediate_counter.get_max_used();
shmem_per_thread = static_cast<int>(
Expand Down Expand Up @@ -322,6 +332,7 @@ class expression_parser {
bool _has_nulls;
std::vector<detail::device_data_reference> _data_references;
std::vector<ast_operator> _operators;
std::vector<int8_t> _operator_arities;
std::vector<cudf::size_type> _operator_source_indices;
std::vector<generic_scalar_device_view> _literals;
};
Expand Down
Loading
Loading