Detecting and Fixing Precision-Specific Operations for Measuring Floating-Point Errors

Similar documents
Microsoft PowerPoint - STU_EC_Ch02.ppt

Improved Preimage Attacks on AES-like Hash Functions: Applications to Whirlpool and Grøstl

Microsoft PowerPoint _代工實例-1

~ ~

C C

Microsoft Word - 澎湖田調報告_璉謙組.doc

(baking powder) 1 ( ) ( ) 1 10g g (two level design, D-optimal) 32 1/2 fraction Two Level Fractional Factorial Design D-Optimal D

2/80 2

C/C++语言 - C/C++数据

CC213

A VALIDATION STUDY OF THE ACHIEVEMENT TEST OF TEACHING CHINESE AS THE SECOND LANGUAGE by Chen Wei A Thesis Submitted to the Graduate School and Colleg

SHIMPO_表1-表4

Microsoft Word - 論文封面 修.doc

SHIMPO_表1-表4

TA-research-stats.key

Microsoft Word - chnInfoPaper6

Microsoft Word - A _ doc

Microsoft PowerPoint ARIS_Platform_en.ppt

Shanghai International Studies University THE STUDY AND PRACTICE OF SITUATIONAL LANGUAGE TEACHING OF ADVERB AT BEGINNING AND INTERMEDIATE LEVEL A Thes

®

McGraw-Hill School Education Group Physics : Principles and Problems G S 24

<4D F736F F D20B1D0B14DACE D303133A6A8AA47B3F8A76928A4FDAFC0AD7329>

Microsoft Word - Preface_1_14.doc

(Pattern Recognition) 1 1. CCD

Microsoft PowerPoint - STU_EC_Ch08.ppt

JOURNAL OF EARTHQUAKE ENGINEERING AND ENGINEERING VIBRATION Vol. 31 No. 5 Oct /35 TU3521 P315.

穨423.PDF

一般社団法人電子情報通信学会 信学技報 THE INSTITUTE OF ELECTRONICS, IEICE Technical Report INFORMATION THE INSTITUTE OF AND ELECTRONICS, COMMUNICATION ENGINEERS IEICE L

Corpus Word Parser 183

Microsoft Word - 01李惠玲ok.doc

Vol. 36 ( 2016 ) No. 6 J. of Math. (PRC) HS, (, ) :. HS,. HS. : ; HS ; ; Nesterov MR(2010) : 90C05; 65K05 : O221.1 : A : (2016)

(Microsoft Word - \261M\256\327\272\353\302\262\263\370\247iEnd.doc)

纽约留学日记

EXCEL EXCEL

< F63756D656E D2D796E2D31C6DABFAF2D31D6D0D2BDD2A9CFD6B4FABBAF2D C4EA2DB5DA38C6DA2D30362DC3F1D7E5D2BDD2A92E6D6469>

Microsoft PowerPoint - ATF2015.ppt [相容模式]

林教授2.PDF

Vol. 22 No. 4 JOURNAL OF HARBIN UNIVERSITY OF SCIENCE AND TECHNOLOGY Aug GPS,,, : km, 2. 51, , ; ; ; ; DOI: 10.

VLBI2010 [2] 1 mm EOP VLBI VLBI [3 5] VLBI h [6 11] VLBI VLBI VLBI VLBI VLBI GPS GPS ( ) [12] VLBI 10 m VLBI 65 m [13,14] (referen

2 137 [5]. [6].. [7]. [8-9].. (PCA) PCA HIS C1C2C3.. RGB Hotelling. [1-11]. R G B 3. RGB 1) RGB M N 3 x = [x R x G x B ] T. RGB 3 3 C x (1)

1 ABSTRACT

156 ( ) [2] [ 3 ] [ 4 ] [5] [6] 1747 [ 7 ] ( ) [ 8 ] [2] 12 [3] [4] [5] [6] [7] [

2015年4月11日雅思阅读预测机经(新东方版)

2015 Chinese FL Written examination

度 身 體 活 動 量 ; 芬 蘭 幼 兒 呈 現 中 度 身 體 活 動 量 之 比 例 高 於 臺 灣 幼 兒 (5) 幼 兒 在 投 入 度 方 面 亦 達 顯 著 差 異 (χ²=185.35, p <.001), 芬 蘭 與 臺 灣 幼 兒 多 半 表 現 出 中 度 投 入 與 高 度

ii

PowerPoint Presentation

SuperMap 系列产品介绍

Achieving One TeraFLOPS with 28-nm FPGAs

<4D F736F F F696E74202D20B5DAD2BBD5C228B4F2D3A1B0E6292E BBCE6C8DDC4A3CABD5D>

Journal of Curriculum Studies September, 2013, Vol. 8, No. 2, pp A Study of the Relationship between Senior High School Curriculum and the Mult

WWW PHP

Microsoft Word 谢雯雯.doc

ENGG1410-F Tutorial 6

Microsoft PowerPoint - NCBA_Cattlemens_College_Darrh_B

untitled

Untitiled

普通高等学校本科专业设置管理规定

,,,;, ;,,,,,,,,,,, ;, (),, ; ; ;,,,,,,,,,,,,,, ;,,,,, :;,,,,,,,,,, ;,,,;,,;,,,,;,,,, 41

59 1 CSpace 2 CSpace CSpace URL CSpace 1 CSpace URL 2 Lucene 3 ID 4 ID Web 1. 2 CSpace LireSolr 3 LireSolr 3 Web LireSolr ID

Microsoft Word - 11-秦华伟.doc

01 招 生 简 章 03 考 试 说 明 04 笔 试 样 题 2 emba.pbcsf.tsinghua.edu.cn

1.2 资 金 的 管 理 1.1 权 利 义 务 来 源 MOU 1.3 数 据 的 使 用 和 保 护 2 国 际 空 间 站 资 源 分 配 方 案 54

"航海王"人物人格特質探究doc

ZS.indd

<4D F736F F D20B8DFB9B0B0D3B0D3F5E0D3A6C1A6CAB5B2E2D3EBBCC6CBE3BDE1B9FBB2EED2ECD4ADD2F2B7D6CEF62DD5C5B9FAD0C22E646F6378>

Corporate Social Responsibility CSR CSR CSR 1 2 ~ CSR 6 CSR 7 CSR 8 CSR 9 10 ~ CSR 14 CSR CSR 2013 A A 23.

Chinese Journal of Applied Probability and Statistics Vol.25 No.4 Aug (,, ;,, ) (,, ) 应用概率统计 版权所有, Zhang (2002). λ q(t)

(2005 (2006, (2006 ( , ( ,,,,,, ( (ASFR ASFR : x, B x x, P f x x (1 (2 4,, , 2 1 :, 1 2, 20-29

中 国 药 事 2016 年 7 月 第 30 卷 第 7 期 709 体 外 诊 断 试 剂 是 指 用 生 物 化 学 免 疫 学 微 生 物 学 分 子 生 物 学 等 原 理 或 方 法 制 备, 在 体 外 用 于 对 人 体 疾 病 的 诊 断 筛 查 或 监 测 及 流 行 病 学 调

3.1 num = 3 ch = 'C' 2

2011_1_核红.indd

%


~ 10 2 P Y i t = my i t W Y i t 1000 PY i t Y t i W Y i t t i m Y i t t i 15 ~ 49 1 Y Y Y 15 ~ j j t j t = j P i t i = 15 P n i t n Y

國家圖書館典藏電子全文

天 主 教 輔 仁 大 學 社 會 學 系 學 士 論 文 小 別 勝 新 婚? 久 別 要 離 婚? 影 響 遠 距 家 庭 婚 姻 感 情 因 素 之 探 討 Separate marital relations are getting better or getting worse? -Exp

27 :OPC 45 [4] (Automation Interface Standard), (Costom Interface Standard), OPC 2,,, VB Delphi OPC, OPC C++, OPC OPC OPC, [1] 1 OPC 1.1 OPC OPC(OLE f

4 115,,. : p { ( x ( t), y ( t) ) x R m, y R n, t = 1,2,, p} (1),, x ( t), y ( t),,: F : R m R n.,m, n, u.,, Sigmoid. :,f Sigmoid,f ( x) = ^y k ( t) =

Thesis for the Master degree in Engineering Research on Negative Pressure Wave Simulation and Signal Processing of Fluid-Conveying Pipeline Leak Candi

2 ( 自 然 科 学 版 ) 第 20 卷 波 ). 这 种 压 缩 波 空 气 必 然 有 一 部 分 要 绕 流 到 车 身 两 端 的 环 状 空 间 中, 形 成 与 列 车 运 行 方 向 相 反 的 空 气 流 动. 在 列 车 尾 部, 会 产 生 低 于 大 气 压 的 空 气 流

untitled

國立中山大學學位論文典藏.PDF

PowerPoint Presentation

国学思想与大学数学

<4D F736F F D20B8BDBCFE3220BDCCD3FDB2BFD6D8B5E3CAB5D1E9CAD2C4EAB6C8BFBCBACBB1A8B8E6A3A8C4A3B0E5A3A92E646F6378>

~ 4 mm h 8 60 min 1 10 min N min 8. 7% min 2 9 Tab. 1 1 Test result of modified

Microsoft Word - 上傳電子檔.doc

mm 400 mm 15 mm EOF mm/10a Fig. 1 Distributions

<4D F736F F D BFC6BCBCB9A4D7F7C4EAB1A82D FD0DEB8B4B5C45F2E646F63>

Microsoft Word - ch05note_1210.doc

g 100mv /g 0. 5 ~ 5kHz 1 YSV8116 DASP 1 N 2. 2 [ M] { x } + [ C] { x } + [ K]{ x } = { f t } 1 M C K 3 M C K f t x t 1 [ H( ω )] = - ω 2

[1] Nielsen [2]. Richardson [3] Baldock [4] 0.22 mm 0.32 mm Richardson Zaki. [5-6] mm [7] 1 mm. [8] [9] 5 mm 50 mm [10] [11] [12] -- 40% 50%

Microsoft Word doc

Abstract There arouses a fever pursuing the position of being a civil servant in China recently and the phenomenon of thousands of people running to a

2005硕士论文模版

Coudert and Couharde 2005 Goldstein and Lardy % 36% Cline and Williamson 2007 Penn World Table = 100 Krugman 2009 Berg

1. 前 言 由 於 石 油 價 格 浮 動, 汽 油 價 格 節 節 高 升 及 二 氧 化 碳 等 廢 棄 大 量 排 放 造 成 全 球 環 境 的 改 變, 因 此 世 界 各 國 都 極 力 提 倡 節 能 減 碳 進 而 掀 起 腳 踏 車 城 市 的 風 潮 因 應 目 前 自 行 車

論文集29-1_前6P.indd

92南師學術研討會

Transcription:

Detecting Inaccuracies in Floating- Point Programs Yingfei Xiong, Peking University Collaboration with Daming Zou, Ran Wang, Zhendong Su, Xinrui He, Lu Zhang, Gang Huang, Hong Mei

Floating-Point Inaccuracy 0.1 + 0.1 + 0.1 + + 0.1 10000 times Code: float x = 0, a = 0.1; for(int i = 0; i < 10000; i++) { x = x + a; } printf("%.6f", x); Output: 999.902893

Floating-Point Inaccuracy 0.1 + 0.1 + 0.1 + + 0.1 10000 times Code: double x = 0, a = 0.1; for(int i = 0; i < 10000; i++) { x = x + a; } printf("%.6lf", x); Output: 1000.000000

问题背景 浮点误差会导致严重的后果 在海湾战争中, 爱国者导弹由于累积的浮点误差拦截失败, 造成了 28 人丧生

Measure Errors Absolute error: Error abs = x ideal x fp Relative error: Error rel = x ideal x fp x ideal x ideal

Precision Tuning Code: float x = 0, a = 0.1; for(int i = 0; i < 10000; i++) { x = x + a; } printf("%.6f", x); x orignal = 999.902893 Raise precision Code: double x = 0, a = 0.1; for(int i = 0; i < 10000; i++) { x = x + a; } printf("%.6lf", x); x high = 1000.000000

Measure Errors with Precision Tuning Absolute error: Error abs = x ideal x fp Relative error: Error rel = x ideal x fp x ideal x high x original x high x original x high

Precision-Unspecific Semantics Floating-point variables Real numbers Floating-point operations Real number operations Technique: precision tuning On-the-fly detection of instability problems in floating-point program execution A dynamic program analysis to find floating-point accuracy problems Efficient search for inputs causing high floating-point errors Trustworthy numerical computation in scala Automatically improving accuracy for floating point expressions A genetic algorithm for detecting significant floating-point inaccuracies

Assumption: High precision usually produce more accurate output Is it true?

Example A code piece simplified from exp function in the GNU C library: 1: double x = 3.7; 2: double n = 6755399441055744.0; 3: double y = (x + n) n; Answer from computer: y = 4 Raise precision to long double: Answer from computer: y = 3.7002

Example A code piece simplified from exp function in the GNU C library: 1: double x = 3.7; 2: double n = 6755399441055744.0; 3: double y = (x + n) n; The goal of this code is to round x to the nearest integer. n is a magic number specially designed for double precision. (n = 1.5 2 52 )

Example A code piece simplified from exp function in the GNU C library: 1: double x = 3.7; 2: double n = 6755399441055744.0; 3: double y = (x + n) n; A precision-specific operation

Precision-Specific Semantics double x = 3.7; double n = 6755399441055744.0; double y = (x + n) n; Interpret as rounding x to the nearest integer Problems Any other form of precision-specific operations? How to understand its intention? How to compose n for different precisions?

Precision-Specific Semantics double x = 3.7; double n = 6755399441055744.0; double y = (x + n) n; Interpret as rounding x to the nearest integer Problems Any other form of precision-specific operations? How to understand its intention? How to compose n for different precisions? Solution A heuristic to detect precision-specific operations. A fixing approach to enable precision tuning under the presence of precision-specific operations.

Heuristic An instruction is possibly precision-specific if it results in large error inflation in most executions. Intuition Two sources of errors in computations Accumulated Errors: usually small Cancellation: normally occurs in a few executions

Fixing High precision normal operation normal operation normal operation normal operation normal operation Precision-specific operation normal operation normal operation normal operation normal operation High precision Original precision High precision

Fixing Example... x = 3.7; n = 6755399441055744.0; temp = x + n; y = temp n;... Long Double Double Long Double

Automatic Detection Overview Sampling Fixing Execution Detection

Evaluation

Subjects 48 double version math functions of the GNU C library (GLIBC).

Research Questions Distribution Precision and recall Fixing Existing studies

RQ1: Distribution of Precision- Specific Operations FUNCTIONS Others 23 Precisionspecific functions 25

RQ1: Distribution of Precision- Specific Operations FILES Precisionspecific files 10 Others 33

RQ1: Distribution of Precision- Specific Operations In total, 48 precision-specific operations are detected. PRECISION SPECIFIC OPERATIONS Rounding 44 Multiplication 2 Bit operation 2

RQ2: Precision and Recall Precision: 77.5% Recall: 97.92% Detected operations False positives Multiplication Rounding Bit operation

RQ3: Fixing How effective is our fixing approach? We evaluate the average relative error to standard value. Original precision Average Relative error Program High precision Average Relative error Standard value High precision with fixing Average Relative error

RQ3: Automatic Fixing Automatic fixing: fix detected instruction. The results from automatic fix are more accurate than the original precision and the high precision in the vast majority of cases. Precision Recall, error, error Automatic Fixing (E = 10 7 ) > O < O > H < H 20 1 12 2 O: original precision. H: high precision. >: better than. <: worse than

RQ4: Review Existing Study subjects subjects subjects return call Precision-specific Fixed precisionspecific functions functions in GLIBCin GLIBC Function Reported error Actual error exprel_2 2.85e+00 5.25e-12 synchrotron_1 5.35e-03 2.24e-13 synchrotron_2 3.67e-03 5.97e-15 equake (sin, cos) Around 5.00e-01 --

小结与问题 修复精度特定运算之后, 我们可以得到一次计算的误差 如何知道整个程序上是否存在较大误差? 通常我们无法遍历整个程序的输入空间

基于搜索的误差查找 从输入空间选择一个输入 采用动态分析获得对应误差 分析获得下一个输入 关键问题

实证研究 从 GSL 中选取 4 个函数, 仅变化浮点数的尾数位或指数位, 观察它们和内部误差之间的关系 IEEE 754 Floating-Point Representation Single Precision Double Precision Sign Exponent Significand 1 8 23 1 11 52

Log(Relative Error) Log(Relative Error) Log(relative Error) Log(Relative Error) 指数位与误差的关系 -14-15 -16-17 -18 Relative Error by Exponent - legendre_q1 0 206 412 618 824 10301236144216481854 Exponent of Input -9-11 -14-16 -18 Relative Error by Exponent - erf 0 206 412 618 824 10301236144216481854 Exponent of Input Relative Error by Exponent - Ci Relative Error by Exponent - bessel_k0 0-5 -9-14 -18 0 206 412 618 824 10301236144216481854 Exponent of Input -4-8 -11-15 -18 1 104 207 310 413 516 619 722 825 928 Exponent of Input

指数部分对误差的大小有重大影响

能触发大误差的指数往往只存在于一个很小的范围

在大误差的附近常常有高于平均误差的小波动

大误差常常出现在浮点数中段位置

尾数位和浮点数之间的关系

尾数位对浮点误差有显著影响

大量尾数都能触发大误差, 并且在数轴上呈均匀分布

局部敏感型遗传算法 根据以上特征, 本研究设计了局部敏感型遗传算法 对于指数位 初始化时更多生成中位数附近 数值变异 对于尾数位 随机生成 随机变异

实验评估 有效性检验 : 在 6 个经典浮点数程序上测试 结果证明 LSGA 可以区分 stable 和 unstable 程序, 初步证明了算法的可行性与有效性 检验结果 Newton Inv Root Poly Exp Cos Stable? stable stable unstable unstable unstable unstable Max. Error Detected 2.8E-16 3.2E-16 8.1E+76 7.1E-11 1.0E+00 9.2E-01

实验评估 从 GSL 中选取 154 个函数 与随机算法, 标准遗传算法对比

实验评估 检测到最大误差 Total RAND STD LSGA Tied 154 11 (7%) 24 (16%) 105 (68%) 14 (9%) Sign Test 结果 n+ n- N p LSGA vs. RAND 127 12 139 < 4.14e-22 LSGA vs. STD 110 30 140 < 2.46e-11 STD vs. RAND 93 40 133 < 6.52e-06

实验评估 找到潜在内部精度问题的能力 如何定义潜在问题? 相对误差大于 0.1% 绝对误差大于预估绝对误差 10 倍以上

实验评估

小结 浮点数误差是软件开发的经典问题 本研究成果可以自动查找软件代码中的浮点误差问题 本研究成果避免了已有方法可能产生的错误结论 实验结果显示, 我们设计的算法可以在实践中被广泛使用的库函数中找到潜在的精度问题 相关论文 Daming Zou, Ran Wang, Yingfei Xiong, Lu Zhang, Zhendong Su, Hong Mei. A Genetic Algorithm for Detecting Significant Floating-Point Inaccuracies. ICSE'15: 37th International Conference on Software Engineering, pages 529-539, May 2015 Ran Wang, Daming Zou, Xinrui He, Yingfei Xiong, Lu Zhang, Gang Huang. Detecting and Fixing Precision-Specific Operations for Measuring Floating-Point Errors. FSE'16: 24th ACM SIGSOFT International Symposium on the Foundations of Software Engineering, November 2016.