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, implemented for ASCII by the regular expression:
- 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, implemented for ASCII by the 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
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
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. All constants must evaluate to a value as close as possible to their mathematically-accurate real value.
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.
- 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, use nested
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 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 list of bound variables gives the variable's name, its initial value, and the value it is updated to after each iteration. The loop is executed by initializing all bound variables and then evaluating the condition and simultaneously updating the variables until the condition returns false. Once the condition returns false, the return expression is evaluated and its value is returned.