Skip to content

Commit

Permalink
Merge pull request #234 from uwplse/develop
Browse files Browse the repository at this point in the history
Release Herbie 1.3
  • Loading branch information
pavpanchekha authored Jun 19, 2019
2 parents e26cdb8 + f8c8936 commit be39213
Show file tree
Hide file tree
Showing 160 changed files with 7,851 additions and 7,634 deletions.
14 changes: 2 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
*~
graphs
compile/*.o
compile/*.bin
compile/tc*.c
compile/tc*.out
compile/tc.json
compile/nr*.c
compile/nr*.out
compile/nr.json
compile/cost
compiled/
ml-toy
papers
www/demo
demo.log
*.class
cost
infra/cost
previous
*.swp
31 changes: 11 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,22 @@ env:
global:
- RACKET_DIR=~/racket
TBENCHES="bench/tutorial.fpcore bench/hamming/"
HERBIE_SEED="#(2749829514 1059579101 312104142 915324965 966790849 1349306526)"
TSEED="racket $TRAVIS_BUILD_DIR/infra/travis.rkt --seed '${HERBIE_SEED}' $TBENCHES"
TRAND="racket $TRAVIS_BUILD_DIR/infra/travis.rkt $TBENCHES"
UTEST="raco test src"
HERBIE_SEED="0"
UNIT="raco test src/ infra/"
INTEGRATION="racket $TRAVIS_BUILD_DIR/infra/travis.rkt --seed '${HERBIE_SEED}' $TBENCHES"
STABILITY="racket $TRAVIS_BUILD_DIR/infra/travis.rkt $TBENCHES"
matrix:
# separate builds for travis benches and unit tests
- RACKET_VERSION="6.7"
JOB="${TSEED}"
- RACKET_VERSION="6.9"
JOB="${TSEED}"
- RACKET_VERSION="6.11"
JOB="${TSEED}"
- RACKET_VERSION="6.7"
JOB="${UTEST}"
- RACKET_VERSION="6.9"
JOB="${UTEST}"
- RACKET_VERSION="6.11"
JOB="${UTEST}"
- RACKET_VERSION="7.3" JOB="${UNIT}"
- RACKET_VERSION="7.0" JOB="${INTEGRATION}"
- RACKET_VERSION="7.2" JOB="${INTEGRATION}"
- RACKET_VERSION="7.3" JOB="${INTEGRATION}"
# remember to change the `allow_failures` key below!
- RACKET_VERSION="6.11"
JOB="${TRAND}"
- RACKET_VERSION="7.3" JOB="${STABILITY}"
matrix:
allow_failures:
- env: RACKET_VERSION="6.11"
JOB="${TRAND}"
- env: RACKET_VERSION="7.3" JOB="${STABILITY}"
fast_finish: true
before_install:
- git clone https://github.com/greghendershott/travis-racket.git ../travis-racket
- cat ../travis-racket/install-racket.sh | bash
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM jackfirth/racket:6.12
FROM jackfirth/racket:7.3
MAINTAINER Pavel Panchekha <[email protected]>
RUN apt-get update \
&& apt-get install -y libcairo2-dev libjpeg62 libpango1.0-dev \
Expand Down
25 changes: 0 additions & 25 deletions EDITING.md

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2015 Herbie Project
Copyright (c) 2015-2019 Herbie Project
Modified work Copyright 2016 Google Inc.

Permission is hereby granted, free of charge, to any person obtaining
Expand Down
15 changes: 5 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: all install update nightly index clean publish start-server package loc deploy
.PHONY: all install update nightly index publish start-server package deploy

all:
@echo "Type 'make install' to install Herbie as a Racket package,"
Expand All @@ -23,28 +23,23 @@ herbie.zip herbie.zip.CHECKSUM:
mv src.zip herbie.zip
mv src.zip.CHECKSUM herbie.zip.CHECKSUM

clean:
rm -f cost
rm -rf graphs/

publish:
bash infra/publish.sh upload graphs/
bash infra/publish.sh index

start-server:
racket src/herbie.rkt web --seed '#(2775764126 3555076145 3898259844 1891440260 2599947619 1948460636)' --timeout 60 --num-iters 2 --demo --prefix /demo/ --port 4053 --save-session www/demo/ --log infra/server.log --quiet 2>&1
racket src/herbie.rkt web --seed 1 --timeout 150 --num-iters 2 \
--demo --public --prefix /demo/ --port 4053 --save-session www/demo/ \
--log infra/server.log --quiet 2>&1

package:
raco pkg

loc:
find herbie/ -type f -exec cat {} \; | wc -l

# This rule is run by herbie.uwplse.org on every commit to Github.
# It does not restart the demo server, but it does pull new static content
deploy:
cd $(shell ~/uwplse/getdir) && git pull

cost: infra/cost.c
infra/cost: infra/cost.c
$(CC) -O0 $^ -lm -o $@

23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@

[![Build Status](https://travis-ci.org/uwplse/herbie.svg?branch=master)](https://travis-ci.org/uwplse/herbie)

Herbie synthesizes floating-point programs from real-number programs,
automatically handling simple numerical instabilities. Visit [our
website](https://herbie.uwplse.org) for tutorials, documentation, and
an online demo. Herbie has semi-regular releases twice a year,
maintains backwards compatibility, and uses standardized formats.
Herbie automatically improves the error of floating point expressions.
Visit [our website](https://herbie.uwplse.org) for tutorials,
documentation, and an online demo. Herbie has semi-regular releases
once a year, maintains backwards compatibility, and uses standardized
formats.

Installing
----------

For full details on installing Herbie, please see the
[tutorial](http://herbie.uwplse.org/doc/latest/installing.html).

Herbie requires Racket 6.7 or later, and supports Windows, OS X, and
Herbie requires Racket 7.0 or later, and supports Windows, macOS, and
Linux. Install it with:

raco pkg install herbie
raco pkg install --auto herbie

This will install a `herbie` binary to somewhere in your home
directory. You can also run `src/herbie.rkt` directly instead of using
Expand All @@ -35,15 +35,14 @@ Herbie's input is a Scheme-based language called [FPCore](http://fpbench.org/spe
you can several examples in `bench/`.
For example, consider this simple expression:

(FPCore (x)
(- (+ 1 x) x))
(FPCore (x) (- (+ 1 x) x))

Run Herbie from the top-level directory of the repo, and enter the
cancellation test:

$ herbie shell
Herbie 1.2 with seed #(349461420 3681359142 2680361770 2900531005 1939065059 1779362427)
Find help on <https://herbie.uwplse.org/>, exit with Ctrl-D
Herbie 1.3 with seed 1866513483
Find help on https://herbie.uwplse.org/, exit with Ctrl-D
herbie> (FPCore (x) (- (+ 1 x) x))
(FPCore (x) ... 1)

Expand All @@ -53,7 +52,7 @@ the constant `1`.
Besides the `shell`, Herbie also has a `web` interface, and can run on
files of FPCore expressions with the `improve` and `report` commands.
Consult the
[documentation](http://herbie.uwplse.org/doc/latest/options.html).
[documentation](http://herbie.uwplse.org/doc/latest/tutorial.html).
for more.

Helping Out
Expand Down
9 changes: 4 additions & 5 deletions bench/hamming/complex.fpcore
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
; -*- mode: scheme -*-

; TODO: exp function unimplemented.
#;(FPCore (xre xim)
(FPCore (xre xim)
:name "exp with complex power real part (p55)"
(let ([x (complex xre xim)])
(re (/ (+ (exp x) (exp (- x))) (complex 2 0)))))

#;(FPCore (xre xim)
(FPCore (xre xim)
:name "exp with complex power imaginary part (p55)"
(let ([x (complex xre xim)])
(im (/ (+ (exp x) (exp (- x))) (complex 2 0)))))

#;(FPCore (x y)
(FPCore (x y)
:name "Euler formula real part (p55)"
(let ([a (/ (+ (exp x) (exp (- x))) 2)]
[b (/ (- (exp x) (exp (- x))) 2)])
(re (complex (* a (cos y)) (* b (sin y))))))

#;(FPCore (x y)
(FPCore (x y)
:name "Euler formula imaginary part (p55)"
(let ([a (/ (+ (exp x) (exp (- x))) 2)]
[b (/ (- (exp x) (exp (- x))) 2)])
Expand Down
1 change: 1 addition & 0 deletions bench/hamming/machine-decide.fpcore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

(FPCore (a x)
:name "expax (section 3.5)"
:herbie-expected 14
:herbie-target
(if (< (fabs (* a x)) 1/10)
(* (* a x) (+ 1 (+ (/ (* a x) 2) (/ (pow (* a x) 2) 6))))
Expand Down
5 changes: 4 additions & 1 deletion bench/haskell.fpcore
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,10 @@
(if (< z 7.636950090573675e+176)
(* 2.0 (sqrt (+ (* (+ x y) z) (* x y))))
(*
(sqr
(*
(+
(* 1/4 (* (* (pow y -3/4) (* (pow z -3/4) x)) (+ y z)))
(* (pow z 1/4) (pow y 1/4)))
(+
(* 1/4 (* (* (pow y -3/4) (* (pow z -3/4) x)) (+ y z)))
(* (pow z 1/4) (pow y 1/4))))
Expand Down
11 changes: 10 additions & 1 deletion bench/libraries/mathjs/arithmetic.fpcore
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,21 @@

(FPCore (x.re x.im)
:name "math.cube on complex, real part"
:herbie-target
(+ (* (* x.re x.re) (- x.re x.im))
(* (* x.re x.im) (- x.re (* 3 x.im))))

(-
(* (- (* x.re x.re) (* x.im x.im)) x.re)
(* (+ (* x.re x.im) (* x.im x.re)) x.im)))

(FPCore (x.re x.im)
:name "math.cube on complex, imaginary part"
:herbie-target
(+
(* (* x.re x.im) (* 2 x.re))
(* (* x.im (- x.re x.im)) (+ x.re x.im)))

(+
(* (- (* x.re x.re) (* x.im x.im)) x.im)
(* (+ (* x.re x.im) (* x.im x.re)) x.re)))
Expand Down Expand Up @@ -107,7 +116,7 @@

(FPCore (re im)
:name "math.sqrt on complex, imaginary part, im greater than 0 branch"
(* 0.5 (sqrt (* 2.0 (+ (sqrt (- (* re re) (* im im))) re)))))
(* 0.5 (sqrt (* 2.0 (- (sqrt (+ (* re re) (* im im))) re)))))

(FPCore (re im)
:name "math.square on complex, real part"
Expand Down
5 changes: 5 additions & 0 deletions bench/mathematics/excel.fpcore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(FPCore (x0 x1)
:name "(- (/ x0 (- 1 x1)) x0)"
:pre (or (and (== x0 1.855) (== x1 0.000209)) (and (== x0 2.985) (== x1 0.0186)))
:herbie-target (/ (* x0 x1) (- 1 x1))
(- (/ x0 (- 1 x1)) x0))
1 change: 1 addition & 0 deletions bench/mathematics/latlong.fpcore
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
(lambdam (+ lambda1 (atan2 By (+ (cos phi1) Bx)))))
lambdam))))

;; TODO: phi2 unused
(FPCore (lambda1 phi1 phi2 delta theta)
:name "Destination given bearing on a great circle"
(let ((phi2
Expand Down
8 changes: 4 additions & 4 deletions bench/mathematics/sarnoff.fpcore
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,25 @@
(< 4.930380657631324e-32 c 2.028240960365167e31))
(/ (+ (- b) (sqrt (- (* b b) (* 4 a c)))) (* 2 a)))

(FPCore (a b c d)
(FPCore (a b c)
:name "Cubic critical"
(/ (+ (- b) (sqrt (- (* b b) (* 3 a c)))) (* 3 a)))

(FPCore (a b c d)
(FPCore (a b c)
:name "Cubic critical, narrow range"
:pre (and (< 1.0536712127723509e-8 a 9.490626562425156e7)
(< 1.0536712127723509e-8 b 9.490626562425156e7)
(< 1.0536712127723509e-8 c 9.490626562425156e7))
(/ (+ (- b) (sqrt (- (* b b) (* 3 a c)))) (* 3 a)))

(FPCore (a b c d)
(FPCore (a b c)
:name "Cubic critical, medium range"
:pre (and (< 1.1102230246251565e-16 a 9.007199254740992e15)
(< 1.1102230246251565e-16 b 9.007199254740992e15)
(< 1.1102230246251565e-16 c 9.007199254740992e15))
(/ (+ (- b) (sqrt (- (* b b) (* 3 a c)))) (* 3 a)))

(FPCore (a b c d)
(FPCore (a b c)
:name "Cubic critical, wide range"
:pre (and (< 4.930380657631324e-32 a 2.028240960365167e31)
(< 4.930380657631324e-32 b 2.028240960365167e31)
Expand Down
39 changes: 39 additions & 0 deletions bench/numerics/great-debate.fpcore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
(FPCore (y)
:name "Kahan's Monster"
:pre (<= 1 y 9999) ; Integers only in Kahan's example but this is not essential
(let ([Qx (- (fabs (- y (sqrt (+ (* y y) 1))))
(/ 1 (+ y (sqrt (+ (* y y) 1)))))])
(let ([z (* Qx Qx)])
(if (== z 0) 1 (/ (- (exp z) 1) z)))))

(FPCore (y)
:name "Kahan's Unum-Targeted Monster"
:pre (<= 1 y 9999) ; Integers only in Kahan's example but this is not essential
(let ([Qx (- (fabs (- y (sqrt (+ (* y y) 1)))) (/ 1 (+ y (sqrt (+ (* y y) 1)))))])
(let ([z (+ (* Qx Qx) (pow (pow 10 -300) (* 10000 (+ y 1))))])
(if (== z 0) 1 (/ (- (exp z) 1) z)))))

(FPCore (x y)
:name "Kahan p9 Example"
:pre (and (< 0 x 1) (< y 1))
:herbie-target
(if (< 0.5 (fabs (/ x y)) 2)
(/ (* (- x y) (+ x y)) (+ (* x x) (* y y)))
(- 1 (/ 2 (+ 1 (* (/ x y) (/ x y))))))

(/ (* (- x y) (+ x y)) (+ (* x x) (* y y))))

(FPCore (t)
:name "Kahan p13 Example 1"
(let ([u (/ (* 2 t) (+ 1 t))])
(/ (+ 1 (* u u)) (+ 2 (* u u)))))

(FPCore (t)
:name "Kahan p13 Example 2"
(let ([v (- 2 (/ (/ 2 t) (+ 1 (/ 1 t))))])
(/ (+ 1 (* v v)) (+ 2 (* v v)))))

(FPCore (t)
:name "Kahan p13 Example 3"
(let ([v (- 2 (/ (/ 2 t) (+ 1 (/ 1 t))))])
(- 1 (/ 1 (+ 2 (* v v))))))
28 changes: 28 additions & 0 deletions bench/numerics/rump.fpcore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
(FPCore (x y)
:name "Rump's expression from Stadtherr's award speech"
:pre (and (== x 77617) (== y 33096))
:spec -54767/66192
(+ (* 333.75 (pow y 6))
(* (* x x)
(- (* 11 x x y y)
(pow y 6)
(* 121 (pow y 4))
2))
(* 5.5 (pow y 8))
(/ x (* 2 y))))

;; From
;; How Reliable are the Results of Computers
;; Jahrbuch Uberblicke Mathematik (1983)

(FPCore (x y)
:name "From Rump in a 1983 paper"
:pre (and (== x 10864) (== y 18817))
;:pre (and (< 10500 x 11000) (< 18500 y 19000))
(+ (- (* 9 (pow x 4)) (pow y 4)) (* 2 (* y y))))

(FPCore (x y)
:name "From Rump in a 1983 paper, rewritten"
:pre (and (== x 10864) (== y 18817))
;:pre (and (< 10500 x 11000) (< 18500 y 19000))
(- (* 9 (pow x 4)) (* (* y y) (- (* y y) 2))))
Loading

0 comments on commit be39213

Please sign in to comment.