FPBench is a standard benchmark suite for the floating-point community. The benchmark suite contains a common format for floating-point computation and metadata and a common set of accuracy measures:
- The FPCore input format
- FPCore example inputs
- Metadata for FPCore benchmarks
- Standard measures of error
Benchmarks use a simple S-expression syntax with the following grammar.
In this grammar, an FPCore term describes
a single benchmark, with a set of free variables, a collection of
metadata properties, and the
floating-point expression defining the benchmark. White-space is
ignored, and lines starting with the semicolon (
are treated as comments and ignored. The basic tokens are defined
- An optional plus (
+) or minus (
-) sign, followed by a sequence of decimal digits that form the numerator, followed by a slash (
/), followed by a nonzero sequence of decimal digits that form the denominator. This definition is implemented for ASCII by the regular expression:
Every other kind of numeric literal only expresses rational numbers, so every other type of numeric literal can be considered syntax sugar for rational numbers.
- An optional plus (
+) or minus (
-) sign followed by either a sequence of decimal digits which may optionally be followed by a period (
.) and another sequence of digits, or by a period and a sequence of digits. This may be followed by an
e, an optional plus or minus sign, and a final sequence of digits. This definition is implemented for ASCII by the regular expression:
- An optional plus (
+) or minus (
-) sign, followed by the hexadecimal literal identifier
0x, all followed by either a sequence of hexadecimal digits (
[0-9a-f]) which may optionally be followed by a period (
.) and another sequence of hex digits, or by a period and a sequence of hex digits. This may be followed by a
p, an optional plus or minus sign, and a sequence of decimal digits. This definition is implemented for ASCII by the following regular expression, which is case-insensitive:
- Any sequence of letters, digits, or characters from the
~!@$%^&*_-+=<>.?/:not starting with a digit and not matching any other basic token. In ASCII, all symbols match by this regular expression:
- Any sequence of printable characters, spaces, tabs, or
carriage returns, delimited by double quotes
"). Within the double quotes, backslashes (
\) have special meaning. A backslash followed by a double quote represents a double quote and does not terminate the string; a backslash followed by a backslash represents a backslash; other escapes may also be supported by implementations, but their meaning is not defined in this standard. We recommend that implementations only use escapes defined in the C or Matlab standard libraries. This definition is implemented for ASCII by the regular expression:
The following operations are supported:
|Supported Mathematical Operations|
|fdim||copysign||trunc||round||nearbyint||Supported Testing Operations|
All operations have the same signature as the equivalent operations
The arithmetic functions are all binary operators,
except that unary
- represents negation.
The comparison operators and boolean
or allow an arbitrary number of arguments.
A comparison operator with more than two operators is interpreted
as the conjuction of all ordered pairs of arguments. In other
== tests that all
its arguments are equal;
!= tests that all its
arguments are distinct;
>= test that their arguments are sorted (in
the appropriate order), with equal elements allowed
>=, and disallowed
The following constants are supported:
|Supported Mathematical Constants|
|M_2_SQRTPI||SQRT2||SQRT1_2||INFINITY||NAN||Supported Boolean Constants|
The floating-point constants are defined just like their analogs in GNU libc. All constants must evaluate to a value as close as possible to their mathematically-accurate real value, according to the rounding context.
FPCore expressions can describe concrete floating-point computations, abstract specifications of those computations, or intermediates between the two. The semantics of FPCore are correspondingly flexible, and are made explicit by the rounding context.
Values in FPCore expressions are either boolean values or extended real numbers, which can be actual real numbers (usually rounded to some finite precision) or special floating-point values such as infinities and NaN. Numerical operations take extended real values as input and return the corresponding extended real result, rounded according to a rounding context. The behavior of rounding and the rounding context is described in detail under Rounding.
Operations that receive values of mixed or incorrect types, such
(+ 1 TRUE), are illegal and the results of
evaluating them undefined.
- Function application
- The semantics of function application are standard.
ifexpression evaluates the conditional to a boolean and then returns the result of the first branch if the conditional is true or the second branch if the conditional is false.
Bindings in a
letexpression are evaluated simultaneously, as in a simultaneous substitution. Thus,
(let ([a b] [b a]) (- a b))is the same as
(- b a)and
(let ([a 1] [b a]) b)is illegal unless
ais available in the context. For sequentially binding variables, nest
whileloop contains a conditional, a list of bound variables, and a return expression. Both the conditional and the return expression may refer to the bound variables. While loops are evaluated according the equality:
(while cond ([x init update] ...) retexpr)
(let ([x init] ...) (if cond (while cond ([x update update] ...) retexpr) retexpr)
In other words, the list of bound variables gives the variable's name, its initial value, and the expression by which it is updated to after each iteration. The loop initializes all bound variables; evaluates the condition; if true, simultaneously updates the variables with the update expression and repeats; if false, the return expression is evaluated and its value is returned.
castperforms explicit rounding according to the rounding context. If the context specifies real precision, it is guaranteed to be a no-op.
!annotation updates the rounding context for a subexpression. Properties specified in the annotation are set to the provided values, and all other properties are inherited from the parent context. See Rounding.
digitsconstructor allows exact numbers to be specified in any floating-point radix as a triple of significand (or mantissa), exponent, and base.
(digits m e b)represents exactly the value m ✕ be. m, e, and b are integers, with b ≥ 2. The sign of the value is determined by the sign of m.
FPCore allows the precision of program inputs, constants, and operations to be controlled via a rounding context. The context consists of a set of metadata properties, which affect how function application, casts, and constants are rounded.
Number literals, mathematical constants, and program inputs are rounded according to the rounding context. Variables, however, are not rounded where they appear as values (since they hold rounded values, either from the expressions where they are bound or from rounded program inputs).
Function applications round their results using the rounding context.
More precisely, a function application
(f e1 ...) in a
rounding context ρ must evaluate to the same value as
f were evaluated in exact real
arithmetic, and then rounded according to the rounding context.
vi = ⟦ei⟧ρ
(f ei ...)⟧ρ = round( ρ, ⟦f⟧(vi , ... ) )
Casts behave identically to applying the identity function (and then rounding the result).
FPCore does not restrict the behavior of the rounding function or the set
of metadata properties that its behavior depends on. Some common precision
and rounding direction properties are described for the metadata properties
Tools are not required to support all of these rounding behaviors,
and are allowed to introduce new ones and new metadata properties
to control them.
Rounding contexts are initialized with the properties of the
overall FPCore benchmark and are updated with
! annotations. Program inputs can also be annotated
to describe the precision of the input.
! annotations use lexical scoping. For example, in the expression
the subtraction will take place in a context
binary32 precision, but the addition will take
place in a context that has inherited
precision from the annotation enclosing the
let. Both operations will take place in a
context that has inherited
behavior. The examples
contain more details.
If tools do not support the rounding context specified for a computation, the result is undefined, and the tool should give some indication of the reason for the failure. FPCore does not restrict the representation used internally by a tool to store values. Numeric values can be floating-point values of various precisions, fixed-point values, intervals, or any sort of symbolic representations of mathematical real numbers. Though FPCore can represent exact real computations, tools are not required to be able to represent arbitrary real numbers exactly.