mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-31 13:10:34 +00:00
[util] Clean up some ULP errors in tests
The problem with floating point in unit tests is, well, comparisons are finicky.
This commit is contained in:
parent
f18837f195
commit
f098bbf48b
2 changed files with 30 additions and 12 deletions
|
@ -352,7 +352,7 @@ static struct {
|
|||
{0, 0, 1,
|
||||
1, 0, 0,
|
||||
0, 1, 0}},
|
||||
#if defined(__i686__) && defined(__OPTIMIZE__)
|
||||
#if (defined(__i686__) || defined(__aarch64__)) && defined(__OPTIMIZE__)
|
||||
// the fp unit carries more precision than a 32-bit float, so
|
||||
// the close-to-zero errors are different
|
||||
{{s05, 0.0, 0.0, s05},
|
||||
|
|
|
@ -191,7 +191,11 @@ static vec4d_test_t vec4d_tests[] = {
|
|||
T(crossd, one, up, { 1, -1, 0} ),
|
||||
// This one fails when optimizing with -mfma (which is why fma is not
|
||||
// used): ulp errors in z and w
|
||||
T(crossd, qtest, qtest, {0, 0, 0, 0} ),
|
||||
T(crossd, qtest, qtest, {0, 0, 0, 0},
|
||||
#if defined(__aarch64__)
|
||||
{0, 0, -2.1938006966593093e-17, 1.3322676295501878e-17},
|
||||
#endif
|
||||
),
|
||||
|
||||
T(qmuld, qident, qident, qident ),
|
||||
T(qmuld, qident, right, right ),
|
||||
|
@ -213,7 +217,11 @@ static vec4d_test_t vec4d_tests[] = {
|
|||
T(qmuld, one, { 2, 2, 2, -2 }, { 0, 0, 0, -8 } ),
|
||||
// This one fails when optimizing with -mfma (which is why fma is not
|
||||
// used): ulp error in z
|
||||
T(qmuld, qtest, qtest, {0.768, 0.576, 0, -0.28} ),
|
||||
T(qmuld, qtest, qtest, {0.768, 0.576, 0, -0.28},
|
||||
#if defined(__aarch64__)
|
||||
{0, 0, -2.1938006966593093e-17, 0},
|
||||
#endif
|
||||
),
|
||||
|
||||
// The one vector is not unit (magnitude 2), so using it as a rotation
|
||||
// quaternion results in scaling by 4. However, it still has the effect
|
||||
|
@ -316,12 +324,16 @@ static vec4f_test_t vec4f_tests[] = {
|
|||
T(crossf, one, right, { 0, 1, -1} ),
|
||||
T(crossf, one, forward, {-1, 0, 1} ),
|
||||
T(crossf, one, up, { 1, -1, 0} ),
|
||||
#ifdef __aarch64__
|
||||
T(crossf, qtest, qtest, {0, 0, -1.47819534e-09, -1.43051153e-08} ),
|
||||
#else
|
||||
#if !defined(__SSE__) && !defined(__OPTIMIZE__)
|
||||
// when not optimizing and SSE is not available (but ok when
|
||||
// optimizing)
|
||||
T(crossf, qtest, qtest, {0, 0, -1.47819534e-09, 0} ),
|
||||
#else
|
||||
T(crossf, qtest, qtest, {0, 0, 0, 0} ),
|
||||
#endif
|
||||
#endif
|
||||
|
||||
T(qmulf, qident, qident, qident ),
|
||||
|
@ -343,6 +355,9 @@ static vec4f_test_t vec4f_tests[] = {
|
|||
T(qmulf, one, one, { 2, 2, 2, -2 } ),
|
||||
T(qmulf, one, { 2, 2, 2, -2 }, { 0, 0, 0, -8 } ),
|
||||
T(qmulf, qtest, qtest, {0.768, 0.576, 0, -0.28},
|
||||
#ifdef __aarch64__
|
||||
{0, 6e-8, -1.47819534e-09, 2.98023224e-08}
|
||||
#else
|
||||
#if !defined(__SSE__) && !defined(__OPTIMIZE__)
|
||||
// when not optimizing and SSE is not available (but ok when
|
||||
// optimizing)
|
||||
|
@ -351,6 +366,7 @@ static vec4f_test_t vec4f_tests[] = {
|
|||
{0, 6e-8, 0, 6e-8}
|
||||
#else
|
||||
{0, 6e-8, 0, 3e-8}
|
||||
#endif
|
||||
#endif
|
||||
),
|
||||
|
||||
|
@ -373,18 +389,18 @@ static vec4f_test_t vec4f_tests[] = {
|
|||
T(qvmulf, qtest, right, {0.5392, 0.6144, -0.576, 0},
|
||||
{0, -5.9e-8, -6e-8, 0} ),
|
||||
T(qvmulf, qtest, forward, {0.6144, 0.1808, 0.768, 0},
|
||||
#if !defined(__SSE__) && !defined(__OPTIMIZE__)
|
||||
#if !(defined(__SSE__) || defined(__aarch64__)) && !defined(__OPTIMIZE__)
|
||||
{-5.9e-8, 0, 0, 0}
|
||||
#elif !defined(__SSE__)
|
||||
#elif !(defined(__SSE__) || defined(__aarch64__))
|
||||
{-5.9e-8, 3e-8, 0, 0}
|
||||
#else
|
||||
{-5.9e-8, 1.5e-8, 0, 0}
|
||||
#endif
|
||||
),
|
||||
T(qvmulf, qtest, up, {0.576, -0.768, -0.28, 0},
|
||||
#if !defined(__SSE__) && !defined(__OPTIMIZE__)
|
||||
#if !(defined(__SSE__) || defined(__aarch64__)) && !defined(__OPTIMIZE__)
|
||||
{6e-8, 0, 3e-8, 0}
|
||||
#elif !defined(__SSE__)
|
||||
#elif !(defined(__SSE__) || defined(__aarch64__))
|
||||
{6e-8, 0, 6e-8, 0}
|
||||
#else
|
||||
{6e-8, 0, 3e-8, 0}
|
||||
|
@ -393,18 +409,18 @@ static vec4f_test_t vec4f_tests[] = {
|
|||
T(vqmulf, right, qtest, {0.5392, 0.6144, 0.576, 0},
|
||||
{0, -5.9e-8, 5.9e-8, 0} ),
|
||||
T(vqmulf, forward, qtest, {0.6144, 0.1808, -0.768, 0},
|
||||
#if !defined(__SSE__) && !defined(__OPTIMIZE__)
|
||||
#if !(defined(__SSE__) || defined(__aarch64__)) && !defined(__OPTIMIZE__)
|
||||
{-5.9e-8, 0, 0, 0}
|
||||
#elif !defined(__SSE__)
|
||||
#elif !(defined(__SSE__) || defined(__aarch64__))
|
||||
{-5.9e-8, 3e-8, 0, 0}
|
||||
#else
|
||||
{-5.9e-8, 1.5e-8, 0, 0}
|
||||
#endif
|
||||
),
|
||||
T(vqmulf, up, qtest, {-0.576, 0.768, -0.28, 0},
|
||||
#if !defined(__SSE__) && !defined(__OPTIMIZE__)
|
||||
#if !(defined(__SSE__) || defined(__aarch64__)) && !defined(__OPTIMIZE__)
|
||||
{-5.9e-8, 0, 3e-8, 0}
|
||||
#elif !defined(__SSE__)
|
||||
#elif !(defined(__SSE__) || defined(__aarch64__))
|
||||
{-5.9e-8, 0, 6e-8, 0}
|
||||
#else
|
||||
{-5.9e-8, 0, 3e-8, 0}
|
||||
|
@ -501,6 +517,7 @@ run_vec4d_tests (void)
|
|||
printf ("E: " VEC4D_FMT "\n", VEC4_EXP(expect));
|
||||
printf ("e: " VEC4D_FMT "\n", VEC4_EXP(test->expect));
|
||||
printf ("u: " VEC4D_FMT "\n", VEC4_EXP(test->ulp_errors));
|
||||
printf ("U: " VEC4D_FMT "\n", VEC4_EXP(result - test->expect));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
@ -526,6 +543,7 @@ run_vec4f_tests (void)
|
|||
printf ("E: " VEC4F_FMT "\n", VEC4_EXP(expect));
|
||||
printf ("e: " VEC4F_FMT "\n", VEC4_EXP(test->expect));
|
||||
printf ("u: " VEC4F_FMT "\n", VEC4_EXP(test->ulp_errors));
|
||||
printf ("U: " VEC4F_FMT "\n", VEC4_EXP(result - test->expect));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
|
Loading…
Reference in a new issue