560 likes | 711 Views
Rely: Verifying Quantitative Reliability for Programs that Execute on Unreliable Hardware. Michael Carbin , Sasa Misailovic , and Martin Rinard MIT CSAIL. Image Scaling. Image Scaling Kernel: Bilinear Interpolation. =. Bilinear Interpolation.
E N D
Rely: Verifying Quantitative Reliability for Programs that Execute on Unreliable Hardware • Michael Carbin, SasaMisailovic, • and Martin Rinard • MIT CSAIL
Bilinear Interpolation intbilinear_interpolation(inti, int j, intsrc[][], intdest[][]) { inti_src = map_y(i, src, dest), j_src = map_x(j, src, dest); int up = i_src - 1, down = i_src + 1, left = j_src – 1, right = j_src + 1; intval = src[up][left] + src[up][right] + src[down][right] + src[down][left]; return 0.25 * val; }
Bilinear Interpolation intbilinear_interpolation(inti, int j, intsrc[][], intdest[][]) { inti_src = map_y(i, src, dest), j_src = map_x(j, src, dest); int up = i_src - 1, down = i_src + 1, left = j_src – 1, right = j_src + 1; intval = src[up][left] +src[up][right] + src[down][right] +src[down][left]; return 0.25 *val; }
Unreliable Hardware • Unreliable Units (ALUs and Memories) • May produce incorrect results • Faster, smaller, and lower power Memory CPU Registers CU ALU
Image Scaling with Approximate Bilinear Interpolation 20% 40% 99.9% 99% 60% 80% 90% Reliability
Unreliable Hardware • Necessitates • Hardware Specification: probability operations execute correctly • Software Specification: required reliability of computations • Analysis: verify software satisfies its specification on hardware Memory CPU Registers CU ALU
Rely: a Language for Quantitative Reliability Hardware Specification (Architect) Static Analysis (Language) Software Specification (Developer) 20% 40% 99.9% 99% 60% 80% 90% Reliability
Hardware Specification • hardware { • operator (+) = 1 - 10^-7; • operator (-) = 1 - 10^-7; • operator (*) = 1 - 10^-7; • operator (<) = 1 - 10^-7; • memoryurel{rd= 1 - 10^-7, wr= 1}; • }
Approximate Bilinear Interpolation in Rely intbilinear_interpolation(inti, int j, intsrc[][], intdest[][]) { inti_src = map_y(i, src, dest), j_src = map_x(j, src, dest); int up = i_src - 1, down = i_src + 1, left = j_src – 1, right = j_src + 1; intval = src[up][left] +.src[up][right] +. src[down][right] +.src[down][left]; return 0.25 *.val; } Unreliable Operations: executed on unreliable ALUs
Approximate Bilinear Interpolation in Rely intbilinear_interpolation(inti, int j, intin urelsrc[][], intin ureldest[][]) { inti_src = map_y(i, src, dest), j_src = map_x(j, src, dest); int up = i_src - 1, down = i_src + 1, left = j_src – 1, right = j_src + 1; intin urelval= src[up][left] +. src[up][right] +. src[down][right] +. src[down][left]; return 0.25 *. val; } Unreliable Memories: stored in unreliable SRAM/DRAM
Semantics of Reliability • Reliable Hardware • One Execution • Unreliable Hardware • Multiple Executions • Reliability • Probability unreliableexecution reachessame state • Or, = probability over distribution of states that x and y (only) have correct values.
Semantics of Reliability • Reliable Hardware • One Execution • Unreliable Hardware • Multiple Executions • Reliability • Probability unreliableexecution reachessame state • Or, = probability over distribution of states that x and y (only) have correct values.
Approximate Bilinear InterpolationReliability Specification int bilinear_interpolation(inti, int j, int in urelsrc[][], int in ureldest[][]);
Approximate Bilinear InterpolationReliability Specification • Reliability of output is a function of reliability of inputs int<.99> bilinear_interpolation(inti, int j, int in urelsrc[][], int in ureldest[][]);
Approximate Bilinear InterpolationReliability Specification • Reliability of output is a function of reliability of inputs • The term R(i, j, src, dest)abstracts the joint reliabilityof the function’s inputs on entry int<.99 * R(i, j, src, dest)> bilinear_interpolation(inti, int j, int in urelsrc[][], int in ureldest[][]);
Approximate Bilinear InterpolationReliability Specification • Reliability of output is a function of reliability of inputs • The term R(i, j, src, dest)abstracts the joint reliabilityof the function’s inputs on entry • Coefficient .99 bounds reliability degradation int<.99 * R(i, j, src, dest)> bilinear_interpolation(inti, int j, int in urelsrc[][], int in ureldest[][]);
Rely’s Analysis Framework • Precondition generator for statements { Precondition } s { Postcondition } Specification Computation
Assignment Rule x’ = e
Assignment Rule x’ = e Unmodified
Assignment Rule x’ = e Standard Substitution
Assignment Rule • is the probability the expression and write execute correctly x’ = e
Verifying the Reliability of Bilinear Interpolation int<.99 * R(i,j,src,dest)> bilinear_interpolation(inti, int j, intin urelsrc[][], int in ureldest[][]) { inti_src = map_y(i, src, dest), j_src = map_x(j, src, dest); int up = i_src - 1, down = i_src + 1, left = j_src – 1, right = j_src + 1; int in urelval = src[up][left] +. src[up][right] +. src[down][right] +. src[down][left]; return 0.25 *. val; }
Verifying the Reliability of Bilinear Interpolation • Generate postcondition from return statement • Work backwards to produce verification condition • Use hardware specification to replace reliabilities return 0.25 *. val; Reliability of return Reliability of sum of neighbors
Verifying the Reliability of Bilinear Interpolation • Generate postcondition from return statement • Work backwards to produce verification condition • Use hardware specification to replace reliabilities • Discharge Verification Condition return 0.25 *. val;
Verification Condition Checking Insight • Computing full joint distributions is intractable and input distribution dependent
Conjunct Checking • A conjunct is implied by a pair of constraints • Decidable, efficiently checkable,and input distribution agnostic
Verification Condition Checking for Approximate Bilinear Interpolation DataDependences Hardware Specification .99
Conditionals if (y >. 0) x = x+. 1 x = 2 *. x+. 1
Conditionals = y >. 0 if () x1 = x0+. 1 x2= 2 *. x0+. 1
Conditionals = y >. 0 if () x1 = x0+. 1 x2= 2 *. x0+. 1 x = φ(, x1, x2)
Conditionals = y >. 0 if () x1 = x0+. 1 x2= 2 *. x0+. 1 Spec ≤ R(, x1) Spec ≤ R(, x2) x = φ(, x1, x2) Spec ≤ R(x)
Conditionals = y >. 0 if () Spec ≤ op(+.) op(*.) R(, x0) Spec ≤ op(+.) R(, x0) x1 = x0+. 1 x2= 2 *. x0+. 1 Spec ≤ R(, x1) Spec ≤ R(, x2) x = φ(, x1, x2) Spec ≤ R(x)
Conditionals = y >. 0 if () Spec ≤ op(+.) op(*.) R(, x0) Spec ≤ op(+.) R(, x0) x1 = x0+. 1 x2= 2 *. x0+. 1 Spec ≤ R(, x1) Spec ≤ R(, x2) x = φ(, x1, x2) Spec ≤ R(x)
Conditionals Spec ≤ op(+.) op(>.) R(x0, y) Spec ≤ op(+.) op(*.) op(>.) R(x0, y) = y >. 0 if () Spec ≤ op(+.) op(*.) R(, x0) Spec ≤ op(+.) R(, x0) x1 = x0+. 1 x2= 2 *. x0+. 1 Spec ≤ R(, x1) Spec ≤ R(, x2) x = φ(, x1, x2) Spec ≤ R(x)
Simplification Spec ≤ op(+.) op(>.) R(x0, y) Spec ≤ op(+.) op(*.) op(>.) R(x0, y) = y >. 0 if () Spec ≤ op(+.) op(*.) R(, x0) Spec ≤ op(+.) R(, x0) x1 = x0+. 1 x2= 2 *. x0+. 1 Spec ≤ R(, x1) Spec ≤ R(, x2) x = φ(, x1, x2) Spec ≤ R(x)
Simplification Spec ≤ op(+.) op(>.) R(x0, y) Spec ≤ op(+.) op(*.) op(>.) R(x0, y) = y >. 0 if () Spec ≤ op(+.) op(*.) R(, x0) Spec ≤ op(+.) R(, x0) x1 = x0+. 1 x2= 2 *. x0+. 1 Spec ≤ R(, x1) Spec ≤ R(, x2) x = φ(, x1, x2) Spec ≤ R(x)
Loops • Reliability of loop-carried, unreliably updated variables decreases monotonically • Finitely Bounded Loops: bounded decrease • Unbounded loops: conservative result is 0 intsum= 0; for (inti = 0; i < n; i = i+1) { sum = sum+. a[i]; } R(sum) depends on n unreliableadds
Functions • Verification is modular (assume/guarantee) • Recursion similar to loops: unreliably updated variables naturally have 0 reliability y = f(x); int<> f(x);
Rely: a Language for Quantitative Reliability Hardware Specification (Architect) Static Analysis (Language) Software Specification (Developer) 20% 40% 99.9% 99% 60% 80% 90% Reliability
Evaluation • Experiment #1: verify specifications • How does the analysis behave?
Benchmarks • newton: zero-finding using Newton’s method • secant: zero-finding using Secant Method • coord: Cartesian to polar coordinate converter • search_ref: motion estimation • mat_vec: matrix-vector multiply • hadamard: frequency-domain pixel-block difference metric
Experiment #1: Results Observation: small number of conjuncts with simplification
Evaluation • Experiment #2: application scenarios • How to use reliabilities?
Checkable Computations • A simple checker can validate whether the program produced a correct result • Execution time optimization: vs.
Approximate Computations Target Reliability High Quality Quality Bilinear Interpolation Reliability (as Negative Log Failure Probability)