EnerJ: Approximate Data Types for Safe and General Low-Power Computation (PLDI’2011) Adrian Sampson, Werner Dietl, Emily Fortuna Danushen Gnanapragasam, Luis Ceze, Dan Grossman University of Washington Presented by Xianwei Zhang
Overview Observations o Energy is an increasing concern in computer systems (phones, data centers, etc) o Systems spend a significant amount of energy guaranteeing correctness o Many applications have high tolerance to run-time faults. Challenge to exploit energy-accuracy tradeoff o Isolate parts of the program that must be precise from those that can be approximated so that a program functions correctly even QoS degrades. Contributions o Propose a safe and general model for approximate programming o Present EnerJ, an extension of Java with type qualifiers o Demonstrate effectiveness using proposed approximation-aware architecture. 2/20/ Presented by Xianwei Zhang
Perfect Correctness is Not Always Required No perfect answers or hard to get perfect answers o Heuristic algorithms, inherent incorrectness. Care more about aggregate trends o Large-scale data analytics, trends instead of individual data elements. 2/20/2016 3
Not All Data Are Error Resilient Non-critical portion - safely to do approximation o E.g., errors in output pixel data are tolerable and even undectable. Critical portion - must be protected from error o Small errors in image format make the output unreadable. 2/20/ ✗ ✓
Type System for Approximate Computation Safety o Separate critical and non-critical program components. Generality o A range of approximation strategies supported with a single abstraction. EnerJ, an extension to Java that adds approximate data types. o Type qualifiers o Endorsement o Operator overloading o Prevention of implicit flows o Objects: qualifier polymorphism 2/20/2016 5
Type int a = int p = …; p = a; a = p; 2/20/ Every value has an approximate or precise type Precise types are the is made explicit Illegal to assign approx into a precise-typed variable ✓ ✗
Endorsement: Escape int a = expensiveCal(); int p; //precise by default p = endorse (a); //legal quickChecksum (p); output (p); 2/20/ Fully isolating approx and precise parts is not very useful o Programs usually have a phase of fault-tolerant computation followed by a phase of fault-sensitive reduction or output o E.g., image manipulation phase, then a critical checksum over the result. Programmer controls explicitly when approx data can affect precise state
Logic Approximation: int a = …; int p = …; p + p; int int p + a; a + a; int int 2/20/ Overload operators and methods based on type qualifiers o E.g., two signatures for + operator on integers.
Control int a = …; int p = …; if (a == 10) { p = 2; } 2/20/ Disallow implicit flows that occur via control flow o While p is precise and no assignment is present, its value is affected. The restriction is conservative o Prohibits approx conditions even when the result can affect only approx. Work around the restriction using int a = …; int p = …; if (endorse (a == 10)) { p = 2; } ✗ ✓
class FloatSet float[] nums = …; float mean() { calculate mean float mean_APPROX() { take mean of first 1/2 } 2/20/ Classes also support approximation enable approx or precise instances non-static members, depends on the instance’s type o _APPROX: specialize method definitions based on class type FloatSet pSet; pSet.mean(); FloatSet aSet; aSet.mean(); //mean_APPROX
Architectural Approximation Approximate storages o Registers: precise and approx are distinguished using register number o Cache and memory: distinguished by address. Approximate operations o Approx instructions use special FUs that perform approx operations. 2/20/
Hardware Techniques for Saving Energy Voltage scaling in logic circuits Width reduction is FP operations DRAM refresh rate SRAM supply voltage 2/20/
Implementation Annotation o Manually annotate each application using EnerJ o Focused on critical code where most of the time is spent. Simulation o Implemented a compiler and runtime system that executes EnerJ code o Utilize instrumentation calls to inject transient faults to emulate approx. Approximation o Reduce FP bit-width, flip bit of accesses into SRAM and DRAM o Assumption: heap data in DRAM, stack data in SRAM. 2/20/
Annotated Declarations Primary approx data is in a small portion of code Annotations are sparse and straightforward to insert 2/20/
Energy Savings Save 9%-48% of total execution energy Majority of savings come from Base to Mild 2/20/
Output Error Metric: compare approx result against precise one “Mild” configuration is a good fit for all 2/20/
Summary Approximate computing is promising o A new way to save energy in large classes of applications. Proposed type system o Variables and objects can be declared as approx or precise o Safe: guarantees precise unless given explicit programmer permission o General: unifies approx data storage, approx computation and approx algs. Implementations and evaluations o Implemented the type system atop of Java and tested with several apps o Annotations are easy to insert o For annotated programs, the runtime system or arch can choose multi approx execution techniques o Hardware-based model shows potential energy savings in 9%-48% range. 2/20/ Presented by Xianwei Zhang