1*1f21f64aSMarius Strobl 2*1f21f64aSMarius StroblTestFloat Release 2a Source Documentation 3*1f21f64aSMarius Strobl 4*1f21f64aSMarius StroblJohn R. Hauser 5*1f21f64aSMarius Strobl1998 December 16 6*1f21f64aSMarius Strobl 7*1f21f64aSMarius Strobl 8*1f21f64aSMarius Strobl------------------------------------------------------------------------------- 9*1f21f64aSMarius StroblIntroduction 10*1f21f64aSMarius Strobl 11*1f21f64aSMarius StroblTestFloat is a program for testing that a floating-point implementation 12*1f21f64aSMarius Stroblconforms to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. 13*1f21f64aSMarius StroblAll standard operations supported by the system can be tested, except for 14*1f21f64aSMarius Stroblconversions to and from decimal. Any of the following machine formats can 15*1f21f64aSMarius Stroblbe tested: single precision, double precision, extended double precision, 16*1f21f64aSMarius Strobland/or quadruple precision. Testing extended double-precision or quadruple- 17*1f21f64aSMarius Stroblprecision formats requires a C compiler that supports 64-bit integer 18*1f21f64aSMarius Stroblarithmetic. 19*1f21f64aSMarius Strobl 20*1f21f64aSMarius StroblThis document gives information needed for compiling and/or porting 21*1f21f64aSMarius StroblTestFloat. 22*1f21f64aSMarius Strobl 23*1f21f64aSMarius StroblThe source code for TestFloat is intended to be relatively machine- 24*1f21f64aSMarius Stroblindependent. TestFloat is written in C, and should be compilable using 25*1f21f64aSMarius Stroblany ISO/ANSI C compiler. At the time of this writing, the program has 26*1f21f64aSMarius Stroblbeen successfully compiled using the GNU C Compiler (`gcc') for several 27*1f21f64aSMarius Stroblplatforms. Because ISO/ANSI C does not provide access to some features 28*1f21f64aSMarius Stroblof IEC/IEEE floating-point such as the exception flags, porting TestFloat 29*1f21f64aSMarius Stroblunfortunately involves some machine-dependent coding. 30*1f21f64aSMarius Strobl 31*1f21f64aSMarius StroblTestFloat depends on SoftFloat, which is a software implementation of 32*1f21f64aSMarius Stroblfloating-point that conforms to the IEC/IEEE Standard. SoftFloat is not 33*1f21f64aSMarius Stroblincluded with the TestFloat sources. It can be obtained from the Web 34*1f21f64aSMarius Stroblpage `http://HTTP.CS.Berkeley.EDU/~jhauser/arithmetic/SoftFloat.html'. 35*1f21f64aSMarius Strobl 36*1f21f64aSMarius StroblIn addition to a program for testing a machine's floating-point, the 37*1f21f64aSMarius StroblTestFloat package includes a variant for testing SoftFloat called 38*1f21f64aSMarius Strobl`testsoftfloat'. The sources for both programs are intermixed, and both are 39*1f21f64aSMarius Strobldescribed here. 40*1f21f64aSMarius Strobl 41*1f21f64aSMarius StroblThe first release of TestFloat (Release 1) was called _FloatTest_. The old 42*1f21f64aSMarius Stroblname has been obsolete for some time. 43*1f21f64aSMarius Strobl 44*1f21f64aSMarius Strobl 45*1f21f64aSMarius Strobl------------------------------------------------------------------------------- 46*1f21f64aSMarius StroblLimitations 47*1f21f64aSMarius Strobl 48*1f21f64aSMarius StroblTestFloat as written requires an ISO/ANSI-style C compiler. No attempt has 49*1f21f64aSMarius Stroblbeen made to accommodate compilers that are not ISO-conformant. Older ``K&R- 50*1f21f64aSMarius Stroblstyle'' compilers are not adequate for compiling TestFloat. All testing I 51*1f21f64aSMarius Stroblhave done so far has been with the GNU C Compiler. Compilation with other 52*1f21f64aSMarius Stroblcompilers should be possible but has not been tested. 53*1f21f64aSMarius Strobl 54*1f21f64aSMarius StroblThe TestFloat sources assume that source code file names can be longer than 55*1f21f64aSMarius Strobl8 characters. In order to compile under an MS-DOS-style system, many of the 56*1f21f64aSMarius Stroblsource files will need to be renamed, and the source and makefiles edited 57*1f21f64aSMarius Stroblappropriately. Once compiled, the TestFloat program does not depend on the 58*1f21f64aSMarius Stroblexistence of long file names. 59*1f21f64aSMarius Strobl 60*1f21f64aSMarius StroblThe underlying machine is assumed to be binary with a word size that is a 61*1f21f64aSMarius Stroblpower of 2. Bytes are 8 bits. Testing of extended double-precision and 62*1f21f64aSMarius Stroblquadruple-precision formats depends on the C compiler implementing a 64-bit 63*1f21f64aSMarius Stroblinteger type. If the largest integer type supported by the C compiler is 64*1f21f64aSMarius Strobl32 bits, only single- and double-precision operations can be tested. 65*1f21f64aSMarius Strobl 66*1f21f64aSMarius Strobl 67*1f21f64aSMarius Strobl------------------------------------------------------------------------------- 68*1f21f64aSMarius StroblContents 69*1f21f64aSMarius Strobl 70*1f21f64aSMarius Strobl Introduction 71*1f21f64aSMarius Strobl Limitations 72*1f21f64aSMarius Strobl Contents 73*1f21f64aSMarius Strobl Legal Notice 74*1f21f64aSMarius Strobl TestFloat Source Directory Structure 75*1f21f64aSMarius Strobl Target-Independent Modules 76*1f21f64aSMarius Strobl Target-Specific Modules 77*1f21f64aSMarius Strobl Target-Specific Header Files 78*1f21f64aSMarius Strobl processors/*.h 79*1f21f64aSMarius Strobl testfloat/*/milieu.h 80*1f21f64aSMarius Strobl Target-Specific Floating-Point Subroutines 81*1f21f64aSMarius Strobl Steps to Creating the TestFloat Executables 82*1f21f64aSMarius Strobl Improving the Random Number Generator 83*1f21f64aSMarius Strobl Contact Information 84*1f21f64aSMarius Strobl 85*1f21f64aSMarius Strobl 86*1f21f64aSMarius Strobl 87*1f21f64aSMarius Strobl------------------------------------------------------------------------------- 88*1f21f64aSMarius StroblLegal Notice 89*1f21f64aSMarius Strobl 90*1f21f64aSMarius StroblTestFloat was written by John R. Hauser. 91*1f21f64aSMarius Strobl 92*1f21f64aSMarius StroblTHIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort 93*1f21f64aSMarius Stroblhas been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT 94*1f21f64aSMarius StroblTIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO 95*1f21f64aSMarius StroblPERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY 96*1f21f64aSMarius StroblAND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. 97*1f21f64aSMarius Strobl 98*1f21f64aSMarius Strobl 99*1f21f64aSMarius Strobl------------------------------------------------------------------------------- 100*1f21f64aSMarius StroblTestFloat Source Directory Structure 101*1f21f64aSMarius Strobl 102*1f21f64aSMarius StroblBecause TestFloat is targeted to multiple platforms, its source code 103*1f21f64aSMarius Stroblis slightly scattered between target-specific and target-independent 104*1f21f64aSMarius Strobldirectories and files. The directory structure is as follows: 105*1f21f64aSMarius Strobl 106*1f21f64aSMarius Strobl processors 107*1f21f64aSMarius Strobl testfloat 108*1f21f64aSMarius Strobl templates 109*1f21f64aSMarius Strobl 386-Win32-gcc 110*1f21f64aSMarius Strobl SPARC-Solaris-gcc 111*1f21f64aSMarius Strobl 112*1f21f64aSMarius StroblThe two topmost directories and their contents are: 113*1f21f64aSMarius Strobl 114*1f21f64aSMarius Strobl testfloat - Most of the source code needed for TestFloat. 115*1f21f64aSMarius Strobl processors - Target-specific header files that are not specific to 116*1f21f64aSMarius Strobl TestFloat. 117*1f21f64aSMarius Strobl 118*1f21f64aSMarius StroblWithin the `testfloat' directory are subdirectories for each of the 119*1f21f64aSMarius Strobltargeted platforms. The TestFloat source code is distributed with targets 120*1f21f64aSMarius Strobl`386-Win32-gcc' and `SPARC-Solaris-gcc' (and perhaps others) already 121*1f21f64aSMarius Stroblprepared. These can be used as examples for porting to new targets. Source 122*1f21f64aSMarius Stroblfiles that are not within these target-specific subdirectories are intended 123*1f21f64aSMarius Stroblto be target-independent. 124*1f21f64aSMarius Strobl 125*1f21f64aSMarius StroblThe naming convention used for the target-specific directories is 126*1f21f64aSMarius Strobl`<processor>-<executable-type>-<compiler>'. The names of the supplied 127*1f21f64aSMarius Strobltarget directories should be interpreted as follows: 128*1f21f64aSMarius Strobl 129*1f21f64aSMarius Strobl <processor>: 130*1f21f64aSMarius Strobl 386 - Intel 386-compatible processor. 131*1f21f64aSMarius Strobl SPARC - SPARC processor (as used by Sun machines). 132*1f21f64aSMarius Strobl <executable-type>: 133*1f21f64aSMarius Strobl Win32 - Microsoft Win32 executable. 134*1f21f64aSMarius Strobl Solaris - Sun Solaris executable. 135*1f21f64aSMarius Strobl <compiler>: 136*1f21f64aSMarius Strobl gcc - GNU C Compiler. 137*1f21f64aSMarius Strobl 138*1f21f64aSMarius StroblYou do not need to maintain this convention if you do not want to. 139*1f21f64aSMarius Strobl 140*1f21f64aSMarius StroblAlongside the supplied target-specific directories there is a `templates' 141*1f21f64aSMarius Strobldirectory containing a set of ``generic'' target-specific source files. 142*1f21f64aSMarius StroblA new target directory can be created by copying the `templates' directory 143*1f21f64aSMarius Strobland editing the files inside. (Complete instructions for porting TestFloat 144*1f21f64aSMarius Stroblto a new target are in the section _Steps_to_Creating_the_TestFloat_ 145*1f21f64aSMarius Strobl_Executables_.) Note that the `templates' directory will not work as a 146*1f21f64aSMarius Strobltarget directory without some editing. To avoid confusion, it would be wise 147*1f21f64aSMarius Stroblto refrain from editing the files inside `templates' directly. 148*1f21f64aSMarius Strobl 149*1f21f64aSMarius StroblIn addition to the distributed sources, TestFloat depends on the existence 150*1f21f64aSMarius Stroblof an appropriately-compiled SoftFloat binary and the corresponding header 151*1f21f64aSMarius Stroblfile `softfloat.h'. SoftFloat is not included with the TestFloat sources. 152*1f21f64aSMarius StroblIt can be obtained from the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/ 153*1f21f64aSMarius Stroblarithmetic/SoftFloat.html'. 154*1f21f64aSMarius Strobl 155*1f21f64aSMarius StroblAs distributed, the makefiles for TestFloat assume the existence of three 156*1f21f64aSMarius Stroblsibling directories: 157*1f21f64aSMarius Strobl 158*1f21f64aSMarius Strobl processors 159*1f21f64aSMarius Strobl softfloat 160*1f21f64aSMarius Strobl testfloat 161*1f21f64aSMarius Strobl 162*1f21f64aSMarius StroblOnly the `processors' and `testfloat' directories are included in the 163*1f21f64aSMarius StroblTestFloat package. The `softfloat' directory is assumed to contain a 164*1f21f64aSMarius Strobltarget-specific subdirectory within which the SoftFloat header file and 165*1f21f64aSMarius Stroblcompiled binary can be found. (See the source documentation accompanying 166*1f21f64aSMarius StroblSoftFloat.) The `processors' directory distributed with TestFloat is 167*1f21f64aSMarius Stroblintended to be identical to that included with the SoftFloat source. 168*1f21f64aSMarius Strobl 169*1f21f64aSMarius StroblThese are the defaults, but other organizations of the sources are possible. 170*1f21f64aSMarius StroblThe TestFloat makefiles and `milieu.h' files (see below) are easily edited 171*1f21f64aSMarius Stroblto accommodate other arrangements. 172*1f21f64aSMarius Strobl 173*1f21f64aSMarius Strobl 174*1f21f64aSMarius Strobl------------------------------------------------------------------------------- 175*1f21f64aSMarius StroblTarget-Independent Modules 176*1f21f64aSMarius Strobl 177*1f21f64aSMarius StroblThe TestFloat program is composed of a number of modules, some target- 178*1f21f64aSMarius Stroblspecific and some target-independent. The target-independent modules are as 179*1f21f64aSMarius Stroblfollows: 180*1f21f64aSMarius Strobl 181*1f21f64aSMarius Strobl-- The `fail' module provides a common routine for writing an error message 182*1f21f64aSMarius Strobl and aborting. 183*1f21f64aSMarius Strobl 184*1f21f64aSMarius Strobl-- The `random' module generates random integer values. 185*1f21f64aSMarius Strobl 186*1f21f64aSMarius Strobl-- The `writeHex' module defines routines for writing the various types in 187*1f21f64aSMarius Strobl the hexadecimal form used by TestFloat. 188*1f21f64aSMarius Strobl 189*1f21f64aSMarius Strobl-- The `testCases' module generates test cases for the various types. 190*1f21f64aSMarius Strobl 191*1f21f64aSMarius Strobl-- The `testLoops' module contains various routines for exercising two 192*1f21f64aSMarius Strobl implementations of a function and reporting any differences observed. 193*1f21f64aSMarius Strobl 194*1f21f64aSMarius Strobl-- The `slowfloat' module provides the simple floating-point implementation 195*1f21f64aSMarius Strobl used by `testsoftfloat' for comparing against SoftFloat. The heart 196*1f21f64aSMarius Strobl of `slowfloat' is found in either `slowfloat-32' or `slowfloat-64', 197*1f21f64aSMarius Strobl depending on whether the `BITS64' macro is defined. 198*1f21f64aSMarius Strobl 199*1f21f64aSMarius Strobl-- The `systfloat' module gives a SoftFloat-like interface to the machine's 200*1f21f64aSMarius Strobl floating-point. 201*1f21f64aSMarius Strobl 202*1f21f64aSMarius Strobl-- The `testFunction' module implements `testfloat's main loop for testing a 203*1f21f64aSMarius Strobl function for all of the relevant rounding modes and rounding precisions. 204*1f21f64aSMarius Strobl (The `testsoftfloat' program contains its own version of this code.) 205*1f21f64aSMarius Strobl 206*1f21f64aSMarius Strobl-- The `testfloat' and `testsoftfloat' modules are the main modules for the 207*1f21f64aSMarius Strobl `testfloat' and `testsoftfloat' programs. 208*1f21f64aSMarius Strobl 209*1f21f64aSMarius StroblExcept possibly for `systfloat', these modules should not need to be 210*1f21f64aSMarius Stroblmodified. 211*1f21f64aSMarius Strobl 212*1f21f64aSMarius StroblThe `systfloat' module uses the floating-point operations of the C language 213*1f21f64aSMarius Stroblto access a machine's floating-point. Unfortunately, some IEC/IEEE 214*1f21f64aSMarius Stroblfloating-point operations are not accessible within ISO/ANSI C. The 215*1f21f64aSMarius Stroblfollowing machine functions cannot be tested unless an alternate `systfloat' 216*1f21f64aSMarius Stroblmodule is provided: 217*1f21f64aSMarius Strobl 218*1f21f64aSMarius Strobl <float>_to_int32 (rounded according to rounding mode) 219*1f21f64aSMarius Strobl <float>_to_int64 (rounded according to rounding mode) 220*1f21f64aSMarius Strobl <float>_round_to_int 221*1f21f64aSMarius Strobl <float>_rem 222*1f21f64aSMarius Strobl <float>_sqrt, except float64_sqrt 223*1f21f64aSMarius Strobl <float>_eq_signaling 224*1f21f64aSMarius Strobl <float>_le_quiet 225*1f21f64aSMarius Strobl <float>_lt_quiet 226*1f21f64aSMarius Strobl 227*1f21f64aSMarius StroblThe `-list' option to `testfloat' will show the operations the program is 228*1f21f64aSMarius Stroblprepared to test. The section _Target-Specific_Floating-Point_Subroutines_ 229*1f21f64aSMarius Strobllater in this document explains how to create a target-specific `systfloat' 230*1f21f64aSMarius Stroblmodule to change the set of testable functions. 231*1f21f64aSMarius Strobl 232*1f21f64aSMarius Strobl 233*1f21f64aSMarius Strobl------------------------------------------------------------------------------- 234*1f21f64aSMarius StroblTarget-Specific Modules 235*1f21f64aSMarius Strobl 236*1f21f64aSMarius StroblNo target-specific modules are needed for `testsoftfloat'. 237*1f21f64aSMarius Strobl 238*1f21f64aSMarius StroblThe `testfloat' program uses two target-specific modules: 239*1f21f64aSMarius Strobl 240*1f21f64aSMarius Strobl-- The `systmodes' module defines functions for setting the modes 241*1f21f64aSMarius Strobl controlling the system's floating-point, including the rounding mode and 242*1f21f64aSMarius Strobl the rounding precision for extended double precision. 243*1f21f64aSMarius Strobl 244*1f21f64aSMarius Strobl-- The `systflags' module provides a function for clearing and examining the 245*1f21f64aSMarius Strobl system's floating-point exception flags. 246*1f21f64aSMarius Strobl 247*1f21f64aSMarius StroblThese modules must be supplied for each target. They can be implemented in 248*1f21f64aSMarius Stroblany way desired, so long as all is reflected in the target's makefile. For 249*1f21f64aSMarius Stroblthe targets that come with the distributed source, each of these modules is 250*1f21f64aSMarius Stroblimplemented as a single assembly language or C language source file. 251*1f21f64aSMarius Strobl 252*1f21f64aSMarius Strobl 253*1f21f64aSMarius Strobl------------------------------------------------------------------------------- 254*1f21f64aSMarius StroblTarget-Specific Header Files 255*1f21f64aSMarius Strobl 256*1f21f64aSMarius StroblThe purpose of the two target-specific header files is detailed below. 257*1f21f64aSMarius StroblIn the following, the `*' symbol is used in place of the name of a specific 258*1f21f64aSMarius Strobltarget, such as `386-Win32-gcc' or `SPARC-Solaris-gcc', or in place of some 259*1f21f64aSMarius Stroblother text as explained below. 260*1f21f64aSMarius Strobl 261*1f21f64aSMarius Strobl- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 262*1f21f64aSMarius Stroblprocessors/*.h 263*1f21f64aSMarius Strobl 264*1f21f64aSMarius StroblThe target-specific `processors' header file defines integer types 265*1f21f64aSMarius Stroblof various sizes, and also defines certain C preprocessor macros that 266*1f21f64aSMarius Stroblcharacterize the target. The two examples supplied are `386-gcc.h' and 267*1f21f64aSMarius Strobl`SPARC-gcc.h'. The naming convention used for processor header files is 268*1f21f64aSMarius Strobl`<processor>-<compiler>.h'. The `processors' header file used to compile 269*1f21f64aSMarius StroblTestFloat should be the same as that used to compile SoftFloat. 270*1f21f64aSMarius Strobl 271*1f21f64aSMarius StroblIf 64-bit integers are supported by the compiler, the macro name `BITS64' 272*1f21f64aSMarius Stroblshould be defined here along with the corresponding 64-bit integer 273*1f21f64aSMarius Strobltypes. In addition, the function-like macro `LIT64' must be defined for 274*1f21f64aSMarius Stroblconstructing 64-bit integer literals (constants). The `LIT64' macro is used 275*1f21f64aSMarius Stroblconsistently in the TestFloat code to annotate 64-bit literals. 276*1f21f64aSMarius Strobl 277*1f21f64aSMarius StroblIf an inlining attribute (such as an `inline' keyword) is provided by the 278*1f21f64aSMarius Stroblcompiler, the macro `INLINE' should be defined to the appropriate keyword. 279*1f21f64aSMarius StroblIf not, `INLINE' can be set to the keyword `static'. The `INLINE' macro 280*1f21f64aSMarius Stroblappears in the TestFloat source code before every function that should be 281*1f21f64aSMarius Stroblinlined by the compiler. 282*1f21f64aSMarius Strobl 283*1f21f64aSMarius StroblFor maximum flexibility, the TestFloat source files do not include the 284*1f21f64aSMarius Strobl`processors' header file directly; rather, this file is included by the 285*1f21f64aSMarius Strobltarget-specific `milieu.h' header, and `milieu.h' is included by the source 286*1f21f64aSMarius Stroblfiles. 287*1f21f64aSMarius Strobl 288*1f21f64aSMarius Strobl- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 289*1f21f64aSMarius Strobltestfloat/*/milieu.h 290*1f21f64aSMarius Strobl 291*1f21f64aSMarius StroblThe `milieu.h' header file provides declarations that are needed to 292*1f21f64aSMarius Stroblcompile TestFloat. In particular, it is through this header file that 293*1f21f64aSMarius Stroblthe appropriate `processors' header is included to characterize the target 294*1f21f64aSMarius Stroblprocessor. In addition, deviations from ISO/ANSI C by the compiler (such as 295*1f21f64aSMarius Stroblnames not properly declared in system header files) are corrected in this 296*1f21f64aSMarius Stroblheader if possible. 297*1f21f64aSMarius Strobl 298*1f21f64aSMarius StroblIf the preprocessor macro `BITS64' is defined in the `processors' header 299*1f21f64aSMarius Stroblfile but only the 32-bit version of SoftFloat is actually used, the `BITS64' 300*1f21f64aSMarius Stroblmacro should be undefined here after the `processors' header has defined it. 301*1f21f64aSMarius Strobl 302*1f21f64aSMarius StroblIf the C compiler implements the `long double' floating-point type of C 303*1f21f64aSMarius Stroblas extended double precision, then `LONG_DOUBLE_IS_FLOATX80' should be 304*1f21f64aSMarius Strobldefined here. Alternatively, if the C `long double' type is implemented as 305*1f21f64aSMarius Stroblquadruple precision, `LONG_DOUBLE_IS_FLOAT128' should be defined. At most 306*1f21f64aSMarius Stroblone of these macros should be defined. A C compiler is allowed to implement 307*1f21f64aSMarius Strobl`long double' the same as `double', in which case neither of these macros 308*1f21f64aSMarius Stroblshould be defined. 309*1f21f64aSMarius Strobl 310*1f21f64aSMarius Strobl- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 311*1f21f64aSMarius Strobl 312*1f21f64aSMarius Strobl 313*1f21f64aSMarius Strobl------------------------------------------------------------------------------- 314*1f21f64aSMarius StroblTarget-Specific Floating-Point Subroutines 315*1f21f64aSMarius Strobl 316*1f21f64aSMarius StroblThis section applies only to `testfloat' and not to `testsoftfloat'. 317*1f21f64aSMarius Strobl 318*1f21f64aSMarius StroblBy default, TestFloat tests a machine's floating-point by testing the 319*1f21f64aSMarius Stroblfloating-point operations of the C language. Unfortunately, some IEC/IEEE 320*1f21f64aSMarius Stroblfloating-point operations are not defined within ISO/ANSI C. If a machine 321*1f21f64aSMarius Stroblimplements such ``non-C'' operations, target-specific subroutines for 322*1f21f64aSMarius Stroblthe operations can be supplied to allow TestFloat to test these machine 323*1f21f64aSMarius Stroblfeatures. Typically, such subroutines will need to be written in assembly 324*1f21f64aSMarius Strobllanguage, although equivalent functions can sometimes be found among the 325*1f21f64aSMarius Stroblsystem's software libraries. 326*1f21f64aSMarius Strobl 327*1f21f64aSMarius StroblThe following machine functions cannot be tested by TestFloat unless target- 328*1f21f64aSMarius Stroblspecific subroutines are supplied for them: 329*1f21f64aSMarius Strobl 330*1f21f64aSMarius Strobl <float>_to_int32 (rounded according to rounding mode) 331*1f21f64aSMarius Strobl <float>_to_int64 (rounded according to rounding mode) 332*1f21f64aSMarius Strobl <float>_round_to_int 333*1f21f64aSMarius Strobl <float>_rem 334*1f21f64aSMarius Strobl <float>_sqrt, except float64_sqrt 335*1f21f64aSMarius Strobl <float>_eq_signaling 336*1f21f64aSMarius Strobl <float>_le_quiet 337*1f21f64aSMarius Strobl <float>_lt_quiet 338*1f21f64aSMarius Strobl 339*1f21f64aSMarius StroblIn addition to these, none of the `floatx80' functions can be tested by 340*1f21f64aSMarius Strobldefault if the C `long double' type is something other than extended double 341*1f21f64aSMarius Stroblprecision; and likewise, none of the `float128' functions can be tested by 342*1f21f64aSMarius Strobldefault if `long double' is not quadruple precision. Since `long double' 343*1f21f64aSMarius Stroblcannot be both extended double precision and quadruple precision at the 344*1f21f64aSMarius Stroblsame time, at least one of these types cannot be tested by TestFloat without 345*1f21f64aSMarius Stroblappropriate subroutines being supplied for that type. (On the other hand, 346*1f21f64aSMarius Stroblfew systems implement _both_ extended double-precision and quadruple- 347*1f21f64aSMarius Stroblprecision floating-point; and unless a system does implement both, it does 348*1f21f64aSMarius Stroblnot need both tested.) 349*1f21f64aSMarius Strobl 350*1f21f64aSMarius StroblNote that the `-list' option to `testfloat' will show the operations 351*1f21f64aSMarius StroblTestFloat is prepared to test. 352*1f21f64aSMarius Strobl 353*1f21f64aSMarius StroblTestFloat's `systfloat' module supplies the system version of the functions 354*1f21f64aSMarius Stroblto be tested. The names of the `systfloat' subroutines are the same as the 355*1f21f64aSMarius Stroblfunction names used as arguments to the `testfloat' command but with `syst_' 356*1f21f64aSMarius Stroblprefixed--thus, for example, `syst_float32_add' and `syst_int32_to_float32'. 357*1f21f64aSMarius StroblThe default `systfloat' module maps these system functions to the standard 358*1f21f64aSMarius StroblC operations; so `syst_float32_add', for example, is implemented using the 359*1f21f64aSMarius StroblC `+' operation for the single-precision `float' type. For each system 360*1f21f64aSMarius Stroblfunction supplied by `systfloat', a corresponding `SYST_<function>' 361*1f21f64aSMarius Stroblpreprocessor macro is defined in `systfloat.h' to indicate that the function 362*1f21f64aSMarius Stroblexists to be tested (e.g., `SYST_FLOAT32_ADD'). The `systfloat.h' header 363*1f21f64aSMarius Stroblfile also declares function prototypes for the `systfloat' functions. 364*1f21f64aSMarius Strobl 365*1f21f64aSMarius Strobl(The `systfloat.h' file that comes with the TestFloat package declares 366*1f21f64aSMarius Stroblprototypes for all of the possible `systfloat' functions, whether defined in 367*1f21f64aSMarius Strobl`systfloat' or not. There is no penalty for declaring a function prototype 368*1f21f64aSMarius Stroblthat is never used.) 369*1f21f64aSMarius Strobl 370*1f21f64aSMarius StroblA target-specific version of the `systfloat' module can easily be created to 371*1f21f64aSMarius Stroblreplace the generic one. This in fact has been done for the example targets 372*1f21f64aSMarius Strobl`386-Win32-gcc' and `SPARC-Solaris-gcc'. For each target, an assembly 373*1f21f64aSMarius Strobllanguage `systfloat.S' has been created in the target directory along with 374*1f21f64aSMarius Strobla corresponding `systfloat.h' header file defining the `SYST_<function>' 375*1f21f64aSMarius Stroblmacros for the functions implemented. The makefiles of the targets have 376*1f21f64aSMarius Stroblbeen edited to use these target-specific versions of `systfloat' rather than 377*1f21f64aSMarius Stroblthe generic one. 378*1f21f64aSMarius Strobl 379*1f21f64aSMarius StroblThe `systfloat' modules of the example targets have been written entirely 380*1f21f64aSMarius Stroblin assembly language in order to bypass any peculiarities of the C compiler. 381*1f21f64aSMarius StroblAlthough this is probably a good idea, it is certainly not required. 382*1f21f64aSMarius Strobl 383*1f21f64aSMarius Strobl 384*1f21f64aSMarius Strobl------------------------------------------------------------------------------- 385*1f21f64aSMarius StroblSteps to Creating the TestFloat Executables 386*1f21f64aSMarius Strobl 387*1f21f64aSMarius StroblPorting and/or compiling TestFloat involves the following steps: 388*1f21f64aSMarius Strobl 389*1f21f64aSMarius Strobl1. Port SoftFloat and create a SoftFloat binary. (Refer to the 390*1f21f64aSMarius Strobl documentation accompanying SoftFloat.) 391*1f21f64aSMarius Strobl 392*1f21f64aSMarius Strobl2. If one does not already exist, create an appropriate target-specific 393*1f21f64aSMarius Strobl subdirectory under `testfloat' by copying the given `templates' 394*1f21f64aSMarius Strobl directory. The remaining steps occur within the target-specific 395*1f21f64aSMarius Strobl subdirectory. 396*1f21f64aSMarius Strobl 397*1f21f64aSMarius Strobl3. Edit the files `milieu.h' and `Makefile' to reflect the current 398*1f21f64aSMarius Strobl environment. 399*1f21f64aSMarius Strobl 400*1f21f64aSMarius Strobl4. Make `testsoftfloat' by executing `make testsoftfloat' (or `make 401*1f21f64aSMarius Strobl testsoftfloat.exe', or whatever the `testsoftfloat' executable is 402*1f21f64aSMarius Strobl called). Verify that SoftFloat is working correctly by testing it with 403*1f21f64aSMarius Strobl `testsoftfloat'. 404*1f21f64aSMarius Strobl 405*1f21f64aSMarius StroblIf you only wanted `testsoftfloat', you are done. The steps for `testfloat' 406*1f21f64aSMarius Stroblcontinue: 407*1f21f64aSMarius Strobl 408*1f21f64aSMarius Strobl5. In the target-specific subdirectory, implement the `systmodes' and 409*1f21f64aSMarius Strobl `systflags' modules. (The `syst_float_set_rounding_precision' function 410*1f21f64aSMarius Strobl need not do anything if the system does not support extended double 411*1f21f64aSMarius Strobl precision.) 412*1f21f64aSMarius Strobl 413*1f21f64aSMarius Strobl6. If the target machine supports standard floating-point functions that are 414*1f21f64aSMarius Strobl not accessible within ISO/ANSI C, or if the C compiler cannot be trusted 415*1f21f64aSMarius Strobl to use the machine's floating-point directly, create a target-specific 416*1f21f64aSMarius Strobl `systfloat' module. 417*1f21f64aSMarius Strobl 418*1f21f64aSMarius Strobl7. In the target-specific subdirectory, execute `make'. 419*1f21f64aSMarius Strobl 420*1f21f64aSMarius Strobl 421*1f21f64aSMarius Strobl------------------------------------------------------------------------------- 422*1f21f64aSMarius StroblImproving the Random Number Generator 423*1f21f64aSMarius Strobl 424*1f21f64aSMarius StroblIf you are serious about using TestFloat for testing floating-point, you 425*1f21f64aSMarius Stroblshould consider replacing the supplied `random.c' with a better target- 426*1f21f64aSMarius Stroblspecific one. The standard C `rand' function is rather poor on some 427*1f21f64aSMarius Stroblsystems, and consequently `random.c' has been written to assume very little 428*1f21f64aSMarius Stroblabout the quality of `rand'. As a result, the `rand' function is called 429*1f21f64aSMarius Stroblmore frequently than it might need to be, shortening the time before 430*1f21f64aSMarius Stroblthe random number generator repeats, and possibly wasting time as well. 431*1f21f64aSMarius StroblIf `rand' is better on your system, or if another better random number 432*1f21f64aSMarius Stroblgenerator is available (such as `rand48' on most Unix systems), TestFloat 433*1f21f64aSMarius Stroblcan be improved by overriding the given `random.c' with a target-specific 434*1f21f64aSMarius Stroblone. 435*1f21f64aSMarius Strobl 436*1f21f64aSMarius Strobl 437*1f21f64aSMarius Strobl------------------------------------------------------------------------------- 438*1f21f64aSMarius StroblContact Information 439*1f21f64aSMarius Strobl 440*1f21f64aSMarius StroblAt the time of this writing, the most up-to-date information about 441*1f21f64aSMarius StroblTestFloat and the latest release can be found at the Web page `http:// 442*1f21f64aSMarius StroblHTTP.CS.Berkeley.EDU/~jhauser/arithmetic/TestFloat.html'. 443*1f21f64aSMarius Strobl 444*1f21f64aSMarius Strobl 445