tests: math: interpolation: disable floating point contraction
This test cannot tolerate any loss of precision, including the one caused by the compiler contracting floating points operations together, like in fused multiply-add (FMA). Some toolchains enable FP contraction by default, so disable it for the specific test and let the user decide themselves whether precision or performance is needed for their specific application. Co-authored-by: Jordan Yates <jordan@embeint.com> Co-authored-by: Ilya Tagunov <Ilya.Tagunov@synopsys.com> Signed-off-by: Ilya Tagunov <Ilya.Tagunov@synopsys.com>
This commit is contained in:
parent
5011ebad3b
commit
48d2382874
1 changed files with 12 additions and 0 deletions
|
|
@ -6,6 +6,18 @@
|
|||
#include <math.h>
|
||||
|
||||
#include <zephyr/ztest.h>
|
||||
|
||||
#ifdef __clang__
|
||||
/*
|
||||
* Floating-point contraction merges an operation of the form (a*b + c) from
|
||||
* two operations (fmul, fadd) into a single operation (fmadd). This can change
|
||||
* the value of the resulting LSB, causing problems when the expected value is
|
||||
* some multiple of 0.5f and the rounding functions are used. Disable
|
||||
* contraction for the tests to ensure this doesn't occur.
|
||||
*/
|
||||
#pragma STDC FP_CONTRACT OFF
|
||||
#endif
|
||||
|
||||
#include <zephyr/math/interpolation.h>
|
||||
|
||||
ZTEST(interpolation, test_interpolation_oob)
|
||||
|
|
|
|||
Loading…
Reference in a new issue