A floating-point library for integer processors

Christian Bertin, Nicolas Brisebarre, Benoît Dupont de Dinechin, Claude-Pierre Jeannerod, Christophe Monat, Jean‐Michel Muller, Saurabh-Kumar Raina, Arnaud TisserandProceedings of SPIE, the International Society for Optical Engineering/Proceedings of SPIE 2004 · DOI

TL;DR

This paper introduces a C library designed to bring single-precision floating-point (FP) arithmetic to processors lacking dedicated FP hardware, common in embedded systems. The library offers flexible IEEE 754 compliance and demonstrates significant performance improvements over existing software solutions on STMicroelectronics' VLIW processors.

What Problem Does This Paper Address?

Many embedded systems, particularly those involved in digital signal processing, image processing, and control, rely on integer or fixed-point processors to reduce cost and power consumption. However, algorithms that naturally deal with real numbers often require floating-point operations. Implementing these on integer-only processors necessitates complex scaling operations within the software, which is error-prone, time-consuming, and dependent on the specific algorithm and data range. This creates a significant challenge when porting applications from general-purpose processors with FP units to these embedded environments. The paper addresses this by providing a software-based FP emulation layer that is efficient and compliant with the IEEE 754 standard.

Methods

The core of this work is a C library that implements the five basic floating-point operations: addition, subtraction, multiplication, division, and square root. The library is designed to be highly compliant with the IEEE 754 standard for single-precision floating-point numbers, offering options for full compliance or relaxed modes that exclude denormal numbers or use restricted rounding modes.

Key methodological aspects include:

  • Decomposition of Operations: Each FP operation is broken down into four phases: operand decomposition, special value handling, result computation, and output setup.
  • Efficient Special Value Handling: A significant focus is placed on efficiently handling special values like ±∞, ±0, and NaN. This is achieved through a clever use of bitwise operations and comparisons to filter these cases in a minimal number of instructions, avoiding costly "if-then-else" chains.
  • Optimized Algorithms: The library leverages specific processor features, such as the ST200's "count leading zero" instruction, to accelerate computations.
  • Flexible Compliance: Users can choose between a version with full denormal number support and a version without it, allowing for trade-offs between strict standard adherence and performance. Similarly, different rounding modes are supported.
  • Targeted Optimization: The library is specifically optimized and validated for the ST200 family of VLIW processors from STMicroelectronics.

Datasets

Not discussed in the paper. The paper focuses on algorithmic implementation and performance evaluation rather than training on large datasets.

Key Insights and Ideas

  • Special Values are "Rare" but Critical: The paper highlights that while special values (NaN, infinity, zero) are infrequent in typical computations, their efficient handling is crucial for correctness and can significantly impact performance if not optimized. The proposed method for detecting special values in a single test is a key insight.
  • Trade-offs in IEEE 754 Compliance: The library demonstrates that not all aspects of the IEEE 754 standard are equally critical for all applications. Offering options to exclude denormal numbers or use simpler rounding modes can lead to substantial performance gains without sacrificing overall numerical integrity for many use cases.
  • Processor-Specific Optimizations Pay Off: The library's performance on the ST200 VLIW processor is significantly boosted by utilizing its specific instruction set, particularly the "count leading zero" instruction. This underscores the importance of tailoring software to the target hardware architecture.
  • Minimal Code Size Impact for Applications: Despite individual operations potentially having larger code sizes, the overall impact on complete applications is shown to be very small, suggesting that instruction cache performance is unlikely to be negatively affected.

Key Results

The paper reports significant performance improvements for the new floating-point library compared to an "original library" (presumably a less optimized or older software implementation).

  • Addition: The new library (without denormals) is 36% faster (37 bundles vs. 58 bundles) and the version with denormals is 26% faster (43 bundles vs. 58 bundles).
  • Multiplication: The new library (without denormals) is 30% faster (31 bundles vs. 44 bundles) and the version with denormals is 21% faster (35 bundles vs. 44 bundles).
  • Division: The new library (without denormals) is 32% faster (117 bundles vs. 171 bundles) and the version with denormals is 23% faster (131 bundles vs. 171 bundles).
  • Square Root: The new library (without denormals) is 13% faster (107 bundles vs. 123 bundles) and the version with denormals is 8% faster (113 bundles vs. 123 bundles).
  • Application-Level Performance: For typical numerical applications (dot product, integration, linear systems), the improvement with the new library (without denormals) is around 11-14%, and about 5-9% for the version with denormals.
  • Code Size: The code size for individual operations can increase by up to 50%, but the impact on overall application code size is less than 1%.

Limitations and Future Work

  • Flags Not Supported: The current implementation does not handle the IEEE 754 flags (invalid operation, overflow, underflow, division by zero, inexact result). This is noted as a future work item.
  • Denormal Handling Optimization: While the library supports denormal numbers, the authors suggest that further optimization and speed-up for these cases is a direction for future research.
  • Extension of Operations: The library currently covers the basic five FP operations. Future work could extend the set of available operations to include more complex algebraic functions like x², x*y + z, 1/x, 1/√x, and 1/√(x² + y²).
  • Broader Architecture Support: While validated on ST200 VLIW processors, extending the library to other processor architectures without FP hardware would be valuable.

Summary updated

Abstract

This paper presents a C library for the software support of single precision floating-point (FP) arithmetic on processors without FP hardware units such as VLIW or DSP processor cores for embedded applications. This library provides several levels of compliance to the IEEE 754 FP standard. The complete specifications of the standard can be used or just some relaxed characteristics such as restricted rounding modes or computations without denormal numbers. This library is evaluated on the ST200 VLIW processors from STMicroelectronics.
BibTeX
@inproceedings{bertin2004floating,
  author = {Christian Bertin and Nicolas Brisebarre and Benoît Dupont de Dinechin and Claude-Pierre Jeannerod and Christophe Monat and Jean‐Michel Muller and Saurabh-Kumar Raina and Arnaud Tisserand},
  title = {{A floating-point library for integer processors}},
  booktitle = {Proceedings of SPIE, the International Society for Optical Engineering/Proceedings of SPIE},
  year = {2004},
  doi = {10.1117/12.557168},
}
Figure