Skip to content

Commit

Permalink
Merge pull request #465 from herbie-fp/release-1.6
Browse files Browse the repository at this point in the history
Release 1.6
  • Loading branch information
bksaiki committed Jun 12, 2022
2 parents 8dbedf3 + 6142850 commit 600fd02
Show file tree
Hide file tree
Showing 42 changed files with 2,309 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
# Builds output under /herbie/egg-herbie
FROM rust:1.61.0 as egg-herbie-builder
WORKDIR /herbie
COPY . .
COPY egg-herbie egg-herbie
RUN cargo build --release --manifest-path=egg-herbie/Cargo.toml

# Production image
FROM racket/racket:8.5-full AS production
MAINTAINER Pavel Panchekha <[email protected]>
COPY --from=egg-herbie-builder /herbie/egg-herbie /src/egg-herbie
RUN raco pkg install /src/egg-herbie
ADD src /src/herbie
COPY src /src/herbie
RUN raco pkg install --auto /src/herbie
ENTRYPOINT ["racket", "/src/herbie/herbie.rkt"]
EXPOSE 80
Expand Down
6 changes: 4 additions & 2 deletions egg-herbie/info.rkt
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#lang info

(define collection "egg-herbie")
(define version "1.5")
(define version "1.6")

(define pkg-desc "Racket bindings for simplifying math expressions using egg")

(define pkg-authors
`("Oliver Flatt"))

(define build-deps
'("rackunit-lib"))
2 changes: 1 addition & 1 deletion src/config.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
(if (equal? out "") default out))
default))

(define *herbie-version* "1.5")
(define *herbie-version* "1.6")

(define *hostname* (run-command "hostname"))

Expand Down
7 changes: 4 additions & 3 deletions src/info.rkt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#lang info

(define collection "herbie")
(define version "1.5")
(define version "1.6")

;; Packaging information

Expand All @@ -23,13 +23,14 @@
;; Dependencies

(define deps
'(("base" #:version "7.0")
'(("base" #:version "8.0")
"math-lib"
"plot-lib"
"profile-lib"
"rackunit-lib"
"web-server-lib"
("egg-herbie" #:version "1.5")
"draw-lib"
("egg-herbie" #:version "1.6")
("rival" #:version "1.4")
("fpbench" #:version "2.0.3")))

Expand Down
2 changes: 2 additions & 0 deletions src/syntax/read.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,15 @@
(unless (set=? vars used)
(define unused (set-subtract vars used))
(warn 'unused-variable
#:url "faq.html#unused-variable"
"unused ~a ~a" (if (equal? (set-count unused) 1) "variable" "variables")
(string-join (map ~a unused) ", "))))

(define (check-weird-variables vars)
(for* ([var vars] [const (all-constants)])
(when (string-ci=? (symbol->string var) (symbol->string const))
(warn 'strange-variable
#:url "faq.html#strange-variable"
"unusual variable ~a; did you mean ~a?" var const))))

(define (our-read-syntax port name)
Expand Down
13 changes: 13 additions & 0 deletions www/doc/1.6/faq.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,19 @@ <h3 id="unsound-rules">Unsound rule application detected</h3>
failed to simplify the output.
</p>

<h3 id="unused-variable">Unused variable <var>var</var></h3>

<p>
The input FPCore contains a variable that is not
used in the body expression.
</p>

<h3 id="strange-variable">Strange variable <var>var</var></h3>

<p>
The input expression contains a variable that is similar in name
to named constants, e.g. <var>e</var> instead of <var>E</var>.
</p>

<h2>Known bugs</h2>

Expand Down
34 changes: 34 additions & 0 deletions www/doc/1.7/diagrams.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Diagrams</title>
<link rel='stylesheet' type='text/css' href="../../main.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<header>
<a href="../.."><img class="logo" src="../../logo.png" /></a>
<h1>Diagrams</h1>
</header>

<figure>
<img width="100%" src="system-1.6.png" alt="System diagram of Herbie" />
</figure>

<p>
High-level system diagram of Herbie. It highlights Herbie's core architecture,
external libraries, and user interactions.
Basic flow: Herbie passes user input (expression, precondition, etc.) to the
mainloop (scheduler) which alternates between generate and test phases multiple times,
maintaining and improving a set of accurate expressions at each iteration.
Once the generate-and-test phase is complete, Herbie extracts either
one or many output expressions using an algorithm called regime inference.
Regime inference chooses the "best" (usually most accurate)
generated candidate expression or combines multple candidates,
each "best" on a smaller part of the input range, with a branch condition.
</p>

</body>
</html>
135 changes: 135 additions & 0 deletions www/doc/1.7/docker.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Herbie on Docker</title>
<link rel='stylesheet' type='text/css' href='../../main.css'>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script type="text/javascript" src="toc.js"></script>
</head>
<body>
<header>
<a href="../.."><img class="logo" src="../../logo.png" /></a>
<h1>Installing with Docker</h1>
</header>

<p>
<a href="../../">Herbie</a> is available
through <a href="https://www.docker.com/">Docker</a>, which is
sort of like a virtual machine. This page describes how to install
the <a href="https://hub.docker.com/r/uwplse/herbie">official Docker
image</a> for Herbie.
</p>

<p>
Herbie can also be <a href="installing.html">installed from
package or source</a>. Herbie via Docker is only recommended if
you already have Docker experience.
</p>

<h2>Installing Herbie via Docker</h2>

<p>
First, <a href="https://docs.docker.com/installation/">install
Docker</a>. Docker supports Windows, macOS, and Linux. Depending
on how you install Docker, you may need to prefix
the <code>docker</code> commands with <code>sudo</code> or run them
as the administrative user.
</p>

<p>With Docker installed, you can run the <a href="using-cli.html">Herbie shell</a> with:</p>

<pre>docker run -it uwplse/herbie shell</pre>

<p>This will read input from the standard input.</p>

<p>Note that Herbie in Docker is more limited; for example, it will
not recognize plugins installed outside the Docker container.</p>

<h2>Running the web interface</h2>

<p>
You can run the Herbie web server locally with

<pre class="shell">docker run -it --rm -p 8000:80 uwplse/herbie</pre>

and access the server at <a href="http://localhost:8000">http://localhost:8000</a>.
</p>
<p>
(Herbie's Docker image binds to port 80 by
default; this command uses the <code>-p &lt;hostport&gt;:80</code> option to expose Herbie on port 8000.)
</p>

<p>
If you are using the <code>--log</code>
or <code>--save-session</code> flags for the web shell,
you will also need to mount the relevant directories into the
Docker container using the <code>-v</code> Docker option, as in
the examples below.
</p>

<h2>Generating files and reports</h2>

<p>
To use Herbie in <a href="using-cli.html">batch mode</a>, you will
need to mount the input in the Docker container. Do that with:
</p>

<pre class="shell">docker run -it --rm \
-v <var>in-dir</var>:/in \
-v <var>out-dir</var>:/out \
-u $USER \
uwplse/herbie improve /in/<var>in-file</var> /out/<var>out-file</var></pre>

<p>
In this command, you are asking Herbie to read input
from <var>in-file</var> in <var>in-dir</var>, and write output
to <var>out-file</var> in <var>out-dir</var>. The command looks
the same if you want Herbie to read input from a directory;
just leave <var>in-file</var> blank.
</p>

<p>
To generate reports from Herbie, you can run:
</p>

<pre class="shell">docker run -it --rm \
-v <var>in-dir</var>:/in \
-v <var>out-dir</var>:/out \
-u $USER \
uwplse/herbie report /in/<var>in-file</var> /out/</pre>

<p>
As before, the input and output directories must be mounted inside
the Docker container. Note that both here and above, the user is
set to the current user. This is to ensure that the files Herbie creates
have the correct permissions set.
</p>

<h2>For developers: updating the Docker image + Dockerfile</h2>

<p>
For building and testing, first clone the repo and confirm that Herbie builds correctly with <code>make install</code>.
</p>
<p>
Next, examine the Dockerfile and Makefile together. The Dockerfile should follow a process exactly like the Makefile, except a clean initial environment is assumed. The build may be split into 2 or more stages to limit the size of the resulting image. Each stage consists of a <code>FROM</code> command and a series of further commands to build up the desired environment, and later stages can refer to earlier stages by name--for example, <code>COPY --from=earlier-stage ...</code> can copy files compiled in earlier images. You may need to do things like bumping the version of Rust used for binary compilation or the version of Racket used in production, or adjusting paths to match the newest version of the repo.
</p>
<p>
Once you are ready to build:
<pre class="shell">docker build -t herbie-testbuild .</pre>
from the repo's main directory will build a new test image with the tag <code>herbie-testbuild</code>. You can run this image with
<pre class="shell">docker run -p 8000:80 -it herbie-testbuild</pre>
and see the web demo in the host machine's browser at <code>http://localhost:8000</code>.
</p>

<p>
To open a shell in a running container for testing, first get the container ID with
<pre class="shell">docker ps</pre>
and then open a shell in the container as root with
<pre class="shell">docker exec -it &lt;CONTAINER ID&gt; sh</pre>

The code and egg-herbie binaries should be under <code>/src</code>.
</p>

</body>
</html>
Binary file added www/doc/1.7/egg-rr-seed-variance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 600fd02

Please sign in to comment.