uwplse / herbgrind

A Valgrind tool for Herbie
GNU General Public License v3.0
90 stars 7 forks source link

can't match herbgrind output with video #13

Closed dougc333 closed 6 years ago

dougc333 commented 6 years ago

https://www.youtube.com/watch?v=oYtnXEZC0jk&t=1822s

include

include

include

double solve_quadratic(double a, double b, double c){ //there are 2, a plus and minus; we only take the plus return (-b + sqrt(bb - 4ac))/(2a); }

int main(int argc, char* argv) { double b = 1e-10; for (int i =0; i<20; i++){ b=10; printf("%e\n", solve_quadratic(2,b,c));

return 0;

}

above saved as main.c gcc ./main.cpp -O0 -g -lm -o main

/home/dc/herbgrind/valgrind/herbgrind-install/bin/valgrind --tool=herbgrind --no-ranges ./main

main.gh Result @ main.cpp:21 in main (addr 400730) 47.750810 bits average error 64.000000 bits max error Aggregated over 20 instances Influenced by erroneous expression:

(FPCore (x)
      (/ (- (sqrt (- (* x x) (* 8.000000 3.000000))) x) (+ 2.000000 2.000000)))

main.cpp:9 in solve_quartic(double, double, double) (addr 400678) 47.750810 bits average error 64.000000 bits max error 32.000000 bits average local error 64.000000 bits max local error Aggregated over 20 instances

nomatch

dougc333 commented 6 years ago

The FPCore(x) functions are different from the video. Using herbgrind 2.0 from github

wilcoxjay commented 6 years ago

Quick clarification: in the code you pasted, you have solve_quadratic(2,b,c), but in the video it's solve_quadratic(2,b,3). Is that just a typo?

wilcoxjay commented 6 years ago

In any case, the two influenced-by expressions look equivalent to me: one uses 8.0 where the other uses (* 4.0 2.0).

dougc333 commented 6 years ago

Typo.. thanks!!

wilcoxjay commented 6 years ago

I talked with @pavpanchekha (who is traveling and can't post on github right now) and he said that using a different compiler can cause trivial differences like (* 4.0 2.0) vs 8.0.

I don't see any other differences in the output. Am I missing something or can we close this?

HazardousPeach commented 6 years ago

I'm going to close this issue since it seems like @wilcoxjay cleared some stuff up. Feel free to re-open if there's something unresolved!