Repository navigation
GH-12681: [C++] Work around FP rounding issues in quantile tests - #55744
Conversation
On some architectures (such as Risc-V) and/or with some optimizations enabled (such as `-fma` on x86), the quantile compute kernel may not output results rigorously equal to those from a textbook quantile computation as used in the tests. Allow for some slight divergence (1 ULP) between the results.
|
FTR @andishgar :) |
|
@ptrou A few notes:
arrow/cpp/src/arrow/compute/kernels/aggregate_quantile.cc Lines 247 to 257 in 391be25 |
Cryolitia
left a comment
There was a problem hiding this comment.
I confirm that this PR fixes the build on Arch Linux RISC-V, and x86_64 in general with the -mfma parameter (although it may be a little late)
Tested-by: Cryolitia PukNgae <cryolitia.pukngae@linux.dev>
| // The results may not be rigorously equal to the "naive" results | ||
| // on some architecture and/or with some compiler flags (GH-12681). | ||
| AssertWithinUlp(quantiles[j], numeric_scalar->value, 1); |
There was a problem hiding this comment.
@pitrou , I forgot to mention one more thing: ULP-based comparison is inappropriate for LOWER, HIGHER, and NEAREST, since these interpolation methods are expected to return an unchanged input value.
There was a problem hiding this comment.
Well, it's not inappropriate, but you're right it's less strict than ideal :)
Well, I don't think we want to guarantee accuracy, because it can vary depending on the exact algorithm but also the machine/compiler/optimization options.
I don't know, that sounds a bit overkill to me. I'll let others discuss this if there is a desire to do so :) |
Backport the upstream quantile test fix to allow 1 ULP rounding differences from FMA contraction. Replace the flag-stripping workaround so _GLIBCXX_ASSERTIONS stays enabled for the build. Refresh the PKGBUILD overlay and retain the 600-second CTest timeout. All 345 aggregate tests pass with assertions enabled on riscv64 under QEMU with LTO and on x86_64 with -mfma; the unpatched builds fail the same four tests. Overlay application, prepare() and the upstream patch checksum were also validated. apache/arrow#55744 apache/arrow@391be25
Rationale for this change
On some architectures (such as Risc-V) and/or with some optimizations enabled (such as
-fmaon x86), the quantile compute kernel may not output results rigorously equal to those from a textbook quantile computation as used in the tests.Thanks to PukNgae Cryolitia (GH id
Cryolitia) for diagnosing the issue and suggesting the fix.What changes are included in this PR?
Allow for some slight divergence (1 ULP) between the results.
Are these changes tested?
By definition.
Are there any user-facing changes?
No.
Was AI used for this PR?
In accordance to the AI generation guidelines, please disclose below whether and how AI was used in this PR.
PR code and description written by:
Reviewed before submission by: