The FPBench project's FPCore format is a common format for the floating-point research community. However, it can be challenging to translate source code originally written in an imperative language to FPCore. To help, FPBench provides FPImp, an imperative language that can be used as an intermediate language from which to generate FPCore.
This page describes the semantics of FPImp and describes the tools FPBench provides to manipulate it.
FPImp is a simple imperative programming language that compiles to FPCore. Like FPCore, it uses a simple S-expression syntax.
Unlike FPCore, which is expression-oriented, FPImp has both
statements and expressions. Expressions may be any FPCore
expression, while the statements come in three types:
while loops, and many-way
statements. The semantics of assignments,
if statements is standard.
FPImp also allows multiple outputs. This is helpful for
translating code with Fortran
out parameters or C
pointer arguments. Note
output cmds are only valid at
the end of an FPImp program—FPImp does not allow multiple exits from
the a program.
imp2core tool, which ships in
the tools/ directory of the
can compile FPImp programs to FPCore. Run:
racket tools/imp2core.rkt [options] < file.fpimp > file.fpcore
preserves propertys, and compiles each
FPImp program to multiple FPCore computations, one for each output
of the FPImp program.
imp2core accepts two options that modify its
letbindings, instead expanding the
letbindings by substituting the bound variable's value in the final expression. Can produce much larger programs.
--one-to-oneoption can be set to
firstto use only the first output of the FPImp expression, or to
multto use that operator to combine the outputs of the FPImp expression.
An FPImp reference interpreter is also located in the tools/ directory of the FPBench codebase, and can be run with:
racket tools/fpimp.rkt arguments ... < file.fpimp
The arguments in this case are real numbers using the standard floating-point number syntax. For example, running:
racket tools/fpimp.rkt 1.0 2.0 (FPImp (x y) [= z (+ x y)] (output z))