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