Skip to content
/ FpDebug Public

Dynamic Program Analysis based on Valgrind to find Floating-Point Accuracy Problems

License

Notifications You must be signed in to change notification settings

fbenz/FpDebug

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FpDebug

GNU General Public License

FpDebug is a heavyweight Valgrind tool for detecting floating-point accuracy problems.

The tool uses MPFR for its side-by-side computation in higher precision. Because MPFR is run with the tool on top of Valgrind, it has only access to the partial C library provided by Valgrind. Thus, a patch for MPFR is provided that adjusts it to run on top of Valgrind. As GMP is used by MFPR, a patch for GMP is also provided.

Origin

This project was started during my Bachelor’s thesis (winter 2010/11). The results have been published in:

A Dynamic Program Analysis to find Floating-Point Accuracy Problems [PDF]
Florian Benz, Andreas Hildebrandt, and Sebastian Hack
PLDI '12: Proceedings of the 2012 ACM SIGPLAN Conference on Programming Language Design and Implementation

Quick start

The docker folder contains Dockfiles for several systems that can be used to build and play around. During the build a small example program is also built and analyzed to check that everything works.

Build and run Docker image
sudo docker build -t fpdebug .
sudo docker run -it fpdebug /bin/bash

Build from source

Note
The version on master runs with Valgrind 3.7 and might not work on more recent systems than Ubuntu 12.04. However, a version for Valgrind 3.12 can be found here: #2 . But so far it has only been tested on small examples. Tests have been performed on Ubuntu 16.04 and Ubuntu 16.10.
Note
Only 64bit systems are supported.

The following installation instructions are for Ubuntu 12.04.5 LTS (64bit). The instructions should be similar for most other Linux systems.

Install build dependencies
# Git is only needed to check out the sources
sudo apt-get install git
# m4 is a dependency of GMP
sudo apt-get install m4
# libc6-dbg is required for Valgrind (otherwise it fails at runtime)
sudo apt-get install libc6-dbg
Get the sources
git clone [email protected]:fbenz/FpDebug.git
Install patched GMP 5.0.1
./install_gmp.sh
Install patched MPFR 3.0.0
./install_mpfr.sh
Install Valgrind with FpDebug
./install_valgrind.sh

Running FpDebug

Build an example
cd valgrind/fpdebug/examples
gcc test_1.c -O0 -g -o test_1.out
(or $ gcc test_1.c -O0 -g -mfpmath=387 -o test_1.out )
Run FpDebug
./valgrind/install/bin/valgrind --tool=fpdebug valgrind/fpdebug/examples/test_1.out
FpDebug output
==7041== FpDebug-0.1, Floating-point arithmetic debugger
==7041== Copyright (C) 2010-2011 by Florian Benz.
==7041== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==7041== Command: valgrind/fpdebug/examples/test_1.out
==7041==
==7041== precision=120
==7041== mean-error=yes
==7041== ignore-libraries=no
==7041== ignore-accurate=yes
==7041== sim-original=no
==7041== analyze-all=yes
==7041== bad-cancellations=yes
==7041== ignore-end=no
Test program: machine epsilon, client request
Sum: 1.0000000e+00
Running on valgrind
==7041== (float) sum PRINT ERROR OF: 0x7FF0000F4
==7041== (float) sum ORIGINAL:          1.00000000000000 * 10^0, 1/120 bit
==7041== (float) sum SHADOW VALUE:      1.00000025000000 * 10^0, 49/120 bit
==7041== (float) sum ABSOLUTE ERROR:    2.50000002921524 * 10^-7, 27/120 bit
==7041== (float) sum RELATIVE ERROR:    2.49999940421539 * 10^-7, 120/120 bit
==7041== (float) sum CANCELED BITS:     0
==7041== (float) sum Last operation: 0x4007AD: main (test_1.c:14)
==7041== (float) sum Operation count (max path): 5
==7041== DUMP GRAPH (test_1_sum.vcg): successful
==7041==
==7041== DUMP GRAPH (valgrind/fpdebug/examples/test_1.out_1_0.vcg): successful
==7041== SHADOW VALUES (valgrind/fpdebug/examples/test_1.out_shadow_values_relative_error_1): successful
==7041== SHADOW VALUES (valgrind/fpdebug/examples/test_1.out_shadow_values_canceled_1): successful
==7041== SHADOW VALUES (valgrind/fpdebug/examples/test_1.out_shadow_values_special_1): successful
==7041== MEAN ERRORS (valgrind/fpdebug/examples/test_1.out_mean_errors_addr_1): successful
==7041== MEAN ERRORS (valgrind/fpdebug/examples/test_1.out_mean_errors_canceled_1): successful
==7041== MEAN ERRORS (valgrind/fpdebug/examples/test_1.out_mean_errors_intro_1): successful

License

FpDebug is Open Source software released under the GNU General Public License, version 2.

About

Dynamic Program Analysis based on Valgrind to find Floating-Point Accuracy Problems

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages