summaryrefslogtreecommitdiff
path: root/math/test-double.h
AgeCommit message (Collapse)Author
2018-02-09Add test infrastructure for narrowing libm functions.Joseph Myers
This patch continues preparations for adding TS 18661-1 narrowing libm functions by adding the required testsuite infrastructure to test such functions through the libm-test infrastructure. That infrastructure is based around testing for a single type, FLOAT. For the narrowing functions, FLOAT, the "main" type for testing, is the function return type; the argument type is ARG_FLOAT. This is consistent with how the code built once for each type, libm-test-support.c, depends on FLOAT for such things as calculating ulps errors in results but can already handle different argument types (pointers, integers, long double for nexttoward). Makefile machinery is added to handle building tests for all pairs of types for which there are narrowing functions (as with non-narrowing functions, aliases are tested just the same as the functions they alias). gen-auto-libm-tests gains a --narrow option for building outputs for narrowing functions (so narrowing sqrt and fma will share the same inputs as non-narrowing, but gen-auto-libm-tests will be run with and without that option to generate different output files). In the narrowing case, the auto-libm-test-out-narrow-* files include annotations for each test about what properties ARG_FLOAT must have to be able to represent all the inputs for that test; those annotations result in calls to the TEST_COND_arg_fmt macro. gen-libm-test.pl has some minor updates to handle narrowing tests (for example, arguments in such tests must be surrounded by ARG_LIT calls instead of LIT calls). Various new macros are added to the C test support code (for example, sNaN initializers need to be properly typed, so arg_snan_value is added; other such arg_* macros are added as it seems cleanest to do so, though some are not strictly required). Special-casing of the ibm128 format to allow for its limitations is adjusted to handle it as the argument format as well as as the result format; thus, the tests of the new functions allow nonzero ulps only in the case where ibm128 is the argument format, as otherwise the functions correspond to fully-defined IEEE operations. The ulps in question appear as e.g. 'Function: "add_ldouble"' in libm-test-ulps (with 1ulp errors then listed for double and float for that function in powerpc); no support is added to generate corresponding faddl / daddl ulps listings in the ulps table in the manual. For the previous patch, I noted the need to avoid spurious macro expansions of identifiers such as "add". A test test-narrow-macros.c is added to verify such macro expansions are successfully avoided, and there is also a -mlong-double-64 version of that test for ldbl-opt. This test is set up to cover the full set of relevant identifiers from the start rather than adding functions one at a time as each function group is added. Tested for x86_64 (this patch in isolation, as well as testing for various configurations in conjunction with the actual addition of "add" functions). * math/Makefile (test-type-pairs): New variable. (test-type-pairs-f64xf128-yes): Likewise. (tests): Add test-narrow-macros. (libm-test-funcs-narrow): New variable. (libm-test-c-narrow): Likewise. (generated): Add $(libm-test-c-narrow). (libm-tests-base-narrow): New variable. (libm-tests-narrow): Likewise. (libm-tests): Add $(libm-tests-narrow). (libm-tests-for-type): Handle $(libm-tests-narrow). (libm-test-c-narrow-obj): New variable. ($(libm-test-c-narrow-obj)): New rule. ($(foreach t,$(libm-tests-narrow),$(objpfx)$(t).c)): Likewise. ($(foreach f,$(libm-test-funcs-narrow),$(objpfx)$(o)-$(f).o)): Use $(o-iterator) to set dependencies and CFLAGS. * math/gen-auto-libm-tests.c: Document use for narrowing functions. (output_for_one_input_case): Take argument NARROW. (generate_output): Likewise. Update call to output_for_one_input_case. (main): Take --narrow option. Update call to generate_output. * math/gen-libm-test.pl (_apply_lit): Take macro name as argument. (apply_lit): Update call to _apply_lit. (apply_arglit): New function. (parse_args): Handle "a" arguments. (parse_auto_input): Handle format names using ":". * math/README.libm-test: Document "a" parameter type. * math/libm-test-support.h (ARG_TYPE_MIN): New macro. (ARG_TYPE_TRUE_MIN): Likewise. (ARG_TYPE_MAX): Likwise. (ARG_MIN_EXP): Likewise. (ARG_MAX_EXP): Likewise. (ARG_MANT_DIG): Likewise. (TEST_COND_arg_ibm128): Likewise. (TEST_COND_ibm128_libgcc): Define conditional on [ARG_FLOAT]. (TEST_COND_arg_fmt): New macro. (init_max_error): Update prototype. * math/libm-test-support.c (test_ibm128): New variable. (init_max_error): Take argument testing_ibm128 and set test_ibm128 instead of using [TEST_COND_ibm128] conditional. (test_exceptions): Use test_ibm128 instead of TEST_COND_ibm128. * math/libm-test-driver.c (STR_ARG_FLOAT): New macro. [TEST_NARROW] (TEST_MSG): New definition. (arg_plus_zero): New macro. (arg_minus_zero): Likewise. (arg_plus_infty): Likewise. (arg_minus_infty): Likewise. (arg_qnan_value_pl): Likewise. (arg_qnan_value): Likewise. (arg_snan_value_pl): Likewise. (arg_snan_value): Likewise. (arg_max_value): Likewise. (arg_min_value): Likewise. (arg_min_subnorm_value): Likewise. [ARG_FLOAT] (struct test_aa_f_data): New struct type. (RUN_TEST_LOOP_aa_f): New macro. (TEST_SUFF): New macro. (TEST_SUFF_STR): Likewise. [!TEST_MATHVEC] (VEC_SUFF): Don't define. (TEST_COND_any_ibm128): New macro. (START): Use TEST_SUFF and TEST_SUFF_STR in initializer for this_func. Update call to init_max_error. * math/test-double.h (FUNC_NARROW_PREFIX): New macro. * math/test-float.h (FUNC_NARROW_PREFIX): Likewise. * math/test-float128.h (FUNC_NARROW_PREFIX): Likewise. * math/test-float32.h (FUNC_NARROW_PREFIX): Likewise. * math/test-float32x.h (FUNC_NARROW_PREFIX): Likewise. * math/test-float64.h (FUNC_NARROW_PREFIX): Likewise. * math/test-float64x.h (FUNC_NARROW_PREFIX): Likewise. * math/test-math-scalar.h (TEST_NARROW): Likewise. * math/test-math-vector.h (TEST_NARROW): Likewise. * math/test-arg-double.h: New file. * math/test-arg-float128.h: Likewise. * math/test-arg-float32x.h: Likewise. * math/test-arg-float64.h: Likewise. * math/test-arg-float64x.h: Likewise. * math/test-arg-ldouble.h: Likewise. * math/test-math-narrow.h: Likewise. * math/test-narrow-macros.c: Likewise. * sysdeps/ieee754/ldbl-opt/test-narrow-macros-ldbl-64.c: Likewise. * sysdeps/ieee754/ldbl-opt/Makefile (tests): Add test-narrow-macros-ldbl-64. (CFLAGS-test-narrow-macros-ldbl-64.c): New variable.
2018-01-01Update copyright dates with scripts/update-copyrights.Joseph Myers
* All files with FSF copyright notices: Update copyright dates using scripts/update-copyrights. * locale/programs/charmap-kw.h: Regenerated. * locale/programs/locfile-kw.h: Likewise.
2017-10-11Run libm long double tests for long double = double.Joseph Myers
All interfaces in the glibc API ought to be covered by the testsuite, even where they alias other interfaces. This patch arranges for libm tests to be run for long double when it aliases double; previously those tests were run only for the floating-point types with distinct formats. The long double tests are made to use the double ulps values in this case, as having a separate duplicate set of ulps for them seems unnecessary; to accommodate that, the test-<type>.h headers now specify the macro indexing into the ulps array explicitly instead of having it computed from PREFIX. Nothing special is done about vector function tests. None are supported for any long double = double platforms, and supporting vector functions for a type alias such as _Float32 would not simply fall out of adding the scalar aliases for that type - it would require vector function wrappers like those for *_finite (or, better, a new GCC feature to allow specifying the asm name for vector functions independently of that for scalar ones, as previously discussed), so it seems reasonable to require the sysdeps makefile setting of libmvec-tests to be updated if any such tests are to be run for type aliases. Tested for x86_64 and arm. * math/Makefile (test-types-basic): New variable. (test-types): Likewise. (libm-test-support): Use $(test-types) instead of $(types). (libm-tests-base-normal): Likewise. (libm-tests-base-finite): Likewise. (libm-tests-base-inline): Likewise. (generated): Likewise. ($(objpfx)libm-test-support-$(t).c): Likewise. (libm-tests-for-type iterator): Likewise. (libm-test-support iterator): Likewise. * math/libm-test-support.c (ulp_i_idx): Use ULP_I_IDX. (ulp_idx): Use ULP_IDX. * math/test-ldouble.h: Include <float.h>. (TYPE_STR): Define conditional on [LDBL_MANT_DIG == DBL_MANT_DIG]. (ULP_IDX): New macro. (ULP_I_IDX): Likewise. * math/test-double.h (ULP_IDX): Likewise. (ULP_I_IDX): Likewise. * math/test-float.h (ULP_IDX): Likewise. (ULP_I_IDX): Likewise. * math/test-float128.h (ULP_IDX): Likewise. (ULP_I_IDX): Likewise.
2017-06-12float128: Add test-{float128,ifloat128,float128-finite}Paul E. Murphy
This adds test support for float128, and lays some groundwork for future _FloatN types. * math/gen-libm-test.pl (@all_floats): Add ifloat128 and float128. (%all_floats_pfx): Add macro prefix for float128 (FLT128). * math/libm-test-exp10.inc (pow10_test): Do not test for _FloatN, * math/libm-test-isfinite.inc (finite_test): Likewise. * math/libm-test-lgamma.inc (gamma_test): Likewise. * math/libm-test-nexttoward.inc (nexttoward_test): Likewise. (nexttoward_test_data}: Likewise. * math/libm-test-remainder.inc (drem_test): Likewise. * math/libm-test-scalb.inc (scalb_test): Likewise. (scalb_test_data): Likewise. * math/libm-test-significand.inc (significand_test): Likewise. (significand_test_data): Likewise. * math/libm-test-support.c (check_complex): Replace __complex__ FLOAT with CFLOAT to get the support for old compiler. * math/libm-test-support.h (check_complex): Likewise. * math/test-double.h (CFLOAT, TEST_FLOATN): New macros. * math/test-float.h (CFLOAT, TEST_FLOATN): Likewise. * math/test-ldouble.h (CFLOAT, TEST_FLOATN): Likewise. * math/test-float128.h: New file. * math/test-math-floatn.h: New file.
2017-01-01Update copyright dates with scripts/update-copyrights.Joseph Myers
2016-12-20Replace use of snprintf with strfrom in libm testsGabriel F. T. Gomes
In order to support float128 tests, the calls to snprintf, which does not support the type __float128, are replaced with calls to strfrom{f,d,l}. Tested for powerpc64le, s390, and x64_64.
2016-10-28Add SNAN, SNANF, SNANL macros.Joseph Myers
TS 18661-1 defines SNAN macros for signaling NaN values, suitable for use in static initializers. This patch adds them to glibc's <math.h> (provided you are building with GCC 3.3 or later; no attempt is made to provide any kind of nonconforming fallback for older compilers without the __builtin_nans functions). Tested for x86_64 and x86. * math/math.h [__GLIBC_USE (IEC_60559_BFP_EXT) && __GNUC_PREREQ (3, 3)] (SNANF): New macro. [__GLIBC_USE (IEC_60559_BFP_EXT) && __GNUC_PREREQ (3, 3)] (SNAN): Likewise. [__GLIBC_USE (IEC_60559_BFP_EXT) && __GNUC_PREREQ (3, 3)] (SNANL): Likewise. * manual/arith.texi (Infinity and NaN): Document SNANF, SNAN and SNANL. * math/test-double.h (snan_value_MACRO): New macro. * math/test-float.h (snan_value_MACRO): Likewise. * math/test-ldouble.h (snan_value_MACRO): Likewise. * math/libm-test.inc (issignaling_test_data): Add tests of snan_value_MACRO.
2016-06-08Remove CHOOSE() macro from libm-tests.incPaul E. Murphy
Use gen-libm-test.pl to generate a list of macros mapping to libm-test-ulps.h as this simplifies adding new types without having to modify a growing number of static headers each time a type is added. This also removes the final usage of the TEST_(DOUBLE|FLOAT|LDOUBLE) macros. Thus, they too are removed.
2016-05-27Replace M_PI2l with lit_pi_2_d in libm-test.incPaul E. Murphy
This is useful in situations where the long double type is less precise than the type under test. This adds a new wrapper macro LITM(x) to each type to append the proper suffix onto macro constants found in math.h.
2016-05-27Begin refactor of libm-test.incPaul E. Murphy
Attempt to creatively redefine the macros to choose tests based on the format being tested, not the type. Note, TS 18661 does not define any printf modifiers, so we need to be a little more verbose about constructing strings to output.
2016-01-04Update copyright dates with scripts/update-copyrights.Joseph Myers
2015-10-28Use C11 CMPLX* macros in libm tests.Joseph Myers
libm-test.inc has a macro BUILD_COMPLEX to construct a complex number with given real and imaginary parts while allowing properly for signed zeroes, infinities and NaNs (which don't work properly with a simple real + I * imag, in the absence of compiler support for imaginary types), using assignment to __real__ and __imag__ parts of the number. C11 defines CMPLX* macros for this purpose, which GCC 4.7 and above provide suitable built-in functions for. This patch redefines BUILD_COMPLEX in terms of the standard macros. Tested for x86_64 and x86. * math/libm-test.inc (BUILD_COMPLEX): Remove macro. * math/test-double.h (BUILD_COMPLEX): New macro. * math/test-float.h (BUILD_COMPLEX): Likewise. * math/test-ldouble.h (BUILD_COMPLEX): Likewise.
2015-06-24Refactor libm tests.Joseph Myers
This patch refactors the libm tests using libm-test.inc to reduce the level of duplicate definitions. New headers are created for the definitions shared by tests for a particular type; by tests of inline functions; by tests of non-inline functions; by scalar tests; and by vector tests. The unused MATHCONST macro is removed. A new macro VEC_LEN is added to the vector headers to allow the macros defining wrappers for vector functions to be defined once, instead of six times each (differing only in vector length) as before. There is still scope for further refactoring, but this seems a useful start. Tested for x86_64. * math/test-double.h: New file. * math/test-float.h: Likewise. * math/test-ldouble.h: Likewise. * math/test-math-inline.h: Likewise. * math/test-math-no-inline.h: Likewise. * math/test-math-scalar.h: Likewise. * math/test-math-vector.h: Likewise. * math/test-vec-loop.h: Remove file. Contents moved into test-math-vector.h. * math/libm-test.inc (MATHCONST): Do not document macro. * math/test-double.c: Include test-double.h, test-math-no-inline.h and test-math-scalar.h. (FUNC): Remove macro. (FUNC_TEST): Likewise. (FLOAT): Likewise. (MATHCONST): Likewise. (PRINTF_EXPR): Likewise. (PRINTF_XEXPR): Likewise. (PRINTF_NEXPR): Likewise. (TEST_DOUBLE): Likewise. (TEST_MATHVEC): Likewise. (__NO_MATH_INLINES): Likewise. * math/test-float.c: Include test-float.h, test-math-no-inline.h and test-math-scalar.h. (FUNC): Remove macro. (FUNC_TEST): Likewise. (FLOAT): Likewise. (MATHCONST): Likewise. (PRINTF_EXPR): Likewise. (PRINTF_XEXPR): Likewise. (PRINTF_NEXPR): Likewise. (TEST_FLOAT): Likewise. (TEST_MATHVEC): Likewise. (__NO_MATH_INLINES): Likewise. * math/test-idouble.c: Include test-double.h, test-math-inline.h and test-math-scalar.h. (FUNC): Remove macro. (FUNC_TEST): Likewise. (FLOAT): Likewise. (MATHCONST): Likewise. (PRINTF_EXPR): Likewise. (PRINTF_XEXPR): Likewise. (PRINTF_NEXPR): Likewise. (TEST_DOUBLE): Likewise. (TEST_MATHVEC): Likewise. (TEST_INLINE): Likewise. (__NO_MATH_INLINES): Likewise. * math/test-ifloat.c: Include test-float.h, test-math-inline.h and test-math-scalar.h. (FUNC): Remove macro. (FUNC_TEST): Likewise. (FLOAT): Likewise. (MATHCONST): Likewise. (PRINTF_EXPR): Likewise. (PRINTF_XEXPR): Likewise. (PRINTF_NEXPR): Likewise. (TEST_FLOAT): Likewise. (TEST_MATHVEC): Likewise. (TEST_INLINE): Likewise. (__NO_MATH_INLINES): Likewise. * math/test-ildoubl.c: Include test-ldouble.h, test-math-inline.h and test-math-scalar.h. (FUNC): Remove macro. (FUNC_TEST): Likewise. (FLOAT): Likewise. (MATHCONST): Likewise. (PRINTF_EXPR): Likewise. (PRINTF_XEXPR): Likewise. (PRINTF_NEXPR): Likewise. (TEST_LDOUBLE): Likewise. (TEST_MATHVEC): Likewise. (TEST_INLINE): Likewise. (__NO_MATH_INLINES): Likewise. * math/test-ldouble.c: Include test-ldouble.h, test-math-no-inline.h and test-math-scalar.h. (FUNC): Remove macro. (FUNC_TEST): Likewise. (FLOAT): Likewise. (MATHCONST): Likewise. (PRINTF_EXPR): Likewise. (PRINTF_XEXPR): Likewise. (PRINTF_NEXPR): Likewise. (TEST_LDOUBLE): Likewise. (TEST_MATHVEC): Likewise. (__NO_MATH_INLINES): Likewise. * math/test-double-vlen2.h: Include test-double.h, test-math-no-inline.h and test-math-vector.h. (FLOAT): Remove macro. (FUNC): Likewise. (MATHCONST): Likewise. (PRINTF_EXPR): Likewise. (PRINTF_XEXPR): Likewise. (PRINTF_NEXPR): Likewise. (TEST_DOUBLE): Likewise. (TEST_MATHVEC): Likewise. (__NO_MATH_INLINES): Likewise. (CNCT): Likewise. (CONCAT): Likewise. (WRAPPER_NAME): Likewise. (WRAPPER_DECL): Likewise. (WRAPPER_DECL_ff): Likewise. (WRAPPER_DECL_fFF): Likewise. (VECTOR_WRAPPER): Likewise. (VECTOR_WRAPPER_ff): Likewise. (VECTOR_WRAPPER_fFF): Likewise. (VEC_LEN): New macro. * math/test-double-vlen4.h: Include test-double.h, test-math-no-inline.h and test-math-vector.h. (FLOAT): Remove macro. (FUNC): Likewise. (MATHCONST): Likewise. (PRINTF_EXPR): Likewise. (PRINTF_XEXPR): Likewise. (PRINTF_NEXPR): Likewise. (TEST_DOUBLE): Likewise. (TEST_MATHVEC): Likewise. (__NO_MATH_INLINES): Likewise. (CNCT): Likewise. (CONCAT): Likewise. (WRAPPER_NAME): Likewise. (WRAPPER_DECL): Likewise. (WRAPPER_DECL_ff): Likewise. (WRAPPER_DECL_fFF): Likewise. (VECTOR_WRAPPER): Likewise. (VECTOR_WRAPPER_ff): Likewise. (VECTOR_WRAPPER_fFF): Likewise. (VEC_LEN): New macro. * math/test-double-vlen8.h: Include test-double.h, test-math-no-inline.h and test-math-vector.h. (FLOAT): Remove macro. (FUNC): Likewise. (MATHCONST): Likewise. (PRINTF_EXPR): Likewise. (PRINTF_XEXPR): Likewise. (PRINTF_NEXPR): Likewise. (TEST_DOUBLE): Likewise. (TEST_MATHVEC): Likewise. (__NO_MATH_INLINES): Likewise. (CNCT): Likewise. (CONCAT): Likewise. (WRAPPER_NAME): Likewise. (WRAPPER_DECL): Likewise. (WRAPPER_DECL_ff): Likewise. (WRAPPER_DECL_fFF): Likewise. (VECTOR_WRAPPER): Likewise. (VECTOR_WRAPPER_ff): Likewise. (VECTOR_WRAPPER_fFF): Likewise. (VEC_LEN): New macro. * math/test-float-vlen4.h: Include test-float.h, test-math-no-inline.h and test-math-vector.h. (FLOAT): Remove macro. (FUNC): Likewise. (MATHCONST): Likewise. (PRINTF_EXPR): Likewise. (PRINTF_XEXPR): Likewise. (PRINTF_NEXPR): Likewise. (TEST_FLOAT): Likewise. (TEST_MATHVEC): Likewise. (__NO_MATH_INLINES): Likewise. (CNCT): Likewise. (CONCAT): Likewise. (WRAPPER_NAME): Likewise. (WRAPPER_DECL): Likewise. (WRAPPER_DECL_ff): Likewise. (WRAPPER_DECL_fFF): Likewise. (VECTOR_WRAPPER): Likewise. (VECTOR_WRAPPER_ff): Likewise. (VECTOR_WRAPPER_fFF): Likewise. (VEC_LEN): New macro. * math/test-float-vlen8.h: Include test-float.h, test-math-no-inline.h and test-math-vector.h. (FLOAT): Remove macro. (FUNC): Likewise. (MATHCONST): Likewise. (PRINTF_EXPR): Likewise. (PRINTF_XEXPR): Likewise. (PRINTF_NEXPR): Likewise. (TEST_FLOAT): Likewise. (TEST_MATHVEC): Likewise. (__NO_MATH_INLINES): Likewise. (CNCT): Likewise. (CONCAT): Likewise. (WRAPPER_NAME): Likewise. (WRAPPER_DECL): Likewise. (WRAPPER_DECL_ff): Likewise. (WRAPPER_DECL_fFF): Likewise. (VECTOR_WRAPPER): Likewise. (VECTOR_WRAPPER_ff): Likewise. (VECTOR_WRAPPER_fFF): Likewise. (VEC_LEN): New macro. * math/test-float-vlen16.h: Include test-float.h, test-math-no-inline.h and test-math-vector.h. (FLOAT): Remove macro. (FUNC): Likewise. (MATHCONST): Likewise. (PRINTF_EXPR): Likewise. (PRINTF_XEXPR): Likewise. (PRINTF_NEXPR): Likewise. (TEST_FLOAT): Likewise. (TEST_MATHVEC): Likewise. (__NO_MATH_INLINES): Likewise. (CNCT): Likewise. (CONCAT): Likewise. (WRAPPER_NAME): Likewise. (WRAPPER_DECL): Likewise. (WRAPPER_DECL_ff): Likewise. (WRAPPER_DECL_fFF): Likewise. (VECTOR_WRAPPER): Likewise. (VECTOR_WRAPPER_ff): Likewise. (VECTOR_WRAPPER_fFF): Likewise. (VEC_LEN): New macro. * sysdeps/x86_64/fpu/test-double-vlen2-wrappers.c: Do not include test-vec-loop.h. * sysdeps/x86_64/fpu/test-double-vlen4-wrappers.c: Likewise. * sysdeps/x86_64/fpu/test-double-vlen4-avx2-wrappers.c: Likewise. * sysdeps/x86_64/fpu/test-double-vlen8-wrappers.c: Likewise. * sysdeps/x86_64/fpu/test-float-vlen4-wrappers.c: Likewise. * sysdeps/x86_64/fpu/test-float-vlen8-wrappers.c: Likewise. * sysdeps/x86_64/fpu/test-float-vlen8-avx2-wrappers.c: Likewise. * sysdeps/x86_64/fpu/test-float-vlen16-wrappers.c: Likewise.