University of Maryland Using Dyninst to Measure Floating-point Error Mike Lam, Jeff Hollingsworth and Pete Stewart.

Slides:



Advertisements
Similar presentations
1/1/ / faculty of Electrical Engineering eindhoven university of technology Introduction Part 2: Data types and addressing modes dr.ir. A.C. Verschueren.
Advertisements

2009 Spring Errors & Source of Errors SpringBIL108E Errors in Computing Several causes for malfunction in computer systems. –Hardware fails –Critical.
Fixed Point Numbers The binary integer arithmetic you are used to is known by the more general term of Fixed Point arithmetic. Fixed Point means that we.
Arithmetic in Computers Chapter 4 Arithmetic in Computers2 Outline Data representation integers Unsigned integers Signed integers Floating-points.
The Assembly Language Level
Numerical Analysis 1 EE, NCKU Tien-Hao Chang (Darby Chang)
2-1 Chapter 2 - Data Representation Computer Architecture and Organization by M. Murdocca and V. Heuring © 2007 M. Murdocca and V. Heuring Computer Architecture.
Lecture 16: Computer Arithmetic Today’s topic –Floating point numbers –IEEE 754 representations –FP arithmetic Reminder –HW 4 due Monday 1.
ECIV 201 Computational Methods for Civil Engineers Richard P. Ray, Ph.D., P.E. Error Analysis.
1 Lecture 9: Floating Point Today’s topics:  Division  IEEE 754 representations  FP arithmetic Reminder: assignment 4 will be posted later today.
Round-Off and Truncation Errors
1 Error Analysis Part 1 The Basics. 2 Key Concepts Analytical vs. numerical Methods Representation of floating-point numbers Concept of significant digits.
CISE-301: Numerical Methods Topic 1: Introduction to Numerical Methods and Taylor Series Lectures 1-4: KFUPM.
February 26, 2003MIPS floating-point arithmetic1 Question  Which of the following are represented by the hexadecimal number 0x ? —the integer.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. by Lale Yurttas, Texas A&M University Chapter 31.
Floating Point Analysis Using Dyninst Mike Lam University of Maryland, College Park Jeff Hollingsworth, Advisor.
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to C++ Programming Outline Introduction to C++ Programming A Simple Program: Printing a.
Information Representation (Level ISA3) Floating point numbers.
Computer Organization and Architecture Computer Arithmetic Chapter 9.
Computer Arithmetic. Instruction Formats Layout of bits in an instruction Includes opcode Includes (implicit or explicit) operand(s) Usually more than.
Background (Floating-Point Representation 101)  Floating-point represents real numbers as (± sig × 2 exp )  Sign bit  Significand (“mantissa” or “fraction”)
Numeric precision in SAS. Two aspects of numeric data in SAS The first is how numeric data are stored (how a number is represented in the computer). –
Fixed-Point Arithmetics: Part II
Computer Science 111 Fundamentals of Programming I Number Systems.
Lecture 2 Number Representation and accuracy
CISE301_Topic11 CISE-301: Numerical Methods Topic 1: Introduction to Numerical Methods and Taylor Series Lectures 1-4:
Modifying Floating-Point Precision with Binary Instrumentation Michael Lam University of Maryland, College Park Jeff Hollingsworth, Advisor.
Numeric Processing Chapter 6, Exploring the Digital Domain.
Data Representation in Computer Systems
ME 142 Engineering Computation I Computer Precision & Round-Off Error.
Round-off Errors.
Fixed and Floating Point Numbers Lesson 3 Ioan Despi.
Round-off Errors and Computer Arithmetic. The arithmetic performed by a calculator or computer is different from the arithmetic in algebra and calculus.
Lecture 9: Floating Point
CSC 221 Computer Organization and Assembly Language
MECN 3500 Inter - Bayamon Lecture 3 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo
ECE 456 Computer Architecture
Engineering Analysis ENG 3420 Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
University of Maryland Dynamic Floating-Point Error Detection Mike Lam, Jeff Hollingsworth and Pete Stewart.
Overview of Previous Lesson(s) Over View  A program must be translated into a form in which it can be executed by a computer.  The software systems.
Integer and Fixed Point P & H: Chapter 3
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Chapter 3.
Lecture 4 - Numerical Errors CVEN 302 June 10, 2002.
1 Lecture 10: Floating Point, Digital Design Today’s topics:  FP arithmetic  Intro to Boolean functions.
Errors in Numerical Methods
IT11004: Data Representation and Organization Floating Point Representation.
CS 125 Lecture 3 Martin van Bommel. Overflow In 16-bit two’s complement, what happens if we add =
First Foray into Programming (the hard way). A reminder from last lesson: A machine code instruction has two parts:  Op-code  Operand An instruction.
Introduction to error analysis Class II "The purpose of computing is insight, not numbers", R. H. Hamming.
Chapter 2 Errors in Numerical Methods and Their Impacts.
1 CE 454 Computer Architecture Lecture 4 Ahmed Ezzat The Digital Logic, Ch-3.1.
Machine arithmetic and associated errors Introduction to error analysis Class II.
Floating Point Math & Representation
IEEE floating point format
A Closer Look at Instruction Set Architectures
Chapter 6 Floating Point
Arithmetic for Computers
Lecture 10: Floating Point, Digital Design
Errors in Numerical Methods
Errors in Numerical Methods
(Part 3-Floating Point Arithmetic)
Approximations and Round-Off Errors Chapter 3
Chapter 1 / Error in Numerical Method
Computer Organization and Assembly Language
Dynamic Binary Translators and Instrumenters
Presentation transcript:

University of Maryland Using Dyninst to Measure Floating-point Error Mike Lam, Jeff Hollingsworth and Pete Stewart

University of Maryland 2 Floating-Point Overview Floating-point representation components Sign (+/-) Significand/mantissa (s) Exponent (e) Base (b) - implicit, usually 2 Observations Actual value is ± s·b e Minimum positive value is called machine  Precision = # of bits in significand Error = |TrueValue - StoredValue|

University of Maryland 3 Problems Quantization error Introduced at initialization Roundoff error Accumulates through operations Cancellation error Occurs under specific conditions

University of Maryland 4 Previous Solutions Reduce error by increasing precision Double-precision (64 bits) Quad-precision (128 bits) Arbitrary-precision libraries Track error Manually insert shadow value analysis in source code Static analysis to bound error mathematically

University of Maryland 5 Motivation Goal Measure floating-point error automatically Benefits Less human effort Less error-prone Better performance by selectively using lower precision where error is at acceptable levels

University of Maryland 6 Our Solution Binary instruction instrumentation No intermediate representation (like w/ Valgrind) We can ignore compiler optimizations No source code required (like w/ static analysis) No special hardware required (like w/ PAPI) Dyninst API Minimal tool code (<1500 LOC) Support for static binary rewriting

University of Maryland 7 Our Solution Two parts Dyninst mutator to insert instrumentation Mutator(Mutatee) => Mutant Runtime library with analysis routines Instrument all floating point instructions In x87, all d8, d9, dc, dd, and de opcodes Insert calls to profiler library with: Raw instruction bytes Register values (EAX-EDX,ESP,EBP)

University of Maryland 8 Quantization Error Overview We can’t store a true value directly Error will be less than machine  Current status Exact solution requires a priori knowledge Currently have to ignore or bound Upper limit is a function of machine 

University of Maryland 9 Overview Error grows with calculations Example: (A is true value, a is stored value) Roundoff Error Error:  Error: 2 

University of Maryland 10 Roundoff Error Sparse shadow value table Maps memory addresses to errors Need to maintain error through FP registers First eight addresses correspond to registers ST0 through ST7 Instrument main() At entry point, initialize shadow value table At exit point, print shadow value table

University of Maryland 11 Roundoff Error For each FP instruction: Use XED to extract info about each operand: Location (register number or memory address) Current value Read/write/both Read current error from shadow value table Calculate new error Save error back to shadow value table

University of Maryland 12 Current status Works for rough upper bounds, but is handicapped because of quantization error Unclear which formulas are best Problem with moves through integer registers Roundoff Error

University of Maryland 13 Cancellation Error Overview Loss of significance during operations Example: = e-16 “Catastrophic” loss of significance Current status Detect this by examining floating-point operands

University of Maryland 14 Cancellation Error Message queue Contains list of cancellation error events Instrument main() At entry point, initialize message queue At exit point, print messages to standard output

University of Maryland 15 Cancellation Error For each FP instruction: Use XED to extract value of each operand Calculate resulting value and compare magnitudes (exponents) If e ans < max(e x,e y ) there is a cancellation For each cancellation event: Record a “priority:” max(e x,e y ) - e ans Save event information to message queue

University of Maryland 16 Results archPI.c Approximates  using two different series and compares results against the known value Series #1 2 cancellations of 51 binary digits each Series diverges to NaN Series #2 No cancellations Final series result is Actual value of  is

University of Maryland 17 Results exponential.c Approximates e x using the Taylor series and checks against built-in exp(x) function For e 50 No cancellations Taylor result: e+21 Builtin result: e+21 For e cancellations (worst priority: 57) Taylor result: e+04 Builtin result: e-22

University of Maryland 18 catastrophic.c Approximates (1 - cos x) / x^2, which is very close to 0.5 in the interval [-4e-8, 4e-8] x = -8e-7 6 cancellations (worst priority: 42) Result: e-01 x = -8e-9 5 cancellations (worst priority: 29) Result: e+00 So cancellations are not necessarily indicative of a real problem Results

University of Maryland 19 Future Work Known issues Address quantization error Shared library handling (ex. libm.so routines) Roundoff analysis “loses” errors Improve reporting Filter events to find true problems Stack traces for events Aggregate error by instruction or variable Visualization or IDE integration

University of Maryland 20 Future Work Use InstructionAPI instead of XED Add program slicing to reduce amount of instrumentation Profile overhead and optimize Expand to more platforms and instruction sets

University of Maryland 21 Conclusion We are using Dyninst to automatically insert floating-point error measurement Detection of cancellation events Tracking for roundoff error Preliminary results are promising Many areas for future work

University of Maryland 22 Thank you!