VirtualBox

source: vbox/trunk/src/libs/softfloat-3e/testfloat/doc/TestFloat-source.html

Last change on this file was 94551, checked in by vboxsync, 3 years ago

libs/softfloat: Copied TestFloat-3e from vendor branch and to testfloat subdir. bugref:9898

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/html
File size: 23.3 KB
Line 
1
2<HTML>
3
4<HEAD>
5<TITLE>Berkeley TestFloat Source Documentation</TITLE>
6</HEAD>
7
8<BODY>
9
10<H1>Berkeley TestFloat Release 3e: Source Documentation</H1>
11
12<P>
13John R. Hauser<BR>
142018 January 20<BR>
15</P>
16
17
18<H2>Contents</H2>
19
20<BLOCKQUOTE>
21<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0>
22<COL WIDTH=25>
23<COL WIDTH=*>
24<TR><TD COLSPAN=2>1. Introduction</TD></TR>
25<TR><TD COLSPAN=2>2. Limitations</TD></TR>
26<TR><TD COLSPAN=2>3. Acknowledgments and License</TD></TR>
27<TR><TD COLSPAN=2>4. TestFloat Package Directory Structure</TD></TR>
28<TR><TD COLSPAN=2>5. Dependence on Berkeley SoftFloat</TD></TR>
29<TR><TD COLSPAN=2>6. Issues for Porting TestFloat to a New Target</TD></TR>
30<TR>
31 <TD></TD>
32 <TD>6.1. Standard Headers <CODE>&lt;stdbool.h&gt;</CODE> and
33 <CODE>&lt;stdint.h&gt;</CODE></TD>
34</TR>
35<TR><TD></TD><TD>6.2. Standard Header <CODE>&lt;fenv.h&gt;</CODE></TD></TR>
36<TR><TD></TD><TD>6.3. Macros for Build Options</TD></TR>
37<TR><TD></TD><TD>6.4. Specializing the <CODE>testfloat</CODE> Program</TD></TR>
38<TR><TD></TD><TD>6.5. Improving the Random Number Functions</TD></TR>
39<TR><TD COLSPAN=2>7. Contact Information</TD></TR>
40</TABLE>
41</BLOCKQUOTE>
42
43
44<H2>1. Introduction</H2>
45
46<P>
47This document gives information needed for compiling and/or porting Berkeley
48TestFloat, a small collection of programs for testing that an implementation of
49binary floating-point conforms to the IEEE Standard for Floating-Point
50Arithmetic.
51For basic documentation about TestFloat refer to
52<A HREF="TestFloat-general.html"><NOBR><CODE>TestFloat-general.html</CODE></NOBR></A>.
53</P>
54
55<P>
56The source code for TestFloat is intended to be relatively machine-independent.
57Most programs in the TestFloat package should be compilable with any
58ISO-Standard C compiler that also supports <NOBR>64-bit</NOBR> integers.
59If the all-in-one <CODE>testfloat</CODE> program will be used to test a new
60floating-point implementation, additional effort will likely be required to
61retarget that program to invoke the new floating-point operations.
62TestFloat has been successfully compiled with the GNU C Compiler
63(<CODE>gcc</CODE>) for several platforms.
64</P>
65
66<P>
67<NOBR>Release 3</NOBR> of TestFloat was a complete rewrite relative to
68<NOBR>Release 2c</NOBR> or earlier.
69The current version of TestFloat is <NOBR>Release 3e</NOBR>.
70</P>
71
72<P>
73TestFloat depends on Berkeley SoftFloat, which is a software implementation of
74binary floating-point that conforms to the IEEE Standard for Floating-Point
75Arithmetic.
76SoftFloat is not included with the TestFloat sources.
77It can be obtained from the Web page
78<A HREF="http://www.jhauser.us/arithmetic/SoftFloat.html"><NOBR><CODE>http://www.jhauser.us/arithmetic/SoftFloat.html</CODE></NOBR></A>.
79</P>
80
81
82<H2>2. Limitations</H2>
83
84<P>
85TestFloat assumes the computer has an addressable byte size of either 8 or
86<NOBR>16 bits</NOBR>.
87(Nearly all computers in use today have <NOBR>8-bit</NOBR> bytes.)
88</P>
89
90<P>
91TestFloat is written entirely <NOBR>in C</NOBR>.
92The C compiler used must conform at a minimum to the 1989 ANSI standard for the
93C language (same as the 1990 ISO standard) and must in addition support basic
94arithmetic on <NOBR>64-bit</NOBR> integers.
95Earlier releases of TestFloat were capable of testing <NOBR>32-bit</NOBR>
96single-precision and <NOBR>64-bit</NOBR> double-precision floating-point
97without requiring compiler support for <NOBR>64-bit</NOBR> integers, but this
98option is not supported starting with <NOBR>Release 3</NOBR>.
99Since 1999, ISO standards for C have mandated compiler support for
100<NOBR>64-bit</NOBR> integers.
101A compiler conforming to the 1999 C Standard or later is recommended but not
102strictly required.
103</P>
104
105<P>
106<NOBR>C Standard</NOBR> header files <CODE>&lt;stdbool.h&gt;</CODE> and
107<CODE>&lt;stdint.h&gt;</CODE> are required for defining standard Boolean and
108integer types.
109If these headers are not supplied with the C compiler, minimal substitutes must
110be provided.
111TestFloat&rsquo;s dependence on these headers is detailed later in
112<NOBR>section 6.1</NOBR>, <I>Standard Headers <CODE>&lt;stdbool.h&gt;</CODE>
113and <CODE>&lt;stdint.h&gt;</CODE></I>.
114</P>
115
116
117<H2>3. Acknowledgments and License</H2>
118
119<P>
120The TestFloat package was written by me, <NOBR>John R.</NOBR> Hauser.
121<NOBR>Release 3</NOBR> of TestFloat was a completely new implementation
122supplanting earlier releases.
123The project to create <NOBR>Release 3</NOBR> (now <NOBR>through 3e</NOBR>) was
124done in the employ of the University of California, Berkeley, within the
125Department of Electrical Engineering and Computer Sciences, first for the
126Parallel Computing Laboratory (Par Lab) and then for the ASPIRE Lab.
127The work was officially overseen by Prof. Krste Asanovic, with funding provided
128by these sources:
129<BLOCKQUOTE>
130<TABLE>
131<COL>
132<COL WIDTH=10>
133<COL>
134<TR>
135<TD VALIGN=TOP><NOBR>Par Lab:</NOBR></TD>
136<TD></TD>
137<TD>
138Microsoft (Award #024263), Intel (Award #024894), and U.C. Discovery
139(Award #DIG07-10227), with additional support from Par Lab affiliates Nokia,
140NVIDIA, Oracle, and Samsung.
141</TD>
142</TR>
143<TR>
144<TD VALIGN=TOP><NOBR>ASPIRE Lab:</NOBR></TD>
145<TD></TD>
146<TD>
147DARPA PERFECT program (Award #HR0011-12-2-0016), with additional support from
148ASPIRE industrial sponsor Intel and ASPIRE affiliates Google, Nokia, NVIDIA,
149Oracle, and Samsung.
150</TD>
151</TR>
152</TABLE>
153</BLOCKQUOTE>
154</P>
155
156<P>
157The following applies to the whole of TestFloat <NOBR>Release 3e</NOBR> as well
158as to each source file individually.
159</P>
160
161<P>
162Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 The Regents of the
163University of California.
164All rights reserved.
165</P>
166
167<P>
168Redistribution and use in source and binary forms, with or without
169modification, are permitted provided that the following conditions are met:
170<OL>
171
172<LI>
173<P>
174Redistributions of source code must retain the above copyright notice, this
175list of conditions, and the following disclaimer.
176</P>
177
178<LI>
179<P>
180Redistributions in binary form must reproduce the above copyright notice, this
181list of conditions, and the following disclaimer in the documentation and/or
182other materials provided with the distribution.
183</P>
184
185<LI>
186<P>
187Neither the name of the University nor the names of its contributors may be
188used to endorse or promote products derived from this software without specific
189prior written permission.
190</P>
191
192</OL>
193</P>
194
195<P>
196THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS &ldquo;AS IS&rdquo;,
197AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
198IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
199DISCLAIMED.
200IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
201INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
202BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
203DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
204LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
205OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
206ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
207</P>
208
209
210<H2>4. TestFloat Package Directory Structure</H2>
211
212<P>
213Because TestFloat is targeted to multiple platforms, its source code is
214slightly scattered between target-specific and target-independent directories
215and files.
216The supplied directory structure is as follows:
217<BLOCKQUOTE>
218<PRE>
219doc
220source
221 subj-C
222build
223 template
224 Linux-386-GCC
225 Linux-386-SSE2-GCC
226 Linux-x86_64-GCC
227 Linux-ARM-VFPv2-GCC
228 Win32-MinGW
229 Win32-SSE2-MinGW
230 Win64-MinGW-w64
231</PRE>
232</BLOCKQUOTE>
233The majority of the TestFloat sources are provided in the <CODE>source</CODE>
234directory.
235The <NOBR><CODE>subj-C</CODE></NOBR> subdirectory contains the sources that
236configure the all-in-one <CODE>testfloat</CODE> program to test the C
237compiler&rsquo;s implementation of the standard C types <CODE>float</CODE>,
238<CODE>double</CODE>, and possibly <CODE>long</CODE> <CODE>double</CODE>.
239The &lsquo;<CODE>subj</CODE>&rsquo; in <NOBR><CODE>subj-C</CODE></NOBR> is an
240abbreviation of <I>subject</I>, referring to the floating-point that is the
241subject of the test.
242If <CODE>testfloat</CODE> is retargeted to test other floating-point
243implementations, the corresponding source files would be expected to be in
244other subdirectories alongside <NOBR><CODE>subj-C</CODE></NOBR>, with names of
245the form <NOBR><CODE>subj-&lt;<I>target</I>&gt;</CODE></NOBR>.
246More about retargeting <CODE>testfloat</CODE> is found in
247<NOBR>section 6.4</NOBR>, <I>Specializing the <CODE>testfloat</CODE>
248Program</I>.
249</P>
250
251<P>
252The <CODE>build</CODE> directory is intended to contain a subdirectory for each
253target platform for which builds of the TestFloat programs may be created.
254For each build target, the target&rsquo;s subdirectory is where all derived
255object files and the completed TestFloat executables are created.
256The <CODE>template</CODE> subdirectory is not an actual build target but
257contains sample files for creating new target directories.
258</P>
259
260<P>
261Ignoring the <CODE>template</CODE> directory, the supplied target directories
262are intended to follow a naming system of
263<NOBR><CODE>&lt;<I>execution-environment</I>&gt;-&lt;<I>compiler</I>&gt;</CODE></NOBR>.
264For the example targets,
265<NOBR><CODE>&lt;<I>execution-environment</I>&gt;</CODE></NOBR> is
266<NOBR><CODE>Linux-386</CODE></NOBR>, <NOBR><CODE>Linux-386-SSE2</CODE></NOBR>,
267<NOBR><CODE>Linux-x86_64</CODE></NOBR>,
268<NOBR><CODE>Linux-ARM-VFPv2</CODE></NOBR>, <CODE>Win32</CODE>,
269<NOBR><CODE>Win32-SSE2</CODE></NOBR>, or <CODE>Win64</CODE>, and
270<NOBR><CODE>&lt;<I>compiler</I>&gt;</CODE></NOBR> is <CODE>GCC</CODE>,
271<CODE>MinGW</CODE>, or <NOBR><CODE>MinGW-w64</CODE></NOBR>.
272</P>
273
274<P>
275All of the supplied target directories are merely examples that may or may not
276be correct for compiling on any particular system.
277There are currently no plans to include and maintain in the TestFloat package
278the build files needed for a great many users&rsquo; compilation environments,
279which can span a huge range of operating systems, compilers, and other tools.
280</P>
281
282<P>
283As supplied, each target directory contains two files:
284<BLOCKQUOTE>
285<PRE>
286Makefile
287platform.h
288</PRE>
289</BLOCKQUOTE>
290The provided <CODE>Makefile</CODE> is written for GNU <CODE>make</CODE>.
291A build of TestFloat for the specific target is begun by executing the
292<CODE>make</CODE> command with the target directory as the current directory.
293A completely different build tool can be used if an appropriate
294<CODE>Makefile</CODE> equivalent is created.
295</P>
296
297<P>
298The <CODE>platform.h</CODE> header file exists to provide a location for
299additional C declarations specific to the build target.
300Every C source file of TestFloat contains a <CODE>#include</CODE> for
301<CODE>platform.h</CODE>.
302In many cases, the contents of <CODE>platform.h</CODE> can be as simple as one
303or two lines of code.
304If the target&rsquo;s compiler or library has bugs or other shortcomings,
305workarounds for these issues may be possible with target-specific declarations
306in <CODE>platform.h</CODE>, without the need to modify the main TestFloat
307sources.
308</P>
309
310<P>
311It may not be necessary to build all of the TestFloat programs.
312For testing a floating-point implementation, typically
313<CODE>testfloat_gen</CODE> and <CODE>testfloat</CODE> will not both be used,
314and <CODE>testfloat_ver</CODE> may not be needed either.
315The Makefile (or equivalent) can be modified not to create unneeded programs.
316This may be especially relevant for the all-in-one test program
317<CODE>testfloat</CODE>, which might not build without special attention.
318</P>
319
320
321<H2>5. Dependence on Berkeley SoftFloat</H2>
322
323<P>
324In addition to the distributed sources, TestFloat depends on the existence of a
325compatible Berkeley SoftFloat library and the corresponding header file
326<CODE>softfloat.h</CODE>.
327As mentioned earlier, SoftFloat is a separate package available at Web page
328<A HREF="http://www.jhauser.us/arithmetic/SoftFloat.html"><NOBR><CODE>http://www.jhauser.us/arithmetic/SoftFloat.html</CODE></NOBR></A>.
329The SoftFloat library must be compiled before the TestFloat programs can be
330built.
331In the example Makefiles, the locations of the SoftFloat header files and
332pre-compiled library are specified by these macros:
333<BLOCKQUOTE>
334<DL>
335<DT><CODE>SOFTFLOAT_INCLUDE_DIR</CODE>
336<DD>
337The path of the directory containing <CODE>softfloat.h</CODE>, as well as other
338nonstandard header files referenced by <CODE>softfloat.h</CODE>, if any.
339<DT><CODE>SOFTFLOAT_H</CODE>
340<DD>
341A list of the full paths of all SoftFloat header files needed by SoftFloat
342clients. This list must include <CODE>softfloat.h</CODE> and may also include
343other header files referenced by <CODE>softfloat.h</CODE>, such as
344<CODE>softfloat_types.h</CODE>.
345This macro is used only to establish build dependencies between the SoftFloat
346header files and TestFloat&rsquo;s source files, in case the SoftFloat header
347files are changed.
348<DT><CODE>SOFTFLOAT_LIB</CODE>
349<DD>
350The full path of the compiled SoftFloat library (usually
351<CODE>softfloat.a</CODE> or <CODE>libsoftfloat.a</CODE>).
352</DL>
353</BLOCKQUOTE>
354</P>
355
356
357<H2>6. Issues for Porting TestFloat to a New Target</H2>
358
359<H3>6.1. Standard Headers <CODE>&lt;stdbool.h&gt;</CODE> and <CODE>&lt;stdint.h&gt;</CODE></H3>
360
361<P>
362The TestFloat sources make use of standard headers
363<CODE>&lt;stdbool.h&gt;</CODE> and <CODE>&lt;stdint.h&gt;</CODE>, which have
364been part of the ISO C Standard Library since 1999.
365With any recent compiler, these standard headers are likely to be supported,
366even if the compiler does not claim complete conformance to the latest ISO C
367Standard.
368For older or nonstandard compilers, substitutes for
369<CODE>&lt;stdbool.h&gt;</CODE> and <CODE>&lt;stdint.h&gt;</CODE> may need to be
370created.
371TestFloat depends on these names from <CODE>&lt;stdbool.h&gt;</CODE>:
372<BLOCKQUOTE>
373<PRE>
374bool
375true
376false
377</PRE>
378</BLOCKQUOTE>
379and on these names from <CODE>&lt;stdint.h&gt;</CODE>:
380<BLOCKQUOTE>
381<PRE>
382uint16_t
383uint32_t
384uint64_t
385int32_t
386int64_t
387UINT64_C
388INT64_C
389uint_least8_t
390uint_fast8_t
391uint_fast16_t
392uint_fast32_t
393uint_fast64_t
394int_fast8_t
395int_fast16_t
396int_fast32_t
397int_fast64_t
398</PRE>
399</BLOCKQUOTE>
400</P>
401
402
403<H3>6.2. Standard Header <CODE>&lt;fenv.h&gt;</CODE></H3>
404
405<P>
406Because the supplied all-in-one <CODE>testfloat</CODE> program tests the
407floating-point operations of the C language, it uses the facilities provided by
408standard C header <CODE>&lt;fenv.h&gt;</CODE> to access the floating-point
409environment of C, in particular to set the rounding mode and to access the
410floating-point exception flags.
411Like <CODE>&lt;stdbool.h&gt;</CODE> and <CODE>&lt;stdint.h&gt;</CODE>,
412<CODE>&lt;fenv.h&gt;</CODE> has been part of the ISO C Standard Library since
4131999, but older or nonstandard C compilers may not support it.
414</P>
415
416<P>
417Some form of standard header <CODE>&lt;fenv.h&gt;</CODE> is needed only if the
418<CODE>testfloat</CODE> program is wanted <EM>and</EM> the program will not be
419retargeted to invoke a floating-point implementation in a way that bypasses the
420standard C environment.
421Typically, if <CODE>testfloat</CODE> is wanted, it will be retargeted to invoke
422a new floating-point implementation directly, making
423<CODE>&lt;fenv.h&gt;</CODE> irrelevant.
424For more about retargeting <CODE>testfloat</CODE>, see <NOBR>section 6.4</NOBR>
425below, <I>Specializing the <CODE>testfloat</CODE> Program</I>.
426</P>
427
428
429<H3>6.3. Macros for Build Options</H3>
430
431<P>
432The TestFloat source files are affected by several C preprocessor macros:
433<BLOCKQUOTE>
434<DL>
435<DT><CODE>LITTLEENDIAN</CODE>
436<DD>
437Must be defined for little-endian machines;
438must not be defined for big-endian machines.
439<DT><CODE>INLINE</CODE>
440<DD>
441Can be defined to a sequence of tokens used to indicate that a C function
442should be inlined.
443If the compiler does not support the inlining of functions, this macro must not
444be defined.
445For compilers that conform to the C Standard&rsquo;s rules for inline
446functions, this macro can be defined as the single keyword <CODE>inline</CODE>.
447For other compilers that follow a convention pre-dating the standardization of
448<CODE>inline</CODE>, this macro may need to be defined to <CODE>extern</CODE>
449<CODE>inline</CODE>.
450<DT><CODE>THREAD_LOCAL</CODE>
451<DD>
452Can be defined to a sequence of tokens that, when appearing at the start of a
453variable declaration, indicates to the C compiler that the variable is
454<I>per-thread</I>, meaning that each execution thread gets its own separate
455instance of the variable.
456This macro is used in the supplied version of Berkeley SoftFloat&rsquo;s header
457<CODE>softfloat.h</CODE>, in the declarations of variables
458<CODE>softfloat_roundingMode</CODE>, <CODE>softfloat_detectTininess</CODE>,
459<CODE>extF80_roundingPrecision</CODE>, and
460<CODE>softfloat_exceptionFlags</CODE>.
461To use the supplied, unmodified header <CODE>softfloat.h</CODE>, this macro
462must be defined (or not defined) the same as when the SoftFloat library was
463built.
464</DL>
465<DL>
466<DT><CODE>FLOAT16</CODE>
467<DD>
468Must be defined if the TestFloat programs are to support the
469<NOBR>16-bit</NOBR> half-precision floating-point format.
470<DT><CODE>FLOAT64</CODE>
471<DD>
472Must be defined if the TestFloat programs are to support the
473<NOBR>64-bit</NOBR> double-precision floating-point format.
474<DT><CODE>EXTFLOAT80</CODE>
475<DD>
476Must be defined if the TestFloat programs are to support the
477<NOBR>80-bit</NOBR> double-extended-precision floating-point format.
478<DT><CODE>FLOAT128</CODE>
479<DD>
480Must be defined if the TestFloat programs are to support the
481<NOBR>128-bit</NOBR> quadruple-precision floating-point format.
482<DT><CODE>FLOAT_ROUND_ODD</CODE>
483<DD>
484Must be defined if the TestFloat programs are to support rounding to odd
485(jamming).
486To be useful, this option also requires that the Berkeley SoftFloat library was
487compiled with macro <CODE>SOFTFLOAT_ROUND_ODD</CODE> defined.
488</DL>
489</BLOCKQUOTE>
490Following the usual custom <NOBR>for C</NOBR>, for all the macros except
491<CODE>INLINE</CODE> and <CODE>THREAD_LOCAL</CODE>, the content of a
492macro&rsquo;s definition is irrelevant;
493what matters is a macro&rsquo;s effect on <CODE>#ifdef</CODE> directives.
494</P>
495
496<P>
497It is recommended that any definition of macros <CODE>LITTLEENDIAN</CODE>,
498<CODE>INLINE</CODE>, and <CODE>THREAD_LOCAL</CODE> be made in a build
499target&rsquo;s <CODE>platform.h</CODE> header file, because these macros are
500expected to be determined inflexibly by the target machine and compiler.
501The other five macros select build options, and hence might be better located
502in the target&rsquo;s Makefile (or its equivalent).
503</P>
504
505
506<H3>6.4. Specializing the <CODE>testfloat</CODE> Program</H3>
507
508<P>
509The supplied sources for the all-in-one <CODE>testfloat</CODE> program cause
510<CODE>testfloat</CODE> to test the C compiler&rsquo;s <CODE>float</CODE> and
511<CODE>double</CODE> types for C operations <CODE>+</CODE>, <CODE>-</CODE>,
512<CODE>*</CODE>, <CODE>/</CODE>, etc.
513The supplied version is also capable of testing C type <CODE>long</CODE>
514<CODE>double</CODE> if the sources are compiled with one of these macros
515defined:
516<BLOCKQUOTE>
517<DL>
518<DT><CODE>LONG_DOUBLE_IS_EXTFLOAT80</CODE>
519<DD>
520Indicates that type <CODE>long</CODE> <CODE>double</CODE> is
521<NOBR>80-bit</NOBR> double-extended-precision floating-point.
522<DT><CODE>LONG_DOUBLE_IS_FLOAT128</CODE>
523<DD>
524Indicates that type <CODE>long</CODE> <CODE>double</CODE> is
525<NOBR>128-bit</NOBR> quadruple-precision floating-point.
526</DL>
527</BLOCKQUOTE>
528By default, <CODE>testfloat</CODE> assumes that only the IEEE Standard&rsquo;s
529original four rounding modes (<CODE>near_even</CODE>, <CODE>minMag</CODE>,
530<CODE>min</CODE>, and <CODE>max</CODE>) are supported by the floating-point
531being tested.
532For other rounding modes, additional macro can be defined:
533<BLOCKQUOTE>
534<DL>
535<DT><CODE>SUBJFLOAT_ROUND_NEAR_MAXMAG</CODE>
536<DD>
537Indicates that the subject floating-point supports rounding mode
538<CODE>near_maxMag</CODE> (nearest/away).
539<DT><CODE>SUBJFLOAT_ROUND_ODD</CODE>
540<DD>
541Indicates that the subject floating-point supports rounding mode
542<CODE>odd</CODE> (jamming).
543</DL>
544</BLOCKQUOTE>
545</P>
546
547<P>
548To test a new and/or different implementation of floating-point,
549<CODE>testfloat</CODE> must normally be retargeted to invoke this other
550floating-point instead of C&rsquo;s floating-point.
551Two source files define the functions that <CODE>testfloat</CODE> uses to
552invoke floating-point operations for testing:
553<BLOCKQUOTE>
554<PRE>
555subjfloat_config.h
556subjfloat.c
557</PRE>
558</BLOCKQUOTE>
559For the default target of testing C&rsquo;s floating-point, these files are
560contained in directory <NOBR><CODE>source/subj-C</CODE></NOBR> as discussed
561earlier.
562For a different subject floating-point, it is recommended that appropriate
563versions of <CODE>subjfloat_config.h</CODE> and <CODE>subjfloat.c</CODE> be
564stored in a sibling <NOBR><CODE>subj-&lt;<I>target</I>&gt;</CODE></NOBR>
565directory, where <CODE>&lt;<I>target</I>&gt;</CODE> names the particular
566target.
567</P>
568
569<P>
570Header file <CODE>subjfloat_config.h</CODE> defines a macro of the form
571<CODE>SUBJ_*</CODE> for each subject function supported.
572For example, if function <CODE>subj_f32_add</CODE> exists to perform
573<NOBR>32-bit</NOBR> floating-point addition, then
574<CODE>subjfloat_config.h</CODE> should have a definition for macro
575<CODE>SUBJ_F32_ADD</CODE>.
576The actual function <CODE>subj_f32_add</CODE> is expected to be defined in
577<CODE>subjfloat.c</CODE>, along with all other subject functions.
578A common header file, <CODE>subjfloat.h</CODE>, (not target-specific) provides
579prototype declarations for all possible subject functions that
580<CODE>testfloat</CODE> may be compiled to test, whether actually existing or
581not.
582(There is no penalty for the header to declare prototypes of nonexistent
583functions that are never called.)
584For a specific build of <CODE>testfloat</CODE>, the <CODE>-list</CODE> option
585will list all subject functions that the <CODE>testfloat</CODE> program is able
586to invoke and thus test.
587</P>
588
589<P>
590In the source code as supplied, macros <CODE>LONG_DOUBLE_IS_EXTFLOAT80</CODE>
591and <CODE>LONG_DOUBLE_IS_FLOAT128</CODE> affect only the target-specific source
592files in <NOBR><CODE>source/subj-C</CODE></NOBR>, so these macros can be
593ignored for any other subject floating-point that does not depend on them.
594On the other hand, macros <CODE>SUBJFLOAT_ROUND_NEAR_MAXMAG</CODE> and
595<CODE>SUBJFLOAT_ROUND_ODD</CODE> always determine whether the
596<CODE>testfloat</CODE> program attempts to test rounding modes
597<CODE>near_maxMag</CODE> and <CODE>odd</CODE>, regardless of the subject
598floating-point.
599</P>
600
601
602<H3>6.5. Improving the Random Number Functions</H3>
603
604<P>
605If you are serious about using TestFloat for testing floating-point, you should
606consider replacing the random number functions in <CODE>random.c</CODE>.
607The supplied random number functions are built on top of the standard C
608<CODE>rand</CODE> function.
609Because function <CODE>rand</CODE> is rather poor on some systems, the
610functions in <CODE>random.c</CODE> assume very little about the quality of
611<CODE>rand</CODE>.
612As a result, <CODE>rand</CODE> is called more frequently than it might need to
613be, shortening the time before random number sequences repeat, and possibly
614wasting time as well.
615If <CODE>rand</CODE> is better on a given target platform, or if another,
616better random number generator is available (such as <CODE>rand48</CODE> on
617UNIX-derived systems), TestFloat can be improved by overriding the given
618<CODE>random.c</CODE> with a target-specific one.
619</P>
620
621<P>
622Rather than modifying the supplied file <CODE>random.c</CODE>, it is
623recommended instead that a new, alternate file be created and the
624target&rsquo;s Makefile be modified to refer to that alternate file in place of
625<CODE>random.c</CODE>.
626</P>
627
628
629<H2>7. Contact Information</H2>
630
631<P>
632At the time of this writing, the most up-to-date information about TestFloat
633and the latest release can be found at the Web page
634<A HREF="http://www.jhauser.us/arithmetic/TestFloat.html"><NOBR><CODE>http://www.jhauser.us/arithmetic/TestFloat.html</CODE></NOBR></A>.
635</P>
636
637
638</BODY>
639
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette