Proposed Consistent Exception Handling for the BLAS and LAPACK

James Demmel, Jack J. Dongarra, Mark Gates, Greg Henry, Julien Langou, Xiaoye S. Li, Piotr Luszczek, Weslley S. Pereira, E. Jason Riedy, Cindy Rubio-González

TL;DR

Numerical software, especially foundational libraries like BLAS and LAPACK, often handles exceptions inconsistently, leading to unpredictable behavior in critical applications. This paper proposes a unified and flexible exception handling mechanism for BLAS and LAPACK to ensure consistent, resilient, and user-controllable error reporting, paving the way for more robust numerical software.

What Problem Does This Paper Address?

As computational systems become more pervasive (e.g., self-driving cars, health monitors), the reliability of numerical software is paramount. Numerical exceptions like overflow, division by zero, or convergence failures are inevitable. However, widely used linear algebra libraries such as BLAS (Basic Linear Algebra Subprograms) and LAPACK (Linear Algebra PACKage) exhibit inconsistent ways of handling these exceptions. This inconsistency makes it difficult for developers to build higher-level, resilient applications, as the behavior of these fundamental building blocks can be unpredictable. The paper aims to address this by designing a consistent and flexible exception handling system for BLAS and LAPACK.

Methods

The authors propose a new interface for LAPACK routines that extends the existing INFO parameter. This new interface introduces three additional arguments: FLAG_REPORT, INFO_ARRAY, and CONTEXT.

  • FLAG_REPORT: This argument, a pair of integers, allows users to specify what kinds of exceptions to check (WHAT) and how to report them (HOW). Options range from disabling all checks to detailed reporting of inputs, outputs, and internal subroutine calls.
  • INFO_ARRAY: This array provides more detailed reporting than the single INFO scalar, capturing information about specific arguments, internal calls, and the nature of the exceptions.
  • CONTEXT: This opaque argument is designed to support multi-threaded environments, allowing different threads to manage exception handling independently.

The paper also details how this new interface would be implemented in specific LAPACK routines like SGESV, SGETRF, and SGETRS, and discusses the necessary modifications to BLAS routines to ensure consistent behavior. They also propose a testing methodology using "fuzzing" to systematically inject exceptions and verify the new handling mechanisms.

Datasets

Not discussed in the paper. The paper focuses on the design and implementation of an exception handling interface for existing libraries rather than training or evaluating models on specific datasets.

Key Insights and Ideas

  • Inconsistency is pervasive: The paper highlights numerous examples of inconsistent exception handling across different BLAS and LAPACK routines, and even within different vendor implementations of BLAS.
  • User needs are diverse: Users have conflicting requirements, from wanting minimal changes to their existing code to needing fine-grained control over error reporting and debugging. The proposed interface aims to accommodate this spectrum.
  • Flexibility is key: A single, rigid exception handling mechanism is insufficient. The proposed system offers configurable options for both the types of checks performed and the reporting methods.
  • Layered approach to testing: "Fuzzing" (injecting exceptions) is proposed as a robust method to test the consistency and propagation of exceptions across the library's call tree.
  • Trade-offs exist: Achieving perfect consistency might incur performance penalties, and the design balances these trade-offs with ease of use and complexity.

Key Results

The paper presents a detailed proposal for a new exception handling interface for LAPACK and discusses its application to key routines like SGESV, SGETRF, and SGETRS. It includes sample implementations of the new interface routines (CHECKINIT1, CHECKINIT2, SGECHECKARG, CHECKCALL, UPDATE_INFO, SGEINFNAN) and modified LAPACK routines (SGESV_EC, SGETRF_EC, SGETRF2_EC, SGETRS_EC). The authors also provide test cases for BLAS routines (IxAMAX, xNRM2) that reveal inconsistencies in current implementations, with the proposed new BLAS routines aiming to pass these tests. While quantitative results are not the primary focus, the paper demonstrates the feasibility of the proposed interface and its potential to improve the robustness of numerical software.

Limitations and Future Work

  • Compromises are necessary: The authors acknowledge that some inconsistencies are outside their control, stemming from different programming languages, compilers, and vendor BLAS implementations.
  • Bit-wise reproducibility: Achieving bit-wise reproducibility of numerical results and exceptions across different platforms and compiler settings is left for future work.
  • Testing rigor: While fuzzing is proposed, a formal proof of correctness for exception handling is suggested as future work.
  • Vendor adoption: The success of the proposed BLAS changes relies on vendors adopting them.
  • Customization of REPORT_EXCEPTIONS: The paper provides placeholder implementations for REPORT_EXCEPTIONS, leaving the detailed customization to other software providers.
  • Further testing and feedback: The authors explicitly welcome comments on their design choices and plan to extend the implementation and testing to the rest of LAPACK.

Summary updated

Abstract

Numerical exceptions, which may be caused by overflow, operations like division by 0 or sqrt(−1), or conver-gence failures, are unavoidable in many cases, in particular when software is used on unforeseen and difficult inputs. As more aspects of society become automated e.g., self-driving cars, health monitors, and cyber-physical systems more generally, it is becoming increasingly important to design software that is resilient to exceptions, and that responds to them in a consistent way. Consistency is needed to allow users to build higher-level software that is also resilient and consistent (and so on recursively). In this paper we explore the design space of consistent exception handling for the widely used BLAS and LAPACK linear algebra libraries, pointing out a variety of instances of inconsistent exception handling in the current versions, and propose a new design that balances consistency, complexity, ease of use, and performance. Some compromises are needed, because there are preexisting inconsistencies that are outside our control, including in or between existing vendor BLAS implementations, different programming languages, and even compilers for the same programming language. And user requests from our surveys are quite diverse. We also propose our design as a possible model for other numerical software, and welcome comments on our design choices.
BibTeX
@inproceedings{demmel2022proposed,
  author = {James Demmel and Jack J. Dongarra and Mark Gates and Greg Henry and Julien Langou and Xiaoye S. Li and Piotr Luszczek and Weslley S. Pereira and E. Jason Riedy and Cindy Rubio-González},
  title = {{Proposed Consistent Exception Handling for the BLAS and LAPACK}},
  booktitle = {Correctness@SC},
  year = {2022},
  url = {https://openreview.net/forum?id=N0fwTpagNE},
}

Loading related content...

Figure