• 中国计算机学会会刊
  • 中国科技核心期刊
  • 中文核心期刊

计算机工程与科学 ›› 2022, Vol. 44 ›› Issue (06): 979-985.

• 高性能计算 • 上一篇    下一篇

基于编译时插桩的浮点异常检测方法

郭思雨,王磊   

  1. (中原工学院前沿信息技术研究院,河南 郑州 450007)

  • 收稿日期:2021-09-24 修回日期:2021-12-14 接受日期:2022-06-25 出版日期:2022-06-25 发布日期:2022-06-17

A floating-point exception detection method based on pile insertion at compile time

GUO Si-yu,WANG Lei   

  1. (The Frontier Information Technology Research Institute,Zhongyuan University of Technology,Zhengzhou 450007,China)
  • Received:2021-09-24 Revised:2021-12-14 Accepted:2022-06-25 Online:2022-06-25 Published:2022-06-17

摘要: 浮点数是实数的有限精度编码,在进行浮点计算时,可能会导致不精确或者异常的结果,因此实现有效的浮点异常检测方法很重要。现有异常检测方法不面向浮点数学函数,由此提出了一种面向浮点数学函数的异常检测方法。该方法依据IEEE-754标准中定义的上溢出、下溢出、被零除、无效操作和不精确5类异常,并结合申威高性能数学函数库中使用的浮点控制寄存器FPCR和IEEE-754标准定义的浮点异常产生条件的相关理论,通过将异常类型和浮点运算指令进行对应分类,在程序编译时进行插桩以检测出浮点数学函数中出现的异常,同时记录代码覆盖率。最后将该方法应用于数学函数库,对库中100多个浮点数学函数进行了测试实验。实验结果表明,该浮点异常检测方法能够有效检测各类异常。

关键词: 浮点数学函数, IEEE-754, 插桩, 异常检测

Abstract: Floating point number is the finite precision coding of real number, which may lead to inexact or exception results in floating point calculation, so it is very important to realize effective floating point exception detection methods. The existing exception detection methods are not oriented to floating-point mathematical functions. In view of the above phenomena, a floating-point mathematical function-oriented exception detection method is proposed. This method is based on five types of exceptions defined in the IEEE-754 standard: overflow, underflow, division by zero, invalid operation and inexact, and is combined with the relevant theories of floating-point exception generation conditions defined by the floating-point control register FPCR and IEEE-754 standard used in Sunway high- performance mathematical function library. By classifying the exception types and floating-point operation instructions, pile insertion is carried out when the program is compiled, so as to detect the exceptions in the floating-point mathematical functions, and record the code coverage at the same time. In the experiment, this method is applied to a mathematical function library, and more than 100 floating-point mathematical functions in the library are tested. Experimental results show that the proposed floating-point exception detection method can effectively detect various types of exceptions. 


Key words: floating-point mathematical function, IEEE-754, insertion pile, exception detection