diff options
author | John Hauser <jhauser@eecs.berkeley.edu> | 2016-07-22 18:04:32 -0700 |
---|---|---|
committer | John Hauser <jhauser@eecs.berkeley.edu> | 2016-07-22 18:04:32 -0700 |
commit | ddfb9e70c434ae238635784ce66cb7ed93d0a2e7 (patch) | |
tree | 3502b5d96dcdbc5ad0c16c00caf4cd21428314b3 /source | |
parent | 11a6a656c7651695deacfdcda9c5d80fdbc05fee (diff) | |
download | berkeley-testfloat-3-ddfb9e70c434ae238635784ce66cb7ed93d0a2e7.zip berkeley-testfloat-3-ddfb9e70c434ae238635784ce66cb7ed93d0a2e7.tar.gz berkeley-testfloat-3-ddfb9e70c434ae238635784ce66cb7ed93d0a2e7.tar.bz2 |
Release 3b. See "doc/TestFloat-history.html".
Diffstat (limited to 'source')
177 files changed, 9730 insertions, 713 deletions
diff --git a/source/fail.c b/source/fail.c index 3c1f01d..732218a 100644 --- a/source/fail.c +++ b/source/fail.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/fail.h b/source/fail.h index cf48227..6a4519a 100644 --- a/source/fail.h +++ b/source/fail.h @@ -1,7 +1,7 @@ /*============================================================================ -This C header file is part of TestFloat, Release 3a, a package of programs for +This C header file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/functionInfos.c b/source/functionInfos.c index dacd1ef..1828c6a 100644 --- a/source/functionInfos.c +++ b/source/functionInfos.c @@ -1,12 +1,12 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. -Copyright 2011, 2012, 2013, 2014 The Regents of the University of California. -All rights reserved. +Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of +California. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -49,13 +49,15 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define EFF_T_REDP FUNC_EFF_TININESSMODE_REDUCEDPREC /*---------------------------------------------------------------------------- -| Warning: This array must match the functions names defined in -| "functions.h". +| Warning: This array must match the list of macros defined in "functions.h". *----------------------------------------------------------------------------*/ const struct functionInfo functionInfos[NUM_FUNCTIONS] = { { 0, 0 }, /*------------------------------------------------------------------------ *------------------------------------------------------------------------*/ +#ifdef FLOAT16 + { "ui32_to_f16", ARG_1 | EFF_R }, +#endif { "ui32_to_f32", ARG_1 | EFF_R }, { "ui32_to_f64", ARG_1 }, #ifdef EXTFLOAT80 @@ -64,6 +66,9 @@ const struct functionInfo functionInfos[NUM_FUNCTIONS] = { #ifdef FLOAT128 { "ui32_to_f128", ARG_1 }, #endif +#ifdef FLOAT16 + { "ui64_to_f16", ARG_1 | EFF_R }, +#endif { "ui64_to_f32", ARG_1 | EFF_R }, { "ui64_to_f64", ARG_1 | EFF_R }, #ifdef EXTFLOAT80 @@ -72,6 +77,9 @@ const struct functionInfo functionInfos[NUM_FUNCTIONS] = { #ifdef FLOAT128 { "ui64_to_f128", ARG_1 }, #endif +#ifdef FLOAT16 + { "i32_to_f16", ARG_1 | EFF_R }, +#endif { "i32_to_f32", ARG_1 | EFF_R }, { "i32_to_f64", ARG_1 }, #ifdef EXTFLOAT80 @@ -80,6 +88,9 @@ const struct functionInfo functionInfos[NUM_FUNCTIONS] = { #ifdef FLOAT128 { "i32_to_f128", ARG_1 }, #endif +#ifdef FLOAT16 + { "i64_to_f16", ARG_1 | EFF_R }, +#endif { "i64_to_f32", ARG_1 | EFF_R }, { "i64_to_f64", ARG_1 | EFF_R }, #ifdef EXTFLOAT80 @@ -90,6 +101,40 @@ const struct functionInfo functionInfos[NUM_FUNCTIONS] = { #endif /*------------------------------------------------------------------------ *------------------------------------------------------------------------*/ +#ifdef FLOAT16 + { "f16_to_ui32", ARG_1 | ARG_R | ARG_E }, + { "f16_to_ui64", ARG_1 | ARG_R | ARG_E }, + { "f16_to_i32", ARG_1 | ARG_R | ARG_E }, + { "f16_to_i64", ARG_1 | ARG_R | ARG_E }, + { "f16_to_ui32_r_minMag", ARG_1 | ARG_E }, + { "f16_to_ui64_r_minMag", ARG_1 | ARG_E }, + { "f16_to_i32_r_minMag", ARG_1 | ARG_E }, + { "f16_to_i64_r_minMag", ARG_1 | ARG_E }, + { "f16_to_f32", ARG_1 }, + { "f16_to_f64", ARG_1 }, +#ifdef EXTFLOAT80 + { "f16_to_extF80", ARG_1 }, +#endif +#ifdef FLOAT128 + { "f16_to_f128", ARG_1 }, +#endif + { "f16_roundToInt", ARG_1 | ARG_R | ARG_E }, + { "f16_add", ARG_2 | EFF_R }, + { "f16_sub", ARG_2 | EFF_R }, + { "f16_mul", ARG_2 | EFF_R | EFF_T }, + { "f16_mulAdd", EFF_R | EFF_T }, + { "f16_div", ARG_2 | EFF_R }, + { "f16_rem", ARG_2 }, + { "f16_sqrt", ARG_1 | EFF_R }, + { "f16_eq", ARG_2 }, + { "f16_le", ARG_2 }, + { "f16_lt", ARG_2 }, + { "f16_eq_signaling", ARG_2 }, + { "f16_le_quiet", ARG_2 }, + { "f16_lt_quiet", ARG_2 }, +#endif + /*------------------------------------------------------------------------ + *------------------------------------------------------------------------*/ { "f32_to_ui32", ARG_1 | ARG_R | ARG_E }, { "f32_to_ui64", ARG_1 | ARG_R | ARG_E }, { "f32_to_i32", ARG_1 | ARG_R | ARG_E }, @@ -98,6 +143,9 @@ const struct functionInfo functionInfos[NUM_FUNCTIONS] = { { "f32_to_ui64_r_minMag", ARG_1 | ARG_E }, { "f32_to_i32_r_minMag", ARG_1 | ARG_E }, { "f32_to_i64_r_minMag", ARG_1 | ARG_E }, +#ifdef FLOAT16 + { "f32_to_f16", ARG_1 | EFF_R | EFF_T }, +#endif { "f32_to_f64", ARG_1 }, #ifdef EXTFLOAT80 { "f32_to_extF80", ARG_1 }, @@ -129,7 +177,10 @@ const struct functionInfo functionInfos[NUM_FUNCTIONS] = { { "f64_to_ui64_r_minMag", ARG_1 | ARG_E }, { "f64_to_i32_r_minMag", ARG_1 | ARG_E }, { "f64_to_i64_r_minMag", ARG_1 | ARG_E }, - { "f64_to_f32", ARG_1 | EFF_R | EFF_T }, +#ifdef FLOAT16 + { "f64_to_f16", ARG_1 | EFF_R | EFF_T }, +#endif + { "f64_to_f32", ARG_1 | EFF_R | EFF_T }, #ifdef EXTFLOAT80 { "f64_to_extF80", ARG_1 }, #endif @@ -161,8 +212,11 @@ const struct functionInfo functionInfos[NUM_FUNCTIONS] = { { "extF80_to_ui64_r_minMag", ARG_1 | ARG_E }, { "extF80_to_i32_r_minMag", ARG_1 | ARG_E }, { "extF80_to_i64_r_minMag", ARG_1 | ARG_E }, - { "extF80_to_f32", ARG_1 | EFF_R | EFF_T }, - { "extF80_to_f64", ARG_1 | EFF_R | EFF_T }, +#ifdef FLOAT16 + { "extF80_to_f16", ARG_1 | EFF_R | EFF_T }, +#endif + { "extF80_to_f32", ARG_1 | EFF_R | EFF_T }, + { "extF80_to_f64", ARG_1 | EFF_R | EFF_T }, #ifdef FLOAT128 { "extF80_to_f128", ARG_1 }, #endif @@ -191,8 +245,11 @@ const struct functionInfo functionInfos[NUM_FUNCTIONS] = { { "f128_to_ui64_r_minMag", ARG_1 | ARG_E }, { "f128_to_i32_r_minMag", ARG_1 | ARG_E }, { "f128_to_i64_r_minMag", ARG_1 | ARG_E }, - { "f128_to_f32", ARG_1 | EFF_R | EFF_T }, - { "f128_to_f64", ARG_1 | EFF_R | EFF_T }, +#ifdef FLOAT16 + { "f128_to_f16", ARG_1 | EFF_R | EFF_T }, +#endif + { "f128_to_f32", ARG_1 | EFF_R | EFF_T }, + { "f128_to_f64", ARG_1 | EFF_R | EFF_T }, #ifdef EXTFLOAT80 { "f128_to_extF80", ARG_1 | EFF_R | EFF_T }, #endif diff --git a/source/functions.h b/source/functions.h index fd76faa..3c128cf 100644 --- a/source/functions.h +++ b/source/functions.h @@ -1,12 +1,12 @@ /*============================================================================ -This C header file is part of TestFloat, Release 3a, a package of programs for +This C header file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. -Copyright 2011, 2012, 2013, 2014 The Regents of the University of California. -All rights reserved. +Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of +California. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -41,7 +41,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | Warning: This list must match the contents of "functionInfos.c". *----------------------------------------------------------------------------*/ enum { + /*------------------------------------------------------------------------ + *------------------------------------------------------------------------*/ +#ifdef FLOAT16 + UI32_TO_F16 = 1, + UI32_TO_F32, +#else UI32_TO_F32 = 1, +#endif UI32_TO_F64, #ifdef EXTFLOAT80 UI32_TO_EXTF80, @@ -49,6 +56,9 @@ enum { #ifdef FLOAT128 UI32_TO_F128, #endif +#ifdef FLOAT16 + UI64_TO_F16, +#endif UI64_TO_F32, UI64_TO_F64, #ifdef EXTFLOAT80 @@ -57,6 +67,9 @@ enum { #ifdef FLOAT128 UI64_TO_F128, #endif +#ifdef FLOAT16 + I32_TO_F16, +#endif I32_TO_F32, I32_TO_F64, #ifdef EXTFLOAT80 @@ -65,6 +78,9 @@ enum { #ifdef FLOAT128 I32_TO_F128, #endif +#ifdef FLOAT16 + I64_TO_F16, +#endif I64_TO_F32, I64_TO_F64, #ifdef EXTFLOAT80 @@ -73,6 +89,42 @@ enum { #ifdef FLOAT128 I64_TO_F128, #endif + /*------------------------------------------------------------------------ + *------------------------------------------------------------------------*/ +#ifdef FLOAT16 + F16_TO_UI32, + F16_TO_UI64, + F16_TO_I32, + F16_TO_I64, + F16_TO_UI32_R_MINMAG, + F16_TO_UI64_R_MINMAG, + F16_TO_I32_R_MINMAG, + F16_TO_I64_R_MINMAG, + F16_TO_F32, + F16_TO_F64, +#ifdef EXTFLOAT80 + F16_TO_EXTF80, +#endif +#ifdef FLOAT128 + F16_TO_F128, +#endif + F16_ROUNDTOINT, + F16_ADD, + F16_SUB, + F16_MUL, + F16_MULADD, + F16_DIV, + F16_REM, + F16_SQRT, + F16_EQ, + F16_LE, + F16_LT, + F16_EQ_SIGNALING, + F16_LE_QUIET, + F16_LT_QUIET, +#endif + /*------------------------------------------------------------------------ + *------------------------------------------------------------------------*/ F32_TO_UI32, F32_TO_UI64, F32_TO_I32, @@ -81,6 +133,9 @@ enum { F32_TO_UI64_R_MINMAG, F32_TO_I32_R_MINMAG, F32_TO_I64_R_MINMAG, +#ifdef FLOAT16 + F32_TO_F16, +#endif F32_TO_F64, #ifdef EXTFLOAT80 F32_TO_EXTF80, @@ -102,6 +157,8 @@ enum { F32_EQ_SIGNALING, F32_LE_QUIET, F32_LT_QUIET, + /*------------------------------------------------------------------------ + *------------------------------------------------------------------------*/ F64_TO_UI32, F64_TO_UI64, F64_TO_I32, @@ -110,6 +167,9 @@ enum { F64_TO_UI64_R_MINMAG, F64_TO_I32_R_MINMAG, F64_TO_I64_R_MINMAG, +#ifdef FLOAT16 + F64_TO_F16, +#endif F64_TO_F32, #ifdef EXTFLOAT80 F64_TO_EXTF80, @@ -131,6 +191,8 @@ enum { F64_EQ_SIGNALING, F64_LE_QUIET, F64_LT_QUIET, + /*------------------------------------------------------------------------ + *------------------------------------------------------------------------*/ #ifdef EXTFLOAT80 EXTF80_TO_UI32, EXTF80_TO_UI64, @@ -140,6 +202,9 @@ enum { EXTF80_TO_UI64_R_MINMAG, EXTF80_TO_I32_R_MINMAG, EXTF80_TO_I64_R_MINMAG, +#ifdef FLOAT16 + EXTF80_TO_F16, +#endif EXTF80_TO_F32, EXTF80_TO_F64, #ifdef FLOAT128 @@ -159,6 +224,8 @@ enum { EXTF80_LE_QUIET, EXTF80_LT_QUIET, #endif + /*------------------------------------------------------------------------ + *------------------------------------------------------------------------*/ #ifdef FLOAT128 F128_TO_UI32, F128_TO_UI64, @@ -168,6 +235,9 @@ enum { F128_TO_UI64_R_MINMAG, F128_TO_I32_R_MINMAG, F128_TO_I64_R_MINMAG, +#ifdef FLOAT16 + F128_TO_F16, +#endif F128_TO_F32, F128_TO_F64, #ifdef EXTFLOAT80 diff --git a/source/functions_common.c b/source/functions_common.c index 0e905b3..0e979ea 100644 --- a/source/functions_common.c +++ b/source/functions_common.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/genCases.h b/source/genCases.h index 3443e36..63c6a3e 100644 --- a/source/genCases.h +++ b/source/genCases.h @@ -1,12 +1,12 @@ /*============================================================================ -This C header file is part of TestFloat, Release 3a, a package of programs for +This C header file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. -Copyright 2011, 2012, 2013, 2014 The Regents of the University of California. -All rights reserved. +Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of +California. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -62,6 +62,16 @@ void genCases_i64_a_init( void ); void genCases_i64_a_next( void ); extern int64_t genCases_i64_a; +#ifdef FLOAT16 +void genCases_f16_a_init( void ); +void genCases_f16_a_next( void ); +void genCases_f16_ab_init( void ); +void genCases_f16_ab_next( void ); +void genCases_f16_abc_init( void ); +void genCases_f16_abc_next( void ); +extern float16_t genCases_f16_a, genCases_f16_b, genCases_f16_c; +#endif + void genCases_f32_a_init( void ); void genCases_f32_a_next( void ); void genCases_f32_ab_init( void ); diff --git a/source/genCases_common.c b/source/genCases_common.c index 83a1fba..28da76b 100644 --- a/source/genCases_common.c +++ b/source/genCases_common.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/genCases_extF80.c b/source/genCases_extF80.c index 33a37a4..e5a552c 100644 --- a/source/genCases_extF80.c +++ b/source/genCases_extF80.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/genCases_f128.c b/source/genCases_f128.c index 68ccf4f..d02b991 100644 --- a/source/genCases_f128.c +++ b/source/genCases_f128.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/genCases_f16.c b/source/genCases_f16.c new file mode 100644 index 0000000..c5aa1b7 --- /dev/null +++ b/source/genCases_f16.c @@ -0,0 +1,585 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3b, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of +California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions, and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=============================================================================*/ + +#include <stdbool.h> +#include <stdint.h> +#include "platform.h" +#include "random.h" +#include "softfloat.h" +#include "genCases.h" + +#ifdef FLOAT16 + +struct sequence { + int expNum, term1Num, term2Num; + bool done; +}; + +union ui16_f16 { uint16_t ui; float16_t f; }; + +enum { + f16NumQIn = 22, + f16NumQOut = 34, + f16NumP1 = 4, + f16NumP2 = 36 +}; +static const uint16_t f16QIn[f16NumQIn] = { + 0x0000, /* positive, subnormal */ + 0x0400, /* positive, -14 */ + 0x1000, /* positive, -11 */ + 0x3400, /* positive, -2 */ + 0x3800, /* positive, -1 */ + 0x3C00, /* positive, 0 */ + 0x4000, /* positive, 1 */ + 0x4400, /* positive, 2 */ + 0x6800, /* positive, 11 */ + 0x7800, /* positive, 15 */ + 0x7C00, /* positive, infinity or NaN */ + 0x8000, /* negative, subnormal */ + 0x8400, /* negative, -14 */ + 0x9000, /* negative, -11 */ + 0xB400, /* negative, -2 */ + 0xB800, /* negative, -1 */ + 0xBC00, /* negative, 0 */ + 0xC000, /* negative, 1 */ + 0xC400, /* negative, 2 */ + 0xE800, /* negative, 11 */ + 0xF800, /* negative, 15 */ + 0xFC00 /* negative, infinity or NaN */ +}; +static const uint16_t f16QOut[f16NumQOut] = { + 0x0000, /* positive, subnormal */ + 0x0400, /* positive, -14 */ + 0x0800, /* positive, -13 */ + 0x1000, /* positive, -11 */ + 0x2C00, /* positive, -4 */ + 0x3000, /* positive, -3 */ + 0x3400, /* positive, -2 */ + 0x3800, /* positive, -1 */ + 0x3C00, /* positive, 0 */ + 0x4000, /* positive, 1 */ + 0x4400, /* positive, 2 */ + 0x4800, /* positive, 3 */ + 0x4C00, /* positive, 4 */ + 0x6800, /* positive, 11 */ + 0x7400, /* positive, 14 */ + 0x7800, /* positive, 15 */ + 0x7C00, /* positive, infinity or NaN */ + 0x8000, /* negative, subnormal */ + 0x8400, /* negative, -14 */ + 0x8800, /* negative, -13 */ + 0x9000, /* negative, -11 */ + 0xAC00, /* negative, -4 */ + 0xB000, /* negative, -3 */ + 0xB400, /* negative, -2 */ + 0xB800, /* negative, -1 */ + 0xBC00, /* negative, 0 */ + 0xC000, /* negative, 1 */ + 0xC400, /* negative, 2 */ + 0xC800, /* negative, 3 */ + 0xCC00, /* negative, 4 */ + 0xE800, /* negative, 11 */ + 0xF400, /* negative, 14 */ + 0xF800, /* negative, 15 */ + 0xFC00 /* negative, infinity or NaN */ +}; +static const uint16_t f16P1[f16NumP1] = { + 0x0000, + 0x0001, + 0x03FF, + 0x03FE +}; +static const uint16_t f16P2[f16NumP2] = { + 0x0000, + 0x0001, + 0x0002, + 0x0004, + 0x0008, + 0x0010, + 0x0020, + 0x0040, + 0x0080, + 0x0100, + 0x0200, + 0x0300, + 0x0380, + 0x03C0, + 0x03E0, + 0x03F0, + 0x03F8, + 0x03FC, + 0x03FE, + 0x03FF, + 0x03FD, + 0x03FB, + 0x03F7, + 0x03EF, + 0x03DF, + 0x03BF, + 0x037F, + 0x02FF, + 0x01FF, + 0x00FF, + 0x007F, + 0x003F, + 0x001F, + 0x000F, + 0x0007, + 0x0003 +}; + +static const uint_fast64_t f16NumQInP1 = f16NumQIn * f16NumP1; +static const uint_fast64_t f16NumQOutP1 = f16NumQOut * f16NumP1; + +static float16_t f16NextQInP1( struct sequence *sequencePtr ) +{ + int expNum, sigNum; + union ui16_f16 uZ; + + expNum = sequencePtr->expNum; + sigNum = sequencePtr->term1Num; + uZ.ui = f16QIn[expNum] | f16P1[sigNum]; + ++sigNum; + if ( f16NumP1 <= sigNum ) { + sigNum = 0; + ++expNum; + if ( f16NumQIn <= expNum ) { + expNum = 0; + sequencePtr->done = true; + } + sequencePtr->expNum = expNum; + } + sequencePtr->term1Num = sigNum; + return uZ.f; + +} + +static float16_t f16NextQOutP1( struct sequence *sequencePtr ) +{ + int expNum, sigNum; + union ui16_f16 uZ; + + expNum = sequencePtr->expNum; + sigNum = sequencePtr->term1Num; + uZ.ui = f16QOut[expNum] | f16P1[sigNum]; + ++sigNum; + if ( f16NumP1 <= sigNum ) { + sigNum = 0; + ++expNum; + if ( f16NumQOut <= expNum ) { + expNum = 0; + sequencePtr->done = true; + } + sequencePtr->expNum = expNum; + } + sequencePtr->term1Num = sigNum; + return uZ.f; + +} + +static const uint_fast64_t f16NumQInP2 = f16NumQIn * f16NumP2; +static const uint_fast64_t f16NumQOutP2 = f16NumQOut * f16NumP2; + +static float16_t f16NextQInP2( struct sequence *sequencePtr ) +{ + int expNum, sigNum; + union ui16_f16 uZ; + + expNum = sequencePtr->expNum; + sigNum = sequencePtr->term1Num; + uZ.ui = f16QIn[expNum] | f16P2[sigNum]; + ++sigNum; + if ( f16NumP2 <= sigNum ) { + sigNum = 0; + ++expNum; + if ( f16NumQIn <= expNum ) { + expNum = 0; + sequencePtr->done = true; + } + sequencePtr->expNum = expNum; + } + sequencePtr->term1Num = sigNum; + return uZ.f; + +} + +static float16_t f16NextQOutP2( struct sequence *sequencePtr ) +{ + int expNum, sigNum; + union ui16_f16 uZ; + + expNum = sequencePtr->expNum; + sigNum = sequencePtr->term1Num; + uZ.ui = f16QOut[expNum] | f16P2[sigNum]; + ++sigNum; + if ( f16NumP2 <= sigNum ) { + sigNum = 0; + ++expNum; + if ( f16NumQOut <= expNum ) { + expNum = 0; + sequencePtr->done = true; + } + sequencePtr->expNum = expNum; + } + sequencePtr->term1Num = sigNum; + return uZ.f; + +} + +static float16_t f16RandomQOutP3( void ) +{ + union ui16_f16 uZ; + + uZ.ui = + f16QOut[randomN_ui8( f16NumQOut )] + | ((f16P2[randomN_ui8( f16NumP2 )] + f16P2[randomN_ui8( f16NumP2 )]) + & 0x03FF); + return uZ.f; + +} + +static float16_t f16RandomQOutPInf( void ) +{ + union ui16_f16 uZ; + + uZ.ui = f16QOut[randomN_ui8( f16NumQOut )] | (random_ui16() & 0x03FF); + return uZ.f; + +} + +enum { f16NumQInfWeightMasks = 4 }; +static const uint16_t f16QInfWeightMasks[f16NumQInfWeightMasks] = + { 0xFC00, 0xFC00, 0xBC00, 0x9C00 }; +static const uint16_t f16QInfWeightOffsets[f16NumQInfWeightMasks] = + { 0x0000, 0x0000, 0x2000, 0x3000 }; + +static float16_t f16RandomQInfP3( void ) +{ + int weightMaskNum; + union ui16_f16 uZ; + + weightMaskNum = randomN_ui8( f16NumQInfWeightMasks ); + uZ.ui = + ((random_ui16() & f16QInfWeightMasks[weightMaskNum]) + + f16QInfWeightOffsets[weightMaskNum]) + | ((f16P2[randomN_ui8( f16NumP2 )] + f16P2[randomN_ui8( f16NumP2 )]) + & 0x03FF); + return uZ.f; + +} + +static float16_t f16RandomQInfPInf( void ) +{ + int weightMaskNum; + union ui16_f16 uZ; + + weightMaskNum = randomN_ui8( f16NumQInfWeightMasks ); + uZ.ui = + (random_ui16() & (f16QInfWeightMasks[weightMaskNum] | 0x03FF)) + + f16QInfWeightOffsets[weightMaskNum]; + return uZ.f; + +} + +static float16_t f16Random( void ) +{ + + switch ( random_ui8() & 7 ) { + case 0: + case 1: + case 2: + return f16RandomQOutP3(); + case 3: + return f16RandomQOutPInf(); + case 4: + case 5: + case 6: + return f16RandomQInfP3(); + case 7: + return f16RandomQInfPInf(); + } + +} + +static struct sequence sequenceA, sequenceB, sequenceC; +static float16_t currentA, currentB, currentC; +static int subcase; + +float16_t genCases_f16_a, genCases_f16_b, genCases_f16_c; + +void genCases_f16_a_init( void ) +{ + + sequenceA.expNum = 0; + sequenceA.term1Num = 0; + sequenceA.term2Num = 0; + sequenceA.done = false; + subcase = 0; + genCases_total = + (genCases_level == 1) ? 3 * f16NumQOutP1 : 2 * f16NumQOutP2; + genCases_done = false; + +} + +void genCases_f16_a_next( void ) +{ + + if ( genCases_level == 1 ) { + switch ( subcase ) { + case 0: + case 1: + genCases_f16_a = f16Random(); + break; + case 2: + genCases_f16_a = f16NextQOutP1( &sequenceA ); + genCases_done = sequenceA.done; + subcase = -1; + break; + } + } else { + switch ( subcase ) { + case 0: + genCases_f16_a = f16Random(); + break; + case 1: + genCases_f16_a = f16NextQOutP2( &sequenceA ); + genCases_done = sequenceA.done; + subcase = -1; + break; + } + } + ++subcase; + +} + +void genCases_f16_ab_init( void ) +{ + + sequenceA.expNum = 0; + sequenceA.term1Num = 0; + sequenceA.term2Num = 0; + sequenceA.done = false; + sequenceB.expNum = 0; + sequenceB.term1Num = 0; + sequenceB.term2Num = 0; + sequenceB.done = false; + subcase = 0; + if ( genCases_level == 1 ) { + genCases_total = 6 * f16NumQInP1 * f16NumQInP1; + currentA = f16NextQInP1( &sequenceA ); + } else { + genCases_total = 2 * f16NumQInP2 * f16NumQInP2; + currentA = f16NextQInP2( &sequenceA ); + } + genCases_done = false; + +} + +void genCases_f16_ab_next( void ) +{ + + if ( genCases_level == 1 ) { + switch ( subcase ) { + case 0: + if ( sequenceB.done ) { + sequenceB.done = false; + currentA = f16NextQInP1( &sequenceA ); + } + currentB = f16NextQInP1( &sequenceB ); + case 2: + case 4: + genCases_f16_a = f16Random(); + genCases_f16_b = f16Random(); + break; + case 1: + genCases_f16_a = currentA; + genCases_f16_b = f16Random(); + break; + case 3: + genCases_f16_a = f16Random(); + genCases_f16_b = currentB; + break; + case 5: + genCases_f16_a = currentA; + genCases_f16_b = currentB; + genCases_done = sequenceA.done & sequenceB.done; + subcase = -1; + break; + } + } else { + switch ( subcase ) { + case 0: + genCases_f16_a = f16Random(); + genCases_f16_b = f16Random(); + break; + case 1: + if ( sequenceB.done ) { + sequenceB.done = false; + currentA = f16NextQInP2( &sequenceA ); + } + genCases_f16_a = currentA; + genCases_f16_b = f16NextQInP2( &sequenceB ); + genCases_done = sequenceA.done & sequenceB.done; + subcase = -1; + break; + } + } + ++subcase; + +} + +void genCases_f16_abc_init( void ) +{ + + sequenceA.expNum = 0; + sequenceA.term1Num = 0; + sequenceA.term2Num = 0; + sequenceA.done = false; + sequenceB.expNum = 0; + sequenceB.term1Num = 0; + sequenceB.term2Num = 0; + sequenceB.done = false; + sequenceC.expNum = 0; + sequenceC.term1Num = 0; + sequenceC.term2Num = 0; + sequenceC.done = false; + subcase = 0; + if ( genCases_level == 1 ) { + genCases_total = 9 * f16NumQInP1 * f16NumQInP1 * f16NumQInP1; + currentA = f16NextQInP1( &sequenceA ); + currentB = f16NextQInP1( &sequenceB ); + } else { + genCases_total = 2 * f16NumQInP2 * f16NumQInP2 * f16NumQInP2; + currentA = f16NextQInP2( &sequenceA ); + currentB = f16NextQInP2( &sequenceB ); + } + genCases_done = false; + +} + +void genCases_f16_abc_next( void ) +{ + + if ( genCases_level == 1 ) { + switch ( subcase ) { + case 0: + if ( sequenceC.done ) { + sequenceC.done = false; + if ( sequenceB.done ) { + sequenceB.done = false; + currentA = f16NextQInP1( &sequenceA ); + } + currentB = f16NextQInP1( &sequenceB ); + } + currentC = f16NextQInP1( &sequenceC ); + genCases_f16_a = f16Random(); + genCases_f16_b = f16Random(); + genCases_f16_c = currentC; + break; + case 1: + genCases_f16_a = currentA; + genCases_f16_b = currentB; + genCases_f16_c = f16Random(); + break; + case 2: + genCases_f16_a = f16Random(); + genCases_f16_b = f16Random(); + genCases_f16_c = f16Random(); + break; + case 3: + genCases_f16_a = f16Random(); + genCases_f16_b = currentB; + genCases_f16_c = currentC; + break; + case 4: + genCases_f16_a = currentA; + genCases_f16_b = f16Random(); + genCases_f16_c = f16Random(); + break; + case 5: + genCases_f16_a = f16Random(); + genCases_f16_b = currentB; + genCases_f16_c = f16Random(); + break; + case 6: + genCases_f16_a = currentA; + genCases_f16_b = f16Random(); + genCases_f16_c = currentC; + break; + case 7: + genCases_f16_a = f16Random(); + genCases_f16_b = f16Random(); + genCases_f16_c = f16Random(); + break; + case 8: + genCases_f16_a = currentA; + genCases_f16_b = currentB; + genCases_f16_c = currentC; + genCases_done = sequenceA.done & sequenceB.done & sequenceC.done; + subcase = -1; + break; + } + } else { + switch ( subcase ) { + case 0: + genCases_f16_a = f16Random(); + genCases_f16_b = f16Random(); + genCases_f16_c = f16Random(); + break; + case 1: + if ( sequenceC.done ) { + sequenceC.done = false; + if ( sequenceB.done ) { + sequenceB.done = false; + currentA = f16NextQInP2( &sequenceA ); + } + currentB = f16NextQInP2( &sequenceB ); + } + genCases_f16_a = currentA; + genCases_f16_b = currentB; + genCases_f16_c = f16NextQInP2( &sequenceC ); + genCases_done = sequenceA.done & sequenceB.done & sequenceC.done; + subcase = -1; + break; + } + } + ++subcase; + +} + +#endif + diff --git a/source/genCases_f32.c b/source/genCases_f32.c index aef84ba..7e81530 100644 --- a/source/genCases_f32.c +++ b/source/genCases_f32.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/genCases_f64.c b/source/genCases_f64.c index d9cbf0a..1ef34be 100644 --- a/source/genCases_f64.c +++ b/source/genCases_f64.c @@ -1,12 +1,12 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. -Copyright 2011, 2012, 2013, 2014 The Regents of the University of California. -All rights reserved. +Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of +California. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -770,7 +770,7 @@ void genCases_f64_abc_next( void ) genCases_f64_a = currentA; genCases_f64_b = currentB; genCases_f64_c = currentC; - genCases_done = sequenceA.done & sequenceB.done & sequenceC.done;; + genCases_done = sequenceA.done & sequenceB.done & sequenceC.done; subcase = -1; break; } @@ -793,7 +793,7 @@ void genCases_f64_abc_next( void ) genCases_f64_a = currentA; genCases_f64_b = currentB; genCases_f64_c = f64NextQInP2( &sequenceC ); - genCases_done = sequenceA.done & sequenceB.done & sequenceC.done;; + genCases_done = sequenceA.done & sequenceB.done & sequenceC.done; subcase = -1; break; } diff --git a/source/genCases_i32.c b/source/genCases_i32.c index f900563..ff6ac15 100644 --- a/source/genCases_i32.c +++ b/source/genCases_i32.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/genCases_i64.c b/source/genCases_i64.c index a25d495..a7daf0c 100644 --- a/source/genCases_i64.c +++ b/source/genCases_i64.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/genCases_ui32.c b/source/genCases_ui32.c index 6eae344..08c978f 100644 --- a/source/genCases_ui32.c +++ b/source/genCases_ui32.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/genCases_ui64.c b/source/genCases_ui64.c index 28d08ac..9e28757 100644 --- a/source/genCases_ui64.c +++ b/source/genCases_ui64.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/genCases_writeTestsTotal.c b/source/genCases_writeTestsTotal.c index 1902331..833cda4 100644 --- a/source/genCases_writeTestsTotal.c +++ b/source/genCases_writeTestsTotal.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/genLoops.c b/source/genLoops.c index 620d306..f8a843a 100644 --- a/source/genLoops.c +++ b/source/genLoops.c @@ -1,12 +1,12 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. -Copyright 2011, 2012, 2013, 2014 The Regents of the University of California. -All rights reserved. +Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of +California. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -53,6 +53,9 @@ bool genLoops_givenCount; uint_fast64_t genLoops_count; uint_fast8_t *genLoops_trueFlagsPtr; +#ifdef FLOAT16 +union ui16_f16 { uint16_t ui; float16_t f; }; +#endif union ui32_f32 { uint32_t ui; float32_t f; }; union ui64_f64 { uint64_t ui; float64_t f; }; @@ -102,6 +105,23 @@ static bool writeGenOutputs_bool( bool z, uint_fast8_t flags ) } +#ifdef FLOAT16 + +static bool writeGenOutputs_ui16( uint_fast16_t z, uint_fast8_t flags ) +{ + + writeHex_ui16( z, ' ' ); + writeGenOutput_flags( flags ); + if ( genLoops_givenCount ) { + --genLoops_count; + if ( ! genLoops_count ) return true; + } + return false; + +} + +#endif + static bool writeGenOutputs_ui32( uint_fast32_t z, uint_fast8_t flags ) { @@ -141,7 +161,7 @@ static void writeHex_uiExtF80M( const extFloat80_t *aPtr, char sepChar ) } static - bool writeGenOutputs_extF80M( const extFloat80_t *aPtr, uint_fast8_t flags ) +bool writeGenOutputs_extF80M( const extFloat80_t *aPtr, uint_fast8_t flags ) { writeHex_uiExtF80M( aPtr, ' ' ); @@ -247,6 +267,70 @@ void gen_a_i64( void ) } +#ifdef FLOAT16 + +void gen_a_f16( void ) +{ + union ui16_f16 uA; + + genCases_f16_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f16_a_next(); + uA.f = genCases_f16_a; + writeHex_ui16( uA.ui, '\n' ); + if ( genLoops_givenCount ) { + --genLoops_count; + if ( ! genLoops_count ) break; + } + } + +} + +void gen_ab_f16( void ) +{ + union ui16_f16 u; + + genCases_f16_ab_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f16_ab_next(); + u.f = genCases_f16_a; + writeHex_ui16( u.ui, ' ' ); + u.f = genCases_f16_b; + writeHex_ui16( u.ui, '\n' ); + if ( genLoops_givenCount ) { + --genLoops_count; + if ( ! genLoops_count ) break; + } + } + +} + +void gen_abc_f16( void ) +{ + union ui16_f16 u; + + genCases_f16_abc_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f16_abc_next(); + u.f = genCases_f16_a; + writeHex_ui16( u.ui, ' ' ); + u.f = genCases_f16_b; + writeHex_ui16( u.ui, ' ' ); + u.f = genCases_f16_c; + writeHex_ui16( u.ui, '\n' ); + if ( genLoops_givenCount ) { + --genLoops_count; + if ( ! genLoops_count ) break; + } + } + +} + +#endif + void gen_a_f32( void ) { union ui32_f32 uA; @@ -477,6 +561,28 @@ void gen_abc_f128( void ) #endif +#ifdef FLOAT16 + +void gen_a_ui32_z_f16( float16_t trueFunction( uint32_t ) ) +{ + union ui16_f16 uTrueZ; + uint_fast8_t trueFlags; + + genCases_ui32_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_ui32_a_next(); + writeHex_ui32( genCases_ui32_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + uTrueZ.f = trueFunction( genCases_ui32_a ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui16( uTrueZ.ui, trueFlags ) ) break; + } + +} + +#endif + void gen_a_ui32_z_f32( float32_t trueFunction( uint32_t ) ) { union ui32_f32 uTrueZ; @@ -557,6 +663,28 @@ void gen_a_ui32_z_f128( void trueFunction( uint32_t, float128_t * ) ) #endif +#ifdef FLOAT16 + +void gen_a_ui64_z_f16( float16_t trueFunction( uint64_t ) ) +{ + union ui16_f16 uTrueZ; + uint_fast8_t trueFlags; + + genCases_ui64_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_ui64_a_next(); + writeHex_ui64( genCases_ui64_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + uTrueZ.f = trueFunction( genCases_ui64_a ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui16( uTrueZ.ui, trueFlags ) ) break; + } + +} + +#endif + void gen_a_ui64_z_f32( float32_t trueFunction( uint64_t ) ) { union ui32_f32 uTrueZ; @@ -637,6 +765,28 @@ void gen_a_ui64_z_f128( void trueFunction( uint64_t, float128_t * ) ) #endif +#ifdef FLOAT16 + +void gen_a_i32_z_f16( float16_t trueFunction( int32_t ) ) +{ + union ui16_f16 uTrueZ; + uint_fast8_t trueFlags; + + genCases_i32_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_i32_a_next(); + writeHex_ui32( genCases_i32_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + uTrueZ.f = trueFunction( genCases_i32_a ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui16( uTrueZ.ui, trueFlags ) ) break; + } + +} + +#endif + void gen_a_i32_z_f32( float32_t trueFunction( int32_t ) ) { union ui32_f32 uTrueZ; @@ -717,6 +867,28 @@ void gen_a_i32_z_f128( void trueFunction( int32_t, float128_t * ) ) #endif +#ifdef FLOAT16 + +void gen_a_i64_z_f16( float16_t trueFunction( int64_t ) ) +{ + union ui16_f16 uTrueZ; + uint_fast8_t trueFlags; + + genCases_i64_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_i64_a_next(); + writeHex_ui64( genCases_i64_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + uTrueZ.f = trueFunction( genCases_i64_a ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui16( uTrueZ.ui, trueFlags ) ) break; + } + +} + +#endif + void gen_a_i64_z_f32( float32_t trueFunction( int64_t ) ) { union ui32_f32 uTrueZ; @@ -797,6 +969,393 @@ void gen_a_i64_z_f128( void trueFunction( int64_t, float128_t * ) ) #endif +#ifdef FLOAT16 + +void + gen_a_f16_z_ui32_rx( + uint_fast32_t trueFunction( float16_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + union ui16_f16 uA; + uint_fast32_t trueZ; + uint_fast8_t trueFlags; + + genCases_f16_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f16_a_next(); + uA.f = genCases_f16_a; + writeHex_ui16( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f16_a, roundingMode, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui32( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_f16_z_ui64_rx( + uint_fast64_t trueFunction( float16_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + union ui16_f16 uA; + uint_fast64_t trueZ; + uint_fast8_t trueFlags; + + genCases_f16_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f16_a_next(); + uA.f = genCases_f16_a; + writeHex_ui16( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f16_a, roundingMode, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui64( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_f16_z_i32_rx( + int_fast32_t trueFunction( float16_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + union ui16_f16 uA; + int_fast32_t trueZ; + uint_fast8_t trueFlags; + + genCases_f16_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f16_a_next(); + uA.f = genCases_f16_a; + writeHex_ui16( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f16_a, roundingMode, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui32( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_f16_z_i64_rx( + int_fast64_t trueFunction( float16_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + union ui16_f16 uA; + int_fast64_t trueZ; + uint_fast8_t trueFlags; + + genCases_f16_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f16_a_next(); + uA.f = genCases_f16_a; + writeHex_ui16( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f16_a, roundingMode, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui64( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_f16_z_ui32_x( + uint_fast32_t trueFunction( float16_t, bool ), bool exact ) +{ + union ui16_f16 uA; + uint_fast32_t trueZ; + uint_fast8_t trueFlags; + + genCases_f16_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f16_a_next(); + uA.f = genCases_f16_a; + writeHex_ui16( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f16_a, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui32( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_f16_z_ui64_x( + uint_fast64_t trueFunction( float16_t, bool ), bool exact ) +{ + union ui16_f16 uA; + uint_fast64_t trueZ; + uint_fast8_t trueFlags; + + genCases_f16_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f16_a_next(); + uA.f = genCases_f16_a; + writeHex_ui16( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f16_a, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui64( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_f16_z_i32_x( int_fast32_t trueFunction( float16_t, bool ), bool exact ) +{ + union ui16_f16 uA; + int_fast32_t trueZ; + uint_fast8_t trueFlags; + + genCases_f16_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f16_a_next(); + uA.f = genCases_f16_a; + writeHex_ui16( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f16_a, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui32( trueZ, trueFlags ) ) break; + } + +} + +void + gen_a_f16_z_i64_x( int_fast64_t trueFunction( float16_t, bool ), bool exact ) +{ + union ui16_f16 uA; + int_fast64_t trueZ; + uint_fast8_t trueFlags; + + genCases_f16_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f16_a_next(); + uA.f = genCases_f16_a; + writeHex_ui16( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f16_a, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui64( trueZ, trueFlags ) ) break; + } + +} + +void gen_a_f16_z_f32( float32_t trueFunction( float16_t ) ) +{ + union ui16_f16 uA; + union ui32_f32 uTrueZ; + uint_fast8_t trueFlags; + + genCases_f16_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f16_a_next(); + uA.f = genCases_f16_a; + writeHex_ui16( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + uTrueZ.f = trueFunction( genCases_f16_a ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui32( uTrueZ.ui, trueFlags ) ) break; + } + +} + +void gen_a_f16_z_f64( float64_t trueFunction( float16_t ) ) +{ + union ui16_f16 uA; + union ui64_f64 uTrueZ; + uint_fast8_t trueFlags; + + genCases_f16_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f16_a_next(); + uA.f = genCases_f16_a; + writeHex_ui16( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + uTrueZ.f = trueFunction( genCases_f16_a ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui64( uTrueZ.ui, trueFlags ) ) break; + } + +} + +#ifdef EXTFLOAT80 + +void gen_a_f16_z_extF80( void trueFunction( float16_t, extFloat80_t * ) ) +{ + union ui16_f16 uA; + extFloat80_t trueZ; + uint_fast8_t trueFlags; + + genCases_f16_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f16_a_next(); + uA.f = genCases_f16_a; + writeHex_ui16( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueFunction( genCases_f16_a, &trueZ ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_extF80M( &trueZ, trueFlags ) ) break; + } + +} + +#endif + +#ifdef FLOAT128 + +void gen_a_f16_z_f128( void trueFunction( float16_t, float128_t * ) ) +{ + union ui16_f16 uA; + float128_t trueZ; + uint_fast8_t trueFlags; + + genCases_f16_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f16_a_next(); + uA.f = genCases_f16_a; + writeHex_ui16( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueFunction( genCases_f16_a, &trueZ ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_f128M( &trueZ, trueFlags ) ) break; + } + +} + +#endif + +void gen_az_f16( float16_t trueFunction( float16_t ) ) +{ + union ui16_f16 u; + uint_fast8_t trueFlags; + + genCases_f16_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f16_a_next(); + u.f = genCases_f16_a; + writeHex_ui16( u.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + u.f = trueFunction( genCases_f16_a ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui16( u.ui, trueFlags ) ) break; + } + +} + +void + gen_az_f16_rx( + float16_t trueFunction( float16_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + union ui16_f16 u; + uint_fast8_t trueFlags; + + genCases_f16_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f16_a_next(); + u.f = genCases_f16_a; + writeHex_ui16( u.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + u.f = trueFunction( genCases_f16_a, roundingMode, exact ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui16( u.ui, trueFlags ) ) break; + } + +} + +void gen_abz_f16( float16_t trueFunction( float16_t, float16_t ) ) +{ + union ui16_f16 u; + uint_fast8_t trueFlags; + + genCases_f16_ab_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f16_ab_next(); + u.f = genCases_f16_a; + writeHex_ui16( u.ui, ' ' ); + u.f = genCases_f16_b; + writeHex_ui16( u.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + u.f = trueFunction( genCases_f16_a, genCases_f16_b ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui16( u.ui, trueFlags ) ) break; + } + +} + +void gen_abcz_f16( float16_t trueFunction( float16_t, float16_t, float16_t ) ) +{ + union ui16_f16 u; + uint_fast8_t trueFlags; + + genCases_f16_abc_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f16_abc_next(); + u.f = genCases_f16_a; + writeHex_ui16( u.ui, ' ' ); + u.f = genCases_f16_b; + writeHex_ui16( u.ui, ' ' ); + u.f = genCases_f16_c; + writeHex_ui16( u.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + u.f = trueFunction( genCases_f16_a, genCases_f16_b, genCases_f16_c ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui16( u.ui, trueFlags ) ) break; + } + +} + +void gen_ab_f16_z_bool( bool trueFunction( float16_t, float16_t ) ) +{ + union ui16_f16 u; + bool trueZ; + uint_fast8_t trueFlags; + + genCases_f16_ab_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f16_ab_next(); + u.f = genCases_f16_a; + writeHex_ui16( u.ui, ' ' ); + u.f = genCases_f16_b; + writeHex_ui16( u.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f16_a, genCases_f16_b ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_bool( trueZ, trueFlags ) ) break; + } + +} + +#endif + void gen_a_f32_z_ui32_rx( uint_fast32_t trueFunction( float32_t, uint_fast8_t, bool ), @@ -983,6 +1542,30 @@ void } +#ifdef FLOAT16 + +void gen_a_f32_z_f16( float16_t trueFunction( float32_t ) ) +{ + union ui32_f32 uA; + union ui16_f16 uTrueZ; + uint_fast8_t trueFlags; + + genCases_f32_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f32_a_next(); + uA.f = genCases_f32_a; + writeHex_ui32( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + uTrueZ.f = trueFunction( genCases_f32_a ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui16( uTrueZ.ui, trueFlags ) ) break; + } + +} + +#endif + void gen_a_f32_z_f64( float64_t trueFunction( float32_t ) ) { union ui32_f32 uA; @@ -1346,6 +1929,30 @@ void } +#ifdef FLOAT16 + +void gen_a_f64_z_f16( float16_t trueFunction( float64_t ) ) +{ + union ui64_f64 uA; + union ui16_f16 uTrueZ; + uint_fast8_t trueFlags; + + genCases_f64_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f64_a_next(); + uA.f = genCases_f64_a; + writeHex_ui64( uA.ui, ' ' ); + *genLoops_trueFlagsPtr = 0; + uTrueZ.f = trueFunction( genCases_f64_a ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui16( uTrueZ.ui, trueFlags ) ) break; + } + +} + +#endif + void gen_a_f64_z_f32( float32_t trueFunction( float64_t ) ) { union ui64_f64 uA; @@ -1697,6 +2304,28 @@ void } +#ifdef FLOAT16 + +void gen_a_extF80_z_f16( float16_t trueFunction( const extFloat80_t * ) ) +{ + union ui16_f16 uTrueZ; + uint_fast8_t trueFlags; + + genCases_extF80_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_extF80_a_next(); + writeHex_uiExtF80M( &genCases_extF80_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + uTrueZ.f = trueFunction( &genCases_extF80_a ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui16( uTrueZ.ui, trueFlags ) ) break; + } + +} + +#endif + void gen_a_extF80_z_f32( float32_t trueFunction( const extFloat80_t * ) ) { union ui32_f32 uTrueZ; @@ -2050,6 +2679,28 @@ void } +#ifdef FLOAT16 + +void gen_a_f128_z_f16( float16_t trueFunction( const float128_t * ) ) +{ + union ui16_f16 uTrueZ; + uint_fast8_t trueFlags; + + genCases_f128_a_init(); + checkEnoughCases(); + while ( ! genLoops_stop && (! genCases_done || genLoops_forever) ) { + genCases_f128_a_next(); + writeHex_uiF128M( &genCases_f128_a, ' ' ); + *genLoops_trueFlagsPtr = 0; + uTrueZ.f = trueFunction( &genCases_f128_a ); + trueFlags = *genLoops_trueFlagsPtr; + if ( writeGenOutputs_ui16( uTrueZ.ui, trueFlags ) ) break; + } + +} + +#endif + void gen_a_f128_z_f32( float32_t trueFunction( const float128_t * ) ) { union ui32_f32 uTrueZ; diff --git a/source/genLoops.h b/source/genLoops.h index 30363af..2125a96 100644 --- a/source/genLoops.h +++ b/source/genLoops.h @@ -1,12 +1,12 @@ /*============================================================================ -This C header file is part of TestFloat, Release 3a, a package of programs for +This C header file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. -Copyright 2011, 2012, 2013, 2014 The Regents of the University of California. -All rights reserved. +Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of +California. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -50,6 +50,11 @@ void gen_a_ui32( void ); void gen_a_ui64( void ); void gen_a_i32( void ); void gen_a_i64( void ); +#ifdef FLOAT16 +void gen_a_f16( void ); +void gen_ab_f16( void ); +void gen_abc_f16( void ); +#endif void gen_a_f32( void ); void gen_ab_f32( void ); void gen_abc_f32( void ); @@ -67,6 +72,9 @@ void gen_ab_f128( void ); void gen_abc_f128( void ); #endif +#ifdef FLOAT16 +void gen_a_ui32_z_f16( float16_t ( uint32_t ) ); +#endif void gen_a_ui32_z_f32( float32_t ( uint32_t ) ); void gen_a_ui32_z_f64( float64_t ( uint32_t ) ); #ifdef EXTFLOAT80 @@ -75,6 +83,9 @@ void gen_a_ui32_z_extF80( void ( uint32_t, extFloat80_t * ) ); #ifdef FLOAT128 void gen_a_ui32_z_f128( void ( uint32_t, float128_t * ) ); #endif +#ifdef FLOAT16 +void gen_a_ui64_z_f16( float16_t ( uint64_t ) ); +#endif void gen_a_ui64_z_f32( float32_t ( uint64_t ) ); void gen_a_ui64_z_f64( float64_t ( uint64_t ) ); #ifdef EXTFLOAT80 @@ -83,6 +94,9 @@ void gen_a_ui64_z_extF80( void ( uint64_t, extFloat80_t * ) ); #ifdef FLOAT128 void gen_a_ui64_z_f128( void ( uint64_t, float128_t * ) ); #endif +#ifdef FLOAT16 +void gen_a_i32_z_f16( float16_t ( int32_t ) ); +#endif void gen_a_i32_z_f32( float32_t ( int32_t ) ); void gen_a_i32_z_f64( float64_t ( int32_t ) ); #ifdef EXTFLOAT80 @@ -91,6 +105,9 @@ void gen_a_i32_z_extF80( void ( int32_t, extFloat80_t * ) ); #ifdef FLOAT128 void gen_a_i32_z_f128( void ( int32_t, float128_t * ) ); #endif +#ifdef FLOAT16 +void gen_a_i64_z_f16( float16_t ( int64_t ) ); +#endif void gen_a_i64_z_f32( float32_t ( int64_t ) ); void gen_a_i64_z_f64( float64_t ( int64_t ) ); #ifdef EXTFLOAT80 @@ -100,6 +117,40 @@ void gen_a_i64_z_extF80( void ( int64_t, extFloat80_t * ) ); void gen_a_i64_z_f128( void ( int64_t, float128_t * ) ); #endif +#ifdef FLOAT16 +void + gen_a_f16_z_ui32_rx( + uint_fast32_t ( float16_t, uint_fast8_t, bool ), uint_fast8_t, bool ); +void + gen_a_f16_z_ui64_rx( + uint_fast64_t ( float16_t, uint_fast8_t, bool ), uint_fast8_t, bool ); +void + gen_a_f16_z_i32_rx( + int_fast32_t ( float16_t, uint_fast8_t, bool ), uint_fast8_t, bool ); +void + gen_a_f16_z_i64_rx( + int_fast64_t ( float16_t, uint_fast8_t, bool ), uint_fast8_t, bool ); +void gen_a_f16_z_ui32_x( uint_fast32_t ( float16_t, bool ), bool ); +void gen_a_f16_z_ui64_x( uint_fast64_t ( float16_t, bool ), bool ); +void gen_a_f16_z_i32_x( int_fast32_t ( float16_t, bool ), bool ); +void gen_a_f16_z_i64_x( int_fast64_t ( float16_t, bool ), bool ); +void gen_a_f16_z_f32( float32_t ( float16_t ) ); +void gen_a_f16_z_f64( float64_t ( float16_t ) ); +#ifdef EXTFLOAT80 +void gen_a_f16_z_extF80( void ( float16_t, extFloat80_t * ) ); +#endif +#ifdef FLOAT128 +void gen_a_f16_z_f128( void ( float16_t, float128_t * ) ); +#endif +void gen_az_f16( float16_t ( float16_t ) ); +void + gen_az_f16_rx( + float16_t ( float16_t, uint_fast8_t, bool ), uint_fast8_t, bool ); +void gen_abz_f16( float16_t ( float16_t, float16_t ) ); +void gen_abcz_f16( float16_t ( float16_t, float16_t, float16_t ) ); +void gen_ab_f16_z_bool( bool ( float16_t, float16_t ) ); +#endif + void gen_a_f32_z_ui32_rx( uint_fast32_t ( float32_t, uint_fast8_t, bool ), uint_fast8_t, bool ); @@ -116,6 +167,9 @@ void gen_a_f32_z_ui32_x( uint_fast32_t ( float32_t, bool ), bool ); void gen_a_f32_z_ui64_x( uint_fast64_t ( float32_t, bool ), bool ); void gen_a_f32_z_i32_x( int_fast32_t ( float32_t, bool ), bool ); void gen_a_f32_z_i64_x( int_fast64_t ( float32_t, bool ), bool ); +#ifdef FLOAT16 +void gen_a_f32_z_f16( float16_t ( float32_t ) ); +#endif void gen_a_f32_z_f64( float64_t ( float32_t ) ); #ifdef EXTFLOAT80 void gen_a_f32_z_extF80( void ( float32_t, extFloat80_t * ) ); @@ -147,6 +201,9 @@ void gen_a_f64_z_ui32_x( uint_fast32_t ( float64_t, bool ), bool ); void gen_a_f64_z_ui64_x( uint_fast64_t ( float64_t, bool ), bool ); void gen_a_f64_z_i32_x( int_fast32_t ( float64_t, bool ), bool ); void gen_a_f64_z_i64_x( int_fast64_t ( float64_t, bool ), bool ); +#ifdef FLOAT16 +void gen_a_f64_z_f16( float16_t ( float64_t ) ); +#endif void gen_a_f64_z_f32( float32_t ( float64_t ) ); #ifdef EXTFLOAT80 void gen_a_f64_z_extF80( void ( float64_t, extFloat80_t * ) ); @@ -193,6 +250,9 @@ void gen_a_extF80_z_ui64_x( uint_fast64_t ( const extFloat80_t *, bool ), bool ); void gen_a_extF80_z_i32_x( int_fast32_t ( const extFloat80_t *, bool ), bool ); void gen_a_extF80_z_i64_x( int_fast64_t ( const extFloat80_t *, bool ), bool ); +#ifdef FLOAT16 +void gen_a_extF80_z_f16( float16_t ( const extFloat80_t * ) ); +#endif void gen_a_extF80_z_f32( float32_t ( const extFloat80_t * ) ); void gen_a_extF80_z_f64( float64_t ( const extFloat80_t * ) ); #ifdef FLOAT128 @@ -251,6 +311,9 @@ void gen_a_f128_z_ui32_x( uint_fast32_t ( const float128_t *, bool ), bool ); void gen_a_f128_z_ui64_x( uint_fast64_t ( const float128_t *, bool ), bool ); void gen_a_f128_z_i32_x( int_fast32_t ( const float128_t *, bool ), bool ); void gen_a_f128_z_i64_x( int_fast64_t ( const float128_t *, bool ), bool ); +#ifdef FLOAT16 +void gen_a_f128_z_f16( float16_t ( const float128_t * ) ); +#endif void gen_a_f128_z_f32( float32_t ( const float128_t * ) ); void gen_a_f128_z_f64( float64_t ( const float128_t * ) ); #ifdef EXTFLOAT80 diff --git a/source/random.c b/source/random.c index 6f61d42..9e81ae7 100644 --- a/source/random.c +++ b/source/random.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/random.h b/source/random.h index 7a0757c..4dfa33f 100644 --- a/source/random.h +++ b/source/random.h @@ -1,7 +1,7 @@ /*============================================================================ -This C header file is part of TestFloat, Release 3a, a package of programs for +This C header file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/readHex.c b/source/readHex.c index 6384ae8..0acb363 100644 --- a/source/readHex.c +++ b/source/readHex.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/readHex.h b/source/readHex.h index 944894f..4632d14 100644 --- a/source/readHex.h +++ b/source/readHex.h @@ -1,7 +1,7 @@ /*============================================================================ -This C header file is part of TestFloat, Release 3a, a package of programs for +This C header file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/slowfloat.c b/source/slowfloat.c index d79cf06..8ecf41f 100644 --- a/source/slowfloat.c +++ b/source/slowfloat.c @@ -1,9 +1,9 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a+, a package of programs -for testing the correctness of floating-point arithmetic complying with the -IEEE Standard for Floating-Point, by John R. Hauser. +This C source file is part of TestFloat, Release 3b, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of California. All rights reserved. @@ -49,6 +49,9 @@ uint_fast8_t slowfloat_exceptionFlags; uint_fast8_t slow_extF80_roundingPrecision; #endif +#ifdef FLOAT16 +union ui16_f16 { uint16_t ui; float16_t f; }; +#endif union ui32_f32 { uint32_t ui; float32_t f; }; union ui64_f64 { uint64_t ui; float64_t f; }; @@ -72,17 +75,64 @@ static const struct floatX floatXNegativeZero = { false, false, true, true, 0, { 0, 0 } }; static - void - roundFloatXTo24( - bool isTiny, struct floatX *xPtr, uint_fast8_t roundingMode, bool exact ) +void + roundFloatXTo11( + bool isTiny, struct floatX *xPtr, uint_fast8_t roundingMode, bool exact ) +{ + uint_fast64_t roundBits, sigX64; + + sigX64 = xPtr->sig.v64; + roundBits = (sigX64 & UINT64_C( 0x1FFFFFFFFFFF )) | (xPtr->sig.v0 != 0); + if ( roundBits ) { + sigX64 &= UINT64_C( 0xFFFFE00000000000 ); + if ( exact ) slowfloat_exceptionFlags |= softfloat_flag_inexact; + if ( isTiny ) slowfloat_exceptionFlags |= softfloat_flag_underflow; + switch ( roundingMode ) { + case softfloat_round_near_even: + if ( roundBits < UINT64_C( 0x100000000000 ) ) goto noIncrement; + if ( + (roundBits == UINT64_C( 0x100000000000 )) + && ! (sigX64 & UINT64_C( 0x200000000000 )) + ) { + goto noIncrement; + } + break; + case softfloat_round_minMag: + goto noIncrement; + case softfloat_round_min: + if ( ! xPtr->sign ) goto noIncrement; + break; + case softfloat_round_max: + if ( xPtr->sign ) goto noIncrement; + break; + case softfloat_round_near_maxMag: + if ( roundBits < UINT64_C( 0x100000000000 ) ) goto noIncrement; + break; + } + sigX64 += UINT64_C( 0x200000000000 ); + if ( sigX64 == UINT64_C( 0x0100000000000000 ) ) { + ++xPtr->exp; + sigX64 = UINT64_C( 0x0080000000000000 ); + } + noIncrement: + xPtr->sig.v64 = sigX64; + xPtr->sig.v0 = 0; + } + +} + +static +void + roundFloatXTo24( + bool isTiny, struct floatX *xPtr, uint_fast8_t roundingMode, bool exact ) { uint_fast64_t sigX64; uint_fast32_t roundBits; - sigX64 = xPtr->sig.v64 | (xPtr->sig.v0 != 0); - roundBits = (uint32_t) sigX64; - sigX64 -= roundBits; + sigX64 = xPtr->sig.v64; + roundBits = (uint32_t) sigX64 | (xPtr->sig.v0 != 0); if ( roundBits ) { + sigX64 &= UINT64_C( 0xFFFFFFFF00000000 ); if ( exact ) slowfloat_exceptionFlags |= softfloat_flag_inexact; if ( isTiny ) slowfloat_exceptionFlags |= softfloat_flag_underflow; switch ( roundingMode ) { @@ -112,25 +162,25 @@ static ++xPtr->exp; sigX64 = UINT64_C( 0x0080000000000000 ); } + noIncrement: + xPtr->sig.v64 = sigX64; + xPtr->sig.v0 = 0; } - noIncrement: - xPtr->sig.v64 = sigX64; - xPtr->sig.v0 = 0; } static - void - roundFloatXTo53( - bool isTiny, struct floatX *xPtr, uint_fast8_t roundingMode, bool exact ) +void + roundFloatXTo53( + bool isTiny, struct floatX *xPtr, uint_fast8_t roundingMode, bool exact ) { uint_fast64_t sigX64; uint_fast8_t roundBits; - sigX64 = xPtr->sig.v64 | (xPtr->sig.v0 != 0); - roundBits = sigX64 & 7; - sigX64 -= roundBits; + sigX64 = xPtr->sig.v64; + roundBits = (sigX64 & 7) | (xPtr->sig.v0 != 0); if ( roundBits ) { + sigX64 &= UINT64_C( 0xFFFFFFFFFFFFFFF8 ); if ( exact ) slowfloat_exceptionFlags |= softfloat_flag_inexact; if ( isTiny ) slowfloat_exceptionFlags |= softfloat_flag_underflow; switch ( roundingMode ) { @@ -155,26 +205,24 @@ static ++xPtr->exp; sigX64 = UINT64_C( 0x0080000000000000 ); } + noIncrement: + xPtr->sig.v64 = sigX64; + xPtr->sig.v0 = 0; } - noIncrement: - xPtr->sig.v64 = sigX64; - xPtr->sig.v0 = 0; } static - void - roundFloatXTo64( - bool isTiny, struct floatX *xPtr, uint_fast8_t roundingMode, bool exact ) +void + roundFloatXTo64( + bool isTiny, struct floatX *xPtr, uint_fast8_t roundingMode, bool exact ) { - uint_fast64_t sigX0; - int_fast64_t roundBits; - uint_fast64_t sigX64; + uint_fast64_t sigX0, roundBits, sigX64; sigX0 = xPtr->sig.v0; roundBits = sigX0 & UINT64_C( 0x00FFFFFFFFFFFFFF ); - sigX0 -= roundBits; if ( roundBits ) { + sigX0 &= UINT64_C( 0xFF00000000000000 ); if ( exact ) slowfloat_exceptionFlags |= softfloat_flag_inexact; if ( isTiny ) slowfloat_exceptionFlags |= softfloat_flag_underflow; switch ( roundingMode ) { @@ -206,25 +254,25 @@ static sigX64 = UINT64_C( 0x0080000000000000 ); } xPtr->sig.v64 = sigX64; + noIncrement: + xPtr->sig.v0 = sigX0; } - noIncrement: - xPtr->sig.v0 = sigX0; } static - void - roundFloatXTo113( - bool isTiny, struct floatX *xPtr, uint_fast8_t roundingMode, bool exact ) +void + roundFloatXTo113( + bool isTiny, struct floatX *xPtr, uint_fast8_t roundingMode, bool exact ) { uint_fast64_t sigX0; - int_fast64_t roundBits; + uint_fast8_t roundBits; uint_fast64_t sigX64; sigX0 = xPtr->sig.v0; roundBits = sigX0 & 0x7F; - sigX0 -= roundBits; if ( roundBits ) { + sigX0 &= UINT64_C( 0xFFFFFFFFFFFFFF80 ); if ( exact ) slowfloat_exceptionFlags |= softfloat_flag_inexact; if ( isTiny ) slowfloat_exceptionFlags |= softfloat_flag_underflow; switch ( roundingMode ) { @@ -251,9 +299,9 @@ static sigX64 = UINT64_C( 0x0080000000000000 ); } xPtr->sig.v64 = sigX64; + noIncrement: + xPtr->sig.v0 = sigX0; } - noIncrement: - xPtr->sig.v0 = sigX0; } @@ -284,9 +332,9 @@ static void ui32ToFloatX( uint_fast32_t a, struct floatX *xPtr ) } static - uint_fast32_t - floatXToUI32( - const struct floatX *xPtr, uint_fast8_t roundingMode, bool exact ) +uint_fast32_t + floatXToUI32( + const struct floatX *xPtr, uint_fast8_t roundingMode, bool exact ) { uint_fast8_t savedExceptionFlags; struct floatX x; @@ -295,7 +343,7 @@ static if ( xPtr->isInf || xPtr->isNaN ) { slowfloat_exceptionFlags |= softfloat_flag_invalid; - return (xPtr->isInf & xPtr->sign) ? 0 : 0xFFFFFFFF; + return (xPtr->isInf && xPtr->sign) ? 0 : 0xFFFFFFFF; } if ( xPtr->isZero ) return 0; savedExceptionFlags = slowfloat_exceptionFlags; @@ -349,9 +397,9 @@ static void ui64ToFloatX( uint_fast64_t a, struct floatX *xPtr ) } static - uint_fast64_t - floatXToUI64( - const struct floatX *xPtr, uint_fast8_t roundingMode, bool exact ) +uint_fast64_t + floatXToUI64( + const struct floatX *xPtr, uint_fast8_t roundingMode, bool exact ) { uint_fast8_t savedExceptionFlags; struct floatX x; @@ -360,7 +408,8 @@ static if ( xPtr->isInf || xPtr->isNaN ) { slowfloat_exceptionFlags |= softfloat_flag_invalid; - return (xPtr->isInf & xPtr->sign) ? 0 : UINT64_C( 0xFFFFFFFFFFFFFFFF ); + return + (xPtr->isInf && xPtr->sign) ? 0 : UINT64_C( 0xFFFFFFFFFFFFFFFF ); } if ( xPtr->isZero ) return 0; savedExceptionFlags = slowfloat_exceptionFlags; @@ -416,9 +465,9 @@ static void i32ToFloatX( int_fast32_t a, struct floatX *xPtr ) } static - int_fast32_t - floatXToI32( - const struct floatX *xPtr, uint_fast8_t roundingMode, bool exact ) +int_fast32_t + floatXToI32( + const struct floatX *xPtr, uint_fast8_t roundingMode, bool exact ) { uint_fast8_t savedExceptionFlags; struct floatX x; @@ -427,7 +476,7 @@ static if ( xPtr->isInf || xPtr->isNaN ) { slowfloat_exceptionFlags |= softfloat_flag_invalid; - return (xPtr->isInf & xPtr->sign) ? -0x7FFFFFFF - 1 : 0x7FFFFFFF; + return (xPtr->isInf && xPtr->sign) ? -0x7FFFFFFF - 1 : 0x7FFFFFFF; } if ( xPtr->isZero ) return 0; savedExceptionFlags = slowfloat_exceptionFlags; @@ -487,9 +536,9 @@ static void i64ToFloatX( int_fast64_t a, struct floatX *xPtr ) } static - int_fast64_t - floatXToI64( - const struct floatX *xPtr, uint_fast8_t roundingMode, bool exact ) +int_fast64_t + floatXToI64( + const struct floatX *xPtr, uint_fast8_t roundingMode, bool exact ) { uint_fast8_t savedExceptionFlags; struct floatX x; @@ -499,7 +548,7 @@ static if ( xPtr->isInf || xPtr->isNaN ) { slowfloat_exceptionFlags |= softfloat_flag_invalid; return - (xPtr->isInf & xPtr->sign) ? -INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1 + (xPtr->isInf && xPtr->sign) ? -INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1 : INT64_C( 0x7FFFFFFFFFFFFFFF ); } if ( xPtr->isZero ) return 0; @@ -532,6 +581,142 @@ static } +#ifdef FLOAT16 + +static void f16ToFloatX( float16_t a, struct floatX *xPtr ) +{ + union ui16_f16 uA; + uint_fast16_t uiA; + int_fast8_t exp; + uint_fast64_t sig64; + + uA.f = a; + uiA = uA.ui; + xPtr->isNaN = false; + xPtr->isInf = false; + xPtr->isZero = false; + xPtr->sign = ((uiA & 0x8000) != 0); + exp = uiA>>10 & 0x1F; + sig64 = uiA & 0x03FF; + sig64 <<= 45; + if ( exp == 0x1F ) { + if ( sig64 ) { + xPtr->isNaN = true; + } else { + xPtr->isInf = true; + } + } else if ( ! exp ) { + if ( ! sig64 ) { + xPtr->isZero = true; + } else { + exp = 1 - 0xF; + do { + --exp; + sig64 <<= 1; + } while ( sig64 < UINT64_C( 0x0080000000000000 ) ); + xPtr->exp = exp; + } + } else { + xPtr->exp = exp - 0xF; + sig64 |= UINT64_C( 0x0080000000000000 ); + } + xPtr->sig.v64 = sig64; + xPtr->sig.v0 = 0; + +} + +static float16_t floatXToF16( const struct floatX *xPtr ) +{ + uint_fast16_t uiZ; + struct floatX x, savedX; + bool isTiny; + int_fast32_t exp; + union ui16_f16 uZ; + + if ( xPtr->isNaN ) { + uiZ = 0xFFFF; + goto uiZ; + } + if ( xPtr->isInf ) { + uiZ = xPtr->sign ? 0xFC00 : 0x7C00; + goto uiZ; + } + if ( xPtr->isZero ) { + uiZ = xPtr->sign ? 0x8000 : 0; + goto uiZ; + } + x = *xPtr; + while ( UINT64_C( 0x0100000000000000 ) <= x.sig.v64 ) { + ++x.exp; + x.sig = shortShiftRightJam128( x.sig, 1 ); + } + while ( x.sig.v64 < UINT64_C( 0x0080000000000000 ) ) { + --x.exp; + x.sig = shortShiftLeft128( x.sig, 1 ); + } + savedX = x; + isTiny = + (slowfloat_detectTininess == softfloat_tininess_beforeRounding) + && (x.exp + 0xF <= 0); + roundFloatXTo11( isTiny, &x, slowfloat_roundingMode, true ); + exp = x.exp + 0xF; + if ( 0x1F <= exp ) { + slowfloat_exceptionFlags |= + softfloat_flag_overflow | softfloat_flag_inexact; + if ( x.sign ) { + switch ( slowfloat_roundingMode ) { + case softfloat_round_near_even: + case softfloat_round_min: + case softfloat_round_near_maxMag: + uiZ = 0xFC00; + break; + case softfloat_round_minMag: + case softfloat_round_max: + uiZ = 0xFBFF; + break; + } + } else { + switch ( slowfloat_roundingMode ) { + case softfloat_round_near_even: + case softfloat_round_max: + case softfloat_round_near_maxMag: + uiZ = 0x7C00; + break; + case softfloat_round_minMag: + case softfloat_round_min: + uiZ = 0x7BFF; + break; + } + } + goto uiZ; + } + if ( exp <= 0 ) { + isTiny = true; + x = savedX; + exp = x.exp + 0xF; + if ( exp < -14 ) { + x.sig.v0 = (x.sig.v64 != 0) || (x.sig.v0 != 0); + x.sig.v64 = 0; + } else { + while ( exp <= 0 ) { + ++exp; + x.sig = shortShiftRightJam128( x.sig, 1 ); + } + } + roundFloatXTo11( isTiny, &x, slowfloat_roundingMode, true ); + exp = (UINT64_C( 0x0080000000000000 ) <= x.sig.v64) ? 1 : 0; + } + uiZ = (uint_fast16_t) exp<<10; + if ( x.sign ) uiZ |= 0x8000; + uiZ |= x.sig.v64>>45 & 0x03FF; + uiZ: + uZ.ui = uiZ; + return uZ.f; + +} + +#endif + static void f32ToFloatX( float32_t a, struct floatX *xPtr ) { union ui32_f32 uA; @@ -1133,9 +1318,8 @@ static void floatXInvalid( struct floatX *xPtr ) } static - void - floatXRoundToInt( - struct floatX *xPtr, uint_fast8_t roundingMode, bool exact ) +void + floatXRoundToInt( struct floatX *xPtr, uint_fast8_t roundingMode, bool exact ) { int_fast32_t exp, shiftDist; struct uint128 sig; @@ -1670,7 +1854,7 @@ static void floatX256Invalid( struct floatX256 *xPtr ) } static - void floatX256Add( struct floatX256 *xPtr, const struct floatX256 *yPtr ) +void floatX256Add( struct floatX256 *xPtr, const struct floatX256 *yPtr ) { int_fast32_t expX, expY, expDiff; struct uint256 sigY; @@ -1747,7 +1931,7 @@ static } static - void floatX256Mul( struct floatX256 *xPtr, const struct floatX256 *yPtr ) +void floatX256Mul( struct floatX256 *xPtr, const struct floatX256 *yPtr ) { struct uint256 sig; int bitNum; @@ -1804,6 +1988,19 @@ static /*---------------------------------------------------------------------------- *----------------------------------------------------------------------------*/ +#ifdef FLOAT16 + +float16_t slow_ui32_to_f16( uint32_t a ) +{ + struct floatX x; + + ui32ToFloatX( a, &x ); + return floatXToF16( &x ); + +} + +#endif + float32_t slow_ui32_to_f32( uint32_t a ) { struct floatX x; @@ -1848,6 +2045,19 @@ void slow_ui32_to_f128M( uint32_t a, float128_t *zPtr ) #endif +#ifdef FLOAT16 + +float16_t slow_ui64_to_f16( uint64_t a ) +{ + struct floatX x; + + ui64ToFloatX( a, &x ); + return floatXToF16( &x ); + +} + +#endif + float32_t slow_ui64_to_f32( uint64_t a ) { struct floatX x; @@ -1892,6 +2102,19 @@ void slow_ui64_to_f128M( uint64_t a, float128_t *zPtr ) #endif +#ifdef FLOAT16 + +float16_t slow_i32_to_f16( int32_t a ) +{ + struct floatX x; + + i32ToFloatX( a, &x ); + return floatXToF16( &x ); + +} + +#endif + float32_t slow_i32_to_f32( int32_t a ) { struct floatX x; @@ -1936,6 +2159,19 @@ void slow_i32_to_f128M( int32_t a, float128_t *zPtr ) #endif +#ifdef FLOAT16 + +float16_t slow_i64_to_f16( int64_t a ) +{ + struct floatX x; + + i64ToFloatX( a, &x ); + return floatXToF16( &x ); + +} + +#endif + float32_t slow_i64_to_f32( int64_t a ) { struct floatX x; @@ -1980,6 +2216,290 @@ void slow_i64_to_f128M( int64_t a, float128_t *zPtr ) #endif +#ifdef FLOAT16 + +uint_fast32_t + slow_f16_to_ui32( float16_t a, uint_fast8_t roundingMode, bool exact ) +{ + struct floatX x; + + f16ToFloatX( a, &x ); + return floatXToUI32( &x, roundingMode, exact ); + +} + +uint_fast64_t + slow_f16_to_ui64( float16_t a, uint_fast8_t roundingMode, bool exact ) +{ + struct floatX x; + + f16ToFloatX( a, &x ); + return floatXToUI64( &x, roundingMode, exact ); + +} + +int_fast32_t + slow_f16_to_i32( float16_t a, uint_fast8_t roundingMode, bool exact ) +{ + struct floatX x; + + f16ToFloatX( a, &x ); + return floatXToI32( &x, roundingMode, exact ); + +} + +int_fast64_t + slow_f16_to_i64( float16_t a, uint_fast8_t roundingMode, bool exact ) +{ + struct floatX x; + + f16ToFloatX( a, &x ); + return floatXToI64( &x, roundingMode, exact ); + +} + +uint_fast32_t slow_f16_to_ui32_r_minMag( float16_t a, bool exact ) +{ + struct floatX x; + + f16ToFloatX( a, &x ); + return floatXToUI32( &x, softfloat_round_minMag, exact ); + +} + +uint_fast64_t slow_f16_to_ui64_r_minMag( float16_t a, bool exact ) +{ + struct floatX x; + + f16ToFloatX( a, &x ); + return floatXToUI64( &x, softfloat_round_minMag, exact ); + +} + +int_fast32_t slow_f16_to_i32_r_minMag( float16_t a, bool exact ) +{ + struct floatX x; + + f16ToFloatX( a, &x ); + return floatXToI32( &x, softfloat_round_minMag, exact ); + +} + +int_fast64_t slow_f16_to_i64_r_minMag( float16_t a, bool exact ) +{ + struct floatX x; + + f16ToFloatX( a, &x ); + return floatXToI64( &x, softfloat_round_minMag, exact ); + +} + +float32_t slow_f16_to_f32( float16_t a ) +{ + struct floatX x; + + f16ToFloatX( a, &x ); + return floatXToF32( &x ); + +} + +float64_t slow_f16_to_f64( float16_t a ) +{ + struct floatX x; + + f16ToFloatX( a, &x ); + return floatXToF64( &x ); + +} + +#ifdef EXTFLOAT80 + +void slow_f16_to_extF80M( float16_t a, extFloat80_t *zPtr ) +{ + struct floatX x; + + f16ToFloatX( a, &x ); + floatXToExtF80M( &x, zPtr ); + +} + +#endif + +#ifdef FLOAT128 + +void slow_f16_to_f128M( float16_t a, float128_t *zPtr ) +{ + struct floatX x; + + f16ToFloatX( a, &x ); + floatXToF128M( &x, zPtr ); + +} + +#endif + +float16_t + slow_f16_roundToInt( float16_t a, uint_fast8_t roundingMode, bool exact ) +{ + struct floatX x; + + f16ToFloatX( a, &x ); + floatXRoundToInt( &x, roundingMode, exact ); + return floatXToF16( &x ); + +} + +float16_t slow_f16_add( float16_t a, float16_t b ) +{ + struct floatX x, y; + + f16ToFloatX( a, &x ); + f16ToFloatX( b, &y ); + floatXAdd( &x, &y ); + return floatXToF16( &x ); + +} + +float16_t slow_f16_sub( float16_t a, float16_t b ) +{ + struct floatX x, y; + + f16ToFloatX( a, &x ); + f16ToFloatX( b, &y ); + y.sign = ! y.sign; + floatXAdd( &x, &y ); + return floatXToF16( &x ); + + +} + +float16_t slow_f16_mul( float16_t a, float16_t b ) +{ + struct floatX x, y; + + f16ToFloatX( a, &x ); + f16ToFloatX( b, &y ); + floatXMul( &x, &y ); + return floatXToF16( &x ); + +} + +float16_t slow_f16_mulAdd( float16_t a, float16_t b, float16_t c ) +{ + struct floatX x, y; + + f16ToFloatX( a, &x ); + f16ToFloatX( b, &y ); + floatXMul( &x, &y ); + f16ToFloatX( c, &y ); + floatXAdd( &x, &y ); + return floatXToF16( &x ); + +} + +float16_t slow_f16_div( float16_t a, float16_t b ) +{ + struct floatX x, y; + + f16ToFloatX( a, &x ); + f16ToFloatX( b, &y ); + floatXDiv( &x, &y ); + return floatXToF16( &x ); + +} + +float16_t slow_f16_rem( float16_t a, float16_t b ) +{ + struct floatX x, y; + + f16ToFloatX( a, &x ); + f16ToFloatX( b, &y ); + floatXRem( &x, &y ); + return floatXToF16( &x ); + +} + +float16_t slow_f16_sqrt( float16_t a ) +{ + struct floatX x; + + f16ToFloatX( a, &x ); + floatXSqrt( &x ); + return floatXToF16( &x ); + +} + +bool slow_f16_eq( float16_t a, float16_t b ) +{ + struct floatX x, y; + + f16ToFloatX( a, &x ); + f16ToFloatX( b, &y ); + return floatXEq( &x, &y ); + +} + +bool slow_f16_le( float16_t a, float16_t b ) +{ + struct floatX x, y; + + f16ToFloatX( a, &x ); + f16ToFloatX( b, &y ); + if ( x.isNaN || y.isNaN ) { + slowfloat_exceptionFlags |= softfloat_flag_invalid; + } + return floatXLe( &x, &y ); + +} + +bool slow_f16_lt( float16_t a, float16_t b ) +{ + struct floatX x, y; + + f16ToFloatX( a, &x ); + f16ToFloatX( b, &y ); + if ( x.isNaN || y.isNaN ) { + slowfloat_exceptionFlags |= softfloat_flag_invalid; + } + return floatXLt( &x, &y ); + +} + +bool slow_f16_eq_signaling( float16_t a, float16_t b ) +{ + struct floatX x, y; + + f16ToFloatX( a, &x ); + f16ToFloatX( b, &y ); + if ( x.isNaN || y.isNaN ) { + slowfloat_exceptionFlags |= softfloat_flag_invalid; + } + return floatXEq( &x, &y ); + +} + +bool slow_f16_le_quiet( float16_t a, float16_t b ) +{ + struct floatX x, y; + + f16ToFloatX( a, &x ); + f16ToFloatX( b, &y ); + return floatXLe( &x, &y ); + +} + +bool slow_f16_lt_quiet( float16_t a, float16_t b ) +{ + struct floatX x, y; + + f16ToFloatX( a, &x ); + f16ToFloatX( b, &y ); + return floatXLt( &x, &y ); + +} + +#endif + uint_fast32_t slow_f32_to_ui32( float32_t a, uint_fast8_t roundingMode, bool exact ) { @@ -2056,6 +2576,19 @@ int_fast64_t slow_f32_to_i64_r_minMag( float32_t a, bool exact ) } +#ifdef FLOAT16 + +float16_t slow_f32_to_f16( float32_t a ) +{ + struct floatX x; + + f32ToFloatX( a, &x ); + return floatXToF16( &x ); + +} + +#endif + float64_t slow_f32_to_f64( float32_t a ) { struct floatX x; @@ -2327,6 +2860,19 @@ int_fast64_t slow_f64_to_i64_r_minMag( float64_t a, bool exact ) } +#ifdef FLOAT16 + +float16_t slow_f64_to_f16( float64_t a ) +{ + struct floatX x; + + f64ToFloatX( a, &x ); + return floatXToF16( &x ); + +} + +#endif + float32_t slow_f64_to_f32( float64_t a ) { struct floatX x; @@ -2607,6 +3153,19 @@ int_fast64_t } +#ifdef FLOAT16 + +float16_t slow_extF80M_to_f16( const extFloat80_t *aPtr ) +{ + struct floatX x; + + extF80MToFloatX( aPtr, &x ); + return floatXToF16( &x ); + +} + +#endif + float32_t slow_extF80M_to_f32( const extFloat80_t *aPtr ) { struct floatX x; @@ -2885,6 +3444,19 @@ int_fast64_t slow_f128M_to_i64_r_minMag( const float128_t *aPtr, bool exact ) } +#ifdef FLOAT16 + +float16_t slow_f128M_to_f16( const float128_t *aPtr ) +{ + struct floatX x; + + f128MToFloatX( aPtr, &x ); + return floatXToF16( &x ); + +} + +#endif + float32_t slow_f128M_to_f32( const float128_t *aPtr ) { struct floatX x; diff --git a/source/slowfloat.h b/source/slowfloat.h index efa13c3..7e9d5f5 100644 --- a/source/slowfloat.h +++ b/source/slowfloat.h @@ -1,12 +1,12 @@ /*============================================================================ -This C header file is part of TestFloat, Release 3a, a package of programs for +This C header file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. -Copyright 2011, 2012, 2013, 2014 The Regents of the University of California. -All rights reserved. +Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of +California. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -46,6 +46,9 @@ extern uint_fast8_t slowfloat_exceptionFlags; extern uint_fast8_t slow_extF80_roundingPrecision; #endif +#ifdef FLOAT16 +float16_t slow_ui32_to_f16( uint32_t ); +#endif float32_t slow_ui32_to_f32( uint32_t ); float64_t slow_ui32_to_f64( uint32_t ); #ifdef EXTFLOAT80 @@ -54,6 +57,9 @@ void slow_ui32_to_extF80M( uint32_t, extFloat80_t * ); #ifdef FLOAT128 void slow_ui32_to_f128M( uint32_t, float128_t * ); #endif +#ifdef FLOAT16 +float16_t slow_ui64_to_f16( uint64_t ); +#endif float32_t slow_ui64_to_f32( uint64_t ); float64_t slow_ui64_to_f64( uint64_t ); #ifdef EXTFLOAT80 @@ -62,6 +68,9 @@ void slow_ui64_to_extF80M( uint64_t, extFloat80_t * ); #ifdef FLOAT128 void slow_ui64_to_f128M( uint64_t, float128_t * ); #endif +#ifdef FLOAT16 +float16_t slow_i32_to_f16( int32_t ); +#endif float32_t slow_i32_to_f32( int32_t ); float64_t slow_i32_to_f64( int32_t ); #ifdef EXTFLOAT80 @@ -70,6 +79,9 @@ void slow_i32_to_extF80M( int32_t, extFloat80_t * ); #ifdef FLOAT128 void slow_i32_to_f128M( int32_t, float128_t * ); #endif +#ifdef FLOAT16 +float16_t slow_i64_to_f16( int64_t ); +#endif float32_t slow_i64_to_f32( int64_t ); float64_t slow_i64_to_f64( int64_t ); #ifdef EXTFLOAT80 @@ -79,6 +91,39 @@ void slow_i64_to_extF80M( int64_t, extFloat80_t * ); void slow_i64_to_f128M( int64_t, float128_t * ); #endif +#ifdef FLOAT16 +uint_fast32_t slow_f16_to_ui32( float16_t, uint_fast8_t, bool ); +uint_fast64_t slow_f16_to_ui64( float16_t, uint_fast8_t, bool ); +int_fast32_t slow_f16_to_i32( float16_t, uint_fast8_t, bool ); +int_fast64_t slow_f16_to_i64( float16_t, uint_fast8_t, bool ); +uint_fast32_t slow_f16_to_ui32_r_minMag( float16_t, bool ); +uint_fast64_t slow_f16_to_ui64_r_minMag( float16_t, bool ); +int_fast32_t slow_f16_to_i32_r_minMag( float16_t, bool ); +int_fast64_t slow_f16_to_i64_r_minMag( float16_t, bool ); +float32_t slow_f16_to_f32( float16_t ); +float64_t slow_f16_to_f64( float16_t ); +#ifdef EXTFLOAT80 +void slow_f16_to_extF80M( float16_t, extFloat80_t * ); +#endif +#ifdef FLOAT128 +void slow_f16_to_f128M( float16_t, float128_t * ); +#endif +float16_t slow_f16_roundToInt( float16_t, uint_fast8_t, bool ); +float16_t slow_f16_add( float16_t, float16_t ); +float16_t slow_f16_sub( float16_t, float16_t ); +float16_t slow_f16_mul( float16_t, float16_t ); +float16_t slow_f16_mulAdd( float16_t, float16_t, float16_t ); +float16_t slow_f16_div( float16_t, float16_t ); +float16_t slow_f16_rem( float16_t, float16_t ); +float16_t slow_f16_sqrt( float16_t ); +bool slow_f16_eq( float16_t, float16_t ); +bool slow_f16_le( float16_t, float16_t ); +bool slow_f16_lt( float16_t, float16_t ); +bool slow_f16_eq_signaling( float16_t, float16_t ); +bool slow_f16_le_quiet( float16_t, float16_t ); +bool slow_f16_lt_quiet( float16_t, float16_t ); +#endif + uint_fast32_t slow_f32_to_ui32( float32_t, uint_fast8_t, bool ); uint_fast64_t slow_f32_to_ui64( float32_t, uint_fast8_t, bool ); int_fast32_t slow_f32_to_i32( float32_t, uint_fast8_t, bool ); @@ -87,6 +132,9 @@ uint_fast32_t slow_f32_to_ui32_r_minMag( float32_t, bool ); uint_fast64_t slow_f32_to_ui64_r_minMag( float32_t, bool ); int_fast32_t slow_f32_to_i32_r_minMag( float32_t, bool ); int_fast64_t slow_f32_to_i64_r_minMag( float32_t, bool ); +#ifdef FLOAT16 +float16_t slow_f32_to_f16( float32_t ); +#endif float64_t slow_f32_to_f64( float32_t ); #ifdef EXTFLOAT80 void slow_f32_to_extF80M( float32_t, extFloat80_t * ); @@ -117,6 +165,9 @@ uint_fast32_t slow_f64_to_ui32_r_minMag( float64_t, bool ); uint_fast64_t slow_f64_to_ui64_r_minMag( float64_t, bool ); int_fast32_t slow_f64_to_i32_r_minMag( float64_t, bool ); int_fast64_t slow_f64_to_i64_r_minMag( float64_t, bool ); +#ifdef FLOAT16 +float16_t slow_f64_to_f16( float64_t ); +#endif float32_t slow_f64_to_f32( float64_t ); #ifdef EXTFLOAT80 void slow_f64_to_extF80M( float64_t, extFloat80_t * ); @@ -148,6 +199,9 @@ uint_fast32_t slow_extF80M_to_ui32_r_minMag( const extFloat80_t *, bool ); uint_fast64_t slow_extF80M_to_ui64_r_minMag( const extFloat80_t *, bool ); int_fast32_t slow_extF80M_to_i32_r_minMag( const extFloat80_t *, bool ); int_fast64_t slow_extF80M_to_i64_r_minMag( const extFloat80_t *, bool ); +#ifdef FLOAT16 +float16_t slow_extF80M_to_f16( const extFloat80_t * ); +#endif float32_t slow_extF80M_to_f32( const extFloat80_t * ); float64_t slow_extF80M_to_f64( const extFloat80_t * ); #ifdef FLOAT128 @@ -196,6 +250,9 @@ uint_fast32_t slow_f128M_to_ui32_r_minMag( const float128_t *, bool ); uint_fast64_t slow_f128M_to_ui64_r_minMag( const float128_t *, bool ); int_fast32_t slow_f128M_to_i32_r_minMag( const float128_t *, bool ); int_fast64_t slow_f128M_to_i64_r_minMag( const float128_t *, bool ); +#ifdef FLOAT16 +float16_t slow_f128M_to_f16( const float128_t * ); +#endif float32_t slow_f128M_to_f32( const float128_t * ); float64_t slow_f128M_to_f64( const float128_t * ); #ifdef EXTFLOAT80 diff --git a/source/standardFunctionInfos.c b/source/standardFunctionInfos.c index 7fbe4cf..3432d39 100644 --- a/source/standardFunctionInfos.c +++ b/source/standardFunctionInfos.c @@ -1,12 +1,12 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. -Copyright 2011, 2012, 2013, 2014 The Regents of the University of California. -All rights reserved. +Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of +California. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -48,6 +48,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. const struct standardFunctionInfo standardFunctionInfos[] = { /*------------------------------------------------------------------------ *------------------------------------------------------------------------*/ +#ifdef FLOAT16 + { "ui32_to_f16", UI32_TO_F16, 0, 0 }, +#endif { "ui32_to_f32", UI32_TO_F32, 0, 0 }, { "ui32_to_f64", UI32_TO_F64, 0, 0 }, #ifdef EXTFLOAT80 @@ -56,6 +59,9 @@ const struct standardFunctionInfo standardFunctionInfos[] = { #ifdef FLOAT128 { "ui32_to_f128", UI32_TO_F128, 0, 0 }, #endif +#ifdef FLOAT16 + { "ui64_to_f16", UI64_TO_F16, 0, 0 }, +#endif { "ui64_to_f32", UI64_TO_F32, 0, 0 }, { "ui64_to_f64", UI64_TO_F64, 0, 0 }, #ifdef EXTFLOAT80 @@ -64,6 +70,9 @@ const struct standardFunctionInfo standardFunctionInfos[] = { #ifdef FLOAT128 { "ui64_to_f128", UI64_TO_F128, 0, 0 }, #endif +#ifdef FLOAT16 + { "i32_to_f16", I32_TO_F16, 0, 0 }, +#endif { "i32_to_f32", I32_TO_F32, 0, 0 }, { "i32_to_f64", I32_TO_F64, 0, 0 }, #ifdef EXTFLOAT80 @@ -72,6 +81,9 @@ const struct standardFunctionInfo standardFunctionInfos[] = { #ifdef FLOAT128 { "i32_to_f128", I32_TO_F128, 0, 0 }, #endif +#ifdef FLOAT16 + { "i64_to_f16", I64_TO_F16, 0, 0 }, +#endif { "i64_to_f32", I64_TO_F32, 0, 0 }, { "i64_to_f64", I64_TO_F64, 0, 0 }, #ifdef EXTFLOAT80 @@ -82,6 +94,77 @@ const struct standardFunctionInfo standardFunctionInfos[] = { #endif /*------------------------------------------------------------------------ *------------------------------------------------------------------------*/ +#ifdef FLOAT16 + { "f16_to_ui32_r_near_even", F16_TO_UI32, RNEVEN, false }, + { "f16_to_ui32_r_minMag", F16_TO_UI32, RMINM, false }, + { "f16_to_ui32_r_min", F16_TO_UI32, RMIN, false }, + { "f16_to_ui32_r_max", F16_TO_UI32, RMAX, false }, + { "f16_to_ui32_r_near_maxMag", F16_TO_UI32, RNMAXM, false }, + { "f16_to_ui64_r_near_even", F16_TO_UI64, RNEVEN, false }, + { "f16_to_ui64_r_minMag", F16_TO_UI64, RMINM, false }, + { "f16_to_ui64_r_min", F16_TO_UI64, RMIN, false }, + { "f16_to_ui64_r_max", F16_TO_UI64, RMAX, false }, + { "f16_to_ui64_r_near_maxMag", F16_TO_UI64, RNMAXM, false }, + { "f16_to_i32_r_near_even", F16_TO_I32, RNEVEN, false }, + { "f16_to_i32_r_minMag", F16_TO_I32, RMINM, false }, + { "f16_to_i32_r_min", F16_TO_I32, RMIN, false }, + { "f16_to_i32_r_max", F16_TO_I32, RMAX, false }, + { "f16_to_i32_r_near_maxMag", F16_TO_I32, RNMAXM, false }, + { "f16_to_i64_r_near_even", F16_TO_I64, RNEVEN, false }, + { "f16_to_i64_r_minMag", F16_TO_I64, RMINM, false }, + { "f16_to_i64_r_min", F16_TO_I64, RMIN, false }, + { "f16_to_i64_r_max", F16_TO_I64, RMAX, false }, + { "f16_to_i64_r_near_maxMag", F16_TO_I64, RNMAXM, false }, + { "f16_to_ui32_rx_near_even", F16_TO_UI32, RNEVEN, true }, + { "f16_to_ui32_rx_minMag", F16_TO_UI32, RMINM, true }, + { "f16_to_ui32_rx_min", F16_TO_UI32, RMIN, true }, + { "f16_to_ui32_rx_max", F16_TO_UI32, RMAX, true }, + { "f16_to_ui32_rx_near_maxMag", F16_TO_UI32, RNMAXM, true }, + { "f16_to_ui64_rx_near_even", F16_TO_UI64, RNEVEN, true }, + { "f16_to_ui64_rx_minMag", F16_TO_UI64, RMINM, true }, + { "f16_to_ui64_rx_min", F16_TO_UI64, RMIN, true }, + { "f16_to_ui64_rx_max", F16_TO_UI64, RMAX, true }, + { "f16_to_ui64_rx_near_maxMag", F16_TO_UI64, RNMAXM, true }, + { "f16_to_i32_rx_near_even", F16_TO_I32, RNEVEN, true }, + { "f16_to_i32_rx_minMag", F16_TO_I32, RMINM, true }, + { "f16_to_i32_rx_min", F16_TO_I32, RMIN, true }, + { "f16_to_i32_rx_max", F16_TO_I32, RMAX, true }, + { "f16_to_i32_rx_near_maxMag", F16_TO_I32, RNMAXM, true }, + { "f16_to_i64_rx_near_even", F16_TO_I64, RNEVEN, true }, + { "f16_to_i64_rx_minMag", F16_TO_I64, RMINM, true }, + { "f16_to_i64_rx_min", F16_TO_I64, RMIN, true }, + { "f16_to_i64_rx_max", F16_TO_I64, RMAX, true }, + { "f16_to_i64_rx_near_maxMag", F16_TO_I64, RNMAXM, true }, + { "f16_to_f32", F16_TO_F32, 0, 0 }, + { "f16_to_f64", F16_TO_F64, 0, 0 }, +#ifdef EXTFLOAT80 + { "f16_to_extF80", F16_TO_EXTF80, 0, 0 }, +#endif +#ifdef FLOAT128 + { "f16_to_f128", F16_TO_F128, 0, 0 }, +#endif + { "f16_roundToInt_r_near_even", F16_ROUNDTOINT, RNEVEN, false }, + { "f16_roundToInt_r_minMag", F16_ROUNDTOINT, RMINM, false }, + { "f16_roundToInt_r_min", F16_ROUNDTOINT, RMIN, false }, + { "f16_roundToInt_r_max", F16_ROUNDTOINT, RMAX, false }, + { "f16_roundToInt_r_near_maxMag", F16_ROUNDTOINT, RNMAXM, false }, + { "f16_roundToInt_x", F16_ROUNDTOINT, 0, true }, + { "f16_add", F16_ADD, 0, 0 }, + { "f16_sub", F16_SUB, 0, 0 }, + { "f16_mul", F16_MUL, 0, 0 }, + { "f16_mulAdd", F16_MULADD, 0, 0 }, + { "f16_div", F16_DIV, 0, 0 }, + { "f16_rem", F16_REM, 0, 0 }, + { "f16_sqrt", F16_SQRT, 0, 0 }, + { "f16_eq", F16_EQ, 0, 0 }, + { "f16_le", F16_LE, 0, 0 }, + { "f16_lt", F16_LT, 0, 0 }, + { "f16_eq_signaling", F16_EQ_SIGNALING, 0, 0 }, + { "f16_le_quiet", F16_LE_QUIET, 0, 0 }, + { "f16_lt_quiet", F16_LT_QUIET, 0, 0 }, +#endif + /*------------------------------------------------------------------------ + *------------------------------------------------------------------------*/ { "f32_to_ui32_r_near_even", F32_TO_UI32, RNEVEN, false }, { "f32_to_ui32_r_minMag", F32_TO_UI32, RMINM, false }, { "f32_to_ui32_r_min", F32_TO_UI32, RMIN, false }, @@ -122,6 +205,9 @@ const struct standardFunctionInfo standardFunctionInfos[] = { { "f32_to_i64_rx_min", F32_TO_I64, RMIN, true }, { "f32_to_i64_rx_max", F32_TO_I64, RMAX, true }, { "f32_to_i64_rx_near_maxMag", F32_TO_I64, RNMAXM, true }, +#ifdef FLOAT16 + { "f32_to_f16", F32_TO_F16, 0, 0 }, +#endif { "f32_to_f64", F32_TO_F64, 0, 0 }, #ifdef EXTFLOAT80 { "f32_to_extF80", F32_TO_EXTF80, 0, 0 }, @@ -190,6 +276,9 @@ const struct standardFunctionInfo standardFunctionInfos[] = { { "f64_to_i64_rx_min", F64_TO_I64, RMIN, true }, { "f64_to_i64_rx_max", F64_TO_I64, RMAX, true }, { "f64_to_i64_rx_near_maxMag", F64_TO_I64, RNMAXM, true }, +#ifdef FLOAT16 + { "f64_to_f16", F64_TO_F16, 0, 0 }, +#endif { "f64_to_f32", F64_TO_F32, 0, 0 }, #ifdef EXTFLOAT80 { "f64_to_extF80", F64_TO_EXTF80, 0, 0 }, @@ -259,6 +348,9 @@ const struct standardFunctionInfo standardFunctionInfos[] = { { "extF80_to_i64_rx_min", EXTF80_TO_I64, RMIN, true }, { "extF80_to_i64_rx_max", EXTF80_TO_I64, RMAX, true }, { "extF80_to_i64_rx_near_maxMag", EXTF80_TO_I64, RNMAXM, true }, +#ifdef FLOAT16 + { "extF80_to_f16", EXTF80_TO_F16, 0, 0 }, +#endif { "extF80_to_f32", EXTF80_TO_F32, 0, 0 }, { "extF80_to_f64", EXTF80_TO_F64, 0, 0 }, #ifdef FLOAT128 @@ -326,6 +418,9 @@ const struct standardFunctionInfo standardFunctionInfos[] = { { "f128_to_i64_rx_min", F128_TO_I64, RMIN, true }, { "f128_to_i64_rx_max", F128_TO_I64, RMAX, true }, { "f128_to_i64_rx_near_maxMag", F128_TO_I64, RNMAXM, true }, +#ifdef FLOAT16 + { "f128_to_f16", F128_TO_F16, 0, 0 }, +#endif { "f128_to_f32", F128_TO_F32, 0, 0 }, { "f128_to_f64", F128_TO_F64, 0, 0 }, #ifdef EXTFLOAT80 diff --git a/source/subj-C/subjfloat.c b/source/subj-C/subjfloat.c index 986d9fc..b42075e 100644 --- a/source/subj-C/subjfloat.c +++ b/source/subj-C/subjfloat.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/subjfloat.h b/source/subjfloat.h index 587ba65..7f83302 100644 --- a/source/subjfloat.h +++ b/source/subjfloat.h @@ -1,12 +1,12 @@ /*============================================================================ -This C header file is part of TestFloat, Release 3a, a package of programs for +This C header file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. -Copyright 2011, 2012, 2013, 2014 The Regents of the University of California. -All rights reserved. +Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of +California. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -54,6 +54,9 @@ uint_fast8_t subjfloat_clearExceptionFlags( void ); /*---------------------------------------------------------------------------- *----------------------------------------------------------------------------*/ +#ifdef FLOAT16 +float16_t subj_ui32_to_f16( uint32_t ); +#endif float32_t subj_ui32_to_f32( uint32_t ); float64_t subj_ui32_to_f64( uint32_t ); #ifdef EXTFLOAT80 @@ -62,6 +65,9 @@ void subj_ui32_to_extF80M( uint32_t, extFloat80_t * ); #ifdef FLOAT128 void subj_ui32_to_f128M( uint32_t, float128_t * ); #endif +#ifdef FLOAT16 +float16_t subj_ui64_to_f16( uint64_t ); +#endif float32_t subj_ui64_to_f32( uint64_t ); float64_t subj_ui64_to_f64( uint64_t ); #ifdef EXTFLOAT80 @@ -70,6 +76,9 @@ void subj_ui64_to_extF80M( uint64_t, extFloat80_t * ); #ifdef FLOAT128 void subj_ui64_to_f128M( uint64_t, float128_t * ); #endif +#ifdef FLOAT16 +float16_t subj_i32_to_f16( int32_t ); +#endif float32_t subj_i32_to_f32( int32_t ); float64_t subj_i32_to_f64( int32_t ); #ifdef EXTFLOAT80 @@ -78,6 +87,9 @@ void subj_i32_to_extF80M( int32_t, extFloat80_t * ); #ifdef FLOAT128 void subj_i32_to_f128M( int32_t, float128_t * ); #endif +#ifdef FLOAT16 +float16_t subj_i64_to_f16( int64_t ); +#endif float32_t subj_i64_to_f32( int64_t ); float64_t subj_i64_to_f64( int64_t ); #ifdef EXTFLOAT80 @@ -89,6 +101,83 @@ void subj_i64_to_f128M( int64_t, float128_t * ); /*---------------------------------------------------------------------------- *----------------------------------------------------------------------------*/ +#ifdef FLOAT16 + +uint_fast32_t subj_f16_to_ui32_r_near_even( float16_t ); +uint_fast32_t subj_f16_to_ui32_r_minMag( float16_t ); +uint_fast32_t subj_f16_to_ui32_r_min( float16_t ); +uint_fast32_t subj_f16_to_ui32_r_max( float16_t ); +uint_fast32_t subj_f16_to_ui32_r_near_maxMag( float16_t ); +uint_fast64_t subj_f16_to_ui64_r_near_even( float16_t ); +uint_fast64_t subj_f16_to_ui64_r_minMag( float16_t ); +uint_fast64_t subj_f16_to_ui64_r_min( float16_t ); +uint_fast64_t subj_f16_to_ui64_r_max( float16_t ); +uint_fast64_t subj_f16_to_ui64_r_near_maxMag( float16_t ); +int_fast32_t subj_f16_to_i32_r_near_even( float16_t ); +int_fast32_t subj_f16_to_i32_r_minMag( float16_t ); +int_fast32_t subj_f16_to_i32_r_min( float16_t ); +int_fast32_t subj_f16_to_i32_r_max( float16_t ); +int_fast32_t subj_f16_to_i32_r_near_maxMag( float16_t ); +int_fast64_t subj_f16_to_i64_r_near_even( float16_t ); +int_fast64_t subj_f16_to_i64_r_minMag( float16_t ); +int_fast64_t subj_f16_to_i64_r_min( float16_t ); +int_fast64_t subj_f16_to_i64_r_max( float16_t ); +int_fast64_t subj_f16_to_i64_r_near_maxMag( float16_t ); + +uint_fast32_t subj_f16_to_ui32_rx_near_even( float16_t ); +uint_fast32_t subj_f16_to_ui32_rx_minMag( float16_t ); +uint_fast32_t subj_f16_to_ui32_rx_min( float16_t ); +uint_fast32_t subj_f16_to_ui32_rx_max( float16_t ); +uint_fast32_t subj_f16_to_ui32_rx_near_maxMag( float16_t ); +uint_fast64_t subj_f16_to_ui64_rx_near_even( float16_t ); +uint_fast64_t subj_f16_to_ui64_rx_minMag( float16_t ); +uint_fast64_t subj_f16_to_ui64_rx_min( float16_t ); +uint_fast64_t subj_f16_to_ui64_rx_max( float16_t ); +uint_fast64_t subj_f16_to_ui64_rx_near_maxMag( float16_t ); +int_fast32_t subj_f16_to_i32_rx_near_even( float16_t ); +int_fast32_t subj_f16_to_i32_rx_minMag( float16_t ); +int_fast32_t subj_f16_to_i32_rx_min( float16_t ); +int_fast32_t subj_f16_to_i32_rx_max( float16_t ); +int_fast32_t subj_f16_to_i32_rx_near_maxMag( float16_t ); +int_fast64_t subj_f16_to_i64_rx_near_even( float16_t ); +int_fast64_t subj_f16_to_i64_rx_minMag( float16_t ); +int_fast64_t subj_f16_to_i64_rx_min( float16_t ); +int_fast64_t subj_f16_to_i64_rx_max( float16_t ); +int_fast64_t subj_f16_to_i64_rx_near_maxMag( float16_t ); + +float32_t subj_f16_to_f32( float16_t ); +float64_t subj_f16_to_f64( float16_t ); +#ifdef EXTFLOAT80 +void subj_f16_to_extF80M( float16_t, extFloat80_t * ); +#endif +#ifdef FLOAT128 +void subj_f16_to_f128M( float16_t, float128_t * ); +#endif + +float16_t subj_f16_roundToInt_r_near_even( float16_t ); +float16_t subj_f16_roundToInt_r_minMag( float16_t ); +float16_t subj_f16_roundToInt_r_min( float16_t ); +float16_t subj_f16_roundToInt_r_max( float16_t ); +float16_t subj_f16_roundToInt_r_near_maxMag( float16_t ); +float16_t subj_f16_roundToInt_x( float16_t ); +float16_t subj_f16_add( float16_t, float16_t ); +float16_t subj_f16_sub( float16_t, float16_t ); +float16_t subj_f16_mul( float16_t, float16_t ); +float16_t subj_f16_mulAdd( float16_t, float16_t, float16_t ); +float16_t subj_f16_div( float16_t, float16_t ); +float16_t subj_f16_rem( float16_t, float16_t ); +float16_t subj_f16_sqrt( float16_t ); +bool subj_f16_eq( float16_t, float16_t ); +bool subj_f16_le( float16_t, float16_t ); +bool subj_f16_lt( float16_t, float16_t ); +bool subj_f16_eq_signaling( float16_t, float16_t ); +bool subj_f16_le_quiet( float16_t, float16_t ); +bool subj_f16_lt_quiet( float16_t, float16_t ); + +#endif + +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ uint_fast32_t subj_f32_to_ui32_r_near_even( float32_t ); uint_fast32_t subj_f32_to_ui32_r_minMag( float32_t ); uint_fast32_t subj_f32_to_ui32_r_min( float32_t ); @@ -131,6 +220,9 @@ int_fast64_t subj_f32_to_i64_rx_min( float32_t ); int_fast64_t subj_f32_to_i64_rx_max( float32_t ); int_fast64_t subj_f32_to_i64_rx_near_maxMag( float32_t ); +#ifdef FLOAT16 +float16_t subj_f32_to_f16( float32_t ); +#endif float64_t subj_f32_to_f64( float32_t ); #ifdef EXTFLOAT80 void subj_f32_to_extF80M( float32_t, extFloat80_t * ); @@ -203,6 +295,9 @@ int_fast64_t subj_f64_to_i64_rx_min( float64_t ); int_fast64_t subj_f64_to_i64_rx_max( float64_t ); int_fast64_t subj_f64_to_i64_rx_near_maxMag( float64_t ); +#ifdef FLOAT16 +float16_t subj_f64_to_f16( float64_t ); +#endif float32_t subj_f64_to_f32( float64_t ); #ifdef EXTFLOAT80 void subj_f64_to_extF80M( float64_t, extFloat80_t * ); @@ -277,6 +372,9 @@ int_fast64_t subj_extF80M_to_i64_rx_min( const extFloat80_t * ); int_fast64_t subj_extF80M_to_i64_rx_max( const extFloat80_t * ); int_fast64_t subj_extF80M_to_i64_rx_near_maxMag( const extFloat80_t * ); +#ifdef FLOAT16 +float16_t subj_extF80M_to_f16( const extFloat80_t * ); +#endif float32_t subj_extF80M_to_f32( const extFloat80_t * ); float64_t subj_extF80M_to_f64( const extFloat80_t * ); #ifdef EXTFLOAT80 @@ -362,6 +460,9 @@ int_fast64_t subj_f128M_to_i64_rx_min( const float128_t * ); int_fast64_t subj_f128M_to_i64_rx_max( const float128_t * ); int_fast64_t subj_f128M_to_i64_rx_near_maxMag( extFloat80_t * ); +#ifdef FLOAT16 +float16_t subj_f128M_to_f16( const float128_t * ); +#endif float32_t subj_f128M_to_f32( const float128_t * ); float64_t subj_f128M_to_f64( const float128_t * ); #ifdef FLOAT128 diff --git a/source/subjfloat_functions.c b/source/subjfloat_functions.c index 07584b4..ab1983e 100644 --- a/source/subjfloat_functions.c +++ b/source/subjfloat_functions.c @@ -1,12 +1,12 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. -Copyright 2011, 2012, 2013, 2014 The Regents of the University of California. -All rights reserved. +Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of +California. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -54,6 +54,13 @@ typedef void genericFuncType(); genericFuncType *const subjfloat_functions[] = { /*------------------------------------------------------------------------ *------------------------------------------------------------------------*/ +#ifdef FLOAT16 +#ifdef SUBJ_UI32_TO_F16 + (genericFuncType *) subj_ui32_to_f16, +#else + 0, +#endif +#endif #ifdef SUBJ_UI32_TO_F32 (genericFuncType *) subj_ui32_to_f32, #else @@ -78,6 +85,13 @@ genericFuncType *const subjfloat_functions[] = { 0, #endif #endif +#ifdef FLOAT16 +#ifdef SUBJ_UI64_TO_F16 + (genericFuncType *) subj_ui64_to_f16, +#else + 0, +#endif +#endif #ifdef SUBJ_UI64_TO_F32 (genericFuncType *) subj_ui64_to_f32, #else @@ -102,6 +116,13 @@ genericFuncType *const subjfloat_functions[] = { 0, #endif #endif +#ifdef FLOAT16 +#ifdef SUBJ_I32_TO_F16 + (genericFuncType *) subj_i32_to_f16, +#else + 0, +#endif +#endif #ifdef SUBJ_I32_TO_F32 (genericFuncType *) subj_i32_to_f32, #else @@ -126,6 +147,13 @@ genericFuncType *const subjfloat_functions[] = { 0, #endif #endif +#ifdef FLOAT16 +#ifdef SUBJ_I64_TO_F16 + (genericFuncType *) subj_i64_to_f16, +#else + 0, +#endif +#endif #ifdef SUBJ_I64_TO_F32 (genericFuncType *) subj_i64_to_f32, #else @@ -152,6 +180,329 @@ genericFuncType *const subjfloat_functions[] = { #endif /*------------------------------------------------------------------------ *------------------------------------------------------------------------*/ +#ifdef FLOAT16 +#ifdef SUBJ_F16_TO_UI32_R_NEAR_EVEN + (genericFuncType *) subj_f16_to_ui32_r_near_even, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_UI32_R_MINMAG + (genericFuncType *) subj_f16_to_ui32_r_minMag, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_UI32_R_MIN + (genericFuncType *) subj_f16_to_ui32_r_min, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_UI32_R_MAX + (genericFuncType *) subj_f16_to_ui32_r_max, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_UI32_R_NEAR_MAXMAG + (genericFuncType *) subj_f16_to_ui32_r_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_UI64_R_NEAR_EVEN + (genericFuncType *) subj_f16_to_ui64_r_near_even, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_UI64_R_MINMAG + (genericFuncType *) subj_f16_to_ui64_r_minMag, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_UI64_R_MIN + (genericFuncType *) subj_f16_to_ui64_r_min, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_UI64_R_MAX + (genericFuncType *) subj_f16_to_ui64_r_max, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_UI64_R_NEAR_MAXMAG + (genericFuncType *) subj_f16_to_ui64_r_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_I32_R_NEAR_EVEN + (genericFuncType *) subj_f16_to_i32_r_near_even, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_I32_R_MINMAG + (genericFuncType *) subj_f16_to_i32_r_minMag, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_I32_R_MIN + (genericFuncType *) subj_f16_to_i32_r_min, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_I32_R_MAX + (genericFuncType *) subj_f16_to_i32_r_max, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_I32_R_NEAR_MAXMAG + (genericFuncType *) subj_f16_to_i32_r_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_I64_R_NEAR_EVEN + (genericFuncType *) subj_f16_to_i64_r_near_even, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_I64_R_MINMAG + (genericFuncType *) subj_f16_to_i64_r_minMag, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_I64_R_MIN + (genericFuncType *) subj_f16_to_i64_r_min, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_I64_R_MAX + (genericFuncType *) subj_f16_to_i64_r_max, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_I64_R_NEAR_MAXMAG + (genericFuncType *) subj_f16_to_i64_r_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_UI32_RX_NEAR_EVEN + (genericFuncType *) subj_f16_to_ui32_rx_near_even, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_UI32_RX_MINMAG + (genericFuncType *) subj_f16_to_ui32_rx_minMag, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_UI32_RX_MIN + (genericFuncType *) subj_f16_to_ui32_rx_min, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_UI32_RX_MAX + (genericFuncType *) subj_f16_to_ui32_rx_max, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_UI32_RX_NEAR_MAXMAG + (genericFuncType *) subj_f16_to_ui32_rx_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_UI64_RX_NEAR_EVEN + (genericFuncType *) subj_f16_to_ui64_rx_near_even, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_UI64_RX_MINMAG + (genericFuncType *) subj_f16_to_ui64_rx_minMag, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_UI64_RX_MIN + (genericFuncType *) subj_f16_to_ui64_rx_min, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_UI64_RX_MAX + (genericFuncType *) subj_f16_to_ui64_rx_max, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_UI64_RX_NEAR_MAXMAG + (genericFuncType *) subj_f16_to_ui64_rx_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_I32_RX_NEAR_EVEN + (genericFuncType *) subj_f16_to_i32_rx_near_even, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_I32_RX_MINMAG + (genericFuncType *) subj_f16_to_i32_rx_minMag, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_I32_RX_MIN + (genericFuncType *) subj_f16_to_i32_rx_min, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_I32_RX_MAX + (genericFuncType *) subj_f16_to_i32_rx_max, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_I32_RX_NEAR_MAXMAG + (genericFuncType *) subj_f16_to_i32_rx_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_I64_RX_NEAR_EVEN + (genericFuncType *) subj_f16_to_i64_rx_near_even, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_I64_RX_MINMAG + (genericFuncType *) subj_f16_to_i64_rx_minMag, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_I64_RX_MIN + (genericFuncType *) subj_f16_to_i64_rx_min, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_I64_RX_MAX + (genericFuncType *) subj_f16_to_i64_rx_max, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_I64_RX_NEAR_MAXMAG + (genericFuncType *) subj_f16_to_i64_rx_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_F32 + (genericFuncType *) subj_f16_to_f32, +#else + 0, +#endif +#ifdef SUBJ_F16_TO_F64 + (genericFuncType *) subj_f16_to_f64, +#else + 0, +#endif +#ifdef EXTFLOAT80 +#ifdef SUBJ_F16_TO_EXTF80 + (genericFuncType *) subj_f16_to_extF80M, +#else + 0, +#endif +#endif +#ifdef FLOAT128 +#ifdef SUBJ_F16_TO_F128 + (genericFuncType *) subj_f16_to_f128M, +#else + 0, +#endif +#endif +#ifdef SUBJ_F16_ROUNDTOINT_R_NEAR_EVEN + (genericFuncType *) subj_f16_roundToInt_r_near_even, +#else + 0, +#endif +#ifdef SUBJ_F16_ROUNDTOINT_R_MINMAG + (genericFuncType *) subj_f16_roundToInt_r_minMag, +#else + 0, +#endif +#ifdef SUBJ_F16_ROUNDTOINT_R_MIN + (genericFuncType *) subj_f16_roundToInt_r_min, +#else + 0, +#endif +#ifdef SUBJ_F16_ROUNDTOINT_R_MAX + (genericFuncType *) subj_f16_roundToInt_r_max, +#else + 0, +#endif +#ifdef SUBJ_F16_ROUNDTOINT_R_NEAR_MAXMAG + (genericFuncType *) subj_f16_roundToInt_r_near_maxMag, +#else + 0, +#endif +#ifdef SUBJ_F16_ROUNDTOINT_X + (genericFuncType *) subj_f16_roundToInt_x, +#else + 0, +#endif +#ifdef SUBJ_F16_ADD + (genericFuncType *) subj_f16_add, +#else + 0, +#endif +#ifdef SUBJ_F16_SUB + (genericFuncType *) subj_f16_sub, +#else + 0, +#endif +#ifdef SUBJ_F16_MUL + (genericFuncType *) subj_f16_mul, +#else + 0, +#endif +#ifdef SUBJ_F16_MULADD + (genericFuncType *) subj_f16_mulAdd, +#else + 0, +#endif +#ifdef SUBJ_F16_DIV + (genericFuncType *) subj_f16_div, +#else + 0, +#endif +#ifdef SUBJ_F16_REM + (genericFuncType *) subj_f16_rem, +#else + 0, +#endif +#ifdef SUBJ_F16_SQRT + (genericFuncType *) subj_f16_sqrt, +#else + 0, +#endif +#ifdef SUBJ_F16_EQ + (genericFuncType *) subj_f16_eq, +#else + 0, +#endif +#ifdef SUBJ_F16_LE + (genericFuncType *) subj_f16_le, +#else + 0, +#endif +#ifdef SUBJ_F16_LT + (genericFuncType *) subj_f16_lt, +#else + 0, +#endif +#ifdef SUBJ_F16_EQ_SIGNALING + (genericFuncType *) subj_f16_eq_signaling, +#else + 0, +#endif +#ifdef SUBJ_F16_LE_QUIET + (genericFuncType *) subj_f16_le_quiet, +#else + 0, +#endif +#ifdef SUBJ_F16_LT_QUIET + (genericFuncType *) subj_f16_lt_quiet, +#else + 0, +#endif +#endif + /*------------------------------------------------------------------------ + *------------------------------------------------------------------------*/ #ifdef SUBJ_F32_TO_UI32_R_NEAR_EVEN (genericFuncType *) subj_f32_to_ui32_r_near_even, #else @@ -352,6 +703,13 @@ genericFuncType *const subjfloat_functions[] = { #else 0, #endif +#ifdef FLOAT16 +#ifdef SUBJ_F32_TO_F16 + (genericFuncType *) subj_f32_to_f16, +#else + 0, +#endif +#endif #ifdef SUBJ_F32_TO_F64 (genericFuncType *) subj_f32_to_f64, #else @@ -668,6 +1026,13 @@ genericFuncType *const subjfloat_functions[] = { #else 0, #endif +#ifdef FLOAT16 +#ifdef SUBJ_F64_TO_F16 + (genericFuncType *) subj_f64_to_f16, +#else + 0, +#endif +#endif #ifdef SUBJ_F64_TO_F32 (genericFuncType *) subj_f64_to_f32, #else @@ -985,6 +1350,13 @@ genericFuncType *const subjfloat_functions[] = { #else 0, #endif +#ifdef FLOAT16 +#ifdef SUBJ_EXTF80_TO_F16 + (genericFuncType *) subj_extF80M_to_f16, +#else + 0, +#endif +#endif #ifdef SUBJ_EXTF80_TO_F32 (genericFuncType *) subj_extF80M_to_f32, #else @@ -1296,6 +1668,13 @@ genericFuncType *const subjfloat_functions[] = { #else 0, #endif +#ifdef FLOAT16 +#ifdef SUBJ_F128_TO_F16 + (genericFuncType *) subj_f128M_to_f16, +#else + 0, +#endif +#endif #ifdef SUBJ_F128_TO_F32 (genericFuncType *) subj_f128M_to_f32, #else diff --git a/source/testLoops.h b/source/testLoops.h index 5222fae..77f6e61 100644 --- a/source/testLoops.h +++ b/source/testLoops.h @@ -1,12 +1,12 @@ /*============================================================================ -This C header file is part of TestFloat, Release 3a, a package of programs for +This C header file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. -Copyright 2011, 2012, 2013, 2014 The Regents of the University of California. -All rights reserved. +Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of +California. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -47,6 +47,9 @@ extern uint_fast8_t (*testLoops_subjFlagsFunction)( void ); /*---------------------------------------------------------------------------- *----------------------------------------------------------------------------*/ +#ifdef FLOAT16 +void test_a_ui32_z_f16( float16_t ( uint32_t ), float16_t ( uint32_t ) ); +#endif void test_a_ui32_z_f32( float32_t ( uint32_t ), float32_t ( uint32_t ) ); void test_a_ui32_z_f64( float64_t ( uint32_t ), float64_t ( uint32_t ) ); #ifdef EXTFLOAT80 @@ -60,6 +63,9 @@ void void ( uint32_t, float128_t * ), void ( uint32_t, float128_t * ) ); #endif +#ifdef FLOAT16 +void test_a_ui64_z_f16( float16_t ( uint64_t ), float16_t ( uint64_t ) ); +#endif void test_a_ui64_z_f32( float32_t ( uint64_t ), float32_t ( uint64_t ) ); void test_a_ui64_z_f64( float64_t ( uint64_t ), float64_t ( uint64_t ) ); #ifdef EXTFLOAT80 @@ -72,6 +78,9 @@ void test_a_ui64_z_f128( void ( uint64_t, float128_t * ), void ( uint64_t, float128_t * ) ); #endif +#ifdef FLOAT16 +void test_a_i32_z_f16( float16_t ( int32_t ), float16_t ( int32_t ) ); +#endif void test_a_i32_z_f32( float32_t ( int32_t ), float32_t ( int32_t ) ); void test_a_i32_z_f64( float64_t ( int32_t ), float64_t ( int32_t ) ); #ifdef EXTFLOAT80 @@ -84,6 +93,9 @@ void test_a_i32_z_f128( void ( int32_t, float128_t * ), void ( int32_t, float128_t * ) ); #endif +#ifdef FLOAT16 +void test_a_i64_z_f16( float16_t ( int64_t ), float16_t ( int64_t ) ); +#endif void test_a_i64_z_f32( float32_t ( int64_t ), float32_t ( int64_t ) ); void test_a_i64_z_f64( float64_t ( int64_t ), float64_t ( int64_t ) ); #ifdef EXTFLOAT80 @@ -99,6 +111,86 @@ void /*---------------------------------------------------------------------------- *----------------------------------------------------------------------------*/ +#ifdef FLOAT16 +void + test_a_f16_z_ui32_rx( + uint_fast32_t ( float16_t, uint_fast8_t, bool ), + uint_fast32_t ( float16_t, uint_fast8_t, bool ), + uint_fast8_t, + bool + ); +void + test_a_f16_z_ui64_rx( + uint_fast64_t ( float16_t, uint_fast8_t, bool ), + uint_fast64_t ( float16_t, uint_fast8_t, bool ), + uint_fast8_t, + bool + ); +void + test_a_f16_z_i32_rx( + int_fast32_t ( float16_t, uint_fast8_t, bool ), + int_fast32_t ( float16_t, uint_fast8_t, bool ), + uint_fast8_t, + bool + ); +void + test_a_f16_z_i64_rx( + int_fast64_t ( float16_t, uint_fast8_t, bool ), + int_fast64_t ( float16_t, uint_fast8_t, bool ), + uint_fast8_t, + bool + ); +void + test_a_f16_z_ui32_x( + uint_fast32_t ( float16_t, bool ), uint_fast32_t ( float16_t, bool ), bool + ); +void + test_a_f16_z_ui64_x( + uint_fast64_t ( float16_t, bool ), uint_fast64_t ( float16_t, bool ), bool + ); +void + test_a_f16_z_i32_x( + int_fast32_t ( float16_t, bool ), int_fast32_t ( float16_t, bool ), bool + ); +void + test_a_f16_z_i64_x( + int_fast64_t ( float16_t, bool ), int_fast64_t ( float16_t, bool ), bool + ); +void test_a_f16_z_f32( float32_t ( float16_t ), float32_t ( float16_t ) ); +void test_a_f16_z_f64( float64_t ( float16_t ), float64_t ( float16_t ) ); +#ifdef EXTFLOAT80 +void + test_a_f16_z_extF80( + void ( float16_t, extFloat80_t * ), void ( float16_t, extFloat80_t * ) ); +#endif +#ifdef FLOAT128 +void + test_a_f16_z_f128( + void ( float16_t, float128_t * ), void ( float16_t, float128_t * ) ); +#endif +void test_az_f16( float16_t ( float16_t ), float16_t ( float16_t ) ); +void + test_az_f16_rx( + float16_t ( float16_t, uint_fast8_t, bool ), + float16_t ( float16_t, uint_fast8_t, bool ), + uint_fast8_t, + bool + ); +void + test_abz_f16( + float16_t ( float16_t, float16_t ), float16_t ( float16_t, float16_t ) ); +void + test_abcz_f16( + float16_t ( float16_t, float16_t, float16_t ), + float16_t ( float16_t, float16_t, float16_t ) + ); +void + test_ab_f16_z_bool( + bool ( float16_t, float16_t ), bool ( float16_t, float16_t ) ); +#endif + +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ void test_a_f32_z_ui32_rx( uint_fast32_t ( float32_t, uint_fast8_t, bool ), @@ -143,6 +235,9 @@ void test_a_f32_z_i64_x( int_fast64_t ( float32_t, bool ), int_fast64_t ( float32_t, bool ), bool ); +#ifdef FLOAT16 +void test_a_f32_z_f16( float16_t ( float32_t ), float16_t ( float32_t ) ); +#endif void test_a_f32_z_f64( float64_t ( float32_t ), float64_t ( float32_t ) ); #ifdef EXTFLOAT80 void @@ -220,6 +315,9 @@ void test_a_f64_z_i64_x( int_fast64_t ( float64_t, bool ), int_fast64_t ( float64_t, bool ), bool ); +#ifdef FLOAT16 +void test_a_f64_z_f16( float16_t ( float64_t ), float16_t ( float64_t ) ); +#endif void test_a_f64_z_f32( float32_t ( float64_t ), float32_t ( float64_t ) ); #ifdef EXTFLOAT80 void @@ -306,6 +404,11 @@ void int_fast64_t ( const extFloat80_t *, bool ), bool ); +#ifdef FLOAT16 +void + test_a_extF80_z_f16( + float16_t ( const extFloat80_t * ), float16_t ( const extFloat80_t * ) ); +#endif void test_a_extF80_z_f32( float32_t ( const extFloat80_t * ), float32_t ( const extFloat80_t * ) ); @@ -415,6 +518,11 @@ void int_fast64_t ( const float128_t *, bool ), bool ); +#ifdef FLOAT16 +void + test_a_f128_z_f16( + float16_t ( const float128_t * ), float16_t ( const float128_t * ) ); +#endif void test_a_f128_z_f32( float32_t ( const float128_t * ), float32_t ( const float128_t * ) ); diff --git a/source/testLoops_common.c b/source/testLoops_common.c index 291d01a..78c79b3 100644 --- a/source/testLoops_common.c +++ b/source/testLoops_common.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_extF80_z_f128.c b/source/test_a_extF80_z_f128.c index 44200ca..d1c7bd0 100644 --- a/source/test_a_extF80_z_f128.c +++ b/source/test_a_extF80_z_f128.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_extF80_z_f16.c b/source/test_a_extF80_z_f16.c new file mode 100644 index 0000000..19e0b83 --- /dev/null +++ b/source/test_a_extF80_z_f16.c @@ -0,0 +1,107 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3b, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of +California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions, and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=============================================================================*/ + +#include <stdio.h> +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#if defined FLOAT16 && defined EXTFLOAT80 + +#pragma STDC FENV_ACCESS ON + +void + test_a_extF80_z_f16( + float16_t trueFunction( const extFloat80_t * ), + float16_t subjFunction( const extFloat80_t * ) + ) +{ + int count; + float16_t trueZ; + uint_fast8_t trueFlags; + float16_t subjZ; + uint_fast8_t subjFlags; + + genCases_extF80_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_extF80_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_extF80_a ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( &genCases_extF80_a ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f16_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && extF80M_isSignalingNaN( &genCases_extF80_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f16_isNaN( trueZ ) + || ! f16_isNaN( subjZ ) + || f16_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_extF80M( &genCases_extF80_a, " " ); + writeCase_z_f16( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_extF80_z_f32.c b/source/test_a_extF80_z_f32.c index 2ee1699..5a5f885 100644 --- a/source/test_a_extF80_z_f32.c +++ b/source/test_a_extF80_z_f32.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_extF80_z_f64.c b/source/test_a_extF80_z_f64.c index 973baf8..f6016c8 100644 --- a/source/test_a_extF80_z_f64.c +++ b/source/test_a_extF80_z_f64.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_extF80_z_i32_rx.c b/source/test_a_extF80_z_i32_rx.c index 60c450a..9df8dc6 100644 --- a/source/test_a_extF80_z_i32_rx.c +++ b/source/test_a_extF80_z_i32_rx.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_extF80_z_i32_x.c b/source/test_a_extF80_z_i32_x.c index 754a6bc..8c70e79 100644 --- a/source/test_a_extF80_z_i32_x.c +++ b/source/test_a_extF80_z_i32_x.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_extF80_z_i64_rx.c b/source/test_a_extF80_z_i64_rx.c index 1b3a9bb..54d7ea6 100644 --- a/source/test_a_extF80_z_i64_rx.c +++ b/source/test_a_extF80_z_i64_rx.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_extF80_z_i64_x.c b/source/test_a_extF80_z_i64_x.c index f13d00b..f52ae5a 100644 --- a/source/test_a_extF80_z_i64_x.c +++ b/source/test_a_extF80_z_i64_x.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_extF80_z_ui32_rx.c b/source/test_a_extF80_z_ui32_rx.c index 446602e..f768040 100644 --- a/source/test_a_extF80_z_ui32_rx.c +++ b/source/test_a_extF80_z_ui32_rx.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_extF80_z_ui32_x.c b/source/test_a_extF80_z_ui32_x.c index 8beb35c..bbef2dd 100644 --- a/source/test_a_extF80_z_ui32_x.c +++ b/source/test_a_extF80_z_ui32_x.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_extF80_z_ui64_rx.c b/source/test_a_extF80_z_ui64_rx.c index 704b8ba..25346ba 100644 --- a/source/test_a_extF80_z_ui64_rx.c +++ b/source/test_a_extF80_z_ui64_rx.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_extF80_z_ui64_x.c b/source/test_a_extF80_z_ui64_x.c index 88ec271..9323f44 100644 --- a/source/test_a_extF80_z_ui64_x.c +++ b/source/test_a_extF80_z_ui64_x.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_f128_z_extF80.c b/source/test_a_f128_z_extF80.c index f742225..b65b37d 100644 --- a/source/test_a_f128_z_extF80.c +++ b/source/test_a_f128_z_extF80.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_f128_z_f16.c b/source/test_a_f128_z_f16.c new file mode 100644 index 0000000..f9438fb --- /dev/null +++ b/source/test_a_f128_z_f16.c @@ -0,0 +1,107 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3b, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of +California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions, and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=============================================================================*/ + +#include <stdint.h> +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#if defined FLOAT16 && defined FLOAT128 + +#pragma STDC FENV_ACCESS ON + +void + test_a_f128_z_f16( + float16_t trueFunction( const float128_t * ), + float16_t subjFunction( const float128_t * ) + ) +{ + int count; + float16_t trueZ; + uint_fast8_t trueFlags; + float16_t subjZ; + uint_fast8_t subjFlags; + + genCases_f128_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f128_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &genCases_f128_a ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( &genCases_f128_a ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f16_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && f128M_isSignalingNaN( &genCases_f128_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f16_isNaN( trueZ ) + || ! f16_isNaN( subjZ ) + || f16_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f128M( &genCases_f128_a, " " ); + writeCase_z_f16( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_f128_z_f32.c b/source/test_a_f128_z_f32.c index ac684ad..3064231 100644 --- a/source/test_a_f128_z_f32.c +++ b/source/test_a_f128_z_f32.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_f128_z_f64.c b/source/test_a_f128_z_f64.c index c93ccbc..4f09acb 100644 --- a/source/test_a_f128_z_f64.c +++ b/source/test_a_f128_z_f64.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_f128_z_i32_rx.c b/source/test_a_f128_z_i32_rx.c index 2344d3c..92ca0d4 100644 --- a/source/test_a_f128_z_i32_rx.c +++ b/source/test_a_f128_z_i32_rx.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_f128_z_i32_x.c b/source/test_a_f128_z_i32_x.c index 82779b9..06f1f69 100644 --- a/source/test_a_f128_z_i32_x.c +++ b/source/test_a_f128_z_i32_x.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_f128_z_i64_rx.c b/source/test_a_f128_z_i64_rx.c index 5a172d1..71cca80 100644 --- a/source/test_a_f128_z_i64_rx.c +++ b/source/test_a_f128_z_i64_rx.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_f128_z_i64_x.c b/source/test_a_f128_z_i64_x.c index 66e0d6c..c219e5d 100644 --- a/source/test_a_f128_z_i64_x.c +++ b/source/test_a_f128_z_i64_x.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_f128_z_ui32_rx.c b/source/test_a_f128_z_ui32_rx.c index a6ec1ad..30e8806 100644 --- a/source/test_a_f128_z_ui32_rx.c +++ b/source/test_a_f128_z_ui32_rx.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_f128_z_ui32_x.c b/source/test_a_f128_z_ui32_x.c index 3b4fcaf..9bce868 100644 --- a/source/test_a_f128_z_ui32_x.c +++ b/source/test_a_f128_z_ui32_x.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_f128_z_ui64_rx.c b/source/test_a_f128_z_ui64_rx.c index e5274a7..28c27a2 100644 --- a/source/test_a_f128_z_ui64_rx.c +++ b/source/test_a_f128_z_ui64_rx.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_f128_z_ui64_x.c b/source/test_a_f128_z_ui64_x.c index 33f4cb5..66fb1f1 100644 --- a/source/test_a_f128_z_ui64_x.c +++ b/source/test_a_f128_z_ui64_x.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_f16_z_extF80.c b/source/test_a_f16_z_extF80.c new file mode 100644 index 0000000..150b71b --- /dev/null +++ b/source/test_a_f16_z_extF80.c @@ -0,0 +1,106 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3b, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of +California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions, and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=============================================================================*/ + +#include <stdint.h> +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#if defined FLOAT16 && defined EXTFLOAT80 + +#pragma STDC FENV_ACCESS ON + +void + test_a_f16_z_extF80( + void trueFunction( float16_t, extFloat80_t * ), + void subjFunction( float16_t, extFloat80_t * ) + ) +{ + int count; + extFloat80_t trueZ; + uint_fast8_t trueFlags; + extFloat80_t subjZ; + uint_fast8_t subjFlags; + + genCases_f16_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f16_a_next(); + *testLoops_trueFlagsPtr = 0; + trueFunction( genCases_f16_a, &trueZ ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjFunction( genCases_f16_a, &subjZ ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! extF80M_same( &trueZ, &subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f16_isSignalingNaN( genCases_f16_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! extF80M_isNaN( &trueZ ) + || ! extF80M_isNaN( &subjZ ) + || extF80M_isSignalingNaN( &subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f16( genCases_f16_a, " " ); + writeCase_z_extF80M( &trueZ, trueFlags, &subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_f16_z_f128.c b/source/test_a_f16_z_f128.c new file mode 100644 index 0000000..2372955 --- /dev/null +++ b/source/test_a_f16_z_f128.c @@ -0,0 +1,106 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3b, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of +California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions, and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=============================================================================*/ + +#include <stdint.h> +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#if defined FLOAT16 && defined FLOAT128 + +#pragma STDC FENV_ACCESS ON + +void + test_a_f16_z_f128( + void trueFunction( float16_t, float128_t * ), + void subjFunction( float16_t, float128_t * ) + ) +{ + int count; + float128_t trueZ; + uint_fast8_t trueFlags; + float128_t subjZ; + uint_fast8_t subjFlags; + + genCases_f16_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f16_a_next(); + *testLoops_trueFlagsPtr = 0; + trueFunction( genCases_f16_a, &trueZ ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjFunction( genCases_f16_a, &subjZ ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f128M_same( &trueZ, &subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f16_isSignalingNaN( genCases_f16_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f128M_isNaN( &trueZ ) + || ! f128M_isNaN( &subjZ ) + || f128M_isSignalingNaN( &subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f16( genCases_f16_a, " " ); + writeCase_z_f128M( &trueZ, trueFlags, &subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_f16_z_f32.c b/source/test_a_f16_z_f32.c new file mode 100644 index 0000000..7612e5d --- /dev/null +++ b/source/test_a_f16_z_f32.c @@ -0,0 +1,104 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3b, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of +California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions, and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=============================================================================*/ + +#include <stdint.h> +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef FLOAT16 + +#pragma STDC FENV_ACCESS ON + +void + test_a_f16_z_f32( + float32_t trueFunction( float16_t ), float32_t subjFunction( float16_t ) ) +{ + int count; + float32_t trueZ; + uint_fast8_t trueFlags; + float32_t subjZ; + uint_fast8_t subjFlags; + + genCases_f16_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f16_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f16_a ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f16_a ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f32_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f16_isSignalingNaN( genCases_f16_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f32_isNaN( trueZ ) + || ! f32_isNaN( subjZ ) + || f32_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f16( genCases_f16_a, " " ); + writeCase_z_f32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_f16_z_f64.c b/source/test_a_f16_z_f64.c new file mode 100644 index 0000000..bbc3f69 --- /dev/null +++ b/source/test_a_f16_z_f64.c @@ -0,0 +1,104 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3b, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of +California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions, and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=============================================================================*/ + +#include <stdint.h> +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef FLOAT16 + +#pragma STDC FENV_ACCESS ON + +void + test_a_f16_z_f64( + float64_t trueFunction( float16_t ), float64_t subjFunction( float16_t ) ) +{ + int count; + float64_t trueZ; + uint_fast8_t trueFlags; + float64_t subjZ; + uint_fast8_t subjFlags; + + genCases_f16_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f16_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f16_a ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f16_a ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f64_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f16_isSignalingNaN( genCases_f16_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f64_isNaN( trueZ ) + || ! f64_isNaN( subjZ ) + || f64_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f16( genCases_f16_a, " " ); + writeCase_z_f64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_f16_z_i32_rx.c b/source/test_a_f16_z_i32_rx.c new file mode 100644 index 0000000..326bf3d --- /dev/null +++ b/source/test_a_f16_z_i32_rx.c @@ -0,0 +1,104 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3b, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of +California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions, and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=============================================================================*/ + +#include <stdbool.h> +#include <stdint.h> +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_a_f16_z_i32_rx( + int_fast32_t trueFunction( float16_t, uint_fast8_t, bool ), + int_fast32_t subjFunction( float16_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int count; + int_fast32_t trueZ; + uint_fast8_t trueFlags; + int_fast32_t subjZ; + uint_fast8_t subjFlags; + + genCases_f16_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f16_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f16_a, roundingMode, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f16_a, roundingMode, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f16_isSignalingNaN( genCases_f16_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != 0x7FFFFFFF) + || ((subjZ != 0x7FFFFFFF) && (subjZ != -0x7FFFFFFF - 1)) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f16( genCases_f16_a, " " ); + writeCase_z_i32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_a_f16_z_i32_x.c b/source/test_a_f16_z_i32_x.c new file mode 100644 index 0000000..217cfae --- /dev/null +++ b/source/test_a_f16_z_i32_x.c @@ -0,0 +1,103 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3b, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of +California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions, and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=============================================================================*/ + +#include <stdbool.h> +#include <stdint.h> +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_a_f16_z_i32_x( + int_fast32_t trueFunction( float16_t, bool ), + int_fast32_t subjFunction( float16_t, bool ), + bool exact + ) +{ + int count; + int_fast32_t trueZ; + uint_fast8_t trueFlags; + int_fast32_t subjZ; + uint_fast8_t subjFlags; + + genCases_f16_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f16_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f16_a, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f16_a, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f16_isSignalingNaN( genCases_f16_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != 0x7FFFFFFF) + || ((subjZ != 0x7FFFFFFF) && (subjZ != -0x7FFFFFFF - 1)) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f16( genCases_f16_a, " " ); + writeCase_z_i32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_a_f16_z_i64_rx.c b/source/test_a_f16_z_i64_rx.c new file mode 100644 index 0000000..e5b445b --- /dev/null +++ b/source/test_a_f16_z_i64_rx.c @@ -0,0 +1,105 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3b, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of +California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions, and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=============================================================================*/ + +#include <stdbool.h> +#include <stdint.h> +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_a_f16_z_i64_rx( + int_fast64_t trueFunction( float16_t, uint_fast8_t, bool ), + int_fast64_t subjFunction( float16_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int count; + int_fast64_t trueZ; + uint_fast8_t trueFlags; + int_fast64_t subjZ; + uint_fast8_t subjFlags; + + genCases_f16_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f16_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f16_a, roundingMode, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f16_a, roundingMode, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f16_isSignalingNaN( genCases_f16_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != INT64_C( 0x7FFFFFFFFFFFFFFF )) + || ((subjZ != INT64_C( 0x7FFFFFFFFFFFFFFF )) + && (subjZ != -INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1)) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f16( genCases_f16_a, " " ); + writeCase_z_i64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_a_f16_z_i64_x.c b/source/test_a_f16_z_i64_x.c new file mode 100644 index 0000000..392d747 --- /dev/null +++ b/source/test_a_f16_z_i64_x.c @@ -0,0 +1,104 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3b, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of +California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions, and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=============================================================================*/ + +#include <stdbool.h> +#include <stdint.h> +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_a_f16_z_i64_x( + int_fast64_t trueFunction( float16_t, bool ), + int_fast64_t subjFunction( float16_t, bool ), + bool exact + ) +{ + int count; + int_fast64_t trueZ; + uint_fast8_t trueFlags; + int_fast64_t subjZ; + uint_fast8_t subjFlags; + + genCases_f16_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f16_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f16_a, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f16_a, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f16_isSignalingNaN( genCases_f16_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != INT64_C( 0x7FFFFFFFFFFFFFFF )) + || ((subjZ != INT64_C( 0x7FFFFFFFFFFFFFFF )) + && (subjZ != -INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1)) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f16( genCases_f16_a, " " ); + writeCase_z_i64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_a_f16_z_ui32_rx.c b/source/test_a_f16_z_ui32_rx.c new file mode 100644 index 0000000..bb0ed33 --- /dev/null +++ b/source/test_a_f16_z_ui32_rx.c @@ -0,0 +1,104 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3b, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of +California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions, and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=============================================================================*/ + +#include <stdbool.h> +#include <stdint.h> +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_a_f16_z_ui32_rx( + uint_fast32_t trueFunction( float16_t, uint_fast8_t, bool ), + uint_fast32_t subjFunction( float16_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int count; + uint_fast32_t trueZ; + uint_fast8_t trueFlags; + uint_fast32_t subjZ; + uint_fast8_t subjFlags; + + genCases_f16_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f16_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f16_a, roundingMode, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f16_a, roundingMode, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f16_isSignalingNaN( genCases_f16_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != 0xFFFFFFFF) + || (subjZ != 0xFFFFFFFF) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f16( genCases_f16_a, " " ); + writeCase_z_ui32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_a_f16_z_ui32_x.c b/source/test_a_f16_z_ui32_x.c new file mode 100644 index 0000000..42184ba --- /dev/null +++ b/source/test_a_f16_z_ui32_x.c @@ -0,0 +1,103 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3b, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of +California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions, and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=============================================================================*/ + +#include <stdbool.h> +#include <stdint.h> +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_a_f16_z_ui32_x( + uint_fast32_t trueFunction( float16_t, bool ), + uint_fast32_t subjFunction( float16_t, bool ), + bool exact + ) +{ + int count; + uint_fast32_t trueZ; + uint_fast8_t trueFlags; + uint_fast32_t subjZ; + uint_fast8_t subjFlags; + + genCases_f16_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f16_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f16_a, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f16_a, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f16_isSignalingNaN( genCases_f16_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != 0xFFFFFFFF) + || (subjZ != 0xFFFFFFFF) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f16( genCases_f16_a, " " ); + writeCase_z_ui32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_a_f16_z_ui64_rx.c b/source/test_a_f16_z_ui64_rx.c new file mode 100644 index 0000000..1ee7359 --- /dev/null +++ b/source/test_a_f16_z_ui64_rx.c @@ -0,0 +1,104 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3b, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of +California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions, and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=============================================================================*/ + +#include <stdbool.h> +#include <stdint.h> +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_a_f16_z_ui64_rx( + uint_fast64_t trueFunction( float16_t, uint_fast8_t, bool ), + uint_fast64_t subjFunction( float16_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int count; + uint_fast64_t trueZ; + uint_fast8_t trueFlags; + uint_fast64_t subjZ; + uint_fast8_t subjFlags; + + genCases_f16_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f16_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f16_a, roundingMode, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f16_a, roundingMode, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f16_isSignalingNaN( genCases_f16_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != 0xFFFFFFFF) + || (subjZ != 0xFFFFFFFF) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f16( genCases_f16_a, " " ); + writeCase_z_ui64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_a_f16_z_ui64_x.c b/source/test_a_f16_z_ui64_x.c new file mode 100644 index 0000000..1d9b225 --- /dev/null +++ b/source/test_a_f16_z_ui64_x.c @@ -0,0 +1,103 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3b, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of +California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions, and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=============================================================================*/ + +#include <stdbool.h> +#include <stdint.h> +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#pragma STDC FENV_ACCESS ON + +void + test_a_f16_z_ui64_x( + uint_fast64_t trueFunction( float16_t, bool ), + uint_fast64_t subjFunction( float16_t, bool ), + bool exact + ) +{ + int count; + uint_fast64_t trueZ; + uint_fast8_t trueFlags; + uint_fast64_t subjZ; + uint_fast8_t subjFlags; + + genCases_f16_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f16_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f16_a, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f16_a, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f16_isSignalingNaN( genCases_f16_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != 0xFFFFFFFF) + || (subjZ != 0xFFFFFFFF) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f16( genCases_f16_a, " " ); + writeCase_z_ui64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + diff --git a/source/test_a_f32_z_extF80.c b/source/test_a_f32_z_extF80.c index 594aaaf..8a4fd51 100644 --- a/source/test_a_f32_z_extF80.c +++ b/source/test_a_f32_z_extF80.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_f32_z_f128.c b/source/test_a_f32_z_f128.c index 67f13a3..06b9d2c 100644 --- a/source/test_a_f32_z_f128.c +++ b/source/test_a_f32_z_f128.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_f32_z_f16.c b/source/test_a_f32_z_f16.c new file mode 100644 index 0000000..8aba974 --- /dev/null +++ b/source/test_a_f32_z_f16.c @@ -0,0 +1,104 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3b, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of +California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions, and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=============================================================================*/ + +#include <stdint.h> +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef FLOAT16 + +#pragma STDC FENV_ACCESS ON + +void + test_a_f32_z_f16( + float16_t trueFunction( float32_t ), float16_t subjFunction( float32_t ) ) +{ + int count; + float16_t trueZ; + uint_fast8_t trueFlags; + float16_t subjZ; + uint_fast8_t subjFlags; + + genCases_f32_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f32_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f32_a ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f32_a ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f16_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f32_isSignalingNaN( genCases_f32_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f16_isNaN( trueZ ) + || ! f16_isNaN( subjZ ) + || f16_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f32( genCases_f32_a, " " ); + writeCase_z_f16( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_f32_z_f64.c b/source/test_a_f32_z_f64.c index 93110b9..895fcf0 100644 --- a/source/test_a_f32_z_f64.c +++ b/source/test_a_f32_z_f64.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_f32_z_i32_rx.c b/source/test_a_f32_z_i32_rx.c index 2d3253e..2d09367 100644 --- a/source/test_a_f32_z_i32_rx.c +++ b/source/test_a_f32_z_i32_rx.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_f32_z_i32_x.c b/source/test_a_f32_z_i32_x.c index c52581f..5b231cf 100644 --- a/source/test_a_f32_z_i32_x.c +++ b/source/test_a_f32_z_i32_x.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_f32_z_i64_rx.c b/source/test_a_f32_z_i64_rx.c index c64f641..2a46473 100644 --- a/source/test_a_f32_z_i64_rx.c +++ b/source/test_a_f32_z_i64_rx.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_f32_z_i64_x.c b/source/test_a_f32_z_i64_x.c index e2497e6..a226906 100644 --- a/source/test_a_f32_z_i64_x.c +++ b/source/test_a_f32_z_i64_x.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_f32_z_ui32_rx.c b/source/test_a_f32_z_ui32_rx.c index edff170..1d60af7 100644 --- a/source/test_a_f32_z_ui32_rx.c +++ b/source/test_a_f32_z_ui32_rx.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_f32_z_ui32_x.c b/source/test_a_f32_z_ui32_x.c index 3c2b583..0ef3daf 100644 --- a/source/test_a_f32_z_ui32_x.c +++ b/source/test_a_f32_z_ui32_x.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_f32_z_ui64_rx.c b/source/test_a_f32_z_ui64_rx.c index dc2d885..8e885c4 100644 --- a/source/test_a_f32_z_ui64_rx.c +++ b/source/test_a_f32_z_ui64_rx.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_f32_z_ui64_x.c b/source/test_a_f32_z_ui64_x.c index 72af38f..00dc606 100644 --- a/source/test_a_f32_z_ui64_x.c +++ b/source/test_a_f32_z_ui64_x.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_f64_z_extF80.c b/source/test_a_f64_z_extF80.c index d18398e..e844f43 100644 --- a/source/test_a_f64_z_extF80.c +++ b/source/test_a_f64_z_extF80.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_f64_z_f128.c b/source/test_a_f64_z_f128.c index a4c27fc..5a37a5a 100644 --- a/source/test_a_f64_z_f128.c +++ b/source/test_a_f64_z_f128.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_f64_z_f16.c b/source/test_a_f64_z_f16.c new file mode 100644 index 0000000..faafce6 --- /dev/null +++ b/source/test_a_f64_z_f16.c @@ -0,0 +1,104 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3b, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of +California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions, and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=============================================================================*/ + +#include <stdint.h> +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef FLOAT16 + +#pragma STDC FENV_ACCESS ON + +void + test_a_f64_z_f16( + float16_t trueFunction( float64_t ), float16_t subjFunction( float64_t ) ) +{ + int count; + float16_t trueZ; + uint_fast8_t trueFlags; + float16_t subjZ; + uint_fast8_t subjFlags; + + genCases_f64_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f64_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f64_a ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f64_a ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f16_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f64_isSignalingNaN( genCases_f64_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f16_isNaN( trueZ ) + || ! f16_isNaN( subjZ ) + || f16_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f64( genCases_f64_a, " " ); + writeCase_z_f16( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_f64_z_f32.c b/source/test_a_f64_z_f32.c index b40b5a6..8239f59 100644 --- a/source/test_a_f64_z_f32.c +++ b/source/test_a_f64_z_f32.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_f64_z_i32_rx.c b/source/test_a_f64_z_i32_rx.c index a960234..fe692d1 100644 --- a/source/test_a_f64_z_i32_rx.c +++ b/source/test_a_f64_z_i32_rx.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_f64_z_i32_x.c b/source/test_a_f64_z_i32_x.c index 3eadc59..818dd0a 100644 --- a/source/test_a_f64_z_i32_x.c +++ b/source/test_a_f64_z_i32_x.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_f64_z_i64_rx.c b/source/test_a_f64_z_i64_rx.c index 71a03f6..99455cb 100644 --- a/source/test_a_f64_z_i64_rx.c +++ b/source/test_a_f64_z_i64_rx.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_f64_z_i64_x.c b/source/test_a_f64_z_i64_x.c index e04e71d..42ebd62 100644 --- a/source/test_a_f64_z_i64_x.c +++ b/source/test_a_f64_z_i64_x.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_f64_z_ui32_rx.c b/source/test_a_f64_z_ui32_rx.c index f41038f..e627b02 100644 --- a/source/test_a_f64_z_ui32_rx.c +++ b/source/test_a_f64_z_ui32_rx.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_f64_z_ui32_x.c b/source/test_a_f64_z_ui32_x.c index 234bd18..941ba75 100644 --- a/source/test_a_f64_z_ui32_x.c +++ b/source/test_a_f64_z_ui32_x.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_f64_z_ui64_rx.c b/source/test_a_f64_z_ui64_rx.c index 2d5e4d0..9520417 100644 --- a/source/test_a_f64_z_ui64_rx.c +++ b/source/test_a_f64_z_ui64_rx.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_f64_z_ui64_x.c b/source/test_a_f64_z_ui64_x.c index 3d6e12e..5af2a02 100644 --- a/source/test_a_f64_z_ui64_x.c +++ b/source/test_a_f64_z_ui64_x.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_i32_z_extF80.c b/source/test_a_i32_z_extF80.c index f0d0370..3b2b3e2 100644 --- a/source/test_a_i32_z_extF80.c +++ b/source/test_a_i32_z_extF80.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_i32_z_f128.c b/source/test_a_i32_z_f128.c index 692ef91..0053c81 100644 --- a/source/test_a_i32_z_f128.c +++ b/source/test_a_i32_z_f128.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_i32_z_f16.c b/source/test_a_i32_z_f16.c new file mode 100644 index 0000000..9e3218e --- /dev/null +++ b/source/test_a_i32_z_f16.c @@ -0,0 +1,99 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3b, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of +California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions, and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=============================================================================*/ + +#include <stdint.h> +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef FLOAT16 + +#pragma STDC FENV_ACCESS ON + +void + test_a_i32_z_f16( + float16_t trueFunction( int32_t ), float16_t subjFunction( int32_t ) ) +{ + int count; + float16_t trueZ; + uint_fast8_t trueFlags; + float16_t subjZ; + uint_fast8_t subjFlags; + + genCases_i32_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_i32_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_i32_a ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_i32_a ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f16_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + verCases_checkNaNs + || ! f16_isNaN( trueZ ) + || ! f16_isNaN( subjZ ) + || f16_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_i32( genCases_i32_a, " " ); + writeCase_z_f16( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_i32_z_f32.c b/source/test_a_i32_z_f32.c index 6e20978..4b9ac1e 100644 --- a/source/test_a_i32_z_f32.c +++ b/source/test_a_i32_z_f32.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_i32_z_f64.c b/source/test_a_i32_z_f64.c index 3c6d827..f526772 100644 --- a/source/test_a_i32_z_f64.c +++ b/source/test_a_i32_z_f64.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_i64_z_extF80.c b/source/test_a_i64_z_extF80.c index 66d2974..f729c29 100644 --- a/source/test_a_i64_z_extF80.c +++ b/source/test_a_i64_z_extF80.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_i64_z_f128.c b/source/test_a_i64_z_f128.c index 3b5e3db..6b0f57e 100644 --- a/source/test_a_i64_z_f128.c +++ b/source/test_a_i64_z_f128.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_i64_z_f16.c b/source/test_a_i64_z_f16.c new file mode 100644 index 0000000..c775908 --- /dev/null +++ b/source/test_a_i64_z_f16.c @@ -0,0 +1,99 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3b, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of +California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions, and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=============================================================================*/ + +#include <stdint.h> +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef FLOAT16 + +#pragma STDC FENV_ACCESS ON + +void + test_a_i64_z_f16( + float16_t trueFunction( int64_t ), float16_t subjFunction( int64_t ) ) +{ + int count; + float16_t trueZ; + uint_fast8_t trueFlags; + float16_t subjZ; + uint_fast8_t subjFlags; + + genCases_i64_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_i64_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_i64_a ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_i64_a ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f16_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + verCases_checkNaNs + || ! f16_isNaN( trueZ ) + || ! f16_isNaN( subjZ ) + || f16_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_i64( genCases_i64_a, " " ); + writeCase_z_f16( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_i64_z_f32.c b/source/test_a_i64_z_f32.c index c1a823d..794d6df 100644 --- a/source/test_a_i64_z_f32.c +++ b/source/test_a_i64_z_f32.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_i64_z_f64.c b/source/test_a_i64_z_f64.c index 605ba7f..8788494 100644 --- a/source/test_a_i64_z_f64.c +++ b/source/test_a_i64_z_f64.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_ui32_z_extF80.c b/source/test_a_ui32_z_extF80.c index 227646a..701fd86 100644 --- a/source/test_a_ui32_z_extF80.c +++ b/source/test_a_ui32_z_extF80.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_ui32_z_f128.c b/source/test_a_ui32_z_f128.c index 6429f2c..a1505d7 100644 --- a/source/test_a_ui32_z_f128.c +++ b/source/test_a_ui32_z_f128.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_ui32_z_f16.c b/source/test_a_ui32_z_f16.c new file mode 100644 index 0000000..149c1b4 --- /dev/null +++ b/source/test_a_ui32_z_f16.c @@ -0,0 +1,99 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3b, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of +California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions, and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=============================================================================*/ + +#include <stdint.h> +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef FLOAT16 + +#pragma STDC FENV_ACCESS ON + +void + test_a_ui32_z_f16( + float16_t trueFunction( uint32_t ), float16_t subjFunction( uint32_t ) ) +{ + int count; + float16_t trueZ; + uint_fast8_t trueFlags; + float16_t subjZ; + uint_fast8_t subjFlags; + + genCases_ui32_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_ui32_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_ui32_a ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_ui32_a ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f16_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + verCases_checkNaNs + || ! f16_isNaN( trueZ ) + || ! f16_isNaN( subjZ ) + || f16_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_ui32( genCases_ui32_a, " " ); + writeCase_z_f16( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_ui32_z_f32.c b/source/test_a_ui32_z_f32.c index ee789e7..82710a3 100644 --- a/source/test_a_ui32_z_f32.c +++ b/source/test_a_ui32_z_f32.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_ui32_z_f64.c b/source/test_a_ui32_z_f64.c index bbee48c..c47cba8 100644 --- a/source/test_a_ui32_z_f64.c +++ b/source/test_a_ui32_z_f64.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_ui64_z_extF80.c b/source/test_a_ui64_z_extF80.c index bcd687f..8e84802 100644 --- a/source/test_a_ui64_z_extF80.c +++ b/source/test_a_ui64_z_extF80.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_ui64_z_f128.c b/source/test_a_ui64_z_f128.c index f9d9cab..9e5c346 100644 --- a/source/test_a_ui64_z_f128.c +++ b/source/test_a_ui64_z_f128.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_ui64_z_f16.c b/source/test_a_ui64_z_f16.c new file mode 100644 index 0000000..2b74134 --- /dev/null +++ b/source/test_a_ui64_z_f16.c @@ -0,0 +1,99 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3b, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of +California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions, and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=============================================================================*/ + +#include <stdint.h> +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef FLOAT16 + +#pragma STDC FENV_ACCESS ON + +void + test_a_ui64_z_f16( + float16_t trueFunction( uint64_t ), float16_t subjFunction( uint64_t ) ) +{ + int count; + float16_t trueZ; + uint_fast8_t trueFlags; + float16_t subjZ; + uint_fast8_t subjFlags; + + genCases_ui64_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_ui64_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_ui64_a ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_ui64_a ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f16_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + verCases_checkNaNs + || ! f16_isNaN( trueZ ) + || ! f16_isNaN( subjZ ) + || f16_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_ui64( genCases_ui64_a, " " ); + writeCase_z_f16( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_a_ui64_z_f32.c b/source/test_a_ui64_z_f32.c index 7f612fb..e9818d5 100644 --- a/source/test_a_ui64_z_f32.c +++ b/source/test_a_ui64_z_f32.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_a_ui64_z_f64.c b/source/test_a_ui64_z_f64.c index 22964af..e194060 100644 --- a/source/test_a_ui64_z_f64.c +++ b/source/test_a_ui64_z_f64.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_ab_extF80_z_bool.c b/source/test_ab_extF80_z_bool.c index f101726..8a04c32 100644 --- a/source/test_ab_extF80_z_bool.c +++ b/source/test_ab_extF80_z_bool.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_ab_f128_z_bool.c b/source/test_ab_f128_z_bool.c index 029b83a..49187ef 100644 --- a/source/test_ab_f128_z_bool.c +++ b/source/test_ab_f128_z_bool.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_ab_f16_z_bool.c b/source/test_ab_f16_z_bool.c new file mode 100644 index 0000000..2424d38 --- /dev/null +++ b/source/test_ab_f16_z_bool.c @@ -0,0 +1,103 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3b, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of +California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions, and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=============================================================================*/ + +#include <stdbool.h> +#include <stdint.h> +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef FLOAT16 + +#pragma STDC FENV_ACCESS ON + +void + test_ab_f16_z_bool( + bool trueFunction( float16_t, float16_t ), + bool subjFunction( float16_t, float16_t ) + ) +{ + int count; + bool trueZ; + uint_fast8_t trueFlags; + bool subjZ; + uint_fast8_t subjFlags; + + genCases_f16_ab_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f16_ab_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f16_a, genCases_f16_b ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f16_a, genCases_f16_b ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && (f16_isSignalingNaN( genCases_f16_a ) + || f16_isSignalingNaN( genCases_f16_b )) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_ab_f16( genCases_f16_a, genCases_f16_b, " " ); + writeCase_z_bool( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_ab_f32_z_bool.c b/source/test_ab_f32_z_bool.c index 30ca986..0cf4da4 100644 --- a/source/test_ab_f32_z_bool.c +++ b/source/test_ab_f32_z_bool.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_ab_f64_z_bool.c b/source/test_ab_f64_z_bool.c index 2dbdc0a..d239996 100644 --- a/source/test_ab_f64_z_bool.c +++ b/source/test_ab_f64_z_bool.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_abcz_f128.c b/source/test_abcz_f128.c index aae1e59..bffdec3 100644 --- a/source/test_abcz_f128.c +++ b/source/test_abcz_f128.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_abcz_f16.c b/source/test_abcz_f16.c new file mode 100644 index 0000000..87945db --- /dev/null +++ b/source/test_abcz_f16.c @@ -0,0 +1,111 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3b, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of +California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions, and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=============================================================================*/ + +#include <stdint.h> +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef FLOAT16 + +#pragma STDC FENV_ACCESS ON + +void + test_abcz_f16( + float16_t trueFunction( float16_t, float16_t, float16_t ), + float16_t subjFunction( float16_t, float16_t, float16_t ) + ) +{ + int count; + float16_t trueZ; + uint_fast8_t trueFlags; + float16_t subjZ; + uint_fast8_t subjFlags; + + genCases_f16_abc_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f16_abc_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f16_a, genCases_f16_b, genCases_f16_c ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f16_a, genCases_f16_b, genCases_f16_c ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f16_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && ( f16_isSignalingNaN( genCases_f16_a ) + || f16_isSignalingNaN( genCases_f16_b ) + || f16_isSignalingNaN( genCases_f16_c ) + ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f16_isNaN( trueZ ) + || ! f16_isNaN( subjZ ) + || f16_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_abc_f16( + genCases_f16_a, genCases_f16_b, genCases_f16_c, " " ); + writeCase_z_f16( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_abcz_f32.c b/source/test_abcz_f32.c index 1b270e8..1b06deb 100644 --- a/source/test_abcz_f32.c +++ b/source/test_abcz_f32.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_abcz_f64.c b/source/test_abcz_f64.c index 00e06cd..ce34e7c 100644 --- a/source/test_abcz_f64.c +++ b/source/test_abcz_f64.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_abz_extF80.c b/source/test_abz_extF80.c index e131496..c697dbe 100644 --- a/source/test_abz_extF80.c +++ b/source/test_abz_extF80.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_abz_f128.c b/source/test_abz_f128.c index 957da36..46b9333 100644 --- a/source/test_abz_f128.c +++ b/source/test_abz_f128.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_abz_f16.c b/source/test_abz_f16.c new file mode 100644 index 0000000..5220788 --- /dev/null +++ b/source/test_abz_f16.c @@ -0,0 +1,108 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3b, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of +California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions, and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=============================================================================*/ + +#include <stdint.h> +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef FLOAT16 + +#pragma STDC FENV_ACCESS ON + +void + test_abz_f16( + float16_t trueFunction( float16_t, float16_t ), + float16_t subjFunction( float16_t, float16_t ) + ) +{ + int count; + float16_t trueZ; + uint_fast8_t trueFlags; + float16_t subjZ; + uint_fast8_t subjFlags; + + genCases_f16_ab_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f16_ab_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f16_a, genCases_f16_b ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f16_a, genCases_f16_b ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f16_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && (f16_isSignalingNaN( genCases_f16_a ) + || f16_isSignalingNaN( genCases_f16_b )) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f16_isNaN( trueZ ) + || ! f16_isNaN( subjZ ) + || f16_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_ab_f16( genCases_f16_a, genCases_f16_b, " " ); + writeCase_z_f16( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_abz_f32.c b/source/test_abz_f32.c index eb9955d..1d57bb7 100644 --- a/source/test_abz_f32.c +++ b/source/test_abz_f32.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_abz_f64.c b/source/test_abz_f64.c index 0d7130a..9b7c517 100644 --- a/source/test_abz_f64.c +++ b/source/test_abz_f64.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_az_extF80.c b/source/test_az_extF80.c index fc50198..4469628 100644 --- a/source/test_az_extF80.c +++ b/source/test_az_extF80.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_az_extF80_rx.c b/source/test_az_extF80_rx.c index f631e9f..2f754c4 100644 --- a/source/test_az_extF80_rx.c +++ b/source/test_az_extF80_rx.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_az_f128.c b/source/test_az_f128.c index 1d1afd0..9ea38c3 100644 --- a/source/test_az_f128.c +++ b/source/test_az_f128.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_az_f128_rx.c b/source/test_az_f128_rx.c index 2590bd6..5335490 100644 --- a/source/test_az_f128_rx.c +++ b/source/test_az_f128_rx.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_az_f16.c b/source/test_az_f16.c new file mode 100644 index 0000000..a5f34f4 --- /dev/null +++ b/source/test_az_f16.c @@ -0,0 +1,104 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3b, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of +California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions, and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=============================================================================*/ + +#include <stdint.h> +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef FLOAT16 + +#pragma STDC FENV_ACCESS ON + +void + test_az_f16( + float16_t trueFunction( float16_t ), float16_t subjFunction( float16_t ) ) +{ + int count; + float16_t trueZ; + uint_fast8_t trueFlags; + float16_t subjZ; + uint_fast8_t subjFlags; + + genCases_f16_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f16_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f16_a ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f16_a ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f16_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f16_isSignalingNaN( genCases_f16_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f16_isNaN( trueZ ) + || ! f16_isNaN( subjZ ) + || f16_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f16( genCases_f16_a, " " ); + writeCase_z_f16( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_az_f16_rx.c b/source/test_az_f16_rx.c new file mode 100644 index 0000000..a919fc3 --- /dev/null +++ b/source/test_az_f16_rx.c @@ -0,0 +1,109 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3b, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of +California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions, and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=============================================================================*/ + +#include <stdbool.h> +#include <stdint.h> +#include "platform.h" +#include "softfloat.h" +#include "genCases.h" +#include "verCases.h" +#include "writeCase.h" +#include "testLoops.h" + +#ifdef FLOAT16 + +#pragma STDC FENV_ACCESS ON + +void + test_az_f16_rx( + float16_t trueFunction( float16_t, uint_fast8_t, bool ), + float16_t subjFunction( float16_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int count; + float16_t trueZ; + uint_fast8_t trueFlags; + float16_t subjZ; + uint_fast8_t subjFlags; + + genCases_f16_a_init(); + genCases_writeTestsTotal( testLoops_forever ); + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! genCases_done || testLoops_forever ) { + genCases_f16_a_next(); + *testLoops_trueFlagsPtr = 0; + trueZ = trueFunction( genCases_f16_a, roundingMode, exact ); + trueFlags = *testLoops_trueFlagsPtr; + testLoops_subjFlagsFunction(); + subjZ = subjFunction( genCases_f16_a, roundingMode, exact ); + subjFlags = testLoops_subjFlagsFunction(); + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f16_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs && f16_isSignalingNaN( genCases_f16_a ) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f16_isNaN( trueZ ) + || ! f16_isNaN( subjZ ) + || f16_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f16( genCases_f16_a, " " ); + writeCase_z_f16( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + diff --git a/source/test_az_f32.c b/source/test_az_f32.c index 14be1ae..a76ae05 100644 --- a/source/test_az_f32.c +++ b/source/test_az_f32.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_az_f32_rx.c b/source/test_az_f32_rx.c index ac8e6c9..2b2892f 100644 --- a/source/test_az_f32_rx.c +++ b/source/test_az_f32_rx.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_az_f64.c b/source/test_az_f64.c index 2c72909..e6e0d63 100644 --- a/source/test_az_f64.c +++ b/source/test_az_f64.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/test_az_f64_rx.c b/source/test_az_f64_rx.c index d19fa10..fcab07d 100644 --- a/source/test_az_f64_rx.c +++ b/source/test_az_f64_rx.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/testfloat.c b/source/testfloat.c index 96258ec..f58cf53 100644 --- a/source/testfloat.c +++ b/source/testfloat.c @@ -1,11 +1,11 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. -Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of +Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of California. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -61,6 +61,9 @@ static void catchSIGINT( int signalCode ) static void (*subjFunctionPtr)(); +#ifdef FLOAT16 +typedef float16_t funcType_a_ui32_z_f16( uint32_t ); +#endif typedef float32_t funcType_a_ui32_z_f32( uint32_t ); typedef float64_t funcType_a_ui32_z_f64( uint32_t ); #ifdef EXTFLOAT80 @@ -69,6 +72,9 @@ typedef void funcType_a_ui32_z_extF80( uint32_t, extFloat80_t * ); #ifdef FLOAT128 typedef void funcType_a_ui32_z_f128( uint32_t, float128_t * ); #endif +#ifdef FLOAT16 +typedef float16_t funcType_a_ui64_z_f16( uint64_t ); +#endif typedef float32_t funcType_a_ui64_z_f32( uint64_t ); typedef float64_t funcType_a_ui64_z_f64( uint64_t ); #ifdef EXTFLOAT80 @@ -77,6 +83,9 @@ typedef void funcType_a_ui64_z_extF80( uint64_t, extFloat80_t * ); #ifdef FLOAT128 typedef void funcType_a_ui64_z_f128( uint64_t, float128_t * ); #endif +#ifdef FLOAT16 +typedef float16_t funcType_a_i32_z_f16( int32_t ); +#endif typedef float32_t funcType_a_i32_z_f32( int32_t ); typedef float64_t funcType_a_i32_z_f64( int32_t ); #ifdef EXTFLOAT80 @@ -85,6 +94,9 @@ typedef void funcType_a_i32_z_extF80( int32_t, extFloat80_t * ); #ifdef FLOAT128 typedef void funcType_a_i32_z_f128( int32_t, float128_t * ); #endif +#ifdef FLOAT16 +typedef float16_t funcType_a_i64_z_f16( int64_t ); +#endif typedef float32_t funcType_a_i64_z_f32( int64_t ); typedef float64_t funcType_a_i64_z_f64( int64_t ); #ifdef EXTFLOAT80 @@ -94,10 +106,32 @@ typedef void funcType_a_i64_z_extF80( int64_t, extFloat80_t * ); typedef void funcType_a_i64_z_f128( int64_t, float128_t * ); #endif +#ifdef FLOAT16 +typedef uint_fast32_t funcType_a_f16_z_ui32( float16_t ); +typedef uint_fast64_t funcType_a_f16_z_ui64( float16_t ); +typedef int_fast32_t funcType_a_f16_z_i32( float16_t ); +typedef int_fast64_t funcType_a_f16_z_i64( float16_t ); +typedef float32_t funcType_a_f16_z_f32( float16_t ); +typedef float64_t funcType_a_f16_z_f64( float16_t ); +#ifdef EXTFLOAT80 +typedef void funcType_a_f16_z_extF80( float16_t, extFloat80_t * ); +#endif +#ifdef FLOAT128 +typedef void funcType_a_f16_z_f128( float16_t, float128_t * ); +#endif +typedef float16_t funcType_az_f16( float16_t ); +typedef float16_t funcType_abz_f16( float16_t, float16_t ); +typedef float16_t funcType_abcz_f16( float16_t, float16_t, float16_t ); +typedef bool funcType_ab_f16_z_bool( float16_t, float16_t ); +#endif + typedef uint_fast32_t funcType_a_f32_z_ui32( float32_t ); typedef uint_fast64_t funcType_a_f32_z_ui64( float32_t ); typedef int_fast32_t funcType_a_f32_z_i32( float32_t ); typedef int_fast64_t funcType_a_f32_z_i64( float32_t ); +#ifdef FLOAT16 +typedef float16_t funcType_a_f32_z_f16( float32_t ); +#endif typedef float64_t funcType_a_f32_z_f64( float32_t ); #ifdef EXTFLOAT80 typedef void funcType_a_f32_z_extF80( float32_t, extFloat80_t * ); @@ -114,6 +148,9 @@ typedef uint_fast32_t funcType_a_f64_z_ui32( float64_t ); typedef uint_fast64_t funcType_a_f64_z_ui64( float64_t ); typedef int_fast32_t funcType_a_f64_z_i32( float64_t ); typedef int_fast64_t funcType_a_f64_z_i64( float64_t ); +#ifdef FLOAT16 +typedef float16_t funcType_a_f64_z_f16( float64_t ); +#endif typedef float32_t funcType_a_f64_z_f32( float64_t ); #ifdef EXTFLOAT80 typedef void funcType_a_f64_z_extF80( float64_t, extFloat80_t * ); @@ -131,6 +168,9 @@ typedef uint_fast32_t funcType_a_extF80_z_ui32( const extFloat80_t * ); typedef uint_fast64_t funcType_a_extF80_z_ui64( const extFloat80_t * ); typedef int_fast32_t funcType_a_extF80_z_i32( const extFloat80_t * ); typedef int_fast64_t funcType_a_extF80_z_i64( const extFloat80_t * ); +#ifdef FLOAT16 +typedef float16_t funcType_a_extF80_z_f16( const extFloat80_t * ); +#endif typedef float32_t funcType_a_extF80_z_f32( const extFloat80_t * ); typedef float64_t funcType_a_extF80_z_f64( const extFloat80_t * ); #ifdef FLOAT128 @@ -150,6 +190,9 @@ typedef uint_fast32_t funcType_a_f128_z_ui32( const float128_t * ); typedef uint_fast64_t funcType_a_f128_z_ui64( const float128_t * ); typedef int_fast32_t funcType_a_f128_z_i32( const float128_t * ); typedef int_fast64_t funcType_a_f128_z_i64( const float128_t * ); +#ifdef FLOAT16 +typedef float16_t funcType_a_f128_z_f16( const float128_t * ); +#endif typedef float32_t funcType_a_f128_z_f32( const float128_t * ); typedef float64_t funcType_a_f128_z_f64( const float128_t * ); #ifdef EXTFLOAT80 @@ -167,10 +210,63 @@ typedef typedef bool funcType_ab_f128_z_bool( const float128_t *, const float128_t * ); #endif +#ifdef FLOAT16 + +static +uint_fast32_t + subjFunction_a_f16_z_ui32_rx( + float16_t a, uint_fast8_t roundingMode, bool exact ) +{ + + return ((funcType_a_f16_z_ui32 *) subjFunctionPtr)( a ); + +} + static - uint_fast32_t - subjFunction_a_f32_z_ui32_rx( - float32_t a, uint_fast8_t roundingMode, bool exact ) +uint_fast64_t + subjFunction_a_f16_z_ui64_rx( + float16_t a, uint_fast8_t roundingMode, bool exact ) +{ + + return ((funcType_a_f16_z_ui64 *) subjFunctionPtr)( a ); + +} + +static +int_fast32_t + subjFunction_a_f16_z_i32_rx( + float16_t a, uint_fast8_t roundingMode, bool exact ) +{ + + return ((funcType_a_f16_z_i32 *) subjFunctionPtr)( a ); + +} + +static +int_fast64_t + subjFunction_a_f16_z_i64_rx( + float16_t a, uint_fast8_t roundingMode, bool exact ) +{ + + return ((funcType_a_f16_z_i64 *) subjFunctionPtr)( a ); + +} + +static +float16_t + subjFunction_az_f16_rx( float16_t a, uint_fast8_t roundingMode, bool exact ) +{ + + return ((funcType_az_f16 *) subjFunctionPtr)( a ); + +} + +#endif + +static +uint_fast32_t + subjFunction_a_f32_z_ui32_rx( + float32_t a, uint_fast8_t roundingMode, bool exact ) { return ((funcType_a_f32_z_ui32 *) subjFunctionPtr)( a ); @@ -178,9 +274,9 @@ static } static - uint_fast64_t - subjFunction_a_f32_z_ui64_rx( - float32_t a, uint_fast8_t roundingMode, bool exact ) +uint_fast64_t + subjFunction_a_f32_z_ui64_rx( + float32_t a, uint_fast8_t roundingMode, bool exact ) { return ((funcType_a_f32_z_ui64 *) subjFunctionPtr)( a ); @@ -188,9 +284,9 @@ static } static - int_fast32_t - subjFunction_a_f32_z_i32_rx( - float32_t a, uint_fast8_t roundingMode, bool exact ) +int_fast32_t + subjFunction_a_f32_z_i32_rx( + float32_t a, uint_fast8_t roundingMode, bool exact ) { return ((funcType_a_f32_z_i32 *) subjFunctionPtr)( a ); @@ -198,9 +294,9 @@ static } static - int_fast64_t - subjFunction_a_f32_z_i64_rx( - float32_t a, uint_fast8_t roundingMode, bool exact ) +int_fast64_t + subjFunction_a_f32_z_i64_rx( + float32_t a, uint_fast8_t roundingMode, bool exact ) { return ((funcType_a_f32_z_i64 *) subjFunctionPtr)( a ); @@ -208,8 +304,8 @@ static } static - float32_t - subjFunction_az_f32_rx( float32_t a, uint_fast8_t roundingMode, bool exact ) +float32_t + subjFunction_az_f32_rx( float32_t a, uint_fast8_t roundingMode, bool exact ) { return ((funcType_az_f32 *) subjFunctionPtr)( a ); @@ -217,9 +313,9 @@ static } static - uint_fast32_t - subjFunction_a_f64_z_ui32_rx( - float64_t a, uint_fast8_t roundingMode, bool exact ) +uint_fast32_t + subjFunction_a_f64_z_ui32_rx( + float64_t a, uint_fast8_t roundingMode, bool exact ) { return ((funcType_a_f64_z_ui32 *) subjFunctionPtr)( a ); @@ -227,9 +323,9 @@ static } static - uint_fast64_t - subjFunction_a_f64_z_ui64_rx( - float64_t a, uint_fast8_t roundingMode, bool exact ) +uint_fast64_t + subjFunction_a_f64_z_ui64_rx( + float64_t a, uint_fast8_t roundingMode, bool exact ) { return ((funcType_a_f64_z_ui64 *) subjFunctionPtr)( a ); @@ -237,9 +333,9 @@ static } static - int_fast32_t - subjFunction_a_f64_z_i32_rx( - float64_t a, uint_fast8_t roundingMode, bool exact ) +int_fast32_t + subjFunction_a_f64_z_i32_rx( + float64_t a, uint_fast8_t roundingMode, bool exact ) { return ((funcType_a_f64_z_i32 *) subjFunctionPtr)( a ); @@ -247,9 +343,9 @@ static } static - int_fast64_t - subjFunction_a_f64_z_i64_rx( - float64_t a, uint_fast8_t roundingMode, bool exact ) +int_fast64_t + subjFunction_a_f64_z_i64_rx( + float64_t a, uint_fast8_t roundingMode, bool exact ) { return ((funcType_a_f64_z_i64 *) subjFunctionPtr)( a ); @@ -257,8 +353,8 @@ static } static - float64_t - subjFunction_az_f64_rx( float64_t a, uint_fast8_t roundingMode, bool exact ) +float64_t + subjFunction_az_f64_rx( float64_t a, uint_fast8_t roundingMode, bool exact ) { return ((funcType_az_f64 *) subjFunctionPtr)( a ); @@ -268,9 +364,9 @@ static #ifdef EXTFLOAT80 static - uint_fast32_t - subjFunction_a_extF80_z_ui32_rx( - const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact ) +uint_fast32_t + subjFunction_a_extF80_z_ui32_rx( + const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact ) { return ((funcType_a_extF80_z_ui32 *) subjFunctionPtr)( aPtr ); @@ -278,9 +374,9 @@ static } static - uint_fast64_t - subjFunction_a_extF80_z_ui64_rx( - const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact ) +uint_fast64_t + subjFunction_a_extF80_z_ui64_rx( + const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact ) { return ((funcType_a_extF80_z_ui64 *) subjFunctionPtr)( aPtr ); @@ -288,9 +384,9 @@ static } static - int_fast32_t - subjFunction_a_extF80_z_i32_rx( - const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact ) +int_fast32_t + subjFunction_a_extF80_z_i32_rx( + const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact ) { return ((funcType_a_extF80_z_i32 *) subjFunctionPtr)( aPtr ); @@ -298,9 +394,9 @@ static } static - int_fast64_t - subjFunction_a_extF80_z_i64_rx( - const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact ) +int_fast64_t + subjFunction_a_extF80_z_i64_rx( + const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact ) { return ((funcType_a_extF80_z_i64 *) subjFunctionPtr)( aPtr ); @@ -308,13 +404,13 @@ static } static - void - subjFunction_az_extF80_rx( - const extFloat80_t *aPtr, - uint_fast8_t roundingMode, - bool exact, - extFloat80_t *zPtr - ) +void + subjFunction_az_extF80_rx( + const extFloat80_t *aPtr, + uint_fast8_t roundingMode, + bool exact, + extFloat80_t *zPtr + ) { return ((funcType_az_extF80 *) subjFunctionPtr)( aPtr, zPtr ); @@ -326,9 +422,9 @@ static #ifdef FLOAT128 static - uint_fast32_t - subjFunction_a_f128_z_ui32_rx( - const float128_t *aPtr, uint_fast8_t roundingMode, bool exact ) +uint_fast32_t + subjFunction_a_f128_z_ui32_rx( + const float128_t *aPtr, uint_fast8_t roundingMode, bool exact ) { return ((funcType_a_f128_z_ui32 *) subjFunctionPtr)( aPtr ); @@ -336,9 +432,9 @@ static } static - uint_fast64_t - subjFunction_a_f128_z_ui64_rx( - const float128_t *aPtr, uint_fast8_t roundingMode, bool exact ) +uint_fast64_t + subjFunction_a_f128_z_ui64_rx( + const float128_t *aPtr, uint_fast8_t roundingMode, bool exact ) { return ((funcType_a_f128_z_ui64 *) subjFunctionPtr)( aPtr ); @@ -346,9 +442,9 @@ static } static - int_fast32_t - subjFunction_a_f128_z_i32_rx( - const float128_t *aPtr, uint_fast8_t roundingMode, bool exact ) +int_fast32_t + subjFunction_a_f128_z_i32_rx( + const float128_t *aPtr, uint_fast8_t roundingMode, bool exact ) { return ((funcType_a_f128_z_i32 *) subjFunctionPtr)( aPtr ); @@ -356,9 +452,9 @@ static } static - int_fast64_t - subjFunction_a_f128_z_i64_rx( - const float128_t *aPtr, uint_fast8_t roundingMode, bool exact ) +int_fast64_t + subjFunction_a_f128_z_i64_rx( + const float128_t *aPtr, uint_fast8_t roundingMode, bool exact ) { return ((funcType_a_f128_z_i64 *) subjFunctionPtr)( aPtr ); @@ -366,13 +462,13 @@ static } static - void - subjFunction_az_f128_rx( - const float128_t *aPtr, - uint_fast8_t roundingMode, - bool exact, - float128_t *zPtr - ) +void + subjFunction_az_f128_rx( + const float128_t *aPtr, + uint_fast8_t roundingMode, + bool exact, + float128_t *zPtr + ) { return ((funcType_az_f128 *) subjFunctionPtr)( aPtr, zPtr ); @@ -382,10 +478,14 @@ static #endif static - void - testFunctionInstance( - int functionCode, uint_fast8_t roundingMode, bool exact ) +void + testFunctionInstance( + int functionCode, uint_fast8_t roundingMode, bool exact ) { +#ifdef FLOAT16 + funcType_abz_f16 *trueFunction_abz_f16; + funcType_ab_f16_z_bool *trueFunction_ab_f16_z_bool; +#endif funcType_abz_f32 *trueFunction_abz_f32; funcType_ab_f32_z_bool *trueFunction_ab_f32_z_bool; funcType_abz_f64 *trueFunction_abz_f64; @@ -405,6 +505,14 @@ static switch ( functionCode ) { /*-------------------------------------------------------------------- *--------------------------------------------------------------------*/ +#ifdef FLOAT16 +#ifdef SUBJ_UI32_TO_F16 + case UI32_TO_F16: + test_a_ui32_z_f16( + ui32_to_f16, (funcType_a_ui32_z_f16 *) subjFunctionPtr ); + break; +#endif +#endif #ifdef SUBJ_UI32_TO_F32 case UI32_TO_F32: test_a_ui32_z_f32( @@ -433,6 +541,14 @@ static break; #endif #endif +#ifdef FLOAT16 +#ifdef SUBJ_UI64_TO_F16 + case UI64_TO_F16: + test_a_ui64_z_f16( + ui64_to_f16, (funcType_a_ui64_z_f16 *) subjFunctionPtr ); + break; +#endif +#endif #ifdef SUBJ_UI64_TO_F32 case UI64_TO_F32: test_a_ui64_z_f32( @@ -461,6 +577,14 @@ static break; #endif #endif +#ifdef FLOAT16 +#ifdef SUBJ_I32_TO_F16 + case I32_TO_F16: + test_a_i32_z_f16( + i32_to_f16, (funcType_a_i32_z_f16 *) subjFunctionPtr ); + break; +#endif +#endif #ifdef SUBJ_I32_TO_F32 case I32_TO_F32: test_a_i32_z_f32( @@ -489,6 +613,14 @@ static break; #endif #endif +#ifdef FLOAT16 +#ifdef SUBJ_I64_TO_F16 + case I64_TO_F16: + test_a_i64_z_f16( + i64_to_f16, (funcType_a_i64_z_f16 *) subjFunctionPtr ); + break; +#endif +#endif #ifdef SUBJ_I64_TO_F32 case I64_TO_F32: test_a_i64_z_f32( @@ -519,6 +651,133 @@ static #endif /*-------------------------------------------------------------------- *--------------------------------------------------------------------*/ +#ifdef FLOAT16 + case F16_TO_UI32: + test_a_f16_z_ui32_rx( + f16_to_ui32, subjFunction_a_f16_z_ui32_rx, roundingMode, exact ); + break; + case F16_TO_UI64: + test_a_f16_z_ui64_rx( + f16_to_ui64, subjFunction_a_f16_z_ui64_rx, roundingMode, exact ); + break; + case F16_TO_I32: + test_a_f16_z_i32_rx( + f16_to_i32, subjFunction_a_f16_z_i32_rx, roundingMode, exact ); + break; + case F16_TO_I64: + test_a_f16_z_i64_rx( + f16_to_i64, subjFunction_a_f16_z_i64_rx, roundingMode, exact ); + break; +#ifdef SUBJ_F16_TO_F32 + case F16_TO_F32: + test_a_f16_z_f32( + f16_to_f32, (funcType_a_f16_z_f32 *) subjFunctionPtr ); + break; +#endif +#ifdef SUBJ_F16_TO_F64 + case F16_TO_F64: + test_a_f16_z_f64( + f16_to_f64, (funcType_a_f16_z_f64 *) subjFunctionPtr ); + break; +#endif +#ifdef EXTFLOAT80 +#ifdef SUBJ_F16_TO_EXTF80 + case F16_TO_EXTF80: + test_a_f16_z_extF80( + f16_to_extF80M, (funcType_a_f16_z_extF80 *) subjFunctionPtr ); + break; +#endif +#endif +#ifdef FLOAT128 +#ifdef SUBJ_F16_TO_F128 + case F16_TO_F128: + test_a_f16_z_f128( + f16_to_f128M, (funcType_a_f16_z_f128 *) subjFunctionPtr ); + break; +#endif +#endif + case F16_ROUNDTOINT: + test_az_f16_rx( + f16_roundToInt, subjFunction_az_f16_rx, roundingMode, exact ); + break; +#ifdef SUBJ_F16_ADD + case F16_ADD: + trueFunction_abz_f16 = f16_add; + goto test_abz_f16; +#endif +#ifdef SUBJ_F16_SUB + case F16_SUB: + trueFunction_abz_f16 = f16_sub; + goto test_abz_f16; +#endif +#ifdef SUBJ_F16_MUL + case F16_MUL: + trueFunction_abz_f16 = f16_mul; + goto test_abz_f16; +#endif +#ifdef SUBJ_F16_MULADD + case F16_MULADD: + test_abcz_f16( f16_mulAdd, (funcType_abcz_f16 *) subjFunctionPtr ); + break; +#endif +#ifdef SUBJ_F16_DIV + case F16_DIV: + trueFunction_abz_f16 = f16_div; + goto test_abz_f16; +#endif +#ifdef SUBJ_F16_REM + case F16_REM: + trueFunction_abz_f16 = f16_rem; + goto test_abz_f16; +#endif + test_abz_f16: + test_abz_f16( + trueFunction_abz_f16, (funcType_abz_f16 *) subjFunctionPtr ); + break; +#ifdef SUBJ_F16_SQRT + case F16_SQRT: + test_az_f16( f16_sqrt, (funcType_az_f16 *) subjFunctionPtr ); + break; +#endif +#ifdef SUBJ_F16_EQ + case F16_EQ: + trueFunction_ab_f16_z_bool = f16_eq; + goto test_ab_f16_z_bool; +#endif +#ifdef SUBJ_F16_LE + case F16_LE: + trueFunction_ab_f16_z_bool = f16_le; + goto test_ab_f16_z_bool; +#endif +#ifdef SUBJ_F16_LT + case F16_LT: + trueFunction_ab_f16_z_bool = f16_lt; + goto test_ab_f16_z_bool; +#endif +#ifdef SUBJ_F16_EQ_SIGNALING + case F16_EQ_SIGNALING: + trueFunction_ab_f16_z_bool = f16_eq_signaling; + goto test_ab_f16_z_bool; +#endif +#ifdef SUBJ_F16_LE_QUIET + case F16_LE_QUIET: + trueFunction_ab_f16_z_bool = f16_le_quiet; + goto test_ab_f16_z_bool; +#endif +#ifdef SUBJ_F16_LT_QUIET + case F16_LT_QUIET: + trueFunction_ab_f16_z_bool = f16_lt_quiet; + goto test_ab_f16_z_bool; +#endif + test_ab_f16_z_bool: + test_ab_f16_z_bool( + trueFunction_ab_f16_z_bool, + (funcType_ab_f16_z_bool *) subjFunctionPtr + ); + break; +#endif + /*-------------------------------------------------------------------- + *--------------------------------------------------------------------*/ case F32_TO_UI32: test_a_f32_z_ui32_rx( f32_to_ui32, subjFunction_a_f32_z_ui32_rx, roundingMode, exact ); @@ -535,6 +794,14 @@ static test_a_f32_z_i64_rx( f32_to_i64, subjFunction_a_f32_z_i64_rx, roundingMode, exact ); break; +#ifdef FLOAT16 +#ifdef SUBJ_F32_TO_F16 + case F32_TO_F16: + test_a_f32_z_f16( + f32_to_f16, (funcType_a_f32_z_f16 *) subjFunctionPtr ); + break; +#endif +#endif #ifdef SUBJ_F32_TO_F64 case F32_TO_F64: test_a_f32_z_f64( @@ -654,6 +921,14 @@ static test_a_f64_z_i64_rx( f64_to_i64, subjFunction_a_f64_z_i64_rx, roundingMode, exact ); break; +#ifdef FLOAT16 +#ifdef SUBJ_F64_TO_F16 + case F64_TO_F16: + test_a_f64_z_f16( + f64_to_f16, (funcType_a_f64_z_f16 *) subjFunctionPtr ); + break; +#endif +#endif #ifdef SUBJ_F64_TO_F32 case F64_TO_F32: test_a_f64_z_f32( @@ -784,6 +1059,14 @@ static extF80M_to_i64, subjFunction_a_extF80_z_i64_rx, roundingMode, exact ); break; +#ifdef FLOAT16 +#ifdef SUBJ_EXTF80_TO_F16 + case EXTF80_TO_F16: + test_a_extF80_z_f16( + extF80M_to_f16, (funcType_a_extF80_z_f16 *) subjFunctionPtr ); + break; +#endif +#endif #ifdef SUBJ_EXTF80_TO_F32 case EXTF80_TO_F32: test_a_extF80_z_f32( @@ -901,6 +1184,14 @@ static test_a_f128_z_i64_rx( f128M_to_i64, subjFunction_a_f128_z_i64_rx, roundingMode, exact ); break; +#ifdef FLOAT16 +#ifdef SUBJ_F128_TO_F16 + case F128_TO_F16: + test_a_f128_z_f16( + f128M_to_f16, (funcType_a_f128_z_f16 *) subjFunctionPtr ); + break; +#endif +#endif #ifdef SUBJ_F128_TO_F32 case F128_TO_F32: test_a_f128_z_f32( @@ -1009,12 +1300,12 @@ static } static - void - testFunction( - const struct standardFunctionInfo *standardFunctionInfoPtr, - uint_fast8_t roundingPrecisionIn, - int roundingCodeIn - ) +void + testFunction( + const struct standardFunctionInfo *standardFunctionInfoPtr, + uint_fast8_t roundingPrecisionIn, + int roundingCodeIn + ) { int functionCode, functionAttribs; bool standardFunctionHasFixedRounding; @@ -1099,6 +1390,7 @@ int main( int argc, char *argv[] ) const char *argPtr; void (*const *subjFunctionPtrPtr)(); const char *functionNamePtr; + unsigned long ui; long i; /*------------------------------------------------------------------------ @@ -1130,6 +1422,8 @@ int main( int argc, char *argv[] ) " <option>: (* is default)\n" " -help --Write this message and exit.\n" " -list --List all testable subject functions and exit.\n" +" -seed <num> --Set pseudo-random number generator seed to <num>.\n" +" * -seed 1\n" " -level <num> --Testing level <num> (1 or 2).\n" " * -level 1\n" " -errors <num> --Stop each function test after <num> errors.\n" @@ -1162,6 +1456,9 @@ int main( int argc, char *argv[] ) " i32 --Signed 32-bit integer.\n" " i64 --Signed 64-bit integer.\n" " <float>:\n" +#ifdef FLOAT16 +" f16 --Binary 16-bit floating-point (half-precision).\n" +#endif " f32 --Binary 32-bit floating-point (single-precision).\n" " f64 --Binary 64-bit floating-point (double-precision).\n" #ifdef EXTFLOAT80 @@ -1191,6 +1488,13 @@ int main( int argc, char *argv[] ) ++subjFunctionPtrPtr; } return EXIT_SUCCESS; + } else if ( ! strcmp( argPtr, "seed" ) ) { + if ( argc < 2 ) goto optionError; + ui = strtoul( argv[1], (char **) &argPtr, 10 ); + if ( *argPtr ) goto optionError; + srand( ui ); + --argc; + ++argv; } else if ( ! strcmp( argPtr, "level" ) ) { if ( argc < 2 ) goto optionError; i = strtol( argv[1], (char **) &argPtr, 10 ); diff --git a/source/testfloat_gen.c b/source/testfloat_gen.c index 161834f..82621bb 100644 --- a/source/testfloat_gen.c +++ b/source/testfloat_gen.c @@ -1,12 +1,12 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. -Copyright 2011, 2012, 2013, 2014 The Regents of the University of California. -All rights reserved. +Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of +California. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -53,6 +53,9 @@ enum { TYPE_UI64, TYPE_I32, TYPE_I64, + TYPE_F16, + TYPE_F16_2, + TYPE_F16_3, TYPE_F32, TYPE_F32_2, TYPE_F32_3, @@ -82,8 +85,13 @@ int main( int argc, char *argv[] ) bool exact; int functionCode; const char *argPtr; + unsigned long ui; long i; int functionAttribs; +#ifdef FLOAT16 + float16_t (*trueFunction_abz_f16)( float16_t, float16_t ); + bool (*trueFunction_ab_f16_z_bool)( float16_t, float16_t ); +#endif float32_t (*trueFunction_abz_f32)( float32_t, float32_t ); bool (*trueFunction_ab_f32_z_bool)( float32_t, float32_t ); float64_t (*trueFunction_abz_f64)( float64_t, float64_t ); @@ -109,7 +117,7 @@ int main( int argc, char *argv[] ) fail_programName = "testfloat_gen"; if ( argc <= 1 ) goto writeHelpMessage; prefixTextPtr = 0; - softfloat_detectTininess = softfloat_tininess_beforeRounding; + softfloat_detectTininess = softfloat_tininess_afterRounding; #ifdef EXTFLOAT80 extF80_roundingPrecision = 80; #endif @@ -136,6 +144,8 @@ int main( int argc, char *argv[] ) " <option>: (* is default)\n" " -help --Write this message and exit.\n" " -prefix <text> --Write <text> as a line of output before any test cases.\n" +" -seed <num> --Set pseudo-random number generator seed to <num>.\n" +" * -seed 1\n" " -level <num> --Testing level <num> (1 or 2).\n" " * -level 1\n" " -n <num> --Generate <num> test cases.\n" @@ -150,8 +160,8 @@ int main( int argc, char *argv[] ) " -rmin --Round to minimum (down).\n" " -rmax --Round to maximum (up).\n" " -rnear_maxMag --Round to nearest/maximum magnitude (nearest/away).\n" -" * -tininessbefore --Detect underflow tininess before rounding.\n" -" -tininessafter --Detect underflow tininess after rounding.\n" +" -tininessbefore --Detect underflow tininess before rounding.\n" +" * -tininessafter --Detect underflow tininess after rounding.\n" " * -notexact --Rounding to integer is not exact (no inexact\n" " exceptions).\n" " -exact --Rounding to integer is exact (raising inexact\n" @@ -175,6 +185,9 @@ int main( int argc, char *argv[] ) " i32 --Signed 32-bit integer.\n" " i64 --Signed 64-bit integer.\n" " <float>:\n" +#ifdef FLOAT16 +" f16 --Binary 16-bit floating-point (half-precision).\n" +#endif " f32 --Binary 32-bit floating-point (single-precision).\n" " f64 --Binary 64-bit floating-point (double-precision).\n" #ifdef EXTFLOAT80 @@ -192,6 +205,13 @@ int main( int argc, char *argv[] ) prefixTextPtr = argv[1]; --argc; ++argv; + } else if ( ! strcmp( argPtr, "seed" ) ) { + if ( argc < 2 ) goto optionError; + ui = strtoul( argv[1], (char **) &argPtr, 10 ); + if ( *argPtr ) goto optionError; + srand( ui ); + --argc; + ++argv; } else if ( ! strcmp( argPtr, "level" ) ) { if ( argc < 2 ) goto optionError; i = strtol( argv[1], (char **) &argPtr, 10 ); @@ -274,6 +294,13 @@ int main( int argc, char *argv[] ) ) { functionCode = TYPE_I64; if ( 2 <= argc ) goto absorbArg1; +#ifdef FLOAT16 + } else if ( + ! strcmp( argPtr, "f16" ) || ! strcmp( argPtr, "float16" ) + ) { + functionCode = TYPE_F16; + goto absorbArg; +#endif } else if ( ! strcmp( argPtr, "f32" ) || ! strcmp( argPtr, "float32" ) ) { @@ -355,6 +382,17 @@ int main( int argc, char *argv[] ) case TYPE_I64: gen_a_i64(); break; +#ifdef FLOAT16 + case TYPE_F16: + gen_a_f16(); + break; + case TYPE_F16_2: + gen_ab_f16(); + break; + case TYPE_F16_3: + gen_abc_f16(); + break; +#endif case TYPE_F32: gen_a_f32(); break; @@ -397,6 +435,11 @@ int main( int argc, char *argv[] ) #endif /*-------------------------------------------------------------------- *--------------------------------------------------------------------*/ +#ifdef FLOAT16 + case UI32_TO_F16: + gen_a_ui32_z_f16( ui32_to_f16 ); + break; +#endif case UI32_TO_F32: gen_a_ui32_z_f32( ui32_to_f32 ); break; @@ -413,6 +456,11 @@ int main( int argc, char *argv[] ) gen_a_ui32_z_f128( ui32_to_f128M ); break; #endif +#ifdef FLOAT16 + case UI64_TO_F16: + gen_a_ui64_z_f16( ui64_to_f16 ); + break; +#endif case UI64_TO_F32: gen_a_ui64_z_f32( ui64_to_f32 ); break; @@ -429,6 +477,11 @@ int main( int argc, char *argv[] ) gen_a_ui64_z_f128( ui64_to_f128M ); break; #endif +#ifdef FLOAT16 + case I32_TO_F16: + gen_a_i32_z_f16( i32_to_f16 ); + break; +#endif case I32_TO_F32: gen_a_i32_z_f32( i32_to_f32 ); break; @@ -445,6 +498,11 @@ int main( int argc, char *argv[] ) gen_a_i32_z_f128( i32_to_f128M ); break; #endif +#ifdef FLOAT16 + case I64_TO_F16: + gen_a_i64_z_f16( i64_to_f16 ); + break; +#endif case I64_TO_F32: gen_a_i64_z_f32( i64_to_f32 ); break; @@ -463,6 +521,84 @@ int main( int argc, char *argv[] ) #endif /*-------------------------------------------------------------------- *--------------------------------------------------------------------*/ +#ifdef FLOAT16 + case F16_TO_UI32: + gen_a_f16_z_ui32_rx( f16_to_ui32, roundingMode, exact ); + break; + case F16_TO_UI64: + gen_a_f16_z_ui64_rx( f16_to_ui64, roundingMode, exact ); + break; + case F16_TO_I32: + gen_a_f16_z_i32_rx( f16_to_i32, roundingMode, exact ); + break; + case F16_TO_I64: + gen_a_f16_z_i64_rx( f16_to_i64, roundingMode, exact ); + break; + case F16_TO_F32: + gen_a_f16_z_f32( f16_to_f32 ); + break; + case F16_TO_F64: + gen_a_f16_z_f64( f16_to_f64 ); + break; +#ifdef EXTFLOAT80 + case F16_TO_EXTF80: + gen_a_f16_z_extF80( f16_to_extF80M ); + break; +#endif +#ifdef FLOAT128 + case F16_TO_F128: + gen_a_f16_z_f128( f16_to_f128M ); + break; +#endif + case F16_ROUNDTOINT: + gen_az_f16_rx( f16_roundToInt, roundingMode, exact ); + break; + case F16_ADD: + trueFunction_abz_f16 = f16_add; + goto gen_abz_f16; + case F16_SUB: + trueFunction_abz_f16 = f16_sub; + goto gen_abz_f16; + case F16_MUL: + trueFunction_abz_f16 = f16_mul; + goto gen_abz_f16; + case F16_DIV: + trueFunction_abz_f16 = f16_div; + goto gen_abz_f16; + case F16_REM: + trueFunction_abz_f16 = f16_rem; + gen_abz_f16: + gen_abz_f16( trueFunction_abz_f16 ); + break; + case F16_MULADD: + gen_abcz_f16( f16_mulAdd ); + break; + case F16_SQRT: + gen_az_f16( f16_sqrt ); + break; + case F16_EQ: + trueFunction_ab_f16_z_bool = f16_eq; + goto gen_ab_f16_z_bool; + case F16_LE: + trueFunction_ab_f16_z_bool = f16_le; + goto gen_ab_f16_z_bool; + case F16_LT: + trueFunction_ab_f16_z_bool = f16_lt; + goto gen_ab_f16_z_bool; + case F16_EQ_SIGNALING: + trueFunction_ab_f16_z_bool = f16_eq_signaling; + goto gen_ab_f16_z_bool; + case F16_LE_QUIET: + trueFunction_ab_f16_z_bool = f16_le_quiet; + goto gen_ab_f16_z_bool; + case F16_LT_QUIET: + trueFunction_ab_f16_z_bool = f16_lt_quiet; + gen_ab_f16_z_bool: + gen_ab_f16_z_bool( trueFunction_ab_f16_z_bool ); + break; +#endif + /*-------------------------------------------------------------------- + *--------------------------------------------------------------------*/ case F32_TO_UI32: gen_a_f32_z_ui32_rx( f32_to_ui32, roundingMode, exact ); break; @@ -475,6 +611,11 @@ int main( int argc, char *argv[] ) case F32_TO_I64: gen_a_f32_z_i64_rx( f32_to_i64, roundingMode, exact ); break; +#ifdef FLOAT16 + case F32_TO_F16: + gen_a_f32_z_f16( f32_to_f16 ); + break; +#endif case F32_TO_F64: gen_a_f32_z_f64( f32_to_f64 ); break; @@ -548,6 +689,11 @@ int main( int argc, char *argv[] ) case F64_TO_I64: gen_a_f64_z_i64_rx( f64_to_i64, roundingMode, exact ); break; +#ifdef FLOAT16 + case F64_TO_F16: + gen_a_f64_z_f16( f64_to_f16 ); + break; +#endif case F64_TO_F32: gen_a_f64_z_f32( f64_to_f32 ); break; @@ -622,6 +768,11 @@ int main( int argc, char *argv[] ) case EXTF80_TO_I64: gen_a_extF80_z_i64_rx( extF80M_to_i64, roundingMode, exact ); break; +#ifdef FLOAT16 + case EXTF80_TO_F16: + gen_a_extF80_z_f16( extF80M_to_f16 ); + break; +#endif case EXTF80_TO_F32: gen_a_extF80_z_f32( extF80M_to_f32 ); break; @@ -692,6 +843,11 @@ int main( int argc, char *argv[] ) case F128_TO_I64: gen_a_f128_z_i64_rx( f128M_to_i64, roundingMode, exact ); break; +#ifdef FLOAT16 + case F128_TO_F16: + gen_a_f128_z_f16( f128M_to_f16 ); + break; +#endif case F128_TO_F32: gen_a_f128_z_f32( f128M_to_f32 ); break; @@ -756,8 +912,6 @@ int main( int argc, char *argv[] ) *------------------------------------------------------------------------*/ optionError: fail( "`%s' option requires numeric argument", *argv ); - /*------------------------------------------------------------------------ - *------------------------------------------------------------------------*/ invalidArg: fail( "Invalid argument `%s'", *argv ); diff --git a/source/testfloat_ver.c b/source/testfloat_ver.c index 9a52c10..e5a74fd 100644 --- a/source/testfloat_ver.c +++ b/source/testfloat_ver.c @@ -1,11 +1,11 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. -Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of +Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of California. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -65,6 +65,10 @@ int main( int argc, char *argv[] ) long i; int functionAttribs; uint_fast8_t roundingMode; +#ifdef FLOAT16 + float16_t (*trueFunction_abz_f16)( float16_t, float16_t ); + bool (*trueFunction_ab_f16_z_bool)( float16_t, float16_t ); +#endif float32_t (*trueFunction_abz_f32)( float32_t, float32_t ); bool (*trueFunction_ab_f32_z_bool)( float32_t, float32_t ); float64_t (*trueFunction_abz_f64)( float64_t, float64_t ); @@ -89,7 +93,7 @@ int main( int argc, char *argv[] ) *------------------------------------------------------------------------*/ fail_programName = "testfloat_ver"; if ( argc <= 1 ) goto writeHelpMessage; - softfloat_detectTininess = softfloat_tininess_beforeRounding; + softfloat_detectTininess = softfloat_tininess_afterRounding; #ifdef EXTFLOAT80 extF80_roundingPrecision = 80; #endif @@ -99,7 +103,7 @@ int main( int argc, char *argv[] ) verLoops_trueFlagsPtr = &softfloat_exceptionFlags; functionCode = 0; roundingCode = ROUND_NEAR_EVEN; - tininessCode = TININESS_BEFORE_ROUNDING; + tininessCode = TININESS_AFTER_ROUNDING; for (;;) { --argc; if ( ! argc ) break; @@ -128,8 +132,8 @@ int main( int argc, char *argv[] ) " -rmin --Round to minimum (down).\n" " -rmax --Round to maximum (up).\n" " -rnear_maxMag --Round to nearest/maximum magnitude (nearest/away).\n" -" * -tininessbefore --Detect underflow tininess before rounding.\n" -" -tininessafter --Detect underflow tininess after rounding.\n" +" -tininessbefore --Detect underflow tininess before rounding.\n" +" * -tininessafter --Detect underflow tininess after rounding.\n" " * -notexact --Rounding to integer is not exact (no inexact\n" " exceptions).\n" " -exact --Rounding to integer is exact (raising inexact\n" @@ -148,6 +152,9 @@ int main( int argc, char *argv[] ) " i32 --Signed 32-bit integer.\n" " i64 --Signed 64-bit integer.\n" " <float>:\n" +#ifdef FLOAT16 +" f16 --Binary 16-bit floating-point (half-precision).\n" +#endif " f32 --Binary 32-bit floating-point (single-precision).\n" " f64 --Binary 64-bit floating-point (double-precision).\n" #ifdef EXTFLOAT80 @@ -262,6 +269,11 @@ int main( int argc, char *argv[] ) switch ( functionCode ) { /*-------------------------------------------------------------------- *--------------------------------------------------------------------*/ +#ifdef FLOAT16 + case UI32_TO_F16: + ver_a_ui32_z_f16( ui32_to_f16 ); + break; +#endif case UI32_TO_F32: ver_a_ui32_z_f32( ui32_to_f32 ); break; @@ -278,6 +290,11 @@ int main( int argc, char *argv[] ) ver_a_ui32_z_f128( ui32_to_f128M ); break; #endif +#ifdef FLOAT16 + case UI64_TO_F16: + ver_a_ui64_z_f16( ui64_to_f16 ); + break; +#endif case UI64_TO_F32: ver_a_ui64_z_f32( ui64_to_f32 ); break; @@ -294,6 +311,11 @@ int main( int argc, char *argv[] ) ver_a_ui64_z_f128( ui64_to_f128M ); break; #endif +#ifdef FLOAT16 + case I32_TO_F16: + ver_a_i32_z_f16( i32_to_f16 ); + break; +#endif case I32_TO_F32: ver_a_i32_z_f32( i32_to_f32 ); break; @@ -310,6 +332,11 @@ int main( int argc, char *argv[] ) ver_a_i32_z_f128( i32_to_f128M ); break; #endif +#ifdef FLOAT16 + case I64_TO_F16: + ver_a_i64_z_f16( i64_to_f16 ); + break; +#endif case I64_TO_F32: ver_a_i64_z_f32( i64_to_f32 ); break; @@ -328,6 +355,84 @@ int main( int argc, char *argv[] ) #endif /*-------------------------------------------------------------------- *--------------------------------------------------------------------*/ +#ifdef FLOAT16 + case F16_TO_UI32: + ver_a_f16_z_ui32_rx( f16_to_ui32, roundingMode, exact ); + break; + case F16_TO_UI64: + ver_a_f16_z_ui64_rx( f16_to_ui64, roundingMode, exact ); + break; + case F16_TO_I32: + ver_a_f16_z_i32_rx( f16_to_i32, roundingMode, exact ); + break; + case F16_TO_I64: + ver_a_f16_z_i64_rx( f16_to_i64, roundingMode, exact ); + break; + case F16_TO_F32: + ver_a_f16_z_f32( f16_to_f32 ); + break; + case F16_TO_F64: + ver_a_f16_z_f64( f16_to_f64 ); + break; +#ifdef EXTFLOAT80 + case F16_TO_EXTF80: + ver_a_f16_z_extF80( f16_to_extF80M ); + break; +#endif +#ifdef FLOAT128 + case F16_TO_F128: + ver_a_f16_z_f128( f16_to_f128M ); + break; +#endif + case F16_ROUNDTOINT: + ver_az_f16_rx( f16_roundToInt, roundingMode, exact ); + break; + case F16_ADD: + trueFunction_abz_f16 = f16_add; + goto ver_abz_f16; + case F16_SUB: + trueFunction_abz_f16 = f16_sub; + goto ver_abz_f16; + case F16_MUL: + trueFunction_abz_f16 = f16_mul; + goto ver_abz_f16; + case F16_DIV: + trueFunction_abz_f16 = f16_div; + goto ver_abz_f16; + case F16_REM: + trueFunction_abz_f16 = f16_rem; + ver_abz_f16: + ver_abz_f16( trueFunction_abz_f16 ); + break; + case F16_MULADD: + ver_abcz_f16( f16_mulAdd ); + break; + case F16_SQRT: + ver_az_f16( f16_sqrt ); + break; + case F16_EQ: + trueFunction_ab_f16_z_bool = f16_eq; + goto ver_ab_f16_z_bool; + case F16_LE: + trueFunction_ab_f16_z_bool = f16_le; + goto ver_ab_f16_z_bool; + case F16_LT: + trueFunction_ab_f16_z_bool = f16_lt; + goto ver_ab_f16_z_bool; + case F16_EQ_SIGNALING: + trueFunction_ab_f16_z_bool = f16_eq_signaling; + goto ver_ab_f16_z_bool; + case F16_LE_QUIET: + trueFunction_ab_f16_z_bool = f16_le_quiet; + goto ver_ab_f16_z_bool; + case F16_LT_QUIET: + trueFunction_ab_f16_z_bool = f16_lt_quiet; + ver_ab_f16_z_bool: + ver_ab_f16_z_bool( trueFunction_ab_f16_z_bool ); + break; +#endif + /*-------------------------------------------------------------------- + *--------------------------------------------------------------------*/ case F32_TO_UI32: ver_a_f32_z_ui32_rx( f32_to_ui32, roundingMode, exact ); break; @@ -340,6 +445,11 @@ int main( int argc, char *argv[] ) case F32_TO_I64: ver_a_f32_z_i64_rx( f32_to_i64, roundingMode, exact ); break; +#ifdef FLOAT16 + case F32_TO_F16: + ver_a_f32_z_f16( f32_to_f16 ); + break; +#endif case F32_TO_F64: ver_a_f32_z_f64( f32_to_f64 ); break; @@ -413,6 +523,11 @@ int main( int argc, char *argv[] ) case F64_TO_I64: ver_a_f64_z_i64_rx( f64_to_i64, roundingMode, exact ); break; +#ifdef FLOAT16 + case F64_TO_F16: + ver_a_f64_z_f16( f64_to_f16 ); + break; +#endif case F64_TO_F32: ver_a_f64_z_f32( f64_to_f32 ); break; @@ -487,6 +602,11 @@ int main( int argc, char *argv[] ) case EXTF80_TO_I64: ver_a_extF80_z_i64_rx( extF80M_to_i64, roundingMode, exact ); break; +#ifdef FLOAT16 + case EXTF80_TO_F16: + ver_a_extF80_z_f16( extF80M_to_f16 ); + break; +#endif case EXTF80_TO_F32: ver_a_extF80_z_f32( extF80M_to_f32 ); break; @@ -557,6 +677,11 @@ int main( int argc, char *argv[] ) case F128_TO_I64: ver_a_f128_z_i64_rx( f128M_to_i64, roundingMode, exact ); break; +#ifdef FLOAT16 + case F128_TO_F16: + ver_a_f128_z_f16( f128M_to_f16 ); + break; +#endif case F128_TO_F32: ver_a_f128_z_f32( f128M_to_f32 ); break; @@ -621,8 +746,6 @@ int main( int argc, char *argv[] ) *------------------------------------------------------------------------*/ optionError: fail( "`%s' option requires numeric argument", *argv ); - /*------------------------------------------------------------------------ - *------------------------------------------------------------------------*/ invalidArg: fail( "Invalid argument `%s'", *argv ); diff --git a/source/testsoftfloat.c b/source/testsoftfloat.c index a93c39d..85585c1 100644 --- a/source/testsoftfloat.c +++ b/source/testsoftfloat.c @@ -1,11 +1,11 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. -Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of +Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of California. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -70,10 +70,16 @@ static uint_fast8_t softfloat_clearExceptionFlags( void ) } static - void - testFunctionInstance( - int functionCode, uint_fast8_t roundingMode, bool exact ) +void + testFunctionInstance( + int functionCode, uint_fast8_t roundingMode, bool exact ) { +#ifdef FLOAT16 + float16_t (*trueFunction_abz_f16)( float16_t, float16_t ); + float16_t (*subjFunction_abz_f16)( float16_t, float16_t ); + bool (*trueFunction_ab_f16_z_bool)( float16_t, float16_t ); + bool (*subjFunction_ab_f16_z_bool)( float16_t, float16_t ); +#endif float32_t (*trueFunction_abz_f32)( float32_t, float32_t ); float32_t (*subjFunction_abz_f32)( float32_t, float32_t ); bool (*trueFunction_ab_f32_z_bool)( float32_t, float32_t ); @@ -109,6 +115,11 @@ static switch ( functionCode ) { /*-------------------------------------------------------------------- *--------------------------------------------------------------------*/ +#ifdef FLOAT16 + case UI32_TO_F16: + test_a_ui32_z_f16( slow_ui32_to_f16, ui32_to_f16 ); + break; +#endif case UI32_TO_F32: test_a_ui32_z_f32( slow_ui32_to_f32, ui32_to_f32 ); break; @@ -125,6 +136,11 @@ static test_a_ui32_z_f128( slow_ui32_to_f128M, ui32_to_f128M ); break; #endif +#ifdef FLOAT16 + case UI64_TO_F16: + test_a_ui64_z_f16( slow_ui64_to_f16, ui64_to_f16 ); + break; +#endif case UI64_TO_F32: test_a_ui64_z_f32( slow_ui64_to_f32, ui64_to_f32 ); break; @@ -141,6 +157,11 @@ static test_a_ui64_z_f128( slow_ui64_to_f128M, ui64_to_f128M ); break; #endif +#ifdef FLOAT16 + case I32_TO_F16: + test_a_i32_z_f16( slow_i32_to_f16, i32_to_f16 ); + break; +#endif case I32_TO_F32: test_a_i32_z_f32( slow_i32_to_f32, i32_to_f32 ); break; @@ -157,6 +178,11 @@ static test_a_i32_z_f128( slow_i32_to_f128M, i32_to_f128M ); break; #endif +#ifdef FLOAT16 + case I64_TO_F16: + test_a_i64_z_f16( slow_i64_to_f16, i64_to_f16 ); + break; +#endif case I64_TO_F32: test_a_i64_z_f32( slow_i64_to_f32, i64_to_f32 ); break; @@ -175,6 +201,117 @@ static #endif /*-------------------------------------------------------------------- *--------------------------------------------------------------------*/ +#ifdef FLOAT16 + case F16_TO_UI32: + test_a_f16_z_ui32_rx( + slow_f16_to_ui32, f16_to_ui32, roundingMode, exact ); + break; + case F16_TO_UI64: + test_a_f16_z_ui64_rx( + slow_f16_to_ui64, f16_to_ui64, roundingMode, exact ); + break; + case F16_TO_I32: + test_a_f16_z_i32_rx( + slow_f16_to_i32, f16_to_i32, roundingMode, exact ); + break; + case F16_TO_I64: + test_a_f16_z_i64_rx( + slow_f16_to_i64, f16_to_i64, roundingMode, exact ); + break; + case F16_TO_UI32_R_MINMAG: + test_a_f16_z_ui32_x( + slow_f16_to_ui32_r_minMag, f16_to_ui32_r_minMag, exact ); + break; + case F16_TO_UI64_R_MINMAG: + test_a_f16_z_ui64_x( + slow_f16_to_ui64_r_minMag, f16_to_ui64_r_minMag, exact ); + break; + case F16_TO_I32_R_MINMAG: + test_a_f16_z_i32_x( + slow_f16_to_i32_r_minMag, f16_to_i32_r_minMag, exact ); + break; + case F16_TO_I64_R_MINMAG: + test_a_f16_z_i64_x( + slow_f16_to_i64_r_minMag, f16_to_i64_r_minMag, exact ); + break; + case F16_TO_F32: + test_a_f16_z_f32( slow_f16_to_f32, f16_to_f32 ); + break; + case F16_TO_F64: + test_a_f16_z_f64( slow_f16_to_f64, f16_to_f64 ); + break; +#ifdef EXTFLOAT80 + case F16_TO_EXTF80: + test_a_f16_z_extF80( slow_f16_to_extF80M, f16_to_extF80M ); + break; +#endif +#ifdef FLOAT128 + case F16_TO_F128: + test_a_f16_z_f128( slow_f16_to_f128M, f16_to_f128M ); + break; +#endif + case F16_ROUNDTOINT: + test_az_f16_rx( + slow_f16_roundToInt, f16_roundToInt, roundingMode, exact ); + break; + case F16_ADD: + trueFunction_abz_f16 = slow_f16_add; + subjFunction_abz_f16 = f16_add; + goto test_abz_f16; + case F16_SUB: + trueFunction_abz_f16 = slow_f16_sub; + subjFunction_abz_f16 = f16_sub; + goto test_abz_f16; + case F16_MUL: + trueFunction_abz_f16 = slow_f16_mul; + subjFunction_abz_f16 = f16_mul; + goto test_abz_f16; + case F16_DIV: + trueFunction_abz_f16 = slow_f16_div; + subjFunction_abz_f16 = f16_div; + goto test_abz_f16; + case F16_REM: + trueFunction_abz_f16 = slow_f16_rem; + subjFunction_abz_f16 = f16_rem; + test_abz_f16: + test_abz_f16( trueFunction_abz_f16, subjFunction_abz_f16 ); + break; + case F16_MULADD: + test_abcz_f16( slow_f16_mulAdd, f16_mulAdd ); + break; + case F16_SQRT: + test_az_f16( slow_f16_sqrt, f16_sqrt ); + break; + case F16_EQ: + trueFunction_ab_f16_z_bool = slow_f16_eq; + subjFunction_ab_f16_z_bool = f16_eq; + goto test_ab_f16_z_bool; + case F16_LE: + trueFunction_ab_f16_z_bool = slow_f16_le; + subjFunction_ab_f16_z_bool = f16_le; + goto test_ab_f16_z_bool; + case F16_LT: + trueFunction_ab_f16_z_bool = slow_f16_lt; + subjFunction_ab_f16_z_bool = f16_lt; + goto test_ab_f16_z_bool; + case F16_EQ_SIGNALING: + trueFunction_ab_f16_z_bool = slow_f16_eq_signaling; + subjFunction_ab_f16_z_bool = f16_eq_signaling; + goto test_ab_f16_z_bool; + case F16_LE_QUIET: + trueFunction_ab_f16_z_bool = slow_f16_le_quiet; + subjFunction_ab_f16_z_bool = f16_le_quiet; + goto test_ab_f16_z_bool; + case F16_LT_QUIET: + trueFunction_ab_f16_z_bool = slow_f16_lt_quiet; + subjFunction_ab_f16_z_bool = f16_lt_quiet; + test_ab_f16_z_bool: + test_ab_f16_z_bool( + trueFunction_ab_f16_z_bool, subjFunction_ab_f16_z_bool ); + break; +#endif + /*-------------------------------------------------------------------- + *--------------------------------------------------------------------*/ case F32_TO_UI32: test_a_f32_z_ui32_rx( slow_f32_to_ui32, f32_to_ui32, roundingMode, exact ); @@ -207,6 +344,11 @@ static test_a_f32_z_i64_x( slow_f32_to_i64_r_minMag, f32_to_i64_r_minMag, exact ); break; +#ifdef FLOAT16 + case F32_TO_F16: + test_a_f32_z_f16( slow_f32_to_f16, f32_to_f16 ); + break; +#endif case F32_TO_F64: test_a_f32_z_f64( slow_f32_to_f64, f32_to_f64 ); break; @@ -313,6 +455,11 @@ static test_a_f64_z_i64_x( slow_f64_to_i64_r_minMag, f64_to_i64_r_minMag, exact ); break; +#ifdef FLOAT16 + case F64_TO_F16: + test_a_f64_z_f16( slow_f64_to_f16, f64_to_f16 ); + break; +#endif case F64_TO_F32: test_a_f64_z_f32( slow_f64_to_f32, f64_to_f32 ); break; @@ -420,6 +567,11 @@ static test_a_extF80_z_i64_x( slow_extF80M_to_i64_r_minMag, extF80M_to_i64_r_minMag, exact ); break; +#ifdef FLOAT16 + case EXTF80_TO_F16: + test_a_extF80_z_f16( slow_extF80M_to_f16, extF80M_to_f16 ); + break; +#endif case EXTF80_TO_F32: test_a_extF80_z_f32( slow_extF80M_to_f32, extF80M_to_f32 ); break; @@ -523,6 +675,11 @@ static test_a_f128_z_i64_x( slow_f128M_to_i64_r_minMag, f128M_to_i64_r_minMag, exact ); break; +#ifdef FLOAT16 + case F128_TO_F16: + test_a_f128_z_f16( slow_f128M_to_f16, f128M_to_f16 ); + break; +#endif case F128_TO_F32: test_a_f128_z_f32( slow_f128M_to_f32, f128M_to_f32 ); break; @@ -604,14 +761,14 @@ static enum { EXACT_FALSE = 1, EXACT_TRUE }; static - void - testFunction( - int functionCode, - uint_fast8_t roundingPrecisionIn, - int roundingCodeIn, - int tininessCodeIn, - int exactCodeIn - ) +void + testFunction( + int functionCode, + uint_fast8_t roundingPrecisionIn, + int roundingCodeIn, + int tininessCodeIn, + int exactCodeIn + ) { int functionAttribs; uint_fast8_t roundingPrecision; @@ -716,6 +873,7 @@ int main( int argc, char *argv[] ) uint_fast8_t roundingPrecision; int roundingCode, tininessCode, exactCode; const char *argPtr; + unsigned long ui; long i; /*------------------------------------------------------------------------ @@ -748,6 +906,8 @@ int main( int argc, char *argv[] ) "testsoftfloat [<option>...] <function>\n" " <option>: (* is default)\n" " -help --Write this message and exit.\n" +" -seed <num> --Set pseudo-random number generator seed to <num>.\n" +" * -seed 1\n" " -level <num> --Testing level <num> (1 or 2).\n" " * -level 1\n" " -errors <num> --Stop each function test after <num> errors.\n" @@ -787,6 +947,9 @@ int main( int argc, char *argv[] ) " i32 --Signed 32-bit integer.\n" " i64 --Signed 64-bit integer.\n" " <float>:\n" +#ifdef FLOAT16 +" f16 --Binary 16-bit floating-point (half-precision).\n" +#endif " f32 --Binary 32-bit floating-point (single-precision).\n" " f64 --Binary 64-bit floating-point (double-precision).\n" #ifdef EXTFLOAT80 @@ -799,6 +962,13 @@ int main( int argc, char *argv[] ) stdout ); return EXIT_SUCCESS; + } else if ( ! strcmp( argPtr, "seed" ) ) { + if ( argc < 2 ) goto optionError; + ui = strtoul( argv[1], (char **) &argPtr, 10 ); + if ( *argPtr ) goto optionError; + srand( ui ); + --argc; + ++argv; } else if ( ! strcmp( argPtr, "level" ) ) { if ( argc < 2 ) goto optionError; i = strtol( argv[1], (char **) &argPtr, 10 ); diff --git a/source/timesoftfloat.c b/source/timesoftfloat.c index 57be35b..b7a4d29 100644 --- a/source/timesoftfloat.c +++ b/source/timesoftfloat.c @@ -1,11 +1,11 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. -Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of +Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of California. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -49,6 +49,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. enum { minIterations = 1000 }; +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ + static const char *functionNamePtr; static uint_fast8_t roundingPrecision; static int roundingCode; @@ -56,6 +59,9 @@ static int tininessCode; static bool usesExact; static bool exact; +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ + static void reportTime( int_fast64_t count, clock_t clockTicks ) { static const char *roundingModeNames[NUM_ROUNDINGMODES] = { @@ -94,9 +100,18 @@ static void reportTime( int_fast64_t count, clock_t clockTicks ) } +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ + +#ifdef FLOAT16 +union ui16_f16 { uint16_t ui; float16_t f; }; +#endif union ui32_f32 { uint32_t ui; float32_t f; }; union ui64_f64 { uint64_t ui; float64_t f; }; +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ + enum { numInputs_ui32 = 32 }; static const uint32_t inputs_ui32[numInputs_ui32] = { @@ -110,6 +125,39 @@ static const uint32_t inputs_ui32[numInputs_ui32] = { 0x40000008, 0x0001BF56, 0x000017F6, 0x000A908A }; +#ifdef FLOAT16 + +static void time_a_ui32_z_f16( float16_t function( uint32_t ) ) +{ + int_fast64_t count; + int inputNum; + clock_t startClock; + int_fast64_t i; + clock_t endClock; + + count = 0; + inputNum = 0; + startClock = clock(); + do { + for ( i = minIterations; i; --i ) { + function( inputs_ui32[inputNum] ); + inputNum = (inputNum + 1) & (numInputs_ui32 - 1); + } + count += minIterations; + } while ( clock() - startClock < CLOCKS_PER_SEC ); + inputNum = 0; + startClock = clock(); + for ( i = count; i; --i ) { + function( inputs_ui32[inputNum] ); + inputNum = (inputNum + 1) & (numInputs_ui32 - 1); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + +#endif + static void time_a_ui32_z_f32( float32_t function( uint32_t ) ) { int_fast64_t count; @@ -236,6 +284,9 @@ static void time_a_ui32_z_f128( void function( uint32_t, float128_t * ) ) #endif +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ + enum { numInputs_ui64 = 32 }; static const int64_t inputs_ui64[numInputs_ui64] = { @@ -257,6 +308,39 @@ static const int64_t inputs_ui64[numInputs_ui64] = { UINT64_C( 0x00000020FBFFFFFE ), UINT64_C( 0x0000099AE6455357 ) }; +#ifdef FLOAT16 + +static void time_a_ui64_z_f16( float16_t function( uint64_t ) ) +{ + int_fast64_t count; + int inputNum; + clock_t startClock; + int_fast64_t i; + clock_t endClock; + + count = 0; + inputNum = 0; + startClock = clock(); + do { + for ( i = minIterations; i; --i ) { + function( inputs_ui64[inputNum] ); + inputNum = (inputNum + 1) & (numInputs_ui64 - 1); + } + count += minIterations; + } while ( clock() - startClock < CLOCKS_PER_SEC ); + inputNum = 0; + startClock = clock(); + for ( i = count; i; --i ) { + function( inputs_ui64[inputNum] ); + inputNum = (inputNum + 1) & (numInputs_ui64 - 1); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + +#endif + static void time_a_ui64_z_f32( float32_t function( uint64_t ) ) { int_fast64_t count; @@ -383,6 +467,9 @@ static void time_a_ui64_z_f128( void function( uint64_t, float128_t * ) ) #endif +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ + enum { numInputs_i32 = 32 }; static const int32_t inputs_i32[numInputs_i32] = { @@ -396,6 +483,39 @@ static const int32_t inputs_i32[numInputs_i32] = { -0x40000008, 0x0001BF56, 0x000017F6, 0x000A908A }; +#ifdef FLOAT16 + +static void time_a_i32_z_f16( float16_t function( int32_t ) ) +{ + int_fast64_t count; + int inputNum; + clock_t startClock; + int_fast64_t i; + clock_t endClock; + + count = 0; + inputNum = 0; + startClock = clock(); + do { + for ( i = minIterations; i; --i ) { + function( inputs_i32[inputNum] ); + inputNum = (inputNum + 1) & (numInputs_i32 - 1); + } + count += minIterations; + } while ( clock() - startClock < CLOCKS_PER_SEC ); + inputNum = 0; + startClock = clock(); + for ( i = count; i; --i ) { + function( inputs_i32[inputNum] ); + inputNum = (inputNum + 1) & (numInputs_i32 - 1); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + +#endif + static void time_a_i32_z_f32( float32_t function( int32_t ) ) { int_fast64_t count; @@ -522,6 +642,9 @@ static void time_a_i32_z_f128( void function( int32_t, float128_t * ) ) #endif +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ + enum { numInputs_i64 = 32 }; static const int64_t inputs_i64[numInputs_i64] = { @@ -543,6 +666,39 @@ static const int64_t inputs_i64[numInputs_i64] = { INT64_C( 0x00000020FBFFFFFE ), INT64_C( 0x0000099AE6455357 ) }; +#ifdef FLOAT16 + +static void time_a_i64_z_f16( float16_t function( int64_t ) ) +{ + int_fast64_t count; + int inputNum; + clock_t startClock; + int_fast64_t i; + clock_t endClock; + + count = 0; + inputNum = 0; + startClock = clock(); + do { + for ( i = minIterations; i; --i ) { + function( inputs_i64[inputNum] ); + inputNum = (inputNum + 1) & (numInputs_i64 - 1); + } + count += minIterations; + } while ( clock() - startClock < CLOCKS_PER_SEC ); + inputNum = 0; + startClock = clock(); + for ( i = count; i; --i ) { + function( inputs_i64[inputNum] ); + inputNum = (inputNum + 1) & (numInputs_i64 - 1); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + +#endif + static void time_a_i64_z_f32( float32_t function( int64_t ) ) { int_fast64_t count; @@ -669,6 +825,655 @@ static void time_a_i64_z_f128( void function( int64_t, float128_t * ) ) #endif +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ + +#ifdef FLOAT16 + +enum { numInputs_f16 = 32 }; + +static const uint16_t inputs_F16UI[numInputs_f16] = { + 0x0BBA, 0x77FE, 0x084F, 0x9C0F, 0x7800, 0x4436, 0xCE67, 0x80F3, + 0x87EF, 0xC2FA, 0x7BFF, 0x13FE, 0x7BFE, 0x1C00, 0xAC46, 0xEAFA, + 0x3813, 0x4804, 0x385E, 0x8000, 0xB86C, 0x4B7D, 0xC7FD, 0xC97F, + 0x260C, 0x78EE, 0xB84F, 0x249E, 0x0D27, 0x37DC, 0x8400, 0xE8EF +}; + +static +void + time_a_f16_z_ui32_rx( + uint_fast32_t function( float16_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int_fast64_t count; + int inputNum; + clock_t startClock; + int_fast64_t i; + union ui16_f16 uA; + clock_t endClock; + + count = 0; + inputNum = 0; + startClock = clock(); + do { + for ( i = minIterations; i; --i ) { + uA.ui = inputs_F16UI[inputNum]; + function( uA.f, roundingMode, exact ); + inputNum = (inputNum + 1) & (numInputs_f16 - 1); + } + count += minIterations; + } while ( clock() - startClock < CLOCKS_PER_SEC ); + inputNum = 0; + startClock = clock(); + for ( i = count; i; --i ) { + uA.ui = inputs_F16UI[inputNum]; + function( uA.f, roundingMode, exact ); + inputNum = (inputNum + 1) & (numInputs_f16 - 1); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + +static +void + time_a_f16_z_ui64_rx( + uint_fast64_t function( float16_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int_fast64_t count; + int inputNum; + clock_t startClock; + int_fast64_t i; + union ui16_f16 uA; + clock_t endClock; + + count = 0; + inputNum = 0; + startClock = clock(); + do { + for ( i = minIterations; i; --i ) { + uA.ui = inputs_F16UI[inputNum]; + function( uA.f, roundingMode, exact ); + inputNum = (inputNum + 1) & (numInputs_f16 - 1); + } + count += minIterations; + } while ( clock() - startClock < CLOCKS_PER_SEC ); + inputNum = 0; + startClock = clock(); + for ( i = count; i; --i ) { + uA.ui = inputs_F16UI[inputNum]; + function( uA.f, roundingMode, exact ); + inputNum = (inputNum + 1) & (numInputs_f16 - 1); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + +static +void + time_a_f16_z_i32_rx( + int_fast32_t function( float16_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int_fast64_t count; + int inputNum; + clock_t startClock; + int_fast64_t i; + union ui16_f16 uA; + clock_t endClock; + + count = 0; + inputNum = 0; + startClock = clock(); + do { + for ( i = minIterations; i; --i ) { + uA.ui = inputs_F16UI[inputNum]; + function( uA.f, roundingMode, exact ); + inputNum = (inputNum + 1) & (numInputs_f16 - 1); + } + count += minIterations; + } while ( clock() - startClock < CLOCKS_PER_SEC ); + inputNum = 0; + startClock = clock(); + for ( i = count; i; --i ) { + uA.ui = inputs_F16UI[inputNum]; + function( uA.f, roundingMode, exact ); + inputNum = (inputNum + 1) & (numInputs_f16 - 1); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + +static +void + time_a_f16_z_i64_rx( + int_fast64_t function( float16_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int_fast64_t count; + int inputNum; + clock_t startClock; + int_fast64_t i; + union ui16_f16 uA; + clock_t endClock; + + count = 0; + inputNum = 0; + startClock = clock(); + do { + for ( i = minIterations; i; --i ) { + uA.ui = inputs_F16UI[inputNum]; + function( uA.f, roundingMode, exact ); + inputNum = (inputNum + 1) & (numInputs_f16 - 1); + } + count += minIterations; + } while ( clock() - startClock < CLOCKS_PER_SEC ); + inputNum = 0; + startClock = clock(); + for ( i = count; i; --i ) { + uA.ui = inputs_F16UI[inputNum]; + function( uA.f, roundingMode, exact ); + inputNum = (inputNum + 1) & (numInputs_f16 - 1); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + +static +void + time_a_f16_z_ui32_x( uint_fast32_t function( float16_t, bool ), bool exact ) +{ + int_fast64_t count; + int inputNum; + clock_t startClock; + int_fast64_t i; + union ui16_f16 uA; + clock_t endClock; + + count = 0; + inputNum = 0; + startClock = clock(); + do { + for ( i = minIterations; i; --i ) { + uA.ui = inputs_F16UI[inputNum]; + function( uA.f, exact ); + inputNum = (inputNum + 1) & (numInputs_f16 - 1); + } + count += minIterations; + } while ( clock() - startClock < CLOCKS_PER_SEC ); + inputNum = 0; + startClock = clock(); + for ( i = count; i; --i ) { + uA.ui = inputs_F16UI[inputNum]; + function( uA.f, exact ); + inputNum = (inputNum + 1) & (numInputs_f16 - 1); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + +static +void + time_a_f16_z_ui64_x( uint_fast64_t function( float16_t, bool ), bool exact ) +{ + int_fast64_t count; + int inputNum; + clock_t startClock; + int_fast64_t i; + union ui16_f16 uA; + clock_t endClock; + + count = 0; + inputNum = 0; + startClock = clock(); + do { + for ( i = minIterations; i; --i ) { + uA.ui = inputs_F16UI[inputNum]; + function( uA.f, exact ); + inputNum = (inputNum + 1) & (numInputs_f16 - 1); + } + count += minIterations; + } while ( clock() - startClock < CLOCKS_PER_SEC ); + inputNum = 0; + startClock = clock(); + for ( i = count; i; --i ) { + uA.ui = inputs_F16UI[inputNum]; + function( uA.f, exact ); + inputNum = (inputNum + 1) & (numInputs_f16 - 1); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + +static +void time_a_f16_z_i32_x( int_fast32_t function( float16_t, bool ), bool exact ) +{ + int_fast64_t count; + int inputNum; + clock_t startClock; + int_fast64_t i; + union ui16_f16 uA; + clock_t endClock; + + count = 0; + inputNum = 0; + startClock = clock(); + do { + for ( i = minIterations; i; --i ) { + uA.ui = inputs_F16UI[inputNum]; + function( uA.f, exact ); + inputNum = (inputNum + 1) & (numInputs_f16 - 1); + } + count += minIterations; + } while ( clock() - startClock < CLOCKS_PER_SEC ); + inputNum = 0; + startClock = clock(); + for ( i = count; i; --i ) { + uA.ui = inputs_F16UI[inputNum]; + function( uA.f, exact ); + inputNum = (inputNum + 1) & (numInputs_f16 - 1); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + +static +void time_a_f16_z_i64_x( int_fast64_t function( float16_t, bool ), bool exact ) +{ + int_fast64_t count; + int inputNum; + clock_t startClock; + int_fast64_t i; + union ui16_f16 uA; + clock_t endClock; + + count = 0; + inputNum = 0; + startClock = clock(); + do { + for ( i = minIterations; i; --i ) { + uA.ui = inputs_F16UI[inputNum]; + function( uA.f, exact ); + inputNum = (inputNum + 1) & (numInputs_f16 - 1); + } + count += minIterations; + } while ( clock() - startClock < CLOCKS_PER_SEC ); + inputNum = 0; + startClock = clock(); + for ( i = count; i; --i ) { + uA.ui = inputs_F16UI[inputNum]; + function( uA.f, exact ); + inputNum = (inputNum + 1) & (numInputs_f16 - 1); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + +static void time_a_f16_z_f32( float32_t function( float16_t ) ) +{ + int_fast64_t count; + int inputNum; + clock_t startClock; + int_fast64_t i; + union ui16_f16 uA; + clock_t endClock; + + count = 0; + inputNum = 0; + startClock = clock(); + do { + for ( i = minIterations; i; --i ) { + uA.ui = inputs_F16UI[inputNum]; + function( uA.f ); + inputNum = (inputNum + 1) & (numInputs_f16 - 1); + } + count += minIterations; + } while ( clock() - startClock < CLOCKS_PER_SEC ); + inputNum = 0; + startClock = clock(); + for ( i = count; i; --i ) { + uA.ui = inputs_F16UI[inputNum]; + function( uA.f ); + inputNum = (inputNum + 1) & (numInputs_f16 - 1); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + +static void time_a_f16_z_f64( float64_t function( float16_t ) ) +{ + int_fast64_t count; + int inputNum; + clock_t startClock; + int_fast64_t i; + union ui16_f16 uA; + clock_t endClock; + + count = 0; + inputNum = 0; + startClock = clock(); + do { + for ( i = minIterations; i; --i ) { + uA.ui = inputs_F16UI[inputNum]; + function( uA.f ); + inputNum = (inputNum + 1) & (numInputs_f16 - 1); + } + count += minIterations; + } while ( clock() - startClock < CLOCKS_PER_SEC ); + inputNum = 0; + startClock = clock(); + for ( i = count; i; --i ) { + uA.ui = inputs_F16UI[inputNum]; + function( uA.f ); + inputNum = (inputNum + 1) & (numInputs_f16 - 1); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + +#ifdef EXTFLOAT80 + +static void time_a_f16_z_extF80( void function( float16_t, extFloat80_t * ) ) +{ + int_fast64_t count; + int inputNum; + clock_t startClock; + int_fast64_t i; + union ui16_f16 uA; + extFloat80_t z; + clock_t endClock; + + count = 0; + inputNum = 0; + startClock = clock(); + do { + for ( i = minIterations; i; --i ) { + uA.ui = inputs_F16UI[inputNum]; + function( uA.f, &z ); + inputNum = (inputNum + 1) & (numInputs_f16 - 1); + } + count += minIterations; + } while ( clock() - startClock < CLOCKS_PER_SEC ); + inputNum = 0; + startClock = clock(); + for ( i = count; i; --i ) { + uA.ui = inputs_F16UI[inputNum]; + function( uA.f, &z ); + inputNum = (inputNum + 1) & (numInputs_f16 - 1); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + +#endif + +#ifdef FLOAT128 + +static void time_a_f16_z_f128( void function( float16_t, float128_t * ) ) +{ + int_fast64_t count; + int inputNum; + clock_t startClock; + int_fast64_t i; + union ui16_f16 uA; + float128_t z; + clock_t endClock; + + count = 0; + inputNum = 0; + startClock = clock(); + do { + for ( i = minIterations; i; --i ) { + uA.ui = inputs_F16UI[inputNum]; + function( uA.f, &z ); + inputNum = (inputNum + 1) & (numInputs_f16 - 1); + } + count += minIterations; + } while ( clock() - startClock < CLOCKS_PER_SEC ); + inputNum = 0; + startClock = clock(); + for ( i = count; i; --i ) { + uA.ui = inputs_F16UI[inputNum]; + function( uA.f, &z ); + inputNum = (inputNum + 1) & (numInputs_f16 - 1); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + +#endif + +static +void + time_az_f16_rx( + float16_t function( float16_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int_fast64_t count; + int inputNum; + clock_t startClock; + int_fast64_t i; + union ui16_f16 uA; + clock_t endClock; + + count = 0; + inputNum = 0; + startClock = clock(); + do { + for ( i = minIterations; i; --i ) { + uA.ui = inputs_F16UI[inputNum]; + function( uA.f, roundingMode, exact ); + inputNum = (inputNum + 1) & (numInputs_f16 - 1); + } + count += minIterations; + } while ( clock() - startClock < CLOCKS_PER_SEC ); + inputNum = 0; + startClock = clock(); + for ( i = count; i; --i ) { + uA.ui = inputs_F16UI[inputNum]; + function( uA.f, roundingMode, exact ); + inputNum = (inputNum + 1) & (numInputs_f16 - 1); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + +static void time_abz_f16( float16_t function( float16_t, float16_t ) ) +{ + int_fast64_t count; + int inputNumA, inputNumB; + clock_t startClock; + int_fast64_t i; + union ui16_f16 uA, uB; + clock_t endClock; + + count = 0; + inputNumA = 0; + inputNumB = 0; + startClock = clock(); + do { + for ( i = minIterations; i; --i ) { + uA.ui = inputs_F16UI[inputNumA]; + uB.ui = inputs_F16UI[inputNumB]; + function( uA.f, uB.f ); + inputNumA = (inputNumA + 1) & (numInputs_f16 - 1); + if ( ! inputNumA ) ++inputNumB; + inputNumB = (inputNumB + 1) & (numInputs_f16 - 1); + } + count += minIterations; + } while ( clock() - startClock < CLOCKS_PER_SEC ); + inputNumA = 0; + inputNumB = 0; + startClock = clock(); + for ( i = count; i; --i ) { + uA.ui = inputs_F16UI[inputNumA]; + uB.ui = inputs_F16UI[inputNumB]; + function( uA.f, uB.f ); + inputNumA = (inputNumA + 1) & (numInputs_f16 - 1); + if ( ! inputNumA ) ++inputNumB; + inputNumB = (inputNumB + 1) & (numInputs_f16 - 1); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + +static +void time_abcz_f16( float16_t function( float16_t, float16_t, float16_t ) ) +{ + int_fast64_t count; + int inputNumA, inputNumB, inputNumC; + clock_t startClock; + int_fast64_t i; + union ui16_f16 uA, uB, uC; + clock_t endClock; + + count = 0; + inputNumA = 0; + inputNumB = 0; + inputNumC = 0; + startClock = clock(); + do { + for ( i = minIterations; i; --i ) { + uA.ui = inputs_F16UI[inputNumA]; + uB.ui = inputs_F16UI[inputNumB]; + uC.ui = inputs_F16UI[inputNumC]; + function( uA.f, uB.f, uC.f ); + inputNumA = (inputNumA + 1) & (numInputs_f16 - 1); + if ( ! inputNumA ) ++inputNumB; + inputNumB = (inputNumB + 1) & (numInputs_f16 - 1); + if ( ! inputNumB ) ++inputNumC; + inputNumC = (inputNumC + 1) & (numInputs_f16 - 1); + } + count += minIterations; + } while ( clock() - startClock < CLOCKS_PER_SEC ); + inputNumA = 0; + inputNumB = 0; + inputNumC = 0; + startClock = clock(); + for ( i = count; i; --i ) { + uA.ui = inputs_F16UI[inputNumA]; + uB.ui = inputs_F16UI[inputNumB]; + uC.ui = inputs_F16UI[inputNumC]; + function( uA.f, uB.f, uC.f ); + inputNumA = (inputNumA + 1) & (numInputs_f16 - 1); + if ( ! inputNumA ) ++inputNumB; + inputNumB = (inputNumB + 1) & (numInputs_f16 - 1); + if ( ! inputNumB ) ++inputNumC; + inputNumC = (inputNumC + 1) & (numInputs_f16 - 1); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + +static void time_ab_f16_z_bool( bool function( float16_t, float16_t ) ) +{ + int_fast64_t count; + int inputNumA, inputNumB; + clock_t startClock; + int_fast64_t i; + union ui16_f16 uA, uB; + clock_t endClock; + + count = 0; + inputNumA = 0; + inputNumB = 0; + startClock = clock(); + do { + for ( i = minIterations; i; --i ) { + uA.ui = inputs_F16UI[inputNumA]; + uB.ui = inputs_F16UI[inputNumB]; + function( uA.f, uB.f ); + inputNumA = (inputNumA + 1) & (numInputs_f16 - 1); + if ( ! inputNumA ) ++inputNumB; + inputNumB = (inputNumB + 1) & (numInputs_f16 - 1); + } + count += minIterations; + } while ( clock() - startClock < CLOCKS_PER_SEC ); + inputNumA = 0; + inputNumB = 0; + startClock = clock(); + for ( i = count; i; --i ) { + uA.ui = inputs_F16UI[inputNumA]; + uB.ui = inputs_F16UI[inputNumB]; + function( uA.f, uB.f ); + inputNumA = (inputNumA + 1) & (numInputs_f16 - 1); + if ( ! inputNumA ) ++inputNumB; + inputNumB = (inputNumB + 1) & (numInputs_f16 - 1); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + +static const uint16_t inputs_F16UI_pos[numInputs_f16] = { + 0x0BBA, 0x77FE, 0x084F, 0x1C0F, 0x7800, 0x4436, 0x4E67, 0x00F3, + 0x07EF, 0x42FA, 0x7BFF, 0x13FE, 0x7BFE, 0x1C00, 0x2C46, 0x6AFA, + 0x3813, 0x4804, 0x385E, 0x0000, 0x386C, 0x4B7D, 0x47FD, 0x497F, + 0x260C, 0x78EE, 0x384F, 0x249E, 0x0D27, 0x37DC, 0x0400, 0x68EF +}; + +static void time_az_f16_pos( float16_t function( float16_t ) ) +{ + int_fast64_t count; + int inputNum; + clock_t startClock; + int_fast64_t i; + union ui16_f16 uA; + clock_t endClock; + + count = 0; + inputNum = 0; + startClock = clock(); + do { + for ( i = minIterations; i; --i ) { + uA.ui = inputs_F16UI_pos[inputNum]; + function( uA.f ); + inputNum = (inputNum + 1) & (numInputs_f16 - 1); + } + count += minIterations; + } while ( clock() - startClock < CLOCKS_PER_SEC ); + inputNum = 0; + startClock = clock(); + for ( i = count; i; --i ) { + uA.ui = inputs_F16UI_pos[inputNum]; + function( uA.f ); + inputNum = (inputNum + 1) & (numInputs_f16 - 1); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + +#endif + +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ + enum { numInputs_f32 = 32 }; static const uint32_t inputs_F32UI[numInputs_f32] = { @@ -683,12 +1488,12 @@ static const uint32_t inputs_F32UI[numInputs_f32] = { }; static - void - time_a_f32_z_ui32_rx( - uint_fast32_t function( float32_t, uint_fast8_t, bool ), - uint_fast8_t roundingMode, - bool exact - ) +void + time_a_f32_z_ui32_rx( + uint_fast32_t function( float32_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) { int_fast64_t count; int inputNum; @@ -721,12 +1526,12 @@ static } static - void - time_a_f32_z_ui64_rx( - uint_fast64_t function( float32_t, uint_fast8_t, bool ), - uint_fast8_t roundingMode, - bool exact - ) +void + time_a_f32_z_ui64_rx( + uint_fast64_t function( float32_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) { int_fast64_t count; int inputNum; @@ -759,12 +1564,12 @@ static } static - void - time_a_f32_z_i32_rx( - int_fast32_t function( float32_t, uint_fast8_t, bool ), - uint_fast8_t roundingMode, - bool exact - ) +void + time_a_f32_z_i32_rx( + int_fast32_t function( float32_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) { int_fast64_t count; int inputNum; @@ -797,12 +1602,12 @@ static } static - void - time_a_f32_z_i64_rx( - int_fast64_t function( float32_t, uint_fast8_t, bool ), - uint_fast8_t roundingMode, - bool exact - ) +void + time_a_f32_z_i64_rx( + int_fast64_t function( float32_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) { int_fast64_t count; int inputNum; @@ -835,8 +1640,8 @@ static } static - void - time_a_f32_z_ui32_x( uint_fast32_t function( float32_t, bool ), bool exact ) +void + time_a_f32_z_ui32_x( uint_fast32_t function( float32_t, bool ), bool exact ) { int_fast64_t count; int inputNum; @@ -869,8 +1674,8 @@ static } static - void - time_a_f32_z_ui64_x( uint_fast64_t function( float32_t, bool ), bool exact ) +void + time_a_f32_z_ui64_x( uint_fast64_t function( float32_t, bool ), bool exact ) { int_fast64_t count; int inputNum; @@ -903,8 +1708,7 @@ static } static - void - time_a_f32_z_i32_x( int_fast32_t function( float32_t, bool ), bool exact ) +void time_a_f32_z_i32_x( int_fast32_t function( float32_t, bool ), bool exact ) { int_fast64_t count; int inputNum; @@ -937,8 +1741,7 @@ static } static - void - time_a_f32_z_i64_x( int_fast64_t function( float32_t, bool ), bool exact ) +void time_a_f32_z_i64_x( int_fast64_t function( float32_t, bool ), bool exact ) { int_fast64_t count; int inputNum; @@ -970,6 +1773,42 @@ static } +#ifdef FLOAT16 + +static void time_a_f32_z_f16( float16_t function( float32_t ) ) +{ + int_fast64_t count; + int inputNum; + clock_t startClock; + int_fast64_t i; + union ui32_f32 uA; + clock_t endClock; + + count = 0; + inputNum = 0; + startClock = clock(); + do { + for ( i = minIterations; i; --i ) { + uA.ui = inputs_F32UI[inputNum]; + function( uA.f ); + inputNum = (inputNum + 1) & (numInputs_f32 - 1); + } + count += minIterations; + } while ( clock() - startClock < CLOCKS_PER_SEC ); + inputNum = 0; + startClock = clock(); + for ( i = count; i; --i ) { + uA.ui = inputs_F32UI[inputNum]; + function( uA.f ); + inputNum = (inputNum + 1) & (numInputs_f32 - 1); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + +#endif + static void time_a_f32_z_f64( float64_t function( float32_t ) ) { int_fast64_t count; @@ -1077,12 +1916,12 @@ static void time_a_f32_z_f128( void function( float32_t, float128_t * ) ) #endif static - void - time_az_f32_rx( - float32_t function( float32_t, uint_fast8_t, bool ), - uint_fast8_t roundingMode, - bool exact - ) +void + time_az_f32_rx( + float32_t function( float32_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) { int_fast64_t count; int inputNum; @@ -1155,7 +1994,7 @@ static void time_abz_f32( float32_t function( float32_t, float32_t ) ) } static - void time_abcz_f32( float32_t function( float32_t, float32_t, float32_t ) ) +void time_abcz_f32( float32_t function( float32_t, float32_t, float32_t ) ) { int_fast64_t count; int inputNumA, inputNumB, inputNumC; @@ -1286,6 +2125,9 @@ static void time_az_f32_pos( float32_t function( float32_t ) ) } +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ + enum { numInputs_f64 = 32 }; static const uint64_t inputs_F64UI[numInputs_f64] = { @@ -1324,12 +2166,12 @@ static const uint64_t inputs_F64UI[numInputs_f64] = { }; static - void - time_a_f64_z_ui32_rx( - uint_fast32_t function( float64_t, uint_fast8_t, bool ), - uint_fast8_t roundingMode, - bool exact - ) +void + time_a_f64_z_ui32_rx( + uint_fast32_t function( float64_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) { int_fast64_t count; int inputNum; @@ -1362,12 +2204,12 @@ static } static - void - time_a_f64_z_ui64_rx( - uint_fast64_t function( float64_t, uint_fast8_t, bool ), - uint_fast8_t roundingMode, - bool exact - ) +void + time_a_f64_z_ui64_rx( + uint_fast64_t function( float64_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) { int_fast64_t count; int inputNum; @@ -1400,12 +2242,12 @@ static } static - void - time_a_f64_z_i32_rx( - int_fast32_t function( float64_t, uint_fast8_t, bool ), - uint_fast8_t roundingMode, - bool exact - ) +void + time_a_f64_z_i32_rx( + int_fast32_t function( float64_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) { int_fast64_t count; int inputNum; @@ -1438,12 +2280,12 @@ static } static - void - time_a_f64_z_i64_rx( - int_fast64_t function( float64_t, uint_fast8_t, bool ), - uint_fast8_t roundingMode, - bool exact - ) +void + time_a_f64_z_i64_rx( + int_fast64_t function( float64_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) { int_fast64_t count; int inputNum; @@ -1476,8 +2318,8 @@ static } static - void - time_a_f64_z_ui32_x( uint_fast32_t function( float64_t, bool ), bool exact ) +void + time_a_f64_z_ui32_x( uint_fast32_t function( float64_t, bool ), bool exact ) { int_fast64_t count; int inputNum; @@ -1510,8 +2352,8 @@ static } static - void - time_a_f64_z_ui64_x( uint_fast64_t function( float64_t, bool ), bool exact ) +void + time_a_f64_z_ui64_x( uint_fast64_t function( float64_t, bool ), bool exact ) { int_fast64_t count; int inputNum; @@ -1544,8 +2386,7 @@ static } static - void - time_a_f64_z_i32_x( int_fast32_t function( float64_t, bool ), bool exact ) +void time_a_f64_z_i32_x( int_fast32_t function( float64_t, bool ), bool exact ) { int_fast64_t count; int inputNum; @@ -1578,8 +2419,7 @@ static } static - void - time_a_f64_z_i64_x( int_fast64_t function( float64_t, bool ), bool exact ) +void time_a_f64_z_i64_x( int_fast64_t function( float64_t, bool ), bool exact ) { int_fast64_t count; int inputNum; @@ -1611,6 +2451,42 @@ static } +#ifdef FLOAT16 + +static void time_a_f64_z_f16( float16_t function( float64_t ) ) +{ + int_fast64_t count; + int inputNum; + clock_t startClock; + int_fast64_t i; + union ui64_f64 uA; + clock_t endClock; + + count = 0; + inputNum = 0; + startClock = clock(); + do { + for ( i = minIterations; i; --i ) { + uA.ui = inputs_F64UI[inputNum]; + function( uA.f ); + inputNum = (inputNum + 1) & (numInputs_f64 - 1); + } + count += minIterations; + } while ( clock() - startClock < CLOCKS_PER_SEC ); + inputNum = 0; + startClock = clock(); + for ( i = count; i; --i ) { + uA.ui = inputs_F64UI[inputNum]; + function( uA.f ); + inputNum = (inputNum + 1) & (numInputs_f64 - 1); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + +#endif + static void time_a_f64_z_f32( float32_t function( float64_t ) ) { int_fast64_t count; @@ -1718,12 +2594,12 @@ static void time_a_f64_z_f128( void function( float64_t, float128_t * ) ) #endif static - void - time_az_f64_rx( - float64_t function( float64_t, uint_fast8_t, bool ), - uint_fast8_t roundingMode, - bool exact - ) +void + time_az_f64_rx( + float64_t function( float64_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) { int_fast64_t count; int inputNum; @@ -1796,7 +2672,7 @@ static void time_abz_f64( float64_t function( float64_t, float64_t ) ) } static - void time_abcz_f64( float64_t function( float64_t, float64_t, float64_t ) ) +void time_abcz_f64( float64_t function( float64_t, float64_t, float64_t ) ) { int_fast64_t count; int inputNumA, inputNumB, inputNumC; @@ -1951,6 +2827,9 @@ static void time_az_f64_pos( float64_t function( float64_t ) ) } +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ + #ifdef EXTFLOAT80 #ifdef LITTLEENDIAN @@ -1962,49 +2841,49 @@ static void time_az_f64_pos( float64_t function( float64_t ) ) enum { numInputs_extF80 = 32 }; static - const union { struct extFloat80M s; extFloat80_t f; } - inputs_extF80[numInputs_extF80] = { - extF80Const( 0xC03F, 0xA9BE15A19C1E8B62 ), - extF80Const( 0x8000, 0x0000000000000000 ), - extF80Const( 0x75A8, 0xE59591E4788957A5 ), - extF80Const( 0xBFFF, 0xFFF0000000000040 ), - extF80Const( 0x0CD8, 0xFC000000000007FE ), - extF80Const( 0x43BA, 0x99A4000000000000 ), - extF80Const( 0x3FFF, 0x8000000000000000 ), - extF80Const( 0x4081, 0x94FBF1BCEB5545F0 ), - extF80Const( 0x403E, 0xFFF0000000002000 ), - extF80Const( 0x3FFE, 0xC860E3C75D224F28 ), - extF80Const( 0x407E, 0xFC00000FFFFFFFFE ), - extF80Const( 0x737A, 0x800000007FFDFFFE ), - extF80Const( 0x4044, 0xFFFFFF80000FFFFF ), - extF80Const( 0xBBFE, 0x8000040000001FFE ), - extF80Const( 0xC002, 0xFF80000000000020 ), - extF80Const( 0xDE8D, 0xFFFFFFFFFFE00004 ), - extF80Const( 0xC004, 0x8000000000003FFB ), - extF80Const( 0x407F, 0x800000000003FFFE ), - extF80Const( 0xC000, 0xA459EE6A5C16CA55 ), - extF80Const( 0x8003, 0xC42CBF7399AEEB94 ), - extF80Const( 0xBF7F, 0xF800000000000006 ), - extF80Const( 0xC07F, 0xBF56BE8871F28FEA ), - extF80Const( 0xC07E, 0xFFFF77FFFFFFFFFE ), - extF80Const( 0xADC9, 0x8000000FFFFFFFDE ), - extF80Const( 0xC001, 0xEFF7FFFFFFFFFFFF ), - extF80Const( 0x4001, 0xBE84F30125C497A6 ), - extF80Const( 0xC06B, 0xEFFFFFFFFFFFFFFF ), - extF80Const( 0x4080, 0xFFFFFFFFBFFFFFFF ), - extF80Const( 0x87E9, 0x81FFFFFFFFFFFBFF ), - extF80Const( 0xA63F, 0x801FFFFFFEFFFFFE ), - extF80Const( 0x403C, 0x801FFFFFFFF7FFFF ), - extF80Const( 0x4018, 0x8000000000080003 ) -}; +const union { struct extFloat80M s; extFloat80_t f; } + inputs_extF80[numInputs_extF80] = { + extF80Const( 0xC03F, 0xA9BE15A19C1E8B62 ), + extF80Const( 0x8000, 0x0000000000000000 ), + extF80Const( 0x75A8, 0xE59591E4788957A5 ), + extF80Const( 0xBFFF, 0xFFF0000000000040 ), + extF80Const( 0x0CD8, 0xFC000000000007FE ), + extF80Const( 0x43BA, 0x99A4000000000000 ), + extF80Const( 0x3FFF, 0x8000000000000000 ), + extF80Const( 0x4081, 0x94FBF1BCEB5545F0 ), + extF80Const( 0x403E, 0xFFF0000000002000 ), + extF80Const( 0x3FFE, 0xC860E3C75D224F28 ), + extF80Const( 0x407E, 0xFC00000FFFFFFFFE ), + extF80Const( 0x737A, 0x800000007FFDFFFE ), + extF80Const( 0x4044, 0xFFFFFF80000FFFFF ), + extF80Const( 0xBBFE, 0x8000040000001FFE ), + extF80Const( 0xC002, 0xFF80000000000020 ), + extF80Const( 0xDE8D, 0xFFFFFFFFFFE00004 ), + extF80Const( 0xC004, 0x8000000000003FFB ), + extF80Const( 0x407F, 0x800000000003FFFE ), + extF80Const( 0xC000, 0xA459EE6A5C16CA55 ), + extF80Const( 0x8003, 0xC42CBF7399AEEB94 ), + extF80Const( 0xBF7F, 0xF800000000000006 ), + extF80Const( 0xC07F, 0xBF56BE8871F28FEA ), + extF80Const( 0xC07E, 0xFFFF77FFFFFFFFFE ), + extF80Const( 0xADC9, 0x8000000FFFFFFFDE ), + extF80Const( 0xC001, 0xEFF7FFFFFFFFFFFF ), + extF80Const( 0x4001, 0xBE84F30125C497A6 ), + extF80Const( 0xC06B, 0xEFFFFFFFFFFFFFFF ), + extF80Const( 0x4080, 0xFFFFFFFFBFFFFFFF ), + extF80Const( 0x87E9, 0x81FFFFFFFFFFFBFF ), + extF80Const( 0xA63F, 0x801FFFFFFEFFFFFE ), + extF80Const( 0x403C, 0x801FFFFFFFF7FFFF ), + extF80Const( 0x4018, 0x8000000000080003 ) + }; static - void - time_a_extF80_z_ui32_rx( - uint_fast32_t function( const extFloat80_t *, uint_fast8_t, bool ), - uint_fast8_t roundingMode, - bool exact - ) +void + time_a_extF80_z_ui32_rx( + uint_fast32_t function( const extFloat80_t *, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) { int_fast64_t count; int inputNum; @@ -2034,12 +2913,12 @@ static } static - void - time_a_extF80_z_ui64_rx( - uint_fast64_t function( const extFloat80_t *, uint_fast8_t, bool ), - uint_fast8_t roundingMode, - bool exact - ) +void + time_a_extF80_z_ui64_rx( + uint_fast64_t function( const extFloat80_t *, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) { int_fast64_t count; int inputNum; @@ -2069,12 +2948,12 @@ static } static - void - time_a_extF80_z_i32_rx( - int_fast32_t function( const extFloat80_t *, uint_fast8_t, bool ), - uint_fast8_t roundingMode, - bool exact - ) +void + time_a_extF80_z_i32_rx( + int_fast32_t function( const extFloat80_t *, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) { int_fast64_t count; int inputNum; @@ -2104,12 +2983,12 @@ static } static - void - time_a_extF80_z_i64_rx( - int_fast64_t function( const extFloat80_t *, uint_fast8_t, bool ), - uint_fast8_t roundingMode, - bool exact - ) +void + time_a_extF80_z_i64_rx( + int_fast64_t function( const extFloat80_t *, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) { int_fast64_t count; int inputNum; @@ -2139,9 +3018,9 @@ static } static - void - time_a_extF80_z_ui32_x( - uint_fast32_t function( const extFloat80_t *, bool ), bool exact ) +void + time_a_extF80_z_ui32_x( + uint_fast32_t function( const extFloat80_t *, bool ), bool exact ) { int_fast64_t count; int inputNum; @@ -2171,9 +3050,9 @@ static } static - void - time_a_extF80_z_ui64_x( - uint_fast64_t function( const extFloat80_t *, bool ), bool exact ) +void + time_a_extF80_z_ui64_x( + uint_fast64_t function( const extFloat80_t *, bool ), bool exact ) { int_fast64_t count; int inputNum; @@ -2203,9 +3082,9 @@ static } static - void - time_a_extF80_z_i32_x( - int_fast32_t function( const extFloat80_t *, bool ), bool exact ) +void + time_a_extF80_z_i32_x( + int_fast32_t function( const extFloat80_t *, bool ), bool exact ) { int_fast64_t count; int inputNum; @@ -2235,9 +3114,9 @@ static } static - void - time_a_extF80_z_i64_x( - int_fast64_t function( const extFloat80_t *, bool ), bool exact ) +void + time_a_extF80_z_i64_x( + int_fast64_t function( const extFloat80_t *, bool ), bool exact ) { int_fast64_t count; int inputNum; @@ -2266,6 +3145,39 @@ static } +#ifdef FLOAT16 + +static void time_a_extF80_z_f16( float16_t function( const extFloat80_t * ) ) +{ + int_fast64_t count; + int inputNum; + clock_t startClock; + int_fast64_t i; + clock_t endClock; + + count = 0; + inputNum = 0; + startClock = clock(); + do { + for ( i = minIterations; i; --i ) { + function( &inputs_extF80[inputNum].f ); + inputNum = (inputNum + 1) & (numInputs_extF80 - 1); + } + count += minIterations; + } while ( clock() - startClock < CLOCKS_PER_SEC ); + inputNum = 0; + startClock = clock(); + for ( i = count; i; --i ) { + function( &inputs_extF80[inputNum].f ); + inputNum = (inputNum + 1) & (numInputs_extF80 - 1); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + +#endif + static void time_a_extF80_z_f32( float32_t function( const extFloat80_t * ) ) { int_fast64_t count; @@ -2327,8 +3239,8 @@ static void time_a_extF80_z_f64( float64_t function( const extFloat80_t * ) ) #ifdef FLOAT128 static - void - time_a_extF80_z_f128( void function( const extFloat80_t *, float128_t * ) ) +void + time_a_extF80_z_f128( void function( const extFloat80_t *, float128_t * ) ) { int_fast64_t count; int inputNum; @@ -2361,13 +3273,12 @@ static #endif static - void - time_az_extF80_rx( - void - function( const extFloat80_t *, uint_fast8_t, bool, extFloat80_t * ), - uint_fast8_t roundingMode, - bool exact - ) +void + time_az_extF80_rx( + void function( const extFloat80_t *, uint_fast8_t, bool, extFloat80_t * ), + uint_fast8_t roundingMode, + bool exact + ) { int_fast64_t count; int inputNum; @@ -2398,11 +3309,11 @@ static } static - void - time_abz_extF80( - void - function( const extFloat80_t *, const extFloat80_t *, extFloat80_t * ) - ) +void + time_abz_extF80( + void + function( const extFloat80_t *, const extFloat80_t *, extFloat80_t * ) + ) { int_fast64_t count; int inputNumA, inputNumB; @@ -2441,16 +3352,16 @@ static } static - void - time_abcz_extF80( - void - function( - const extFloat80_t *, - const extFloat80_t *, - const extFloat80_t *, - extFloat80_t * - ) - ) +void + time_abcz_extF80( + void + function( + const extFloat80_t *, + const extFloat80_t *, + const extFloat80_t *, + extFloat80_t * + ) + ) { int_fast64_t count; int inputNumA, inputNumB, inputNumC; @@ -2503,9 +3414,9 @@ static } static - void - time_ab_extF80_z_bool( - bool function( const extFloat80_t *, const extFloat80_t * ) ) +void + time_ab_extF80_z_bool( + bool function( const extFloat80_t *, const extFloat80_t * ) ) { int_fast64_t count; int inputNumA, inputNumB; @@ -2542,45 +3453,45 @@ static } static - const union { struct extFloat80M s; extFloat80_t f; } - inputs_extF80_pos[numInputs_extF80] = { - extF80Const( 0x403F, 0xA9BE15A19C1E8B62 ), - extF80Const( 0x0000, 0x0000000000000000 ), - extF80Const( 0x75A8, 0xE59591E4788957A5 ), - extF80Const( 0x3FFF, 0xFFF0000000000040 ), - extF80Const( 0x0CD8, 0xFC000000000007FE ), - extF80Const( 0x43BA, 0x99A4000000000000 ), - extF80Const( 0x3FFF, 0x8000000000000000 ), - extF80Const( 0x4081, 0x94FBF1BCEB5545F0 ), - extF80Const( 0x403E, 0xFFF0000000002000 ), - extF80Const( 0x3FFE, 0xC860E3C75D224F28 ), - extF80Const( 0x407E, 0xFC00000FFFFFFFFE ), - extF80Const( 0x737A, 0x800000007FFDFFFE ), - extF80Const( 0x4044, 0xFFFFFF80000FFFFF ), - extF80Const( 0x3BFE, 0x8000040000001FFE ), - extF80Const( 0x4002, 0xFF80000000000020 ), - extF80Const( 0x5E8D, 0xFFFFFFFFFFE00004 ), - extF80Const( 0x4004, 0x8000000000003FFB ), - extF80Const( 0x407F, 0x800000000003FFFE ), - extF80Const( 0x4000, 0xA459EE6A5C16CA55 ), - extF80Const( 0x0003, 0xC42CBF7399AEEB94 ), - extF80Const( 0x3F7F, 0xF800000000000006 ), - extF80Const( 0x407F, 0xBF56BE8871F28FEA ), - extF80Const( 0x407E, 0xFFFF77FFFFFFFFFE ), - extF80Const( 0x2DC9, 0x8000000FFFFFFFDE ), - extF80Const( 0x4001, 0xEFF7FFFFFFFFFFFF ), - extF80Const( 0x4001, 0xBE84F30125C497A6 ), - extF80Const( 0x406B, 0xEFFFFFFFFFFFFFFF ), - extF80Const( 0x4080, 0xFFFFFFFFBFFFFFFF ), - extF80Const( 0x07E9, 0x81FFFFFFFFFFFBFF ), - extF80Const( 0x263F, 0x801FFFFFFEFFFFFE ), - extF80Const( 0x403C, 0x801FFFFFFFF7FFFF ), - extF80Const( 0x4018, 0x8000000000080003 ) -}; +const union { struct extFloat80M s; extFloat80_t f; } + inputs_extF80_pos[numInputs_extF80] = { + extF80Const( 0x403F, 0xA9BE15A19C1E8B62 ), + extF80Const( 0x0000, 0x0000000000000000 ), + extF80Const( 0x75A8, 0xE59591E4788957A5 ), + extF80Const( 0x3FFF, 0xFFF0000000000040 ), + extF80Const( 0x0CD8, 0xFC000000000007FE ), + extF80Const( 0x43BA, 0x99A4000000000000 ), + extF80Const( 0x3FFF, 0x8000000000000000 ), + extF80Const( 0x4081, 0x94FBF1BCEB5545F0 ), + extF80Const( 0x403E, 0xFFF0000000002000 ), + extF80Const( 0x3FFE, 0xC860E3C75D224F28 ), + extF80Const( 0x407E, 0xFC00000FFFFFFFFE ), + extF80Const( 0x737A, 0x800000007FFDFFFE ), + extF80Const( 0x4044, 0xFFFFFF80000FFFFF ), + extF80Const( 0x3BFE, 0x8000040000001FFE ), + extF80Const( 0x4002, 0xFF80000000000020 ), + extF80Const( 0x5E8D, 0xFFFFFFFFFFE00004 ), + extF80Const( 0x4004, 0x8000000000003FFB ), + extF80Const( 0x407F, 0x800000000003FFFE ), + extF80Const( 0x4000, 0xA459EE6A5C16CA55 ), + extF80Const( 0x0003, 0xC42CBF7399AEEB94 ), + extF80Const( 0x3F7F, 0xF800000000000006 ), + extF80Const( 0x407F, 0xBF56BE8871F28FEA ), + extF80Const( 0x407E, 0xFFFF77FFFFFFFFFE ), + extF80Const( 0x2DC9, 0x8000000FFFFFFFDE ), + extF80Const( 0x4001, 0xEFF7FFFFFFFFFFFF ), + extF80Const( 0x4001, 0xBE84F30125C497A6 ), + extF80Const( 0x406B, 0xEFFFFFFFFFFFFFFF ), + extF80Const( 0x4080, 0xFFFFFFFFBFFFFFFF ), + extF80Const( 0x07E9, 0x81FFFFFFFFFFFBFF ), + extF80Const( 0x263F, 0x801FFFFFFEFFFFFE ), + extF80Const( 0x403C, 0x801FFFFFFFF7FFFF ), + extF80Const( 0x4018, 0x8000000000080003 ) + }; static - void - time_az_extF80_pos( void function( const extFloat80_t *, extFloat80_t * ) ) +void + time_az_extF80_pos( void function( const extFloat80_t *, extFloat80_t * ) ) { int_fast64_t count; int inputNum; @@ -2612,6 +3523,9 @@ static #endif +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ + #ifdef FLOAT128 #ifdef LITTLEENDIAN @@ -2623,49 +3537,49 @@ static enum { numInputs_f128 = 32 }; static - const union { struct uint128 ui; float128_t f; } - inputs_f128[numInputs_f128] = { - f128Const( 0x3FDA200000100000, 0x0000000000000000 ), - f128Const( 0x3FFF000000000000, 0x0000000000000000 ), - f128Const( 0x85F14776190C8306, 0xD8715F4E3D54BB92 ), - f128Const( 0xF2B00000007FFFFF, 0xFFFFFFFFFFF7FFFF ), - f128Const( 0x8000000000000000, 0x0000000000000000 ), - f128Const( 0xBFFFFFFFFFE00000, 0x0000008000000000 ), - f128Const( 0x407F1719CE722F3E, 0xDA6B3FE5FF29425B ), - f128Const( 0x43FFFF8000000000, 0x0000000000400000 ), - f128Const( 0x401E000000000100, 0x0000000000002000 ), - f128Const( 0x3FFED71DACDA8E47, 0x4860E3C75D224F28 ), - f128Const( 0xBF7ECFC1E90647D1, 0x7A124FE55623EE44 ), - f128Const( 0x0DF7007FFFFFFFFF, 0xFFFFFFFFEFFFFFFF ), - f128Const( 0x3FE5FFEFFFFFFFFF, 0xFFFFFFFFFFFFEFFF ), - f128Const( 0x403FFFFFFFFFFFFF, 0xFFFFFFFFFFFFFBFE ), - f128Const( 0xBFFB2FBF7399AFEB, 0xA459EE6A5C16CA55 ), - f128Const( 0xBDB8FFFFFFFFFFFC, 0x0000000000000400 ), - f128Const( 0x3FC8FFDFFFFFFFFF, 0xFFFFFFFFF0000000 ), - f128Const( 0x3FFBFFFFFFDFFFFF, 0xFFF8000000000000 ), - f128Const( 0x407043C11737BE84, 0xDDD58212ADC937F4 ), - f128Const( 0x8001000000000000, 0x0000001000000001 ), - f128Const( 0xC036FFFFFFFFFFFF, 0xFE40000000000000 ), - f128Const( 0x4002FFFFFE000002, 0x0000000000000000 ), - f128Const( 0x4000C3FEDE897773, 0x326AC4FD8EFBE6DC ), - f128Const( 0xBFFF0000000FFFFF, 0xFFFFFE0000000000 ), - f128Const( 0x62C3E502146E426D, 0x43F3CAA0DC7DF1A0 ), - f128Const( 0xB5CBD32E52BB570E, 0xBCC477CB11C6236C ), - f128Const( 0xE228FFFFFFC00000, 0x0000000000000000 ), - f128Const( 0x3F80000000000000, 0x0000000080000008 ), - f128Const( 0xC1AFFFDFFFFFFFFF, 0xFFFC000000000000 ), - f128Const( 0xC96F000000000000, 0x00000001FFFBFFFF ), - f128Const( 0x3DE09BFE7923A338, 0xBCC8FBBD7CEC1F4F ), - f128Const( 0x401CFFFFFFFFFFFF, 0xFFFFFFFEFFFFFF80 ) -}; +const union { struct uint128 ui; float128_t f; } + inputs_f128[numInputs_f128] = { + f128Const( 0x3FDA200000100000, 0x0000000000000000 ), + f128Const( 0x3FFF000000000000, 0x0000000000000000 ), + f128Const( 0x85F14776190C8306, 0xD8715F4E3D54BB92 ), + f128Const( 0xF2B00000007FFFFF, 0xFFFFFFFFFFF7FFFF ), + f128Const( 0x8000000000000000, 0x0000000000000000 ), + f128Const( 0xBFFFFFFFFFE00000, 0x0000008000000000 ), + f128Const( 0x407F1719CE722F3E, 0xDA6B3FE5FF29425B ), + f128Const( 0x43FFFF8000000000, 0x0000000000400000 ), + f128Const( 0x401E000000000100, 0x0000000000002000 ), + f128Const( 0x3FFED71DACDA8E47, 0x4860E3C75D224F28 ), + f128Const( 0xBF7ECFC1E90647D1, 0x7A124FE55623EE44 ), + f128Const( 0x0DF7007FFFFFFFFF, 0xFFFFFFFFEFFFFFFF ), + f128Const( 0x3FE5FFEFFFFFFFFF, 0xFFFFFFFFFFFFEFFF ), + f128Const( 0x403FFFFFFFFFFFFF, 0xFFFFFFFFFFFFFBFE ), + f128Const( 0xBFFB2FBF7399AFEB, 0xA459EE6A5C16CA55 ), + f128Const( 0xBDB8FFFFFFFFFFFC, 0x0000000000000400 ), + f128Const( 0x3FC8FFDFFFFFFFFF, 0xFFFFFFFFF0000000 ), + f128Const( 0x3FFBFFFFFFDFFFFF, 0xFFF8000000000000 ), + f128Const( 0x407043C11737BE84, 0xDDD58212ADC937F4 ), + f128Const( 0x8001000000000000, 0x0000001000000001 ), + f128Const( 0xC036FFFFFFFFFFFF, 0xFE40000000000000 ), + f128Const( 0x4002FFFFFE000002, 0x0000000000000000 ), + f128Const( 0x4000C3FEDE897773, 0x326AC4FD8EFBE6DC ), + f128Const( 0xBFFF0000000FFFFF, 0xFFFFFE0000000000 ), + f128Const( 0x62C3E502146E426D, 0x43F3CAA0DC7DF1A0 ), + f128Const( 0xB5CBD32E52BB570E, 0xBCC477CB11C6236C ), + f128Const( 0xE228FFFFFFC00000, 0x0000000000000000 ), + f128Const( 0x3F80000000000000, 0x0000000080000008 ), + f128Const( 0xC1AFFFDFFFFFFFFF, 0xFFFC000000000000 ), + f128Const( 0xC96F000000000000, 0x00000001FFFBFFFF ), + f128Const( 0x3DE09BFE7923A338, 0xBCC8FBBD7CEC1F4F ), + f128Const( 0x401CFFFFFFFFFFFF, 0xFFFFFFFEFFFFFF80 ) + }; static - void - time_a_f128_z_ui32_rx( - uint_fast32_t function( const float128_t *, uint_fast8_t, bool ), - uint_fast8_t roundingMode, - bool exact - ) +void + time_a_f128_z_ui32_rx( + uint_fast32_t function( const float128_t *, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) { int_fast64_t count; int inputNum; @@ -2695,12 +3609,12 @@ static } static - void - time_a_f128_z_ui64_rx( - uint_fast64_t function( const float128_t *, uint_fast8_t, bool ), - uint_fast8_t roundingMode, - bool exact - ) +void + time_a_f128_z_ui64_rx( + uint_fast64_t function( const float128_t *, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) { int_fast64_t count; int inputNum; @@ -2730,12 +3644,12 @@ static } static - void - time_a_f128_z_i32_rx( - int_fast32_t function( const float128_t *, uint_fast8_t, bool ), - uint_fast8_t roundingMode, - bool exact - ) +void + time_a_f128_z_i32_rx( + int_fast32_t function( const float128_t *, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) { int_fast64_t count; int inputNum; @@ -2765,12 +3679,12 @@ static } static - void - time_a_f128_z_i64_rx( - int_fast64_t function( const float128_t *, uint_fast8_t, bool ), - uint_fast8_t roundingMode, - bool exact - ) +void + time_a_f128_z_i64_rx( + int_fast64_t function( const float128_t *, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) { int_fast64_t count; int inputNum; @@ -2800,9 +3714,9 @@ static } static - void - time_a_f128_z_ui32_x( - uint_fast32_t function( const float128_t *, bool ), bool exact ) +void + time_a_f128_z_ui32_x( + uint_fast32_t function( const float128_t *, bool ), bool exact ) { int_fast64_t count; int inputNum; @@ -2832,9 +3746,9 @@ static } static - void - time_a_f128_z_ui64_x( - uint_fast64_t function( const float128_t *, bool ), bool exact ) +void + time_a_f128_z_ui64_x( + uint_fast64_t function( const float128_t *, bool ), bool exact ) { int_fast64_t count; int inputNum; @@ -2864,9 +3778,9 @@ static } static - void - time_a_f128_z_i32_x( - int_fast32_t function( const float128_t *, bool ), bool exact ) +void + time_a_f128_z_i32_x( + int_fast32_t function( const float128_t *, bool ), bool exact ) { int_fast64_t count; int inputNum; @@ -2896,9 +3810,9 @@ static } static - void - time_a_f128_z_i64_x( - int_fast64_t function( const float128_t *, bool ), bool exact ) +void + time_a_f128_z_i64_x( + int_fast64_t function( const float128_t *, bool ), bool exact ) { int_fast64_t count; int inputNum; @@ -2927,6 +3841,39 @@ static } +#ifdef FLOAT16 + +static void time_a_f128_z_f16( float16_t function( const float128_t * ) ) +{ + int_fast64_t count; + int inputNum; + clock_t startClock; + int_fast64_t i; + clock_t endClock; + + count = 0; + inputNum = 0; + startClock = clock(); + do { + for ( i = minIterations; i; --i ) { + function( &inputs_f128[inputNum].f ); + inputNum = (inputNum + 1) & (numInputs_f128 - 1); + } + count += minIterations; + } while ( clock() - startClock < CLOCKS_PER_SEC ); + inputNum = 0; + startClock = clock(); + for ( i = count; i; --i ) { + function( &inputs_f128[inputNum].f ); + inputNum = (inputNum + 1) & (numInputs_f128 - 1); + } + endClock = clock(); + reportTime( count, endClock - startClock ); + +} + +#endif + static void time_a_f128_z_f32( float32_t function( const float128_t * ) ) { int_fast64_t count; @@ -2988,8 +3935,8 @@ static void time_a_f128_z_f64( float64_t function( const float128_t * ) ) #ifdef EXTFLOAT80 static - void - time_a_f128_z_extF80( void function( const float128_t *, extFloat80_t * ) ) +void + time_a_f128_z_extF80( void function( const float128_t *, extFloat80_t * ) ) { int_fast64_t count; int inputNum; @@ -3022,12 +3969,12 @@ static #endif static - void - time_az_f128_rx( - void function( const float128_t *, uint_fast8_t, bool, float128_t * ), - uint_fast8_t roundingMode, - bool exact - ) +void + time_az_f128_rx( + void function( const float128_t *, uint_fast8_t, bool, float128_t * ), + uint_fast8_t roundingMode, + bool exact + ) { int_fast64_t count; int inputNum; @@ -3058,9 +4005,9 @@ static } static - void - time_abz_f128( - void function( const float128_t *, const float128_t *, float128_t * ) ) +void + time_abz_f128( + void function( const float128_t *, const float128_t *, float128_t * ) ) { int_fast64_t count; int inputNumA, inputNumB; @@ -3098,16 +4045,16 @@ static } static - void - time_abcz_f128( - void - function( - const float128_t *, - const float128_t *, - const float128_t *, - float128_t * - ) - ) +void + time_abcz_f128( + void + function( + const float128_t *, + const float128_t *, + const float128_t *, + float128_t * + ) + ) { int_fast64_t count; int inputNumA, inputNumB, inputNumC; @@ -3160,9 +4107,8 @@ static } static - void - time_ab_f128_z_bool( - bool function( const float128_t *, const float128_t * ) ) +void + time_ab_f128_z_bool( bool function( const float128_t *, const float128_t * ) ) { int_fast64_t count; int inputNumA, inputNumB; @@ -3198,44 +4144,44 @@ static } static - const union { struct uint128 ui; float128_t f; } - inputs_f128_pos[numInputs_f128] = { - f128Const( 0x3FDA200000100000, 0x0000000000000000 ), - f128Const( 0x3FFF000000000000, 0x0000000000000000 ), - f128Const( 0x05F14776190C8306, 0xD8715F4E3D54BB92 ), - f128Const( 0x72B00000007FFFFF, 0xFFFFFFFFFFF7FFFF ), - f128Const( 0x0000000000000000, 0x0000000000000000 ), - f128Const( 0x3FFFFFFFFFE00000, 0x0000008000000000 ), - f128Const( 0x407F1719CE722F3E, 0xDA6B3FE5FF29425B ), - f128Const( 0x43FFFF8000000000, 0x0000000000400000 ), - f128Const( 0x401E000000000100, 0x0000000000002000 ), - f128Const( 0x3FFED71DACDA8E47, 0x4860E3C75D224F28 ), - f128Const( 0x3F7ECFC1E90647D1, 0x7A124FE55623EE44 ), - f128Const( 0x0DF7007FFFFFFFFF, 0xFFFFFFFFEFFFFFFF ), - f128Const( 0x3FE5FFEFFFFFFFFF, 0xFFFFFFFFFFFFEFFF ), - f128Const( 0x403FFFFFFFFFFFFF, 0xFFFFFFFFFFFFFBFE ), - f128Const( 0x3FFB2FBF7399AFEB, 0xA459EE6A5C16CA55 ), - f128Const( 0x3DB8FFFFFFFFFFFC, 0x0000000000000400 ), - f128Const( 0x3FC8FFDFFFFFFFFF, 0xFFFFFFFFF0000000 ), - f128Const( 0x3FFBFFFFFFDFFFFF, 0xFFF8000000000000 ), - f128Const( 0x407043C11737BE84, 0xDDD58212ADC937F4 ), - f128Const( 0x0001000000000000, 0x0000001000000001 ), - f128Const( 0x4036FFFFFFFFFFFF, 0xFE40000000000000 ), - f128Const( 0x4002FFFFFE000002, 0x0000000000000000 ), - f128Const( 0x4000C3FEDE897773, 0x326AC4FD8EFBE6DC ), - f128Const( 0x3FFF0000000FFFFF, 0xFFFFFE0000000000 ), - f128Const( 0x62C3E502146E426D, 0x43F3CAA0DC7DF1A0 ), - f128Const( 0x35CBD32E52BB570E, 0xBCC477CB11C6236C ), - f128Const( 0x6228FFFFFFC00000, 0x0000000000000000 ), - f128Const( 0x3F80000000000000, 0x0000000080000008 ), - f128Const( 0x41AFFFDFFFFFFFFF, 0xFFFC000000000000 ), - f128Const( 0x496F000000000000, 0x00000001FFFBFFFF ), - f128Const( 0x3DE09BFE7923A338, 0xBCC8FBBD7CEC1F4F ), - f128Const( 0x401CFFFFFFFFFFFF, 0xFFFFFFFEFFFFFF80 ) -}; +const union { struct uint128 ui; float128_t f; } + inputs_f128_pos[numInputs_f128] = { + f128Const( 0x3FDA200000100000, 0x0000000000000000 ), + f128Const( 0x3FFF000000000000, 0x0000000000000000 ), + f128Const( 0x05F14776190C8306, 0xD8715F4E3D54BB92 ), + f128Const( 0x72B00000007FFFFF, 0xFFFFFFFFFFF7FFFF ), + f128Const( 0x0000000000000000, 0x0000000000000000 ), + f128Const( 0x3FFFFFFFFFE00000, 0x0000008000000000 ), + f128Const( 0x407F1719CE722F3E, 0xDA6B3FE5FF29425B ), + f128Const( 0x43FFFF8000000000, 0x0000000000400000 ), + f128Const( 0x401E000000000100, 0x0000000000002000 ), + f128Const( 0x3FFED71DACDA8E47, 0x4860E3C75D224F28 ), + f128Const( 0x3F7ECFC1E90647D1, 0x7A124FE55623EE44 ), + f128Const( 0x0DF7007FFFFFFFFF, 0xFFFFFFFFEFFFFFFF ), + f128Const( 0x3FE5FFEFFFFFFFFF, 0xFFFFFFFFFFFFEFFF ), + f128Const( 0x403FFFFFFFFFFFFF, 0xFFFFFFFFFFFFFBFE ), + f128Const( 0x3FFB2FBF7399AFEB, 0xA459EE6A5C16CA55 ), + f128Const( 0x3DB8FFFFFFFFFFFC, 0x0000000000000400 ), + f128Const( 0x3FC8FFDFFFFFFFFF, 0xFFFFFFFFF0000000 ), + f128Const( 0x3FFBFFFFFFDFFFFF, 0xFFF8000000000000 ), + f128Const( 0x407043C11737BE84, 0xDDD58212ADC937F4 ), + f128Const( 0x0001000000000000, 0x0000001000000001 ), + f128Const( 0x4036FFFFFFFFFFFF, 0xFE40000000000000 ), + f128Const( 0x4002FFFFFE000002, 0x0000000000000000 ), + f128Const( 0x4000C3FEDE897773, 0x326AC4FD8EFBE6DC ), + f128Const( 0x3FFF0000000FFFFF, 0xFFFFFE0000000000 ), + f128Const( 0x62C3E502146E426D, 0x43F3CAA0DC7DF1A0 ), + f128Const( 0x35CBD32E52BB570E, 0xBCC477CB11C6236C ), + f128Const( 0x6228FFFFFFC00000, 0x0000000000000000 ), + f128Const( 0x3F80000000000000, 0x0000000080000008 ), + f128Const( 0x41AFFFDFFFFFFFFF, 0xFFFC000000000000 ), + f128Const( 0x496F000000000000, 0x00000001FFFBFFFF ), + f128Const( 0x3DE09BFE7923A338, 0xBCC8FBBD7CEC1F4F ), + f128Const( 0x401CFFFFFFFFFFFF, 0xFFFFFFFEFFFFFF80 ) + }; static - void time_az_f128_pos( void function( const float128_t *, float128_t * ) ) +void time_az_f128_pos( void function( const float128_t *, float128_t * ) ) { int_fast64_t count; int inputNum; @@ -3267,11 +4213,18 @@ static #endif +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ + static - void - timeFunctionInstance( - int functionCode, uint_fast8_t roundingMode, bool exact ) +void + timeFunctionInstance( + int functionCode, uint_fast8_t roundingMode, bool exact ) { +#ifdef FLOAT16 + float16_t (*function_abz_f16)( float16_t, float16_t ); + bool (*function_ab_f16_z_bool)( float16_t, float16_t ); +#endif float32_t (*function_abz_f32)( float32_t, float32_t ); bool (*function_ab_f32_z_bool)( float32_t, float32_t ); float64_t (*function_abz_f64)( float64_t, float64_t ); @@ -3294,6 +4247,11 @@ static switch ( functionCode ) { /*-------------------------------------------------------------------- *--------------------------------------------------------------------*/ +#ifdef FLOAT16 + case UI32_TO_F16: + time_a_ui32_z_f16( ui32_to_f16 ); + break; +#endif case UI32_TO_F32: time_a_ui32_z_f32( ui32_to_f32 ); break; @@ -3310,6 +4268,11 @@ static time_a_ui32_z_f128( ui32_to_f128M ); break; #endif +#ifdef FLOAT16 + case UI64_TO_F16: + time_a_ui64_z_f16( ui64_to_f16 ); + break; +#endif case UI64_TO_F32: time_a_ui64_z_f32( ui64_to_f32 ); break; @@ -3326,6 +4289,11 @@ static time_a_ui64_z_f128( ui64_to_f128M ); break; #endif +#ifdef FLOAT16 + case I32_TO_F16: + time_a_i32_z_f16( i32_to_f16 ); + break; +#endif case I32_TO_F32: time_a_i32_z_f32( i32_to_f32 ); break; @@ -3342,6 +4310,11 @@ static time_a_i32_z_f128( i32_to_f128M ); break; #endif +#ifdef FLOAT16 + case I64_TO_F16: + time_a_i64_z_f16( i64_to_f16 ); + break; +#endif case I64_TO_F32: time_a_i64_z_f32( i64_to_f32 ); break; @@ -3360,6 +4333,96 @@ static #endif /*-------------------------------------------------------------------- *--------------------------------------------------------------------*/ +#ifdef FLOAT16 + case F16_TO_UI32: + time_a_f16_z_ui32_rx( f16_to_ui32, roundingMode, exact ); + break; + case F16_TO_UI64: + time_a_f16_z_ui64_rx( f16_to_ui64, roundingMode, exact ); + break; + case F16_TO_I32: + time_a_f16_z_i32_rx( f16_to_i32, roundingMode, exact ); + break; + case F16_TO_I64: + time_a_f16_z_i64_rx( f16_to_i64, roundingMode, exact ); + break; + case F16_TO_UI32_R_MINMAG: + time_a_f16_z_ui32_x( f16_to_ui32_r_minMag, exact ); + break; + case F16_TO_UI64_R_MINMAG: + time_a_f16_z_ui64_x( f16_to_ui64_r_minMag, exact ); + break; + case F16_TO_I32_R_MINMAG: + time_a_f16_z_i32_x( f16_to_i32_r_minMag, exact ); + break; + case F16_TO_I64_R_MINMAG: + time_a_f16_z_i64_x( f16_to_i64_r_minMag, exact ); + break; + case F16_TO_F32: + time_a_f16_z_f32( f16_to_f32 ); + break; + case F16_TO_F64: + time_a_f16_z_f64( f16_to_f64 ); + break; +#ifdef EXTFLOAT80 + case F16_TO_EXTF80: + time_a_f16_z_extF80( f16_to_extF80M ); + break; +#endif +#ifdef FLOAT128 + case F16_TO_F128: + time_a_f16_z_f128( f16_to_f128M ); + break; +#endif + case F16_ROUNDTOINT: + time_az_f16_rx( f16_roundToInt, roundingMode, exact ); + break; + case F16_ADD: + function_abz_f16 = f16_add; + goto time_abz_f16; + case F16_SUB: + function_abz_f16 = f16_sub; + goto time_abz_f16; + case F16_MUL: + function_abz_f16 = f16_mul; + goto time_abz_f16; + case F16_DIV: + function_abz_f16 = f16_div; + goto time_abz_f16; + case F16_REM: + function_abz_f16 = f16_rem; + time_abz_f16: + time_abz_f16( function_abz_f16 ); + break; + case F16_MULADD: + time_abcz_f16( f16_mulAdd ); + break; + case F16_SQRT: + time_az_f16_pos( f16_sqrt ); + break; + case F16_EQ: + function_ab_f16_z_bool = f16_eq; + goto time_ab_f16_z_bool; + case F16_LE: + function_ab_f16_z_bool = f16_le; + goto time_ab_f16_z_bool; + case F16_LT: + function_ab_f16_z_bool = f16_lt; + goto time_ab_f16_z_bool; + case F16_EQ_SIGNALING: + function_ab_f16_z_bool = f16_eq_signaling; + goto time_ab_f16_z_bool; + case F16_LE_QUIET: + function_ab_f16_z_bool = f16_le_quiet; + goto time_ab_f16_z_bool; + case F16_LT_QUIET: + function_ab_f16_z_bool = f16_lt_quiet; + time_ab_f16_z_bool: + time_ab_f16_z_bool( function_ab_f16_z_bool ); + break; +#endif + /*-------------------------------------------------------------------- + *--------------------------------------------------------------------*/ case F32_TO_UI32: time_a_f32_z_ui32_rx( f32_to_ui32, roundingMode, exact ); break; @@ -3384,6 +4447,11 @@ static case F32_TO_I64_R_MINMAG: time_a_f32_z_i64_x( f32_to_i64_r_minMag, exact ); break; +#ifdef FLOAT16 + case F32_TO_F16: + time_a_f32_z_f16( f32_to_f16 ); + break; +#endif case F32_TO_F64: time_a_f32_z_f64( f32_to_f64 ); break; @@ -3469,6 +4537,11 @@ static case F64_TO_I64_R_MINMAG: time_a_f64_z_i64_x( f64_to_i64_r_minMag, exact ); break; +#ifdef FLOAT16 + case F64_TO_F16: + time_a_f64_z_f16( f64_to_f16 ); + break; +#endif case F64_TO_F32: time_a_f64_z_f32( f64_to_f32 ); break; @@ -3555,6 +4628,11 @@ static case EXTF80_TO_I64_R_MINMAG: time_a_extF80_z_i64_x( extF80M_to_i64_r_minMag, exact ); break; +#ifdef FLOAT16 + case EXTF80_TO_F16: + time_a_extF80_z_f16( extF80M_to_f16 ); + break; +#endif case EXTF80_TO_F32: time_a_extF80_z_f32( extF80M_to_f32 ); break; @@ -3637,6 +4715,11 @@ static case F128_TO_I64_R_MINMAG: time_a_f128_z_i64_x( f128M_to_i64_r_minMag, exact ); break; +#ifdef FLOAT16 + case F128_TO_F16: + time_a_f128_z_f16( f128M_to_f16 ); + break; +#endif case F128_TO_F32: time_a_f128_z_f32( f128M_to_f32 ); break; @@ -3702,14 +4785,14 @@ static enum { EXACT_FALSE = 1, EXACT_TRUE }; static - void - timeFunction( - int functionCode, - uint_fast8_t roundingPrecisionIn, - int roundingCodeIn, - int tininessCodeIn, - int exactCodeIn - ) +void + timeFunction( + int functionCode, + uint_fast8_t roundingPrecisionIn, + int roundingCodeIn, + int tininessCodeIn, + int exactCodeIn + ) { int functionAttribs, exactCode; uint_fast8_t roundingMode, tininessMode; @@ -3858,6 +4941,9 @@ int main( int argc, char *argv[] ) " i32 --Signed 32-bit integer.\n" " i64 --Signed 64-bit integer.\n" " <float>:\n" +#ifdef FLOAT16 +" f16 --Binary 16-bit floating-point (half-precision).\n" +#endif " f32 --Binary 32-bit floating-point (single-precision).\n" " f64 --Binary 64-bit floating-point (double-precision).\n" #ifdef EXTFLOAT80 @@ -3947,8 +5033,8 @@ int main( int argc, char *argv[] ) if ( ! numOperands || (functionInfos[functionCode].attribs - & (numOperands == 1) ? FUNC_ARG_UNARY - : FUNC_ARG_BINARY) + & ((numOperands == 1) ? FUNC_ARG_UNARY + : FUNC_ARG_BINARY)) ) { timeFunction( functionCode, diff --git a/source/uint128.c b/source/uint128.c index 779427f..e9b24e5 100644 --- a/source/uint128.c +++ b/source/uint128.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/uint128.h b/source/uint128.h index fefadbd..0f433bb 100644 --- a/source/uint128.h +++ b/source/uint128.h @@ -1,12 +1,12 @@ /*============================================================================ -This C header file is part of TestFloat, Release 3a, a package of programs for +This C header file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. -Copyright 2011, 2012, 2013, 2014 The Regents of the University of California. -All rights reserved. +Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of +California. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -47,6 +47,8 @@ struct uint128 { uint64_t v0, v64; }; struct uint128 { uint64_t v64, v0; }; #endif +#ifdef INLINE + INLINE bool eq128( struct uint128 a, struct uint128 b ) { return (a.v64 == b.v64) && (a.v0 == b.v0); } @@ -56,6 +58,14 @@ INLINE bool le128( struct uint128 a, struct uint128 b ) INLINE bool lt128( struct uint128 a, struct uint128 b ) { return (a.v64 < b.v64) || ((a.v64 == b.v64) && (a.v0 < b.v0)); } +#else + +bool eq128( struct uint128, struct uint128 ); +bool le128( struct uint128, struct uint128 ); +bool lt128( struct uint128, struct uint128 ); + +#endif + struct uint128 shortShiftLeft128( struct uint128, int ); struct uint128 shortShiftRight128( struct uint128, int ); struct uint128 shortShiftRightJam128( struct uint128, int ); diff --git a/source/uint128_inline.c b/source/uint128_inline.c new file mode 100644 index 0000000..4f5f60f --- /dev/null +++ b/source/uint128_inline.c @@ -0,0 +1,56 @@ + +/*============================================================================ + +This C header file is part of TestFloat, Release 3b, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of +California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions, and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=============================================================================*/ + +#include <stdbool.h> +#include <stdint.h> +#include "platform.h" + +#ifdef LITTLEENDIAN +struct uint128 { uint64_t v0, v64; }; +#else +struct uint128 { uint64_t v64, v0; }; +#endif + +bool eq128( struct uint128 a, struct uint128 b ) + { return (a.v64 == b.v64) && (a.v0 == b.v0); } + +bool le128( struct uint128 a, struct uint128 b ) + { return (a.v64 < b.v64) || ((a.v64 == b.v64) && (a.v0 <= b.v0)); } + +bool lt128( struct uint128 a, struct uint128 b ) + { return (a.v64 < b.v64) || ((a.v64 == b.v64) && (a.v0 < b.v0)); } + diff --git a/source/verCases.h b/source/verCases.h index ad7fd9a..941a0e5 100644 --- a/source/verCases.h +++ b/source/verCases.h @@ -1,12 +1,12 @@ /*============================================================================ -This C header file is part of TestFloat, Release 3a, a package of programs for +This C header file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. -Copyright 2011, 2012, 2013, 2014 The Regents of the University of California. -All rights reserved. +Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of +California. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -64,6 +64,27 @@ void verCases_exitWithStatus( void ); /*---------------------------------------------------------------------------- *----------------------------------------------------------------------------*/ +#ifdef INLINE + +#ifdef FLOAT16 + +INLINE bool f16_same( float16_t a, float16_t b ) +{ + union { uint16_t ui; float16_t f; } uA, uB; + uA.f = a; + uB.f = b; + return (uA.ui == uB.ui); +} + +INLINE bool f16_isNaN( float16_t a ) +{ + union { uint16_t ui; float16_t f; } uA; + uA.f = a; + return 0x7C00 < (uA.ui & 0x7FFF); +} + +#endif + INLINE bool f32_same( float32_t a, float32_t b ) { union { uint32_t ui; float32_t f; } uA, uB; @@ -136,6 +157,27 @@ INLINE bool f128M_isNaN( const float128_t *aPtr ) #endif +#else + +#ifdef FLOAT16 +bool f16_same( float16_t, float16_t ); +bool f16_isNaN( float16_t ); +#endif +bool f32_same( float32_t, float32_t ); +bool f32_isNaN( float32_t ); +bool f64_same( float64_t, float64_t ); +bool f64_isNaN( float64_t ); +#ifdef EXTFLOAT80 +bool extF80M_same( const extFloat80_t *, const extFloat80_t * ); +bool extF80M_isNaN( const extFloat80_t * ); +#endif +#ifdef FLOAT128 +bool f128M_same( const float128_t *, const float128_t * ); +bool f128M_isNaN( const float128_t * ); +#endif + +#endif + extern uint_fast32_t verCases_tenThousandsCount, verCases_errorCount; void verCases_writeTestsPerformed( int ); diff --git a/source/verCases_common.c b/source/verCases_common.c index 6a18b40..db8e588 100644 --- a/source/verCases_common.c +++ b/source/verCases_common.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/verCases_inline.c b/source/verCases_inline.c new file mode 100644 index 0000000..0cdc479 --- /dev/null +++ b/source/verCases_inline.c @@ -0,0 +1,134 @@ + +/*============================================================================ + +This C header file is part of TestFloat, Release 3b, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of +California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions, and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=============================================================================*/ + +#include <stdbool.h> +#include <stdint.h> +#include "platform.h" +#include "uint128.h" +#include "softfloat.h" + +#ifdef FLOAT16 + +bool f16_same( float16_t a, float16_t b ) +{ + union { uint16_t ui; float16_t f; } uA, uB; + uA.f = a; + uB.f = b; + return (uA.ui == uB.ui); +} + +bool f16_isNaN( float16_t a ) +{ + union { uint16_t ui; float16_t f; } uA; + uA.f = a; + return 0x7C00 < (uA.ui & 0x7FFF); +} + +#endif + +bool f32_same( float32_t a, float32_t b ) +{ + union { uint32_t ui; float32_t f; } uA, uB; + uA.f = a; + uB.f = b; + return (uA.ui == uB.ui); +} + +bool f32_isNaN( float32_t a ) +{ + union { uint32_t ui; float32_t f; } uA; + uA.f = a; + return 0x7F800000 < (uA.ui & 0x7FFFFFFF); +} + +bool f64_same( float64_t a, float64_t b ) +{ + union { uint64_t ui; float64_t f; } uA, uB; + uA.f = a; + uB.f = b; + return (uA.ui == uB.ui); +} + +bool f64_isNaN( float64_t a ) +{ + union { uint64_t ui; float64_t f; } uA; + uA.f = a; + return + UINT64_C( 0x7FF0000000000000 ) + < (uA.ui & UINT64_C( 0x7FFFFFFFFFFFFFFF )); +} + +#ifdef EXTFLOAT80 + +bool extF80M_same( const extFloat80_t *aPtr, const extFloat80_t *bPtr ) +{ + const struct extFloat80M *aSPtr = (const struct extFloat80M *) aPtr; + const struct extFloat80M *bSPtr = (const struct extFloat80M *) bPtr; + return + (aSPtr->signExp == bSPtr->signExp) && (aSPtr->signif == bSPtr->signif); +} + +bool extF80M_isNaN( const extFloat80_t *aPtr ) +{ + const struct extFloat80M *aSPtr = (const struct extFloat80M *) aPtr; + return + ((aSPtr->signExp & 0x7FFF) == 0x7FFF) + && (aSPtr->signif & UINT64_C( 0x7FFFFFFFFFFFFFFF )); +} + +#endif + +#ifdef FLOAT128 + +bool f128M_same( const float128_t *aPtr, const float128_t *bPtr ) +{ + const struct uint128 *uiAPtr = (const struct uint128 *) aPtr; + const struct uint128 *uiBPtr = (const struct uint128 *) bPtr; + return (uiAPtr->v64 == uiBPtr->v64) && (uiAPtr->v0 == uiBPtr->v0); +} + +bool f128M_isNaN( const float128_t *aPtr ) +{ + const struct uint128 *uiAPtr = (const struct uint128 *) aPtr; + uint_fast64_t absA64 = uiAPtr->v64 & UINT64_C( 0x7FFFFFFFFFFFFFFF ); + return + (UINT64_C( 0x7FFF000000000000 ) < absA64) + || ((absA64 == UINT64_C( 0x7FFF000000000000 )) && uiAPtr->v0); +} + +#endif + diff --git a/source/verCases_writeFunctionName.c b/source/verCases_writeFunctionName.c index 4c225d0..93c91ac 100644 --- a/source/verCases_writeFunctionName.c +++ b/source/verCases_writeFunctionName.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/verLoops.c b/source/verLoops.c index d5b78d6..ff61436 100644 --- a/source/verLoops.c +++ b/source/verLoops.c @@ -1,12 +1,12 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. -Copyright 2011, 2012, 2013, 2014 The Regents of the University of California. -All rights reserved. +Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of +California. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -114,6 +114,19 @@ static void readVerInput_i64( int_fast64_t *aPtr ) } +#ifdef FLOAT16 + +static void readVerInput_f16( float16_t *aPtr ) +{ + union { uint16_t ui; float16_t f; } uA; + + if ( ! readHex_ui16( &uA.ui, ' ' ) ) failFromBadInput(); + *aPtr = uA.f; + +} + +#endif + static void readVerInput_f32( float32_t *aPtr ) { union { uint32_t ui; float32_t f; } uA; @@ -187,6 +200,55 @@ static void readVerInput_flags( uint_fast8_t *flagsPtr ) /*---------------------------------------------------------------------------- *----------------------------------------------------------------------------*/ + +#ifdef FLOAT16 + +void ver_a_ui32_z_f16( float16_t trueFunction( uint32_t ) ) +{ + int count; + uint_fast32_t a; + float16_t subjZ; + uint_fast8_t subjFlags; + float16_t trueZ; + uint_fast8_t trueFlags; + + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! atEndOfInput() ) { + readVerInput_ui32( &a ); + readVerInput_f16( &subjZ ); + readVerInput_flags( &subjFlags ); + *verLoops_trueFlagsPtr = 0; + trueZ = trueFunction( a ); + trueFlags = *verLoops_trueFlagsPtr; + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f16_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + verCases_checkNaNs + || ! f16_isNaN( trueZ ) + || ! f16_isNaN( subjZ ) + || f16_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_ui32( a, " " ); + writeCase_z_f16( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + void ver_a_ui32_z_f32( float32_t trueFunction( uint32_t ) ) { int count; @@ -373,6 +435,55 @@ void ver_a_ui32_z_f128( void trueFunction( uint32_t, float128_t * ) ) /*---------------------------------------------------------------------------- *----------------------------------------------------------------------------*/ + +#ifdef FLOAT16 + +void ver_a_ui64_z_f16( float16_t trueFunction( uint64_t ) ) +{ + int count; + uint_fast64_t a; + float16_t subjZ; + uint_fast8_t subjFlags; + float16_t trueZ; + uint_fast8_t trueFlags; + + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! atEndOfInput() ) { + readVerInput_ui64( &a ); + readVerInput_f16( &subjZ ); + readVerInput_flags( &subjFlags ); + *verLoops_trueFlagsPtr = 0; + trueZ = trueFunction( a ); + trueFlags = *verLoops_trueFlagsPtr; + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f16_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + verCases_checkNaNs + || ! f16_isNaN( trueZ ) + || ! f16_isNaN( subjZ ) + || f16_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_ui64( a, " " ); + writeCase_z_f16( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + void ver_a_ui64_z_f32( float32_t trueFunction( uint64_t ) ) { int count; @@ -559,6 +670,55 @@ void ver_a_ui64_z_f128( void trueFunction( uint64_t, float128_t * ) ) /*---------------------------------------------------------------------------- *----------------------------------------------------------------------------*/ + +#ifdef FLOAT16 + +void ver_a_i32_z_f16( float16_t trueFunction( int32_t ) ) +{ + int count; + int_fast32_t a; + float16_t subjZ; + uint_fast8_t subjFlags; + float16_t trueZ; + uint_fast8_t trueFlags; + + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! atEndOfInput() ) { + readVerInput_i32( &a ); + readVerInput_f16( &subjZ ); + readVerInput_flags( &subjFlags ); + *verLoops_trueFlagsPtr = 0; + trueZ = trueFunction( a ); + trueFlags = *verLoops_trueFlagsPtr; + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f16_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + verCases_checkNaNs + || ! f16_isNaN( trueZ ) + || ! f16_isNaN( subjZ ) + || f16_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_i32( a, " " ); + writeCase_z_f16( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + void ver_a_i32_z_f32( float32_t trueFunction( int32_t ) ) { int count; @@ -745,6 +905,55 @@ void ver_a_i32_z_f128( void trueFunction( int32_t, float128_t * ) ) /*---------------------------------------------------------------------------- *----------------------------------------------------------------------------*/ + +#ifdef FLOAT16 + +void ver_a_i64_z_f16( float16_t trueFunction( int64_t ) ) +{ + int count; + int_fast64_t a; + float16_t subjZ; + uint_fast8_t subjFlags; + float16_t trueZ; + uint_fast8_t trueFlags; + + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! atEndOfInput() ) { + readVerInput_i64( &a ); + readVerInput_f16( &subjZ ); + readVerInput_flags( &subjFlags ); + *verLoops_trueFlagsPtr = 0; + trueZ = trueFunction( a ); + trueFlags = *verLoops_trueFlagsPtr; + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f16_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + verCases_checkNaNs + || ! f16_isNaN( trueZ ) + || ! f16_isNaN( subjZ ) + || f16_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_i64( a, " " ); + writeCase_z_f16( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + void ver_a_i64_z_f32( float32_t trueFunction( int64_t ) ) { int count; @@ -931,6 +1140,852 @@ void ver_a_i64_z_f128( void trueFunction( int64_t, float128_t * ) ) /*---------------------------------------------------------------------------- *----------------------------------------------------------------------------*/ + +#ifdef FLOAT16 + +void + ver_a_f16_z_ui32_rx( + uint_fast32_t trueFunction( float16_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int count; + float16_t a; + uint_fast32_t subjZ; + uint_fast8_t subjFlags; + uint_fast32_t trueZ; + uint_fast8_t trueFlags; + + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! atEndOfInput() ) { + readVerInput_f16( &a ); + readVerInput_ui32( &subjZ ); + readVerInput_flags( &subjFlags ); + *verLoops_trueFlagsPtr = 0; + trueZ = trueFunction( a, roundingMode, exact ); + trueFlags = *verLoops_trueFlagsPtr; + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( ! verCases_checkNaNs && f16_isSignalingNaN( a ) ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != 0xFFFFFFFF) + || (subjZ != 0xFFFFFFFF) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f16( a, " " ); + writeCase_z_ui32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +void + ver_a_f16_z_ui64_rx( + uint_fast64_t trueFunction( float16_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int count; + float16_t a; + uint_fast64_t subjZ; + uint_fast8_t subjFlags; + uint_fast64_t trueZ; + uint_fast8_t trueFlags; + + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! atEndOfInput() ) { + readVerInput_f16( &a ); + readVerInput_ui64( &subjZ ); + readVerInput_flags( &subjFlags ); + *verLoops_trueFlagsPtr = 0; + trueZ = trueFunction( a, roundingMode, exact ); + trueFlags = *verLoops_trueFlagsPtr; + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( ! verCases_checkNaNs && f16_isSignalingNaN( a ) ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != UINT64_C( 0xFFFFFFFFFFFFFFFF )) + || (subjZ != UINT64_C( 0xFFFFFFFFFFFFFFFF )) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f16( a, " " ); + writeCase_z_ui64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +void + ver_a_f16_z_i32_rx( + int_fast32_t trueFunction( float16_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int count; + float16_t a; + int_fast32_t subjZ; + uint_fast8_t subjFlags; + int_fast32_t trueZ; + uint_fast8_t trueFlags; + + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! atEndOfInput() ) { + readVerInput_f16( &a ); + readVerInput_i32( &subjZ ); + readVerInput_flags( &subjFlags ); + *verLoops_trueFlagsPtr = 0; + trueZ = trueFunction( a, roundingMode, exact ); + trueFlags = *verLoops_trueFlagsPtr; + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( ! verCases_checkNaNs && f16_isSignalingNaN( a ) ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != 0x7FFFFFFF) + || ((subjZ != 0x7FFFFFFF) && (subjZ != -0x7FFFFFFF - 1)) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f16( a, " " ); + writeCase_z_i32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +void + ver_a_f16_z_i64_rx( + int_fast64_t trueFunction( float16_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int count; + float16_t a; + int_fast64_t subjZ; + uint_fast8_t subjFlags; + int_fast64_t trueZ; + uint_fast8_t trueFlags; + + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! atEndOfInput() ) { + readVerInput_f16( &a ); + readVerInput_i64( &subjZ ); + readVerInput_flags( &subjFlags ); + *verLoops_trueFlagsPtr = 0; + trueZ = trueFunction( a, roundingMode, exact ); + trueFlags = *verLoops_trueFlagsPtr; + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( ! verCases_checkNaNs && f16_isSignalingNaN( a ) ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != INT64_C( 0x7FFFFFFFFFFFFFFF )) + || ((subjZ != INT64_C( 0x7FFFFFFFFFFFFFFF )) + && (subjZ != -INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1)) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f16( a, " " ); + writeCase_z_i64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +void + ver_a_f16_z_ui32_x( + uint_fast32_t trueFunction( float16_t, bool ), bool exact ) +{ + int count; + float16_t a; + uint_fast32_t subjZ; + uint_fast8_t subjFlags; + uint_fast32_t trueZ; + uint_fast8_t trueFlags; + + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! atEndOfInput() ) { + readVerInput_f16( &a ); + readVerInput_ui32( &subjZ ); + readVerInput_flags( &subjFlags ); + *verLoops_trueFlagsPtr = 0; + trueZ = trueFunction( a, exact ); + trueFlags = *verLoops_trueFlagsPtr; + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( ! verCases_checkNaNs && f16_isSignalingNaN( a ) ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != 0xFFFFFFFF) + || (subjZ != 0xFFFFFFFF) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f16( a, " " ); + writeCase_z_ui32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +void + ver_a_f16_z_ui64_x( + uint_fast64_t trueFunction( float16_t, bool ), bool exact ) +{ + int count; + float16_t a; + uint_fast64_t subjZ; + uint_fast8_t subjFlags; + uint_fast64_t trueZ; + uint_fast8_t trueFlags; + + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! atEndOfInput() ) { + readVerInput_f16( &a ); + readVerInput_ui64( &subjZ ); + readVerInput_flags( &subjFlags ); + *verLoops_trueFlagsPtr = 0; + trueZ = trueFunction( a, exact ); + trueFlags = *verLoops_trueFlagsPtr; + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( ! verCases_checkNaNs && f16_isSignalingNaN( a ) ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != UINT64_C( 0xFFFFFFFFFFFFFFFF )) + || (subjZ != UINT64_C( 0xFFFFFFFFFFFFFFFF )) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f16( a, " " ); + writeCase_z_ui64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +void + ver_a_f16_z_i32_x( + int_fast32_t trueFunction( float16_t, bool ), bool exact ) +{ + int count; + float16_t a; + int_fast32_t subjZ; + uint_fast8_t subjFlags; + int_fast32_t trueZ; + uint_fast8_t trueFlags; + + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! atEndOfInput() ) { + readVerInput_f16( &a ); + readVerInput_i32( &subjZ ); + readVerInput_flags( &subjFlags ); + *verLoops_trueFlagsPtr = 0; + trueZ = trueFunction( a, exact ); + trueFlags = *verLoops_trueFlagsPtr; + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( ! verCases_checkNaNs && f16_isSignalingNaN( a ) ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != 0x7FFFFFFF) + || ((subjZ != 0x7FFFFFFF) && (subjZ != -0x7FFFFFFF - 1)) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f16( a, " " ); + writeCase_z_i32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +void + ver_a_f16_z_i64_x( + int_fast64_t trueFunction( float16_t, bool ), bool exact ) +{ + int count; + float16_t a; + int_fast64_t subjZ; + uint_fast8_t subjFlags; + int_fast64_t trueZ; + uint_fast8_t trueFlags; + + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! atEndOfInput() ) { + readVerInput_f16( &a ); + readVerInput_i64( &subjZ ); + readVerInput_flags( &subjFlags ); + *verLoops_trueFlagsPtr = 0; + trueZ = trueFunction( a, exact ); + trueFlags = *verLoops_trueFlagsPtr; + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( ! verCases_checkNaNs && f16_isSignalingNaN( a ) ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + (trueZ != INT64_C( 0x7FFFFFFFFFFFFFFF )) + || ((subjZ != INT64_C( 0x7FFFFFFFFFFFFFFF )) + && (subjZ != -INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1)) + || (trueFlags != softfloat_flag_invalid) + || (subjFlags != softfloat_flag_invalid) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f16( a, " " ); + writeCase_z_i64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +void ver_a_f16_z_f32( float32_t trueFunction( float16_t ) ) +{ + int count; + float16_t a; + float32_t subjZ; + uint_fast8_t subjFlags; + float32_t trueZ; + uint_fast8_t trueFlags; + + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! atEndOfInput() ) { + readVerInput_f16( &a ); + readVerInput_f32( &subjZ ); + readVerInput_flags( &subjFlags ); + *verLoops_trueFlagsPtr = 0; + trueZ = trueFunction( a ); + trueFlags = *verLoops_trueFlagsPtr; + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f32_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( ! verCases_checkNaNs && f16_isSignalingNaN( a ) ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f32_isNaN( trueZ ) + || ! f32_isNaN( subjZ ) + || f32_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f16( a, " " ); + writeCase_z_f32( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +void ver_a_f16_z_f64( float64_t trueFunction( float16_t ) ) +{ + int count; + float16_t a; + float64_t subjZ; + uint_fast8_t subjFlags; + float64_t trueZ; + uint_fast8_t trueFlags; + + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! atEndOfInput() ) { + readVerInput_f16( &a ); + readVerInput_f64( &subjZ ); + readVerInput_flags( &subjFlags ); + *verLoops_trueFlagsPtr = 0; + trueZ = trueFunction( a ); + trueFlags = *verLoops_trueFlagsPtr; + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f64_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( ! verCases_checkNaNs && f16_isSignalingNaN( a ) ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f64_isNaN( trueZ ) + || ! f64_isNaN( subjZ ) + || f64_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f16( a, " " ); + writeCase_z_f64( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#ifdef EXTFLOAT80 + +void ver_a_f16_z_extF80( void trueFunction( float16_t, extFloat80_t * ) ) +{ + int count; + float16_t a; + extFloat80_t subjZ; + uint_fast8_t subjFlags; + extFloat80_t trueZ; + uint_fast8_t trueFlags; + + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! atEndOfInput() ) { + readVerInput_f16( &a ); + readVerInput_extF80( &subjZ ); + readVerInput_flags( &subjFlags ); + *verLoops_trueFlagsPtr = 0; + trueFunction( a, &trueZ ); + trueFlags = *verLoops_trueFlagsPtr; + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! extF80M_same( &trueZ, &subjZ ) || (trueFlags != subjFlags) ) { + if ( ! verCases_checkNaNs && f16_isSignalingNaN( a ) ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! extF80M_isNaN( &trueZ ) + || ! extF80M_isNaN( &subjZ ) + || extF80M_isSignalingNaN( &subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f16( a, " " ); + writeCase_z_extF80M( &trueZ, trueFlags, &subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + +#ifdef FLOAT128 + +void ver_a_f16_z_f128( void trueFunction( float16_t, float128_t * ) ) +{ + int count; + float16_t a; + float128_t subjZ; + uint_fast8_t subjFlags; + float128_t trueZ; + uint_fast8_t trueFlags; + + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! atEndOfInput() ) { + readVerInput_f16( &a ); + readVerInput_f128( &subjZ ); + readVerInput_flags( &subjFlags ); + *verLoops_trueFlagsPtr = 0; + trueFunction( a, &trueZ ); + trueFlags = *verLoops_trueFlagsPtr; + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f128M_same( &trueZ, &subjZ ) || (trueFlags != subjFlags) ) { + if ( ! verCases_checkNaNs && f16_isSignalingNaN( a ) ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f128M_isNaN( &trueZ ) + || ! f128M_isNaN( &subjZ ) + || f128M_isSignalingNaN( &subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f16( a, " " ); + writeCase_z_f128M( &trueZ, trueFlags, &subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + +void ver_az_f16( float16_t trueFunction( float16_t ) ) +{ + int count; + float16_t a, subjZ; + uint_fast8_t subjFlags; + float16_t trueZ; + uint_fast8_t trueFlags; + + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! atEndOfInput() ) { + readVerInput_f16( &a ); + readVerInput_f16( &subjZ ); + readVerInput_flags( &subjFlags ); + *verLoops_trueFlagsPtr = 0; + trueZ = trueFunction( a ); + trueFlags = *verLoops_trueFlagsPtr; + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f16_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( ! verCases_checkNaNs && f16_isSignalingNaN( a ) ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f16_isNaN( trueZ ) + || ! f16_isNaN( subjZ ) + || f16_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f16( a, " " ); + writeCase_z_f16( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +void + ver_az_f16_rx( + float16_t trueFunction( float16_t, uint_fast8_t, bool ), + uint_fast8_t roundingMode, + bool exact + ) +{ + int count; + float16_t a, subjZ; + uint_fast8_t subjFlags; + float16_t trueZ; + uint_fast8_t trueFlags; + + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! atEndOfInput() ) { + readVerInput_f16( &a ); + readVerInput_f16( &subjZ ); + readVerInput_flags( &subjFlags ); + *verLoops_trueFlagsPtr = 0; + trueZ = trueFunction( a, roundingMode, exact ); + trueFlags = *verLoops_trueFlagsPtr; + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f16_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( ! verCases_checkNaNs && f16_isSignalingNaN( a ) ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f16_isNaN( trueZ ) + || ! f16_isNaN( subjZ ) + || f16_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f16( a, " " ); + writeCase_z_f16( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +void ver_abz_f16( float16_t trueFunction( float16_t, float16_t ) ) +{ + int count; + float16_t a, b, subjZ; + uint_fast8_t subjFlags; + float16_t trueZ; + uint_fast8_t trueFlags; + + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! atEndOfInput() ) { + readVerInput_f16( &a ); + readVerInput_f16( &b ); + readVerInput_f16( &subjZ ); + readVerInput_flags( &subjFlags ); + *verLoops_trueFlagsPtr = 0; + trueZ = trueFunction( a, b ); + trueFlags = *verLoops_trueFlagsPtr; + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f16_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && (f16_isSignalingNaN( a ) || f16_isSignalingNaN( b )) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f16_isNaN( trueZ ) + || ! f16_isNaN( subjZ ) + || f16_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_ab_f16( a, b, " " ); + writeCase_z_f16( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +void ver_abcz_f16( float16_t trueFunction( float16_t, float16_t, float16_t ) ) +{ + int count; + float16_t a, b, c, subjZ; + uint_fast8_t subjFlags; + float16_t trueZ; + uint_fast8_t trueFlags; + + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! atEndOfInput() ) { + readVerInput_f16( &a ); + readVerInput_f16( &b ); + readVerInput_f16( &c ); + readVerInput_f16( &subjZ ); + readVerInput_flags( &subjFlags ); + *verLoops_trueFlagsPtr = 0; + trueZ = trueFunction( a, b, c ); + trueFlags = *verLoops_trueFlagsPtr; + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f16_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && (f16_isSignalingNaN( a ) || f16_isSignalingNaN( b ) + || f16_isSignalingNaN( c )) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f16_isNaN( trueZ ) + || ! f16_isNaN( subjZ ) + || f16_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_abc_f16( a, b, c, "\n\t" ); + writeCase_z_f16( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +void ver_ab_f16_z_bool( bool trueFunction( float16_t, float16_t ) ) +{ + int count; + float16_t a, b; + bool subjZ; + uint_fast8_t subjFlags; + bool trueZ; + uint_fast8_t trueFlags; + + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! atEndOfInput() ) { + readVerInput_f16( &a ); + readVerInput_f16( &b ); + readVerInput_bool( &subjZ ); + readVerInput_flags( &subjFlags ); + *verLoops_trueFlagsPtr = 0; + trueZ = trueFunction( a, b ); + trueFlags = *verLoops_trueFlagsPtr; + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + if ( + ! verCases_checkNaNs + && (f16_isSignalingNaN( a ) || f16_isSignalingNaN( b )) + ) { + trueFlags |= softfloat_flag_invalid; + } + if ( (trueZ != subjZ) || (trueFlags != subjFlags) ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_ab_f16( a, b, " " ); + writeCase_z_bool( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ + void ver_a_f32_z_ui32_rx( uint_fast32_t trueFunction( float32_t, uint_fast8_t, bool ), @@ -1329,6 +2384,57 @@ void } +#ifdef FLOAT16 + +void ver_a_f32_z_f16( float16_t trueFunction( float32_t ) ) +{ + int count; + float32_t a; + float16_t subjZ; + uint_fast8_t subjFlags; + float16_t trueZ; + uint_fast8_t trueFlags; + + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! atEndOfInput() ) { + readVerInput_f32( &a ); + readVerInput_f16( &subjZ ); + readVerInput_flags( &subjFlags ); + *verLoops_trueFlagsPtr = 0; + trueZ = trueFunction( a ); + trueFlags = *verLoops_trueFlagsPtr; + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f16_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( ! verCases_checkNaNs && f32_isSignalingNaN( a ) ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f16_isNaN( trueZ ) + || ! f16_isNaN( subjZ ) + || f16_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f32( a, " " ); + writeCase_z_f16( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + void ver_a_f32_z_f64( float64_t trueFunction( float32_t ) ) { int count; @@ -1724,6 +2830,7 @@ void ver_ab_f32_z_bool( bool trueFunction( float32_t, float32_t ) ) /*---------------------------------------------------------------------------- *----------------------------------------------------------------------------*/ + void ver_a_f64_z_ui32_rx( uint_fast32_t trueFunction( float64_t, uint_fast8_t, bool ), @@ -2122,6 +3229,57 @@ void } +#ifdef FLOAT16 + +void ver_a_f64_z_f16( float16_t trueFunction( float64_t ) ) +{ + int count; + float64_t a; + float16_t subjZ; + uint_fast8_t subjFlags; + float16_t trueZ; + uint_fast8_t trueFlags; + + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! atEndOfInput() ) { + readVerInput_f64( &a ); + readVerInput_f16( &subjZ ); + readVerInput_flags( &subjFlags ); + *verLoops_trueFlagsPtr = 0; + trueZ = trueFunction( a ); + trueFlags = *verLoops_trueFlagsPtr; + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f16_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( ! verCases_checkNaNs && f64_isSignalingNaN( a ) ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f16_isNaN( trueZ ) + || ! f16_isNaN( subjZ ) + || f16_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f64( a, " " ); + writeCase_z_f16( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + void ver_a_f64_z_f32( float32_t trueFunction( float64_t ) ) { int count; @@ -2517,6 +3675,7 @@ void ver_ab_f64_z_bool( bool trueFunction( float64_t, float64_t ) ) /*---------------------------------------------------------------------------- *----------------------------------------------------------------------------*/ + #ifdef EXTFLOAT80 void @@ -2917,6 +4076,57 @@ void } +#ifdef FLOAT16 + +void ver_a_extF80_z_f16( float16_t trueFunction( const extFloat80_t * ) ) +{ + int count; + extFloat80_t a; + float16_t subjZ; + uint_fast8_t subjFlags; + float16_t trueZ; + uint_fast8_t trueFlags; + + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! atEndOfInput() ) { + readVerInput_extF80( &a ); + readVerInput_f16( &subjZ ); + readVerInput_flags( &subjFlags ); + *verLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &a ); + trueFlags = *verLoops_trueFlagsPtr; + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f16_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( ! verCases_checkNaNs && extF80M_isSignalingNaN( &a ) ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f16_isNaN( trueZ ) + || ! f16_isNaN( subjZ ) + || f16_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_extF80M( &a, "\n\t" ); + writeCase_z_f16( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + void ver_a_extF80_z_f32( float32_t trueFunction( const extFloat80_t * ) ) { int count; @@ -3207,7 +4417,7 @@ void ) { ++verCases_errorCount; verCases_writeErrorFound( 10000 - count ); - writeCase_ab_extF80M( &a, &b, "\n\t" ); + writeCase_ab_extF80M( &a, &b, " " ); writeCase_z_extF80M( &trueZ, trueFlags, &subjZ, subjFlags ); if ( verCases_errorCount == verCases_maxErrorCount ) break; } @@ -3332,6 +4542,7 @@ void /*---------------------------------------------------------------------------- *----------------------------------------------------------------------------*/ + #ifdef FLOAT128 void @@ -3732,6 +4943,57 @@ void } +#ifdef FLOAT16 + +void ver_a_f128_z_f16( float16_t trueFunction( const float128_t * ) ) +{ + int count; + float128_t a; + float16_t subjZ; + uint_fast8_t subjFlags; + float16_t trueZ; + uint_fast8_t trueFlags; + + verCases_errorCount = 0; + verCases_tenThousandsCount = 0; + count = 10000; + while ( ! atEndOfInput() ) { + readVerInput_f128( &a ); + readVerInput_f16( &subjZ ); + readVerInput_flags( &subjFlags ); + *verLoops_trueFlagsPtr = 0; + trueZ = trueFunction( &a ); + trueFlags = *verLoops_trueFlagsPtr; + --count; + if ( ! count ) { + verCases_perTenThousand(); + count = 10000; + } + if ( ! f16_same( trueZ, subjZ ) || (trueFlags != subjFlags) ) { + if ( ! verCases_checkNaNs && f128M_isSignalingNaN( &a ) ) { + trueFlags |= softfloat_flag_invalid; + } + if ( + verCases_checkNaNs + || ! f16_isNaN( trueZ ) + || ! f16_isNaN( subjZ ) + || f16_isSignalingNaN( subjZ ) + || (trueFlags != subjFlags) + ) { + ++verCases_errorCount; + verCases_writeErrorFound( 10000 - count ); + writeCase_a_f128M( &a, "\n\t" ); + writeCase_z_f16( trueZ, trueFlags, subjZ, subjFlags ); + if ( verCases_errorCount == verCases_maxErrorCount ) break; + } + } + } + verCases_writeTestsPerformed( 10000 - count ); + +} + +#endif + void ver_a_f128_z_f32( float32_t trueFunction( const float128_t * ) ) { int count; diff --git a/source/verLoops.h b/source/verLoops.h index 324a250..347bda3 100644 --- a/source/verLoops.h +++ b/source/verLoops.h @@ -1,12 +1,12 @@ /*============================================================================ -This C header file is part of TestFloat, Release 3a, a package of programs for +This C header file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. -Copyright 2011, 2012, 2013, 2014 The Regents of the University of California. -All rights reserved. +Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of +California. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -41,6 +41,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. extern uint_fast8_t *verLoops_trueFlagsPtr; +#ifdef FLOAT16 +void ver_a_ui32_z_f16( float16_t ( uint32_t ) ); +#endif void ver_a_ui32_z_f32( float32_t ( uint32_t ) ); void ver_a_ui32_z_f64( float64_t ( uint32_t ) ); #ifdef EXTFLOAT80 @@ -49,6 +52,9 @@ void ver_a_ui32_z_extF80( void ( uint32_t, extFloat80_t * ) ); #ifdef FLOAT128 void ver_a_ui32_z_f128( void ( uint32_t, float128_t * ) ); #endif +#ifdef FLOAT16 +void ver_a_ui64_z_f16( float16_t ( uint64_t ) ); +#endif void ver_a_ui64_z_f32( float32_t ( uint64_t ) ); void ver_a_ui64_z_f64( float64_t ( uint64_t ) ); #ifdef EXTFLOAT80 @@ -57,6 +63,9 @@ void ver_a_ui64_z_extF80( void ( uint64_t, extFloat80_t * ) ); #ifdef FLOAT128 void ver_a_ui64_z_f128( void ( uint64_t, float128_t * ) ); #endif +#ifdef FLOAT16 +void ver_a_i32_z_f16( float16_t ( int32_t ) ); +#endif void ver_a_i32_z_f32( float32_t ( int32_t ) ); void ver_a_i32_z_f64( float64_t ( int32_t ) ); #ifdef EXTFLOAT80 @@ -65,6 +74,9 @@ void ver_a_i32_z_extF80( void ( int32_t, extFloat80_t * ) ); #ifdef FLOAT128 void ver_a_i32_z_f128( void ( int32_t, float128_t * ) ); #endif +#ifdef FLOAT16 +void ver_a_i64_z_f16( float16_t ( int64_t ) ); +#endif void ver_a_i64_z_f32( float32_t ( int64_t ) ); void ver_a_i64_z_f64( float64_t ( int64_t ) ); #ifdef EXTFLOAT80 @@ -74,6 +86,40 @@ void ver_a_i64_z_extF80( void ( int64_t, extFloat80_t * ) ); void ver_a_i64_z_f128( void ( int64_t, float128_t * ) ); #endif +#ifdef FLOAT16 +void + ver_a_f16_z_ui32_rx( + uint_fast32_t ( float16_t, uint_fast8_t, bool ), uint_fast8_t, bool ); +void + ver_a_f16_z_ui64_rx( + uint_fast64_t ( float16_t, uint_fast8_t, bool ), uint_fast8_t, bool ); +void + ver_a_f16_z_i32_rx( + int_fast32_t ( float16_t, uint_fast8_t, bool ), uint_fast8_t, bool ); +void + ver_a_f16_z_i64_rx( + int_fast64_t ( float16_t, uint_fast8_t, bool ), uint_fast8_t, bool ); +void ver_a_f16_z_ui32_x( uint_fast32_t ( float16_t, bool ), bool ); +void ver_a_f16_z_ui64_x( uint_fast64_t ( float16_t, bool ), bool ); +void ver_a_f16_z_i32_x( int_fast32_t ( float16_t, bool ), bool ); +void ver_a_f16_z_i64_x( int_fast64_t ( float16_t, bool ), bool ); +void ver_a_f16_z_f32( float32_t ( float16_t ) ); +void ver_a_f16_z_f64( float64_t ( float16_t ) ); +#ifdef EXTFLOAT80 +void ver_a_f16_z_extF80( void ( float16_t, extFloat80_t * ) ); +#endif +#ifdef FLOAT128 +void ver_a_f16_z_f128( void ( float16_t, float128_t * ) ); +#endif +void ver_az_f16( float16_t ( float16_t ) ); +void + ver_az_f16_rx( + float16_t ( float16_t, uint_fast8_t, bool ), uint_fast8_t, bool ); +void ver_abz_f16( float16_t ( float16_t, float16_t ) ); +void ver_abcz_f16( float16_t ( float16_t, float16_t, float16_t ) ); +void ver_ab_f16_z_bool( bool ( float16_t, float16_t ) ); +#endif + void ver_a_f32_z_ui32_rx( uint_fast32_t ( float32_t, uint_fast8_t, bool ), uint_fast8_t, bool ); @@ -90,6 +136,9 @@ void ver_a_f32_z_ui32_x( uint_fast32_t ( float32_t, bool ), bool ); void ver_a_f32_z_ui64_x( uint_fast64_t ( float32_t, bool ), bool ); void ver_a_f32_z_i32_x( int_fast32_t ( float32_t, bool ), bool ); void ver_a_f32_z_i64_x( int_fast64_t ( float32_t, bool ), bool ); +#ifdef FLOAT16 +void ver_a_f32_z_f16( float16_t ( float32_t ) ); +#endif void ver_a_f32_z_f64( float64_t ( float32_t ) ); #ifdef EXTFLOAT80 void ver_a_f32_z_extF80( void ( float32_t, extFloat80_t * ) ); @@ -121,6 +170,9 @@ void ver_a_f64_z_ui32_x( uint_fast32_t ( float64_t, bool ), bool ); void ver_a_f64_z_ui64_x( uint_fast64_t ( float64_t, bool ), bool ); void ver_a_f64_z_i32_x( int_fast32_t ( float64_t, bool ), bool ); void ver_a_f64_z_i64_x( int_fast64_t ( float64_t, bool ), bool ); +#ifdef FLOAT16 +void ver_a_f64_z_f16( float16_t ( float64_t ) ); +#endif void ver_a_f64_z_f32( float32_t ( float64_t ) ); #ifdef EXTFLOAT80 void ver_a_f64_z_extF80( void ( float64_t, extFloat80_t * ) ); @@ -167,6 +219,9 @@ void ver_a_extF80_z_ui64_x( uint_fast64_t ( const extFloat80_t *, bool ), bool ); void ver_a_extF80_z_i32_x( int_fast32_t ( const extFloat80_t *, bool ), bool ); void ver_a_extF80_z_i64_x( int_fast64_t ( const extFloat80_t *, bool ), bool ); +#ifdef FLOAT16 +void ver_a_extF80_z_f16( float16_t ( const extFloat80_t * ) ); +#endif void ver_a_extF80_z_f32( float32_t ( const extFloat80_t * ) ); void ver_a_extF80_z_f64( float64_t ( const extFloat80_t * ) ); #ifdef FLOAT128 @@ -225,6 +280,9 @@ void ver_a_f128_z_ui32_x( uint_fast32_t ( const float128_t *, bool ), bool ); void ver_a_f128_z_ui64_x( uint_fast64_t ( const float128_t *, bool ), bool ); void ver_a_f128_z_i32_x( int_fast32_t ( const float128_t *, bool ), bool ); void ver_a_f128_z_i64_x( int_fast64_t ( const float128_t *, bool ), bool ); +#ifdef FLOAT16 +void ver_a_f128_z_f16( float16_t ( const float128_t * ) ); +#endif void ver_a_f128_z_f32( float32_t ( const float128_t * ) ); void ver_a_f128_z_f64( float64_t ( const float128_t * ) ); #ifdef EXTFLOAT80 diff --git a/source/writeCase.h b/source/writeCase.h index de9005c..f8eb025 100644 --- a/source/writeCase.h +++ b/source/writeCase.h @@ -1,12 +1,12 @@ /*============================================================================ -This C header file is part of TestFloat, Release 3a, a package of programs for +This C header file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. -Copyright 2011, 2012, 2013, 2014 The Regents of the University of California. -All rights reserved. +Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of +California. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -43,6 +43,11 @@ void writeCase_a_ui32( uint_fast32_t, const char * ); void writeCase_a_ui64( uint_fast64_t, const char * ); #define writeCase_a_i32 writeCase_a_ui32 #define writeCase_a_i64 writeCase_a_ui64 +#ifdef FLOAT16 +void writeCase_a_f16( float16_t, const char * ); +void writeCase_ab_f16( float16_t, float16_t, const char * ); +void writeCase_abc_f16( float16_t, float16_t, float16_t, const char * ); +#endif void writeCase_a_f32( float32_t, const char * ); void writeCase_ab_f32( float32_t, float32_t, const char * ); void writeCase_abc_f32( float32_t, float32_t, float32_t, const char * ); @@ -79,6 +84,9 @@ void writeCase_z_ui64( uint_fast64_t, uint_fast8_t, uint_fast64_t, uint_fast8_t ); #define writeCase_z_i32 writeCase_z_ui32 #define writeCase_z_i64 writeCase_z_ui64 +#ifdef FLOAT16 +void writeCase_z_f16( float16_t, uint_fast8_t, float16_t, uint_fast8_t ); +#endif void writeCase_z_f32( float32_t, uint_fast8_t, float32_t, uint_fast8_t ); void writeCase_z_f64( float64_t, uint_fast8_t, float64_t, uint_fast8_t ); #ifdef EXTFLOAT80 diff --git a/source/writeCase_a_extF80M.c b/source/writeCase_a_extF80M.c index 119338f..ada36fc 100644 --- a/source/writeCase_a_extF80M.c +++ b/source/writeCase_a_extF80M.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/writeCase_a_f128M.c b/source/writeCase_a_f128M.c index bb162c3..67315fd 100644 --- a/source/writeCase_a_f128M.c +++ b/source/writeCase_a_f128M.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/writeCase_a_f16.c b/source/writeCase_a_f16.c new file mode 100644 index 0000000..4354dd9 --- /dev/null +++ b/source/writeCase_a_f16.c @@ -0,0 +1,55 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3b, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of +California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions, and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=============================================================================*/ + +#include <stdint.h> +#include <stdio.h> +#include "platform.h" +#include "writeHex.h" +#include "writeCase.h" + +#ifdef FLOAT16 + +void writeCase_a_f16( float16_t a, const char *sepStringPtr ) +{ + + writeHex_f16( a, 0 ); + fputs( sepStringPtr, stdout ); + +} + +#endif + diff --git a/source/writeCase_a_f32.c b/source/writeCase_a_f32.c index 3487c53..3ce35a9 100644 --- a/source/writeCase_a_f32.c +++ b/source/writeCase_a_f32.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/writeCase_a_f64.c b/source/writeCase_a_f64.c index 2646859..41e5852 100644 --- a/source/writeCase_a_f64.c +++ b/source/writeCase_a_f64.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/writeCase_a_ui32.c b/source/writeCase_a_ui32.c index ae69526..20856a2 100644 --- a/source/writeCase_a_ui32.c +++ b/source/writeCase_a_ui32.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/writeCase_a_ui64.c b/source/writeCase_a_ui64.c index 3bb1202..133628f 100644 --- a/source/writeCase_a_ui64.c +++ b/source/writeCase_a_ui64.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/writeCase_ab_extF80M.c b/source/writeCase_ab_extF80M.c index f861080..009401a 100644 --- a/source/writeCase_ab_extF80M.c +++ b/source/writeCase_ab_extF80M.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/writeCase_ab_f128M.c b/source/writeCase_ab_f128M.c index a1946f3..a4c5dda 100644 --- a/source/writeCase_ab_f128M.c +++ b/source/writeCase_ab_f128M.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/writeCase_ab_f16.c b/source/writeCase_ab_f16.c new file mode 100644 index 0000000..23dc7ee --- /dev/null +++ b/source/writeCase_ab_f16.c @@ -0,0 +1,57 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3b, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of +California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions, and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=============================================================================*/ + +#include <stdint.h> +#include <stdio.h> +#include "platform.h" +#include "writeHex.h" +#include "writeCase.h" + +#ifdef FLOAT16 + +void writeCase_ab_f16( float16_t a, float16_t b, const char *sepStringPtr ) +{ + + writeHex_f16( a, 0 ); + fputs( " ", stdout ); + writeHex_f16( b, 0 ); + fputs( sepStringPtr, stdout ); + +} + +#endif + diff --git a/source/writeCase_ab_f32.c b/source/writeCase_ab_f32.c index b109ce9..f5d8385 100644 --- a/source/writeCase_ab_f32.c +++ b/source/writeCase_ab_f32.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/writeCase_ab_f64.c b/source/writeCase_ab_f64.c index a117696..349b99d 100644 --- a/source/writeCase_ab_f64.c +++ b/source/writeCase_ab_f64.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/writeCase_abc_extF80M.c b/source/writeCase_abc_extF80M.c index e53cf88..5620d48 100644 --- a/source/writeCase_abc_extF80M.c +++ b/source/writeCase_abc_extF80M.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/writeCase_abc_f128M.c b/source/writeCase_abc_f128M.c index fe279b2..5ddcac2 100644 --- a/source/writeCase_abc_f128M.c +++ b/source/writeCase_abc_f128M.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/writeCase_abc_f16.c b/source/writeCase_abc_f16.c new file mode 100644 index 0000000..1f0471d --- /dev/null +++ b/source/writeCase_abc_f16.c @@ -0,0 +1,57 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3b, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of +California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions, and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=============================================================================*/ + +#include <stdint.h> +#include <stdio.h> +#include "platform.h" +#include "writeHex.h" +#include "writeCase.h" + +void + writeCase_abc_f16( + float16_t a, float16_t b, float16_t c, const char *sepStringPtr ) +{ + + writeHex_f16( a, 0 ); + fputs( " ", stdout ); + writeHex_f16( b, 0 ); + fputs( " ", stdout ); + writeHex_f16( c, 0 ); + fputs( sepStringPtr, stdout ); + +} + diff --git a/source/writeCase_abc_f32.c b/source/writeCase_abc_f32.c index c088ddc..53067ee 100644 --- a/source/writeCase_abc_f32.c +++ b/source/writeCase_abc_f32.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/writeCase_abc_f64.c b/source/writeCase_abc_f64.c index b14a6fd..891c0e1 100644 --- a/source/writeCase_abc_f64.c +++ b/source/writeCase_abc_f64.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/writeCase_z_bool.c b/source/writeCase_z_bool.c index 589916e..6c1cc7d 100644 --- a/source/writeCase_z_bool.c +++ b/source/writeCase_z_bool.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/writeCase_z_extF80M.c b/source/writeCase_z_extF80M.c index a878edf..70c9c77 100644 --- a/source/writeCase_z_extF80M.c +++ b/source/writeCase_z_extF80M.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/writeCase_z_f128M.c b/source/writeCase_z_f128M.c index 31c611c..00d96f8 100644 --- a/source/writeCase_z_f128M.c +++ b/source/writeCase_z_f128M.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/writeCase_z_f16.c b/source/writeCase_z_f16.c new file mode 100644 index 0000000..6168c5f --- /dev/null +++ b/source/writeCase_z_f16.c @@ -0,0 +1,63 @@ + +/*============================================================================ + +This C source file is part of TestFloat, Release 3b, a package of programs for +testing the correctness of floating-point arithmetic complying with the IEEE +Standard for Floating-Point, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of +California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions, and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=============================================================================*/ + +#include <stdint.h> +#include <stdio.h> +#include "platform.h" +#include "softfloat.h" +#include "writeHex.h" +#include "writeCase.h" + +void + writeCase_z_f16( + float16_t trueZ, + uint_fast8_t trueFlags, + float16_t subjZ, + uint_fast8_t subjFlags + ) +{ + + fputs( "=> ", stdout ); + writeHex_f16( subjZ, ' ' ); + writeHex_softfloat_flags( subjFlags, 0 ); + fputs( " expected ", stdout ); + writeHex_f16( trueZ, ' ' ); + writeHex_softfloat_flags( trueFlags, '\n' ); + fflush( stdout ); + +} + diff --git a/source/writeCase_z_f32.c b/source/writeCase_z_f32.c index c779d11..04d7d16 100644 --- a/source/writeCase_z_f32.c +++ b/source/writeCase_z_f32.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/writeCase_z_f64.c b/source/writeCase_z_f64.c index d8b2c7a..b448555 100644 --- a/source/writeCase_z_f64.c +++ b/source/writeCase_z_f64.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/writeCase_z_ui32.c b/source/writeCase_z_ui32.c index 3d99845..9553cf9 100644 --- a/source/writeCase_z_ui32.c +++ b/source/writeCase_z_ui32.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/writeCase_z_ui64.c b/source/writeCase_z_ui64.c index 0a82933..f4c7e46 100644 --- a/source/writeCase_z_ui64.c +++ b/source/writeCase_z_ui64.c @@ -1,7 +1,7 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. diff --git a/source/writeHex.c b/source/writeHex.c index 2271fcc..0a3109c 100644 --- a/source/writeHex.c +++ b/source/writeHex.c @@ -1,12 +1,12 @@ /*============================================================================ -This C source file is part of TestFloat, Release 3a, a package of programs for +This C source file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. -Copyright 2011, 2012, 2013, 2014 The Regents of the University of California. -All rights reserved. +Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of +California. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -118,6 +118,25 @@ void writeHex_ui64( uint_fast64_t a, char sepChar ) } +#ifdef FLOAT16 + +void writeHex_f16( float16_t a, char sepChar ) +{ + union { uint16_t ui; float16_t f; } uA; + uint_fast16_t uiA; + + uA.f = a; + uiA = uA.ui; + fputc( uiA & 0x8000 ? '-' : '+', stdout ); + writeHex_ui8( uiA>>10 & 0x1F, 0 ); + fputc( '.', stdout ); + fputc( '0' + (uiA>>8 & 3), stdout ); + writeHex_ui8( uiA, sepChar ); + +} + +#endif + void writeHex_f32( float32_t a, char sepChar ) { union { uint32_t ui; float32_t f; } uA; @@ -125,7 +144,7 @@ void writeHex_f32( float32_t a, char sepChar ) uA.f = a; uiA = uA.ui; - fputc( (0x80000000 <= uiA) ? '8' : '0', stdout ); + fputc( uiA & 0x80000000 ? '-' : '+', stdout ); writeHex_ui8( uiA>>23, 0 ); fputc( '.', stdout ); writeHex_ui8( uiA>>16 & 0x7F, 0 ); @@ -140,7 +159,8 @@ void writeHex_f64( float64_t a, char sepChar ) uA.f = a; uiA = uA.ui; - writeHex_ui12( uiA>>52, 0 ); + fputc( uiA & UINT64_C( 0x8000000000000000 ) ? '-' : '+', stdout ); + writeHex_ui12( uiA>>52 & 0x7FF, 0 ); fputc( '.', stdout ); writeHex_ui12( uiA>>40, 0 ); writeHex_ui8( uiA>>32, 0 ); @@ -153,9 +173,12 @@ void writeHex_f64( float64_t a, char sepChar ) void writeHex_extF80M( const extFloat80_t *aPtr, char sepChar ) { const struct extFloat80M *aSPtr; + uint_fast16_t uiA64; aSPtr = (const struct extFloat80M *) aPtr; - writeHex_ui16( aSPtr->signExp, 0 ); + uiA64 = aSPtr->signExp; + fputc( uiA64 & 0x8000 ? '-' : '+', stdout ); + writeHex_ui16( uiA64 & 0x7FFF, 0 ); fputc( '.', stdout ); writeHex_ui64( aSPtr->signif, sepChar ); @@ -172,7 +195,8 @@ void writeHex_f128M( const float128_t *aPtr, char sepChar ) uiAPtr = (const struct uint128 *) aPtr; uiA64 = uiAPtr->v64; - writeHex_ui16( uiA64>>48, 0 ); + fputc( uiA64 & UINT64_C( 0x8000000000000000 ) ? '-' : '+', stdout ); + writeHex_ui16( uiA64>>48 & 0x7FFF, 0 ); fputc( '.', stdout ); writeHex_ui16( uiA64>>32, 0 ); writeHex_ui32( uiA64, 0 ); diff --git a/source/writeHex.h b/source/writeHex.h index 6fc0ce6..84d2a2f 100644 --- a/source/writeHex.h +++ b/source/writeHex.h @@ -1,12 +1,12 @@ /*============================================================================ -This C header file is part of TestFloat, Release 3a, a package of programs for +This C header file is part of TestFloat, Release 3b, a package of programs for testing the correctness of floating-point arithmetic complying with the IEEE Standard for Floating-Point, by John R. Hauser. -Copyright 2011, 2012, 2013, 2014 The Regents of the University of California. -All rights reserved. +Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of +California. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -44,6 +44,9 @@ void writeHex_ui8( uint_fast8_t, char ); void writeHex_ui16( uint_fast16_t, char ); void writeHex_ui32( uint_fast32_t, char ); void writeHex_ui64( uint_fast64_t, char ); +#ifdef FLOAT16 +void writeHex_f16( float16_t, char ); +#endif void writeHex_f32( float32_t, char ); void writeHex_f64( float64_t, char ); #ifdef EXTFLOAT80 |