The syntax is 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
- Any sequence of letters, digits, or characters from the
~!@$%^&*_-+=<>.?/:not starting with a digit. The regular expression
[a-zA-Z~!@$%^&*_\-+=<>.?/:][a-zA-Z0-9~!@$%^&*_\-+=<>.?/:]*implements this definition for ASCII alphabets.
- An optional plus (
+) or minus (
-) sign followed by any sequence of digits. These may be optionally followed by a period (
.) and another sequence of digits, which themselves may be optionally followed by an
e, optional plus or minus sign, and a sequence of digits. The regular expression
[-+]?[0-9]+(\.[0-9]+(e[-+]?[0-9]+)?)?implements this definition.
- 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. The regular expression
"([\x20-\x5b\x5d-\x7e]|\\["\\])+?"implements this definition for ASCII alphabets.
The following operations are supported:
|Supported Mathematical Operations|
|fdim||copysign||trunc||round||nearbyint||Supported Testing Operations|
- which can be unary to represent negation.
All operations have the same signature as the equivalent operations
The arithmetic functions are all binary operators,
The comparison operators and boolean operators
or take 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
Following IEEE-754 and common C and Fortran implementations,
FPCore does not prescribe an accuracy to any mathematical
functions except the arithmetic operators,
fma. If the exact accuracy is important, we
recommend that benchmark users declare the implementation used and
its accuracy with
The following constants are supported:
|Supported Mathematical Constants|
|2_SQRTPI||SQRT2||SQRT1_2||INFINITY||NAN||Supported Boolean Constants|
The floating-point constants defined just like their analogs in GNU libc. This gives FPCore support for all constants commonly provided by C and Fortran implementations. All constants are assumed to be the closest floating-point number to the mathematically-accurate value of the constant.
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.
FPCore does not restrict the representation used to represent
values when evaluating FPCore expressions. Numeric values can be
floating point values of various precision, fixed point values, or
(for abstract uses) mathematical reals, though individual FPCore
expressions can use
property to clarify what representation is expected. Evaluation
nonetheless proceeds by fixed rules.
Expressions return either numeric values or boolean values.
Operations that receive values of mixed or incorrect types, such
(+ 1 TRUE) are illegal and the results of
evaluating them undefined.
The semantics of function application are standard.
if expression evaluates the conditional to a
boolean and then returns the result of evaluating the branch
chosen by the conditional.
Bindings in a
let expression are evaluated
simultaneously, as in a simultaneous substitution.
(let ([a b] [b a]) (- a b)) is
the same as
(- b a) and
(let ([a 1] [b a])
b) is illegal unless
a is available in the
context. For sequentially binding variables, use nested
A while loop 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 x0 x*] ...) body)
(if (let ([x x0] ...) cond) (while cond ([x (let ([x x0] ...) x*) x*] ...) body) (let ([x x0] ...) body))
In other words, the bound variables are initialized by evaluating the initial expression in the surrounding context. On each iteration, the conditional is evaluated in the bound context. If the conditional is false, the return expression is evaluated (in the bound context) and its value is returned. If the condition is true, the update expressions for each variable are evaluated (in the bound context), and then each bound variable is updated to its new value.
If a loop has multiple variables, all of the update expressions
are evaluated before any variable is re-bound; in other words,
(while (< i 1) ([i 0 (+ i 1)] [j 0 (+ i j)]) (+ j 1)) is
evaluated by evaluating
0 to 0;
i to 0 and
j to 0;
(< i 1) to truth;
(+ i 1) to 1 and
(+ i j) to 0;
i to 1 and
j to 0;
(< i 1) to falsehood;
and finally evaluating
(+ j 1) to 1.