Improving the Code Generation of Fixed Point Mathematical Functions with FixM


Daniele Cattaneo, Michele Chiari, Gabriele Magnani, Nicola Fossati, Stefano Cherubin and Giovanni Agosta

Presentation title

Improving the Code Generation of Fixed Point Mathematical Functions with FixM

Authors

Daniele Cattaneo, Michele Chiari, Gabriele Magnani, Nicola Fossati, Stefano Cherubin and Giovanni Agosta

Institution(s)

Politecnico di Milano, Codeplay

Presentation type

Technical presentation

Abstract

Approximate Computing is an increasingly popular approach to achieve large performance and energy improvements in error-tolerant applications [1, 7]. This class of techniques aims at trading off computation accuracy for performance and energy. In particular, among such approximate computing techniques, precision tuning trades off the accuracy of arithmetic operations for performance and energy by employing less precise data types. For example, fixed point is used instead of floating point, or standard 32-bit floating point numbers are replaced with, e.g., bfloat16 [6]. Precision tuning is primarily employed in the field of embedded systems, and in general in environments where it is necessary to achieve high performance with limited resources. However, per- forming precision tuning manually is a non-trivial, error-prone and tedious task, especially when large code bases are involved. To alleviate programmer load, significant research efforts have been spent over the last years to build compiler-based tools to fully or partially automatize this process [3]. However, the current state-of-the-art does not consider the pos- sibility of optimizing mathematical functions whose computation is usually off-loaded to a library. To address this limitation, we extended the TAFFO [5, 4] precision-tuning framework to perform tuning of trigonometric functions as well. We developed a new mathematical function library, which is parameterizable at compile- time depending on the data type, and works natively in the fixed point numeric representation [2]. The parameterized implementa- tions of these functions are then seamlessly inserted by a compiler pass into the program during the precision tuning process. We were able to achieve speedups up to approximately 180% on a microcontroller-based embedded system in benchmarks where trigonometric functions represent the majority of the computational effort, with a negligible cost in terms of error. As a result, we achieved energy savings up to 60%. Previous state-of-the-art float- ing to fixed-point tools are not able to reap any advantages. We demonstrated our approach on the two most common trigono- metric functions, sin and cos, but it is easily extended to the rest of trigonometric functions and then to hyperbolic functions. Future developments include the implementation of these additional func- tions, as well as an exploration of different architectural platforms and of alternative computation algorithms. The integration of F IX M with High Level Synthesis toolchains would also benefit FPGA implementations of algorithms that use trigonometric functions.


Additional material

  • Extended abstract: [pdf]