This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Don't handle ulps for integer tests in libm-test.inc
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: <libc-alpha at sourceware dot org>
- Date: Fri, 17 May 2013 15:27:28 +0000
- Subject: Don't handle ulps for integer tests in libm-test.inc
libm-test.inc handles "ulps" values not just for tests with
floating-point results, but for those with integer results as well.
However, this handling has various problems:
* The code computing differences and absolute values could have signed
integer overflows.
* All integer results should always be exact and any deviation from
expected results is a bug which should be filed in Bugzilla (and if
necessary result in the test being disabled with a comment referring
to the bug) rather than a quality-of-implementation accuracy issue
that it's appropriate to handle through ulps settings.
* The ulps values output, if they do not overflow, end up getting
converted to the FLOAT type, possibly changing the value in some
cases.
This patch changes libm-test.inc not to consider or output ulps in
these cases, so check_int, check_long and check_longlong more closely
correspond to check_bool which also does not consider ulps. Tested
x86_64 and x86.
The immediately following intended cleanups are:
* Rather than gen-libm-test.pl generating a series of #defines in
libm-test-ulps.h, identified by a number for each test, it will
generate a few arrays containing { "test name", ulps-value }
entries, with libm-test.inc then looking up (using bsearch) ulps
values based on the name. This motivates the present change because
the present change will avoid the need for variants of the ulps
structure with integer ulps values.
This patch would be the one that actually removes the max_ulp
parameters from functions no longer needing them, and the associated
fields in test data structures.
* Do not include the function name in the test name strings going in
the arrays of tests. This is so that one array of tests can be
shared between multiple functions (e.g. gamma, lgamma, lgamma_r)
whose semantics are similar enough - and also so that (later) one
array can give expected results for all rounding modes, each of
which would have its own ulps value. Reuse of test arrays will
complicate gen-libm-test.pl knowing all the complete test names
associated with a given TEST_* line to find the corresponding DELTA*
macros. This motivates the previous change because runtime lookup
of ulps values avoids the need to determine complete test names and
ulps values when processing a TEST_* line.
2013-05-17 Joseph Myers <joseph@codesourcery.com>
* math/libm-test.inc (check_int): Expect result to be exactly
equal to expected value and do not handle ulps.
(check_long): Likewise.
(check_longlong): Likewise.
diff --git a/math/libm-test.inc b/math/libm-test.inc
index f5fabd3..1d478ed 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -734,19 +734,15 @@ static void
check_int (const char *test_name, int computed, int expected, int max_ulp,
int exceptions)
{
- int diff = computed - expected;
int ok = 0;
int errno_value = errno;
test_exceptions (test_name, exceptions);
test_errno (test_name, errno_value, exceptions);
noTests++;
- if (abs (diff) <= max_ulp)
+ if (computed == expected)
ok = 1;
- if (!ok)
- print_ulps (test_name, diff);
-
if (print_screen (ok))
{
if (!ok)
@@ -768,19 +764,15 @@ static void
check_long (const char *test_name, long int computed, long int expected,
long int max_ulp, int exceptions)
{
- long int diff = computed - expected;
int ok = 0;
int errno_value = errno;
test_exceptions (test_name, exceptions);
test_errno (test_name, errno_value, exceptions);
noTests++;
- if (labs (diff) <= max_ulp)
+ if (computed == expected)
ok = 1;
- if (!ok)
- print_ulps (test_name, diff);
-
if (print_screen (ok))
{
if (!ok)
@@ -834,19 +826,15 @@ check_longlong (const char *test_name, long long int computed,
long long int max_ulp,
int exceptions)
{
- long long int diff = computed - expected;
int ok = 0;
int errno_value = errno;
test_exceptions (test_name, exceptions);
test_errno (test_name, errno_value, exceptions);
noTests++;
- if (llabs (diff) <= max_ulp)
+ if (computed == expected)
ok = 1;
- if (!ok)
- print_ulps (test_name, diff);
-
if (print_screen (ok))
{
if (!ok)
--
Joseph S. Myers
joseph@codesourcery.com