summaryrefslogtreecommitdiff
path: root/doc/testsoftfloat.html
blob: 705ad84c3f4d2f0c58fb2abffa716f73ddda1bd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236

<HTML>

<HEAD>
<TITLE>testsoftfloat</TITLE>
</HEAD>

<BODY>

<H1>Berkeley TestFloat Release 3c: <CODE>testsoftfloat</CODE></H1>

<P>
John R. Hauser<BR>
2017 February 10<BR>
</P>


<H2>Overview</H2>

<P>
The <CODE>testsoftfloat</CODE> program tests that a build of the Berkeley
SoftFloat library conforms to the IEEE Standard for Binary Floating-Point
Arithmetic as expected.
Program <CODE>testsoftfloat</CODE> is part of the Berkeley TestFloat package, a
small collection of programs for performing such tests.
For general information about TestFloat, as well as for basics about the
operation of <CODE>testsoftfloat</CODE> and how to interpret its output, see
file
<A HREF="TestFloat-general.html"><NOBR><CODE>TestFloat-general.html</CODE></NOBR></A>.
</P>

<P>
Note that, even if there are no bugs in the source code for SoftFloat (not
guaranteed), a build of SoftFloat might still fail due to an issue with the
build process, such as an incompatible compiler option or a compiler bug.
</P>

<P>
The <CODE>testsoftfloat</CODE> program will ordinarily test a function for all
five rounding modes defined by the IEEE Floating-Point Standard, one after the
other, plus possibly a sixth mode, <I>round to odd</I> (depending on the
options selected when <CODE>testsoftfloat</CODE> was compiled).
If an operation is not supposed to require rounding, it will by default be
tested only with the rounding mode set to <CODE>near_even</CODE>
(nearest/even).
In the same way, if an operation is affected by the way in which underflow
tininess is detected, <CODE>testsoftfloat</CODE> tests the function with
tininess detected both before rounding and after rounding.
For <NOBR>80-bit</NOBR> double-extended-precision operations affected by
rounding precision control, <CODE>testsoftfloat</CODE> also tests the function
for all three rounding precision modes, one after the other.
Testing can be limited to a single rounding mode, a single tininess mode,
and/or a single rounding precision with appropriate command-line options.
</P>


<H2>Command Syntax</H2>

<P>
The <CODE>testsoftfloat</CODE> program is executed as a command with this
syntax:
<BLOCKQUOTE>
<PRE>
testsoftfloat [&lt;<I>option</I>&gt;...] &lt;<I>function</I>&gt;
</PRE>
</BLOCKQUOTE>
Square brackets (<CODE>[ ]</CODE>) denote optional arguments,
<CODE>&lt;<I>option</I>&gt;</CODE> is a supported option, and
<CODE>&lt;<I>function</I>&gt;</CODE> is the name of either a testable function
or a function set.
The available options and function sets are documented below.
If <CODE>testsoftfloat</CODE> is executed without any arguments, a summary of
usage is written.
</P>


<H2>Options</H2>

<P>
The <CODE>testsoftfloat</CODE> program accepts several command options.
If mutually contradictory options are given, the last one has priority.
</P>

<H3><CODE>-help</CODE></H3>

<P>
The <CODE>-help</CODE> option causes a summary of program usage to be written,
after which the program exits.
</P>

<H3><CODE>-seed &lt;<I>num</I>&gt;</CODE></H3>

<P>
The <CODE>-seed</CODE> option sets the seed for the pseudo-random number
generator used for generating test cases.
The argument to <CODE>-seed</CODE> is a nonnegative integer.
Executing the same <CODE>testsoftfloat</CODE> program with the same arguments
(including the same pseudo-random number seed) should always perform the same
sequence of tests, whereas changing the pseudo-random number seed should result
in a different sequence of tests.
The default seed number <NOBR>is 1</NOBR>.
</P>

<H3><CODE>-level &lt;<I>num</I>&gt;</CODE></H3>

<P>
The <CODE>-level</CODE> option sets the level of testing.
The argument to <CODE>-level</CODE> can be either 1 <NOBR>or 2</NOBR>.
The default is <NOBR>level 1</NOBR>.
Level 2 performs many more tests than <NOBR>level 1</NOBR> and thus can reveal
bugs not found by <NOBR>level 1</NOBR>.
</P>

<H3><CODE>-errors &lt;<I>num</I>&gt;</CODE></H3>

<P>
The <CODE>-errors</CODE> option instructs <CODE>testsoftfloat</CODE> to report
no more than the specified number of errors for any combination of function,
rounding mode, etc.
The argument to <CODE>-errors</CODE> must be a nonnegative decimal integer.
Once the specified number of error reports has been generated,
<CODE>testsoftfloat</CODE> ends the current test and begins the next one, if
any.
The default is <NOBR><CODE>-errors</CODE> <CODE>20</CODE></NOBR>.
</P>

<P>
Against intuition, <NOBR><CODE>-errors</CODE> <CODE>0</CODE></NOBR> causes
<CODE>testsoftfloat</CODE> to report every error it finds.
</P>

<H3><CODE>-errorstop</CODE></H3>

<P>
The <CODE>-errorstop</CODE> option causes the program to exit after the first
function for which any errors are reported.
</P>

<H3><CODE>-forever</CODE></H3>

<P>
The <CODE>-forever</CODE> option causes a single function to be repeatedly
tested.
Only one rounding mode and/or rounding precision can be tested in a single
execution.
If not specified, the rounding mode defaults to nearest/even.
For <NOBR>80-bit</NOBR> double-extended-precision functions, the rounding
precision defaults to full double-extended precision.
The testing level is set to 2 by this option.
</P>

<H3><CODE>-precision32, -precision64, -precision80</CODE></H3>

<P>
For <NOBR>80-bit</NOBR> double-extended-precision funcions affected by
rounding precision control, the <CODE>-precision32</CODE> option restricts
testing to only the cases in which the rounding precision is
<NOBR>32 bits</NOBR>, equivalent to <NOBR>32-bit</NOBR> single-precision.
The other rounding precision choices are not tested.
Likewise, <CODE>-precision64</CODE> fixes the rounding precision to
<NOBR>64 bits</NOBR>, equivalent to <NOBR>64-bit</NOBR> double-precision;
and <CODE>-precision80</CODE> fixes the rounding precision to the full
<NOBR>80 bits</NOBR> of the double-extended-precision format.
All these options are ignored for operations not affected by rounding precision
control.
</P>

<H3><CODE>-rnear_even, -rnear_maxMag, -rminMag, -rmin, -rmax, -rodd</CODE></H3>

<P>
The <CODE>-rnear_even</CODE> option restricts testing to only the cases in
which the rounding mode is nearest/even.
The other rounding mode choices are not tested.
Likewise, <CODE>-rnear_maxMag</CODE> forces rounding to nearest/maximum
magnitude (nearest-away), <CODE>-rminMag</CODE> forces rounding to minimum
magnitude (toward zero), <CODE>-rmin</CODE> forces rounding to minimum (down,
toward negative infinity), <CODE>-rmax</CODE> forces rounding to maximum (up,
toward positive infinity), and <CODE>-rodd</CODE>, if supported, forces
rounding to odd.
These options are ignored for operations that are exact and thus do not round.
</P>

<H3><CODE>-tininessbefore, -tininessafter</CODE></H3>

<P>
The <CODE>-tininessbefore</CODE> option restricts testing to only the cases in
which tininess on underflow is detected before rounding.
Likewise, <CODE>-tininessafter</CODE> restricts testing to only the cases in
which tininess on underflow is detected after rounding.
</P>

<H3><CODE>-notexact, -exact</CODE></H3>

<P>
For functions that round to an integer (conversions to integer types and the
<CODE>roundToInt</CODE> functions), the <CODE>-notexact</CODE> option restricts
testing to only the cases for which the <CODE><I>exact</I></CODE> operand
(specifying whether the <I>inexact</I> exception flag may be raised) is
<CODE>false</CODE>.
Likewise, the <CODE>-exact</CODE> option restricts testing to only the cases
for which the <CODE><I>exact</I></CODE> operand is <CODE>true</CODE>.
</P>


<H2>Function Sets</H2>

<P>
Just as <CODE>testsoftfloat</CODE> can test a function for all five or six
rounding modes in sequence, multiple functions can be tested with a single
execution of <CODE>testsoftfloat</CODE>.
Two sets are recognized:  <CODE>-all1</CODE> and <CODE>-all2</CODE>.
The set <CODE>-all1</CODE> is all one-operand operations, while
<CODE>-all2</CODE> is all two-operand operations.
A function set is used in place of a function name in the
<CODE>testsoftfloat</CODE> command line, such as
<BLOCKQUOTE>
<PRE>
testsoftfloat [&lt;<I>option</I>&gt;...] -all1
</PRE>
</BLOCKQUOTE>
</P>

<P>
For the purpose of deciding the number of operands of an operation, any
<CODE><I>roundingMode</I></CODE> and <CODE><I>exact</I></CODE> arguments are
ignored.
(Such arguments specify the rounding mode and whether the <I>inexact</I>
exception flag may be raised, respectively.)
Thus, functions that convert to integer type and the <CODE>roundToInt</CODE>
functions are included in the set of one-operand operations tested by
<CODE>-all1</CODE>.
</P>


</BODY>