Skip to content

Commit

Permalink
bruteforce: Fix retry logic for cases with subnormals
Browse files Browse the repository at this point in the history
  • Loading branch information
tnimburk authored and Sreelakshmi Haridas Maruthur committed Sep 25, 2024
1 parent cd74e02 commit 0f8ee56
Showing 1 changed file with 53 additions and 72 deletions.
125 changes: 53 additions & 72 deletions test_conformance/math_brute_force/ternary_half.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,9 @@ int TestFunc_Half_Half_Half_Half(const Func *f, MTdata d, bool relaxedMode)
if (fail && ftz)
{
// retry per section 6.5.3.2 with flushing on
if (0.0f == test
&& 0.0f
== f->func.f_fma(HTF(hp0[j]), HTF(hp1[j]),
HTF(hp2[j]), FLUSHED))
float r = f->func.f_fma(HTF(hp0[j]), HTF(hp1[j]), HTF(hp2[j]), FLUSHED);
cl_half c = HFF(r);
if (0.0f == HTF(test) && IsHalfSubnormal(c))
{
fail = 0;
err = 0.0f;
Expand Down Expand Up @@ -349,13 +348,12 @@ int TestFunc_Half_Half_Half_Half(const Func *f, MTdata d, bool relaxedMode)
if (fabsf(err3) < fabsf(err)) err = err3;

// retry per section 6.5.3.4
if (0.0f == test
&& (0.0f
== f->func.f_fma(0.0f, HTF(hp1[j]),
HTF(hp2[j]), FLUSHED)
|| 0.0f
== f->func.f_fma(-0.0f, HTF(hp1[j]),
HTF(hp2[j]), FLUSHED)))
float r3 = f->func.f_fma(0.0f, HTF(hp1[j]), HTF(hp2[j]), FLUSHED);
float r4 = f->func.f_fma(-0.0f, HTF(hp1[j]) , HTF(hp2[j]), FLUSHED);
cl_half c3 = HFF(r3);
cl_half c4 = HFF(r4);

if (0.0f == HTF(test) && (IsHalfSubnormal(c3) || IsHalfSubnormal(c4)))
{
fail = 0;
err = 0.0f;
Expand Down Expand Up @@ -424,28 +422,21 @@ int TestFunc_Half_Half_Half_Half(const Func *f, MTdata d, bool relaxedMode)
if (fabsf(err5) < fabsf(err)) err = err5;

// retry per section 6.5.3.4
if (0.0f == test
&& (0.0f
== f->func.f_fma(0.0f, 0.0f,
HTF(hp2[j]),
FLUSHED)
|| 0.0f
== f->func.f_fma(-0.0f, 0.0f,
HTF(hp2[j]),
FLUSHED)
|| 0.0f
== f->func.f_fma(0.0f, -0.0f,
HTF(hp2[j]),
FLUSHED)
|| 0.0f
== f->func.f_fma(-0.0f, -0.0f,
HTF(hp2[j]),
FLUSHED)))
float r5 = f->func.f_fma(0.0f, 0.0f, HTF(hp2[j]), FLUSHED);
float r6 = f->func.f_fma(-0.0f, 0.0f, HTF(hp2[j]), FLUSHED);
float r7 = f->func.f_fma(0.0f, -0.0f, HTF(hp2[j]), FLUSHED);
float r8 = f->func.f_fma(-0.0f, -0.0f, HTF(hp2[j]), FLUSHED);

cl_half c5 = HFF(r5);
cl_half c6 = HFF(r6);
cl_half c7 = HFF(r7);
cl_half c8 = HFF(r8);
if (0.0f == HTF(test) && (IsHalfSubnormal(c5) || IsHalfSubnormal(c6)
|| IsHalfSubnormal(c7) || IsHalfSubnormal(c8)))
{
fail = 0;
err = 0.0f;
}

if (IsHalfSubnormal(hp2[j]))
{
if (test == 0.0f) // 0*0+0 is 0
Expand Down Expand Up @@ -517,19 +508,17 @@ int TestFunc_Half_Half_Half_Half(const Func *f, MTdata d, bool relaxedMode)
if (fabsf(err5) < fabsf(err)) err = err5;

// retry per section 6.5.3.4
if (0.0f == test
&& (0.0f
== f->func.f_fma(0.0f, HTF(hp1[j]),
0.0f, FLUSHED)
|| 0.0f
== f->func.f_fma(-0.0f, HTF(hp1[j]),
0.0f, FLUSHED)
|| 0.0f
== f->func.f_fma(0.0f, HTF(hp1[j]),
-0.0f, FLUSHED)
|| 0.0f
== f->func.f_fma(-0.0f, HTF(hp1[j]),
-0.0f, FLUSHED)))
float r9 = f->func.f_fma(0.0f, HTF(hp1[j]), 0.0f, FLUSHED);
float r10 = f->func.f_fma(-0.0f, HTF(hp1[j]), 0.0f, FLUSHED);
float r11 = f->func.f_fma(0.0f, HTF(hp1[j]), -0.0f, FLUSHED);
float r12 = f->func.f_fma(-0.0f, HTF(hp1[j]), -0.0f, FLUSHED);

cl_half c9 = HFF(r9);
cl_half c10 = HFF(r10);
cl_half c11 = HFF(r11);
cl_half c12 = HFF(r12);
if (0.0f == HTF(test) && (IsHalfSubnormal(c9) || IsHalfSubnormal(c10)
|| IsHalfSubnormal(c11) || IsHalfSubnormal(c12)))
{
fail = 0;
err = 0.0f;
Expand Down Expand Up @@ -575,13 +564,11 @@ int TestFunc_Half_Half_Half_Half(const Func *f, MTdata d, bool relaxedMode)
if (fabsf(err3) < fabsf(err)) err = err3;

// retry per section 6.5.3.4
if (0.0f == test
&& (0.0f
== f->func.f_fma(HTF(hp0[j]), 0.0f,
HTF(hp2[j]), FLUSHED)
|| 0.0f
== f->func.f_fma(HTF(hp0[j]), -0.0f,
HTF(hp2[j]), FLUSHED)))
float r7 = f->func.f_fma(HTF(hp0[j]), 0.0f, HTF(hp2[j]), FLUSHED);
float r8 = f->func.f_fma(HTF(hp0[j]), -0.0f, HTF(hp2[j]), FLUSHED);
cl_half c7 = HFF(r7);
cl_half c8 = HFF(r8);
if (0.0f == HTF(test) && (IsHalfSubnormal(c7) || IsHalfSubnormal(c8)))
{
fail = 0;
err = 0.0f;
Expand Down Expand Up @@ -650,19 +637,17 @@ int TestFunc_Half_Half_Half_Half(const Func *f, MTdata d, bool relaxedMode)
if (fabsf(err5) < fabsf(err)) err = err5;

// retry per section 6.5.3.4
if (0.0f == test
&& (0.0f
== f->func.f_fma(HTF(hp0[j]), 0.0f,
0.0f, FLUSHED)
|| 0.0f
== f->func.f_fma(HTF(hp0[j]), -0.0f,
0.0f, FLUSHED)
|| 0.0f
== f->func.f_fma(HTF(hp0[j]), 0.0f,
-0.0f, FLUSHED)
|| 0.0f
== f->func.f_fma(HTF(hp0[j]), -0.0f,
-0.0f, FLUSHED)))
float r13 = f->func.f_fma(HTF(hp0[j]), 0.0f, 0.0f, FLUSHED);
float r14= f->func.f_fma(HTF(hp0[j]), -0.0f, 0.0f, FLUSHED);
float r15 = f->func.f_fma(HTF(hp0[j]), 0.0f, -0.0f, FLUSHED);
float r16 = f->func.f_fma(HTF(hp0[j]), -0.0f, -0.0f, FLUSHED);

cl_half c9 = HFF(r13);
cl_half c10 = HFF(r14);
cl_half c11 = HFF(r15);
cl_half c12 = HFF(r16);
if (0.0f == HTF(test) && (IsHalfSubnormal(c9) || IsHalfSubnormal(c10)
|| IsHalfSubnormal(c11) || IsHalfSubnormal(c12)))
{
fail = 0;
err = 0.0f;
Expand Down Expand Up @@ -706,16 +691,12 @@ int TestFunc_Half_Half_Half_Half(const Func *f, MTdata d, bool relaxedMode)
if (fabsf(err2) < fabsf(err)) err = err2;
if (fabsf(err3) < fabsf(err)) err = err3;

// retry per section 6.5.3.4
if (0.0f == test
&& (0.0f
== f->func.f_fma(HTF(hp0[j]),
HTF(hp1[j]), 0.0f,
FLUSHED)
|| 0.0f
== f->func.f_fma(HTF(hp0[j]),
HTF(hp1[j]), -0.0f,
FLUSHED)))
// retry per section 6.5.3.4
float r17 = f->func.f_fma(HTF(hp0[j]), HTF(hp1[j]), 0.0f, FLUSHED);
float r18 = f->func.f_fma(HTF(hp0[j]), HTF(hp1[j]), -0.0f, FLUSHED);
cl_half c13 = HFF(r17);
cl_half c14 = HFF(r18);
if (0.0f == HTF(test) && (IsHalfSubnormal(c13) || IsHalfSubnormal(c14)))
{
fail = 0;
err = 0.0f;
Expand Down

0 comments on commit 0f8ee56

Please sign in to comment.