aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJose Fonseca <[email protected]>2016-04-15 11:02:06 +0100
committerJose Fonseca <[email protected]>2016-04-19 11:31:53 +0100
commitbb9e8c5090f0826dcf24368f3017c784f45cfac8 (patch)
tree04fabb76ed4fc138e38a29d223d536a6ad3612e6
parentee9876be1d0a1d4efd3bbee398f984d4eba1a6f6 (diff)
llvmpipe: Skip false exp2 failure in lp_test_arit due to buggy MSVCRT.
64bits MSVCRT's exp2f(-inf) returns -inf instead of 0. Tested with MSVC 2013's CRT. (I haven't tried 2015 yet.) Also this does not happen with MinGW. Reviewed-by: Roland Scheidegger <[email protected]>
-rw-r--r--src/gallium/drivers/llvmpipe/lp_test_arit.c38
1 files changed, 34 insertions, 4 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_test_arit.c b/src/gallium/drivers/llvmpipe/lp_test_arit.c
index f3ba5a1f119..f0582ff83e1 100644
--- a/src/gallium/drivers/llvmpipe/lp_test_arit.c
+++ b/src/gallium/drivers/llvmpipe/lp_test_arit.c
@@ -108,6 +108,28 @@ static float sgnf(float x)
}
+const float sgn_values[] = {
+ -INFINITY,
+ -60,
+ -4,
+ -2,
+ -1,
+ -1e-007,
+ 0,
+ 1e-007,
+ 0.01,
+ 0.1,
+ 0.9,
+ 0.99,
+ 1,
+ 2,
+ 4,
+ 60,
+ INFINITY,
+ NAN
+};
+
+
const float exp2_values[] = {
-INFINITY,
-60,
@@ -273,9 +295,10 @@ const float fract_values[] = {
static const struct unary_test_t
unary_tests[] = {
- {"abs", &lp_build_abs, &fabsf, exp2_values, Elements(exp2_values), 20.0 },
- {"neg", &lp_build_negate, &negf, exp2_values, Elements(exp2_values), 20.0 },
- {"exp2", &lp_build_exp2, &exp2f, exp2_values, Elements(exp2_values), 20.0 },
+ {"abs", &lp_build_abs, &fabsf, sgn_values, Elements(sgn_values), 20.0 },
+ {"neg", &lp_build_negate, &negf, sgn_values, Elements(sgn_values), 20.0 },
+ {"sgn", &lp_build_sgn, &sgnf, sgn_values, Elements(sgn_values), 20.0 },
+ {"exp2", &lp_build_exp2, &exp2f, exp2_values, Elements(exp2_values), 18.0 },
{"log2", &lp_build_log2_safe, &log2f, log2_values, Elements(log2_values), 20.0 },
{"exp", &lp_build_exp, &expf, exp2_values, Elements(exp2_values), 18.0 },
{"log", &lp_build_log_safe, &logf, log2_values, Elements(log2_values), 20.0 },
@@ -283,7 +306,7 @@ unary_tests[] = {
{"rsqrt", &lp_build_rsqrt, &rsqrtf, rsqrt_values, Elements(rsqrt_values), 20.0 },
{"sin", &lp_build_sin, &sinf, sincos_values, Elements(sincos_values), 20.0 },
{"cos", &lp_build_cos, &cosf, sincos_values, Elements(sincos_values), 20.0 },
- {"sgn", &lp_build_sgn, &sgnf, exp2_values, Elements(exp2_values), 20.0 },
+ {"sgn", &lp_build_sgn, &sgnf, sgn_values, Elements(sgn_values), 20.0 },
{"round", &lp_build_round, &nearbyintf, round_values, Elements(round_values), 24.0 },
{"trunc", &lp_build_trunc, &truncf, round_values, Elements(round_values), 24.0 },
{"floor", &lp_build_floor, &floorf, round_values, Elements(round_values), 24.0 },
@@ -441,6 +464,13 @@ test_unary(unsigned verbose, FILE *fp, const struct unary_test_t *test, unsigned
expected_pass = FALSE;
}
+ if (test->ref == &expf && util_inf_sign(testval) == -1) {
+ /* XXX: 64bits MSVCRT's expf(-inf) returns -inf instead of 0 */
+#if defined(_MSC_VER) && defined(_WIN64)
+ expected_pass = FALSE;
+#endif
+ }
+
if (pass != expected_pass || verbose) {
printf("%s(%.9g): ref = %.9g, out = %.9g, precision = %f bits, %s%s\n",
test_name, in[i], ref, out[i], precision,