Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
40 changes: 40 additions & 0 deletions bench/mo_exact_decimal.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
/* Copyright 2026 Sirius Contributors. SPDX-License-Identifier: Apache-2.0 */
#include "expression/ast/node.hpp"
#include "expression_evaluator/expression_evaluator.hpp"
#include "numeric/decimal_aggregate_layout.hpp"
#include "numeric/exact_decimal_gpu.hpp"

#include <cudf/binaryop.hpp>
#include <cudf/reduction.hpp>
#include <cudf/unary.hpp>
#include <cudf/utilities/error.hpp>

Expand Down Expand Up @@ -79,6 +81,16 @@ int main()
auto b = input(narrow, stream.view(), mr);
auto x = input(wide, stream.view(), mr);
auto y = input(wide, stream.view(), mr);
// Ramp idle-device clocks before the fixed per-case warm-ups. Keep this
// bounded and identical for every run; do not change device clock settings.
auto warm_until = std::chrono::steady_clock::now() + std::chrono::seconds(3);
do {
auto ordinary = cudf::binary_operation(
a->view(), b->view(), cudf::binary_operator::ADD, a->type(), stream.view(), mr);
auto checked = evaluate_decimal_columns(
decimal_op::divide, x->view(), wide, y->view(), wide, wide, nullptr, stream.view(), mr);
stream.synchronize();
} while (std::chrono::steady_clock::now() < warm_until);
std::cout << "case,rows,repetition,wall_ms,rows_per_second\n";
for (auto operation : {decimal_op::add, decimal_op::multiply}) {
auto out = operation == decimal_op::add ? narrow : decimal_type{128, 38, 0};
Expand Down Expand Up @@ -138,4 +150,32 @@ int main()
return evaluator.evaluate(cudf::table_view{{a->view(), b->view()}});
});
}
// At this fixed row bound, even the entire signed physical input domain
// fits the declared 128-bit result. Widen before the ordinary reduction so
// both paths include safe accumulation, allocation and stream completion.
measure("cudf_sum64_to128", stream.view(), [&] {
auto widened =
cudf::cast(a->view(), cudf::data_type{cudf::type_id::DECIMAL128, 0}, stream.view(), mr);
auto result = cudf::reduce(widened->view(),
*cudf::make_sum_aggregation<cudf::reduce_aggregation>(),
widened->type(),
stream.view(),
mr);
stream.synchronize();
return result;
});
duckdb::vector<std::unique_ptr<sirius::ast::node>> aggregates;
std::vector<std::unique_ptr<sirius::ast::node>> args;
args.push_back(std::make_unique<sirius::ast::node>(
sirius::ast::reference{0, sirius::logical_type::make_mo_decimal({64, 15, 0}, false)}));
aggregates.push_back(std::make_unique<sirius::ast::node>(
sirius::ast::aggregate{sirius::aggregate_id::mo_decimal_sum,
std::move(args),
sirius::logical_type::make_mo_decimal({128, 37, 0}, true),
false}));
auto layout = make_aggregate_layout({}, aggregates);
measure("exact_sum64_to128", stream.view(), [&] {
auto state = local_aggregate_table(cudf::table_view{{a->view()}}, *layout, stream.view(), mr);
return merge_aggregate_tables({state->view()}, *layout, stream.view(), mr);
});
}
18 changes: 16 additions & 2 deletions cmake/sirius-embedding-tests.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Embedding control tests need neither a GPU nor a DuckDB runtime. Keep them
# independently runnable from the linked ABI and GPU integration tests.
add_executable(
sirius_exact_decimal_unittest test/cpp/exec/execution_evidence_unittest.cpp
test/cpp/embedding/test_exact_decimal.cpp)
sirius_exact_decimal_unittest
test/cpp/exec/execution_evidence_unittest.cpp
test/cpp/embedding/test_exact_decimal.cpp
test/cpp/embedding/test_decimal_aggregate.cpp)
target_compile_features(sirius_exact_decimal_unittest PRIVATE cxx_std_20)
target_include_directories(
sirius_exact_decimal_unittest PRIVATE "${CMAKE_SOURCE_DIR}/third_party/catch"
Expand Down Expand Up @@ -45,6 +47,17 @@ target_include_directories(
"${SIRIUS_SUBSTRAIT_DIR}/third_party/substrait")
target_link_libraries(sirius_native_result_integration PRIVATE Sirius::embed
Threads::Threads)
add_executable(
sirius_native_numeric_unittest test/cpp/exec/execution_evidence_unittest.cpp
test/cpp/embedding/test_native_numeric.cpp)
target_compile_features(sirius_native_numeric_unittest PRIVATE cxx_std_20)
target_include_directories(
sirius_native_numeric_unittest
PRIVATE "${CMAKE_SOURCE_DIR}/third_party/catch"
"${SIRIUS_SUBSTRAIT_DIR}/third_party"
"${SIRIUS_SUBSTRAIT_DIR}/third_party/substrait")
target_link_libraries(sirius_native_numeric_unittest PRIVATE Sirius::embed
Threads::Threads)

add_executable(
sirius_native_binding_unittest
Expand Down Expand Up @@ -76,6 +89,7 @@ add_executable(
test/cpp/embedding/test_native_result_codec.cpp
test/cpp/embedding/test_exact_decimal_gpu.cpp
test/cpp/embedding/test_decimal_expression_gpu.cpp
test/cpp/embedding/test_decimal_aggregate_gpu.cpp
test/cpp/embedding/test_tae_gpu.cpp
src/embedding/c_api.cpp)
target_compile_features(sirius_native_gpu_unittest PRIVATE cxx_std_20)
Expand Down
4 changes: 4 additions & 0 deletions docs/mo-exact-decimal-import.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ This is the first of the two native integration increments approved for
merged Sirius #25 and importer #4. The semantic contract remains the approved
MO #29449 document blob `42a89f09a1d168d02b9583cb3ea7b4de6dbb5634`.

This document records the Native A boundary and its historical measurements.
[Native B](mo-exact-decimal-integration.md) supersedes the exposure boundary
below with complete embedded preparation, aggregates, keys and capability 16u.

## Contract and ownership

Physical coefficient width, declared precision, scale, and nullability survive
Expand Down
211 changes: 211 additions & 0 deletions docs/mo-exact-decimal-integration-kernels.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
run,case,rows,repetition,wall_ms,rows_per_second
1,cudf_add64,262144,0,0.20497,1.27894e+09
1,cudf_add64,262144,1,0.188959,1.38731e+09
1,cudf_add64,262144,2,0.193369,1.35567e+09
1,cudf_add64,262144,3,0.1946,1.34709e+09
1,cudf_add64,262144,4,0.194839,1.34544e+09
1,cudf_add64,262144,5,0.199599,1.31335e+09
1,cudf_add64,262144,6,0.197809,1.32524e+09
1,checked_add64,262144,0,0.02917,8.98677e+09
1,checked_add64,262144,1,0.03414,7.6785e+09
1,checked_add64,262144,2,0.02703,9.69826e+09
1,checked_add64,262144,3,0.03307,7.92694e+09
1,checked_add64,262144,4,0.03386,7.742e+09
1,checked_add64,262144,5,0.0338,7.75574e+09
1,checked_add64,262144,6,0.02713,9.66251e+09
1,cudf_widen_multiply64_to128,262144,0,0.501388,5.22837e+08
1,cudf_widen_multiply64_to128,262144,1,0.494758,5.29843e+08
1,cudf_widen_multiply64_to128,262144,2,0.496258,5.28241e+08
1,cudf_widen_multiply64_to128,262144,3,0.496198,5.28305e+08
1,cudf_widen_multiply64_to128,262144,4,0.495969,5.28549e+08
1,cudf_widen_multiply64_to128,262144,5,0.505178,5.18914e+08
1,cudf_widen_multiply64_to128,262144,6,0.495688,5.28849e+08
1,checked_multiply64_to128,262144,0,0.502158,5.22035e+08
1,checked_multiply64_to128,262144,1,0.498948,5.25393e+08
1,checked_multiply64_to128,262144,2,0.504449,5.19664e+08
1,checked_multiply64_to128,262144,3,0.494338,5.30293e+08
1,checked_multiply64_to128,262144,4,0.492638,5.32123e+08
1,checked_multiply64_to128,262144,5,0.494428,5.30197e+08
1,checked_multiply64_to128,262144,6,0.493968,5.3069e+08
1,checked_add256,262144,0,0.267809,9.78847e+08
1,checked_add256,262144,1,0.261119,1.00393e+09
1,checked_add256,262144,2,0.260409,1.00666e+09
1,checked_add256,262144,3,0.258879,1.01261e+09
1,checked_add256,262144,4,0.259119,1.01167e+09
1,checked_add256,262144,5,0.266299,9.84397e+08
1,checked_add256,262144,6,0.265619,9.86917e+08
1,checked_divide256,262144,0,4.72385,5.54937e+07
1,checked_divide256,262144,1,4.72027,5.55358e+07
1,checked_divide256,262144,2,4.71809,5.55614e+07
1,checked_divide256,262144,3,4.72171,5.55188e+07
1,checked_divide256,262144,4,4.72278,5.55063e+07
1,checked_divide256,262144,5,4.71955,5.55442e+07
1,checked_divide256,262144,6,4.71993,5.55398e+07
1,ordinary_expression_add64,262144,0,0.199669,1.31289e+09
1,ordinary_expression_add64,262144,1,0.196089,1.33686e+09
1,ordinary_expression_add64,262144,2,0.20103,1.304e+09
1,ordinary_expression_add64,262144,3,0.196079,1.33693e+09
1,ordinary_expression_add64,262144,4,0.195619,1.34007e+09
1,ordinary_expression_add64,262144,5,0.196169,1.33632e+09
1,ordinary_expression_add64,262144,6,0.19765,1.3263e+09
1,exact_expression_add64,262144,0,0.16399,1.59854e+09
1,exact_expression_add64,262144,1,0.161689,1.62129e+09
1,exact_expression_add64,262144,2,0.160069,1.63769e+09
1,exact_expression_add64,262144,3,0.16064,1.63187e+09
1,exact_expression_add64,262144,4,0.163799,1.6004e+09
1,exact_expression_add64,262144,5,0.15962,1.6423e+09
1,exact_expression_add64,262144,6,0.159089,1.64778e+09
1,cudf_sum64_to128,262144,0,0.285259,9.18968e+08
1,cudf_sum64_to128,262144,1,0.270139,9.70404e+08
1,cudf_sum64_to128,262144,2,0.276389,9.4846e+08
1,cudf_sum64_to128,262144,3,0.271249,9.66433e+08
1,cudf_sum64_to128,262144,4,0.275289,9.5225e+08
1,cudf_sum64_to128,262144,5,0.272939,9.60449e+08
1,cudf_sum64_to128,262144,6,0.270939,9.67539e+08
1,exact_sum64_to128,262144,0,0.221459,1.18371e+09
1,exact_sum64_to128,262144,1,0.222239,1.17956e+09
1,exact_sum64_to128,262144,2,0.21954,1.19406e+09
1,exact_sum64_to128,262144,3,0.218509,1.19969e+09
1,exact_sum64_to128,262144,4,0.218459,1.19997e+09
1,exact_sum64_to128,262144,5,0.218719,1.19854e+09
1,exact_sum64_to128,262144,6,0.216399,1.21139e+09
2,cudf_add64,262144,0,0.204999,1.27876e+09
2,cudf_add64,262144,1,0.186999,1.40185e+09
2,cudf_add64,262144,2,0.194959,1.34461e+09
2,cudf_add64,262144,3,0.19545,1.34123e+09
2,cudf_add64,262144,4,0.194719,1.34627e+09
2,cudf_add64,262144,5,0.198849,1.31831e+09
2,cudf_add64,262144,6,0.19526,1.34254e+09
2,checked_add64,262144,0,0.02703,9.69826e+09
2,checked_add64,262144,1,0.02729,9.60586e+09
2,checked_add64,262144,2,0.03485,7.52207e+09
2,checked_add64,262144,3,0.02695,9.72705e+09
2,checked_add64,262144,4,0.02753,9.52212e+09
2,checked_add64,262144,5,0.034279,7.64736e+09
2,checked_add64,262144,6,0.03381,7.75345e+09
2,cudf_widen_multiply64_to128,262144,0,0.509678,5.14333e+08
2,cudf_widen_multiply64_to128,262144,1,0.496268,5.28231e+08
2,cudf_widen_multiply64_to128,262144,2,0.500418,5.2385e+08
2,cudf_widen_multiply64_to128,262144,3,0.501069,5.23169e+08
2,cudf_widen_multiply64_to128,262144,4,0.504228,5.19892e+08
2,cudf_widen_multiply64_to128,262144,5,0.499158,5.25172e+08
2,cudf_widen_multiply64_to128,262144,6,0.503338,5.20811e+08
2,checked_multiply64_to128,262144,0,0.499178,5.25151e+08
2,checked_multiply64_to128,262144,1,0.511978,5.12022e+08
2,checked_multiply64_to128,262144,2,0.497248,5.2719e+08
2,checked_multiply64_to128,262144,3,0.497919,5.26479e+08
2,checked_multiply64_to128,262144,4,0.498268,5.2611e+08
2,checked_multiply64_to128,262144,5,0.497968,5.26427e+08
2,checked_multiply64_to128,262144,6,0.494468,5.30154e+08
2,checked_add256,262144,0,0.258559,1.01387e+09
2,checked_add256,262144,1,0.264199,9.92222e+08
2,checked_add256,262144,2,0.264149,9.9241e+08
2,checked_add256,262144,3,0.268029,9.78043e+08
2,checked_add256,262144,4,0.266119,9.85063e+08
2,checked_add256,262144,5,0.258619,1.01363e+09
2,checked_add256,262144,6,0.264479,9.91171e+08
2,checked_divide256,262144,0,4.7162,5.55837e+07
2,checked_divide256,262144,1,4.7215,5.55213e+07
2,checked_divide256,262144,2,4.71662,5.55787e+07
2,checked_divide256,262144,3,4.71515,5.55961e+07
2,checked_divide256,262144,4,4.71569,5.55897e+07
2,checked_divide256,262144,5,4.71772,5.55658e+07
2,checked_divide256,262144,6,4.71491,5.55989e+07
2,ordinary_expression_add64,262144,0,0.197489,1.32739e+09
2,ordinary_expression_add64,262144,1,0.195739,1.33925e+09
2,ordinary_expression_add64,262144,2,0.197019,1.33055e+09
2,ordinary_expression_add64,262144,3,0.20012,1.30993e+09
2,ordinary_expression_add64,262144,4,0.200429,1.30791e+09
2,ordinary_expression_add64,262144,5,0.198379,1.32143e+09
2,ordinary_expression_add64,262144,6,0.197039,1.33042e+09
2,exact_expression_add64,262144,0,0.1585,1.65391e+09
2,exact_expression_add64,262144,1,0.159569,1.64283e+09
2,exact_expression_add64,262144,2,0.15803,1.65882e+09
2,exact_expression_add64,262144,3,0.168509,1.55567e+09
2,exact_expression_add64,262144,4,0.159799,1.64046e+09
2,exact_expression_add64,262144,5,0.15778,1.66145e+09
2,exact_expression_add64,262144,6,0.163029,1.60796e+09
2,cudf_sum64_to128,262144,0,0.279139,9.39116e+08
2,cudf_sum64_to128,262144,1,0.272269,9.62813e+08
2,cudf_sum64_to128,262144,2,0.284509,9.21391e+08
2,cudf_sum64_to128,262144,3,0.274519,9.54921e+08
2,cudf_sum64_to128,262144,4,0.273739,9.57642e+08
2,cudf_sum64_to128,262144,5,0.273149,9.59711e+08
2,cudf_sum64_to128,262144,6,0.276819,9.46987e+08
2,exact_sum64_to128,262144,0,0.217059,1.20771e+09
2,exact_sum64_to128,262144,1,0.224169,1.1694e+09
2,exact_sum64_to128,262144,2,0.218149,1.20167e+09
2,exact_sum64_to128,262144,3,0.218899,1.19756e+09
2,exact_sum64_to128,262144,4,0.21724,1.2067e+09
2,exact_sum64_to128,262144,5,0.217039,1.20782e+09
2,exact_sum64_to128,262144,6,0.217799,1.20361e+09
3,cudf_add64,262144,0,0.20639,1.27014e+09
3,cudf_add64,262144,1,0.191469,1.36912e+09
3,cudf_add64,262144,2,0.198879,1.31811e+09
3,cudf_add64,262144,3,0.201479,1.3011e+09
3,cudf_add64,262144,4,0.19953,1.31381e+09
3,cudf_add64,262144,5,0.204569,1.28145e+09
3,cudf_add64,262144,6,0.199409,1.3146e+09
3,checked_add64,262144,0,0.02819,9.29918e+09
3,checked_add64,262144,1,0.034299,7.64291e+09
3,checked_add64,262144,2,0.02779,9.43303e+09
3,checked_add64,262144,3,0.03435,7.63156e+09
3,checked_add64,262144,4,0.03699,7.08689e+09
3,checked_add64,262144,5,0.02679,9.78514e+09
3,checked_add64,262144,6,0.03394,7.72375e+09
3,cudf_widen_multiply64_to128,262144,0,0.509878,5.14131e+08
3,cudf_widen_multiply64_to128,262144,1,0.509238,5.14777e+08
3,cudf_widen_multiply64_to128,262144,2,0.512789,5.11212e+08
3,cudf_widen_multiply64_to128,262144,3,0.508449,5.15576e+08
3,cudf_widen_multiply64_to128,262144,4,0.508378,5.15648e+08
3,cudf_widen_multiply64_to128,262144,5,0.508818,5.15202e+08
3,cudf_widen_multiply64_to128,262144,6,0.511298,5.12703e+08
3,checked_multiply64_to128,262144,0,0.507528,5.16511e+08
3,checked_multiply64_to128,262144,1,0.506148,5.1792e+08
3,checked_multiply64_to128,262144,2,0.514158,5.09851e+08
3,checked_multiply64_to128,262144,3,0.506589,5.17469e+08
3,checked_multiply64_to128,262144,4,0.512928,5.11074e+08
3,checked_multiply64_to128,262144,5,0.505498,5.18586e+08
3,checked_multiply64_to128,262144,6,0.507998,5.16034e+08
3,checked_add256,262144,0,0.264629,9.90609e+08
3,checked_add256,262144,1,0.273349,9.59008e+08
3,checked_add256,262144,2,0.267969,9.78262e+08
3,checked_add256,262144,3,0.261749,1.00151e+09
3,checked_add256,262144,4,0.266089,9.85174e+08
3,checked_add256,262144,5,0.264099,9.92597e+08
3,checked_add256,262144,6,0.262539,9.98495e+08
3,checked_divide256,262144,0,4.72434,5.54879e+07
3,checked_divide256,262144,1,4.72097,5.55275e+07
3,checked_divide256,262144,2,4.72129,5.55238e+07
3,checked_divide256,262144,3,4.72736,5.54525e+07
3,checked_divide256,262144,4,4.72303,5.55033e+07
3,checked_divide256,262144,5,4.7266,5.54614e+07
3,checked_divide256,262144,6,4.72237,5.55111e+07
3,ordinary_expression_add64,262144,0,0.202799,1.29263e+09
3,ordinary_expression_add64,262144,1,0.20388,1.28578e+09
3,ordinary_expression_add64,262144,2,0.201169,1.3031e+09
3,ordinary_expression_add64,262144,3,0.200309,1.3087e+09
3,ordinary_expression_add64,262144,4,0.200629,1.30661e+09
3,ordinary_expression_add64,262144,5,0.2,1.31072e+09
3,ordinary_expression_add64,262144,6,0.203589,1.28761e+09
3,exact_expression_add64,262144,0,0.165029,1.58847e+09
3,exact_expression_add64,262144,1,0.16826,1.55797e+09
3,exact_expression_add64,262144,2,0.172959,1.51564e+09
3,exact_expression_add64,262144,3,0.172239,1.52198e+09
3,exact_expression_add64,262144,4,0.1656,1.583e+09
3,exact_expression_add64,262144,5,0.165249,1.58636e+09
3,exact_expression_add64,262144,6,0.164699,1.59166e+09
3,cudf_sum64_to128,262144,0,0.282999,9.26307e+08
3,cudf_sum64_to128,262144,1,0.279929,9.36466e+08
3,cudf_sum64_to128,262144,2,0.284129,9.22623e+08
3,cudf_sum64_to128,262144,3,0.282809,9.26929e+08
3,cudf_sum64_to128,262144,4,0.283009,9.26274e+08
3,cudf_sum64_to128,262144,5,0.279079,9.39318e+08
3,cudf_sum64_to128,262144,6,0.283039,9.26176e+08
3,exact_sum64_to128,262144,0,0.223419,1.17333e+09
3,exact_sum64_to128,262144,1,0.232619,1.12692e+09
3,exact_sum64_to128,262144,2,0.224789,1.16618e+09
3,exact_sum64_to128,262144,3,0.222589,1.1777e+09
3,exact_sum64_to128,262144,4,0.22315,1.17474e+09
3,exact_sum64_to128,262144,5,0.226679,1.15645e+09
3,exact_sum64_to128,262144,6,0.231379,1.13296e+09
Loading
Loading