Add optional sticky fixed-point overflow tracking (CUDF_TRACK_FIXED_POINT_OVERFLOW)#22356
Add optional sticky fixed-point overflow tracking (CUDF_TRACK_FIXED_POINT_OVERFLOW)#22356Avinash-Raj wants to merge 2 commits intorapidsai:mainfrom
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
I would favor adding new operators/functions rather than a compile-time flag — we want to be able to ship one build of cuDF that works universally. |
|
@bdice I'd imagine this is not limited to scalar functions like binaryops and such. We'd also need to detect overflow in aggregations like groupby and reduce. And those would require overloading the existing +,* operators. What's your opinion on adding a new type maybe called safe_decimal. Spark should also have a concept of arithmetic exception for overflows. How do they support this with libcudf decimal? |
Inline with this thinking, we could extend cudf's and use |
|
This is related to ANSI support that I've recently filed: #21676 |
|
Ok, replaced the CMake |
|
You might want to put overflow tracking into the floating <--> decimal conversion code as well (include/cudf/fixed_point/detail/floating_conversion.hpp). E.g. there are the guarded_left_shift() and guarded_right_shift() functions, and there are potential overflows in convert_floating_to_integral_shifting(), shift_to_decimal_pospow(), and shift_to_decimal_negpow(). All potential overflow sites are mentioned explicitly in the code comments in these functions. |
Summary
CUDF_TRACK_FIXED_POINT_OVERFLOW(default OFF). When enabled, definesCUDF_TRACK_FIXED_POINT_OVERFLOWfor thecudftarget (PUBLIC) so headers and translation units agree onfixed_pointlayout.fixed_pointcarries a sticky_overflow_flag, exposed asoverflow_occurred(), updated on+,-,*,/andrescaled()(including shift overflow viadetail::shift_overflows).__CUDACC_DEBUG__; enabling tracking does not by itself turn overflows into exceptions.velox-cudfthrows an exception whenever an decimal overflow occurs.