diff mbox

[FFmpeg-devel,PATCHv2,2/2] checkasm: float_dsp: Scale FLT/DBL_EPSILON sufficiently when comparing

Message ID 20191211092114.31501-1-martin@martin.st
State Accepted
Commit 8f70e261fa6ff1f3efda5dbcebf02dcf6dea13b4
Headers show

Commit Message

Martin Storsjö Dec. 11, 2019, 9:21 a.m. UTC
As the values generated by av_bmg_get can be arbitrarily large
(only the stddev is specified), we can't use a fixed tolerance.

This matches what was done for test_vector_dmul_scalar in
38f966b2222db.

This fixes the float_dsp checkasm test for some seeds, when built
with clang for mingw/x86_32.
---
Tweaked the form of the tolerance to match the existing case, removed
unnecessarily wordy comments.
---
 tests/checkasm/float_dsp.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Michael Niedermayer Dec. 11, 2019, 2:55 p.m. UTC | #1
On Wed, Dec 11, 2019 at 11:21:14AM +0200, Martin Storsjö wrote:
> As the values generated by av_bmg_get can be arbitrarily large
> (only the stddev is specified), we can't use a fixed tolerance.
> 
> This matches what was done for test_vector_dmul_scalar in
> 38f966b2222db.
> 
> This fixes the float_dsp checkasm test for some seeds, when built
> with clang for mingw/x86_32.
> ---
> Tweaked the form of the tolerance to match the existing case, removed
> unnecessarily wordy comments.
> ---
>  tests/checkasm/float_dsp.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)

LGTM

thx
diff mbox

Patch

diff --git a/tests/checkasm/float_dsp.c b/tests/checkasm/float_dsp.c
index 2abe4eccbd..a1616a61a8 100644
--- a/tests/checkasm/float_dsp.c
+++ b/tests/checkasm/float_dsp.c
@@ -51,7 +51,8 @@  static void test_vector_fmul(const float *src0, const float *src1)
     call_ref(cdst, src0, src1, LEN);
     call_new(odst, src0, src1, LEN);
     for (i = 0; i < LEN; i++) {
-        if (!float_near_abs_eps(cdst[i], odst[i], FLT_EPSILON)) {
+        double t = fabs(src0[i]) + fabs(src1[i]) + fabs(src0[i] * src1[i]) + 1.0;
+        if (!float_near_abs_eps(cdst[i], odst[i], t * 2 * FLT_EPSILON)) {
             fprintf(stderr, "%d: %- .12f - %- .12f = % .12g\n",
                     i, cdst[i], odst[i], cdst[i] - odst[i]);
             fail();
@@ -73,7 +74,8 @@  static void test_vector_dmul(const double *src0, const double *src1)
     call_ref(cdst, src0, src1, LEN);
     call_new(odst, src0, src1, LEN);
     for (i = 0; i < LEN; i++) {
-        if (!double_near_abs_eps(cdst[i], odst[i], DBL_EPSILON)) {
+        double t = fabs(src0[i]) + fabs(src1[i]) + fabs(src0[i] * src1[i]) + 1.0;
+        if (!double_near_abs_eps(cdst[i], odst[i], t * 2 * DBL_EPSILON)) {
             fprintf(stderr, "%d: %- .12f - %- .12f = % .12g\n",
                     i, cdst[i], odst[i], cdst[i] - odst[i]);
             fail();
@@ -117,7 +119,8 @@  static void test_vector_fmul_scalar(const float *src0, const float *src1)
     call_ref(cdst, src0, src1[0], LEN);
     call_new(odst, src0, src1[0], LEN);
         for (i = 0; i < LEN; i++) {
-            if (!float_near_abs_eps(cdst[i], odst[i], FLT_EPSILON)) {
+            double t = fabs(src0[i]) + fabs(src1[0]) + fabs(src0[i] * src1[0]) + 1.0;
+            if (!float_near_abs_eps(cdst[i], odst[i], t * 2 * FLT_EPSILON)) {
                 fprintf(stderr, "%d: %- .12f - %- .12f = % .12g\n",
                         i, cdst[i], odst[i], cdst[i] - odst[i]);
                 fail();