This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Test underflow exceptions in libm-test.inc


On Thursday, May 24, 2012 00:53:55 Joseph S. Myers wrote:
> Although we have various bug reports referring to missing or spurious
> underflow exceptions from libm functions, the libm-test machinery
> doesn't support testing for such exceptions.  I propose this patch to
> add such support.  I decided to treat underflow exceptions like the
> others tested for - that is, say that we should consider spurious
> underflow exceptions to be bugs, although they are generally allowed
> by C99 Annex F.  (However, in cases of exact results that are
> subnormal or very close to subnormal I generally allow the exceptions
> rather than requiring accurate detection of inexactness - recall that
> exact underflow does not raise the exception in IEEE 754-2008.)
> 
> This will allow testcases to be added for the
> missing-underflow-exception bugs that were fixed by the use of
> -frounding-math to build glibc.
> 
> Tested x86 and x86_64.  The ulps changes are because the "name" of a
> test, used in the test's output as well as ulps files, includes a
> description of the expected exceptions.
> 
> 2012-05-24  Joseph Myers  <joseph@codesourcery.com>
> 
> 	* math/gen-libm-test.pl (%beautify): Add entries for underflow
> 	exceptions.
> 	* math/libm-test.inc ("Philosophy"): Update comment about
> 	exception testing.
> 	(UNDERFLOW_EXCEPTION): New macro.
> 	(UNDERFLOW_EXCEPTION_OK): Likewise.
> 	(UNDERFLOW_EXCEPTION_FLOAT): Likewise.
> 	(UNDERFLOW_EXCEPTION_OK_FLOAT): Likewise.
> 	(UNDERFLOW_EXCEPTION_DOUBLE): Likewise.
> 	(UNDERFLOW_EXCEPTION_LDOUBLE_IBM): Likewise.
> 	(INVALID_EXCEPTION_OK): Update value.
> 	(DIVIDE_BY_ZERO_EXCEPTION_OK): Likewise.
> 	(OVERFLOW_EXCEPTION_OK): Likewise.
> 	(IGNORE_ZERO_INF_SIGN): Likewise.
> 	(test_exceptions): Handle underflow exceptions.
> 	(acos_test): Update for underflow exception expectations.
> 	(cexp_test): Likewise.
> 	(clog_test): Likewise.
> 	(clog10_test): Likewise.
> 	(csqrt_test): Likewise.
> 	(ctan_test): Likewise.
> 	(ctanh_test): Likewise.
> 	(exp_test): Likewise.
> 	(exp10_test): Likewise.
> 	(exp2_test): Likewise.
> 	(expm1_test): Likewise.
> 	(fma_test): Likewise.
> 	(j0_test): Likewise.
> 	(jn_test): Likewise.
> 	(nexttoward_test): Likewise.
> 	(pow_test): Likewise.
> 	(scalbn_test): Likewise.
> 	(scalbln_test): Likewise.
> 	(tan_test): Likewise.
> 	(y1_test): Likewise.
> 	* sysdeps/i386/fpu/libm-test-ulps: Update.
> 	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
> 
> diff --git a/math/gen-libm-test.pl b/math/gen-libm-test.pl
> index 395bb65..2f15747 100755
> --- a/math/gen-libm-test.pl
> +++ b/math/gen-libm-test.pl
> @@ -79,9 +79,15 @@ use vars qw ($output_dir $ulps_file);
>      "INVALID_EXCEPTION" => "invalid exception",
>      "DIVIDE_BY_ZERO_EXCEPTION" => "division by zero exception",
>      "OVERFLOW_EXCEPTION" => "overflow exception",
> +    "UNDERFLOW_EXCEPTION" => "underflow exception",
> +    "UNDERFLOW_EXCEPTION_FLOAT" => "underflow exception for float",
> +    "UNDERFLOW_EXCEPTION_DOUBLE" => "underflow exception for double",
> +    "UNDERFLOW_EXCEPTION_LDOUBLE_IBM" => "underflow exception for
> IBM long double", "INVALID_EXCEPTION_OK" => "invalid exception
> allowed",
>      "DIVIDE_BY_ZERO_EXCEPTION_OK" => "division by zero exception
> allowed", "OVERFLOW_EXCEPTION_OK" => "overflow exception allowed", + 
>   "UNDERFLOW_EXCEPTION_OK" => "underflow exception allowed", +   
> "UNDERFLOW_EXCEPTION_OK_FLOAT" => "underflow exception allowed for
> float", "EXCEPTIONS_OK" => "exceptions allowed",
>      "IGNORE_ZERO_INF_SIGN" => "sign of zero/inf not specified",
>  "INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN" => "invalid exception and
> sign of zero/inf not specified" diff --git a/math/libm-test.inc
> b/math/libm-test.inc
> index 19c3c8a..454ff2d 100644
> --- a/math/libm-test.inc
> +++ b/math/libm-test.inc
> @@ -78,8 +78,8 @@
>     against.  These implemented tests should check all cases that are
>     specified in ISO C99.
> 
> -   Exception testing: At the moment only divide-by-zero, invalid and
> -   overflow exceptions are tested.  Underflow and inexact exceptions
> +   Exception testing: At the moment only divide-by-zero, invalid,
> +   overflow and underflow exceptions are tested.  Inexact exceptions
>     aren't checked at the moment.
> 
>     NaN values: There exist signalling and quiet NaNs.  This
> implementation @@ -149,13 +149,39 @@
>  #define INVALID_EXCEPTION		0x1
>  #define DIVIDE_BY_ZERO_EXCEPTION	0x2
>  #define OVERFLOW_EXCEPTION		0x4
> +#define UNDERFLOW_EXCEPTION		0x8
>  /* The next flags signals that those exceptions are allowed but not
> required.   */ -#define INVALID_EXCEPTION_OK		0x8
> -#define DIVIDE_BY_ZERO_EXCEPTION_OK	0x10
> -#define OVERFLOW_EXCEPTION_OK		0x20
> +#define INVALID_EXCEPTION_OK		0x10
> +#define DIVIDE_BY_ZERO_EXCEPTION_OK	0x20
> +#define OVERFLOW_EXCEPTION_OK		0x40
> +#define UNDERFLOW_EXCEPTION_OK		0x80
>  #define EXCEPTIONS_OK
> INVALID_EXCEPTION_OK+DIVIDE_BY_ZERO_EXCEPTION_OK 
> /* Some special test flags, passed togther with exceptions.  */ -#define

Could you correct the old typo above while you're at it, please? (together)

> IGNORE_ZERO_INF_SIGN		0x40
> +#define IGNORE_ZERO_INF_SIGN		0x100
> +

Thanks, this is ok,
Andreas
-- 
 Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi
  SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
   GF: Jeff Hawn,Jennifer Guild,Felix Imendörffer,HRB16746 (AG Nürnberg)
    GPG fingerprint = 93A3 365E CE47 B889 DF7F  FED1 389A 563C C272 A126


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]