timesoftfloat
John R. Hauser
2014 Dec 17
The timesoftfloat
program provides a simple way to evaluate the
speed of the floating-point operations of the Berkeley SoftFloat library.
Program timesoftfloat
is included with the Berkeley TestFloat
package, a small collection of programs for testing that an implementation of
floating-point conforms to the IEEE Standard for Binary Floating-Point
Arithmetic.
Although timesoftfloat
does not test floating-point correctness
like other TestFloat programs, nevertheless timesoftfloat
is a
partner to TestFloat’s testsoftfloat
program.
For more about TestFloat generally and testsoftfloat
specifically,
see file
TestFloat-general.html
Ordinarily, timesoftfloat
will measure a function’s speed
separately for each rounding mode defined by the IEEE Floating-Point Standard,
one after the other.
If an operation is not supposed to require rounding, it will by default be
timed only with the rounding mode set to near_even
(nearest/even).
In the same way, if an operation is affected by the way in which underflow
tininess is detected, timesoftfloat
times the function with
tininess detected both before rounding and after rounding.
For timesoftfloat
also times the function
for each of the three rounding precision modes, one after the other.
Evaluation of a function can be limited to a single rounding mode, a single
tininess mode, and/or a single rounding precision with appropriate command-line
options.
For each function and mode evaluated, timesoftfloat
reports the
measured speed of the function in Mop/s, or “millions of operations per
second”.
The speeds reported by timesoftfloat
may be affected somewhat by
other software executing at the same time as timesoftfloat
.
Be aware also that the exact execution time of any SoftFloat function depends
partly on the values of arguments and the state of the processor’s caches
at the time the function is called.
Your actual experience with SoftFloat may differ from the speeds reported by
timesoftfloat
for all these reasons.
Note that the remainder operations (f32_rem
, f64_rem
,
extF80_rem
, and f128_rem
) will be markedly slower
than other operations, particularly for double-extended-precision
(extF80_rem
) and quadruple precision (f128_rem
).
This is inherent to the remainder operation itself and is not a failing of the
SoftFloat implementation.
The timesoftfloat
program is executed as a command with this
syntax:
Square brackets (timesoftfloat [<option>...] <function>
[ ]
) denote optional arguments,
<option>
is a supported option, and
<function>
is the name of either a testable function or a
function set.
The available options and function sets are documented below.
If timesoftfloat
is executed without any arguments, a summary of
usage is written.
The timesoftfloat
program accepts several command options.
If mutually contradictory options are given, the last one has priority.
-help
The -help
option causes a summary of program usage to be written,
after which the program exits.
-precision32, -precision64, -precision80
For -precision32
option restricts
timing of an operation to only the cases in which the rounding precision is
-precision64
fixes the rounding precision to
-precision80
fixes the rounding precision to the full
-rnear_even, -rnear_maxMag, -rminMag, -rmin, -rmax
The -rnear_even
option restricts timing of an operation to only
the cases in which the rounding mode is nearest/even.
Other rounding mode choices are not timed.
Likewise, -rnear_maxMag
forces rounding to nearest/maximum
magnitude (nearest-away), -rminMag
forces rounding to minimum
magnitude (toward zero), -rmin
forces rounding to minimum (down,
toward negative infinity), and -rmax
forces rounding to maximum
(up, toward positive infinity).
These options are ignored for operations that are exact and thus do not round.
-tininessbefore, -tininessafter
The -tininessbefore
option restricts timing of an operation to
only the cases in which tininess on underflow is detected before rounding.
Likewise, -tininessafter
restricts measurement to only the cases
in which tininess on underflow is detected after rounding.
-notexact, -exact
For functions that round to an integer (conversions to integer types and the
roundToInt
functions), the -notexact
option restricts
timing of an operation to only the cases for which the
exact
operand (specifying whether the inexact
exception flag may be raised) is false
.
Likewise, the -exact
option restricts measurement to only the
cases for which the exact
operand is true
.
Just as timesoftfloat
can time a function for all five rounding
modes in sequence, multiple functions can be timed with a single execution of
timesoftfloat
.
Three sets are recognized:
-all1
, -all2
, and -all
.
The set -all1
comprises all one-operand operations,
-all2
is all two-operand operations, and -all
is
obviously all operations.
A function set is used in place of a function name in the
timesoftfloat
command line, such as
timesoftfloat [<option>...] -all1
For the purpose of deciding the number of operands of an operation, any
roundingMode
and exact
arguments are
ignored.
(Such arguments specify the rounding mode and whether the inexact
exception flag may be raised, respectively.)
Thus, functions that convert to integer type and the roundToInt
functions are included in the set of one-operand operations timed by
-all1
.