Skip to content

Commit 38a6a40

Browse files
authored
Merge pull request #1326 from herbie-fp/cleanup-docs
Write documentation on adding a platform
2 parents 01c871b + f149460 commit 38a6a40

File tree

9 files changed

+527
-161
lines changed

9 files changed

+527
-161
lines changed

src/api/server.rkt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,7 @@
171171
*reeval-pts*
172172
*node-limit*
173173
*max-find-range-depth*
174-
*pareto-mode*
175174
*platform-name*
176-
*loose-plugins*
177175
*functions*)
178176
(activate-platform! (*platform-name*))
179177
; not sure if the above code is actaully needed.
@@ -292,9 +290,7 @@
292290
*reeval-pts*
293291
*node-limit*
294292
*max-find-range-depth*
295-
*pareto-mode*
296293
*platform-name*
297-
*loose-plugins*
298294
*functions*)
299295
(activate-platform! (*platform-name*))
300296
(define worker-thread
@@ -506,7 +502,7 @@
506502
`(:pre ,(prog->fpcore (test-pre test) (test-context test))))
507503
,@(if (equal? (test-spec test) empty)
508504
'()
509-
`(:herbie-spec ,(prog->fpcore (test-spec test) (test-context test))))
505+
`(:spec ,(prog->fpcore (test-spec test) (test-context test))))
510506
,@(if (equal? (test-expected test) #t)
511507
'()
512508
`(:herbie-expected ,(test-expected test)))

src/config.rkt

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,7 @@
2828
[localize . ()]
2929
[generate . (rr taylor proofs evaluate)]
3030
[reduce . (regimes binary-search branch-expressions)]
31-
[rules
32-
. (arithmetic polynomials
33-
fractions
34-
exponents
35-
trigonometry
36-
hyperbolic
37-
numerics
38-
special
39-
bools
40-
branches)]
31+
[rules . (arithmetic polynomials fractions exponents trigonometry hyperbolic)]
4132
[dump . ()]))
4233

4334
(define (flag-deprecated? category flag)
@@ -51,6 +42,10 @@
5142
[('reduce 'avg-error) #t]
5243
[('localize 'costs) #t]
5344
[('localize 'errors) #t]
45+
[('rules 'numerics) #t]
46+
[('rules 'special) #t]
47+
[('rules 'bools) #t]
48+
[('rules 'branches) #t]
5449
[(_ _) #f]))
5550

5651
; `hash-copy` returns a mutable hash, which makes `dict-update` invalid
@@ -111,6 +106,10 @@
111106
(eprintf "The localize:errors option has been removed.\n")
112107
(eprintf " Herbie no longer performs localization.\n")
113108
(eprintf "See <herbie://herbie.uwplse.org/doc/~a/options.html> for more.\n" *herbie-version*)]
109+
[('rules _)
110+
(eprintf "The rules:~a ruleset has been removed.\n")
111+
(eprintf " These rules are no longer used by Herbie.\n")
112+
(eprintf "See <herbie://herbie.uwplse.org/doc/~a/options.html> for more.\n" *herbie-version*)]
114113
[(_ _) (void)]))
115114

116115
(define (changed-flags)
@@ -154,7 +153,6 @@
154153
(define *binary-search-accuracy* (make-parameter 48))
155154

156155
;; Pherbie related options
157-
(define *pareto-mode* (make-parameter #t))
158156
(define *pareto-pick-limit* (make-parameter 5))
159157

160158
;; If `:precision` is unspecified, which representation should we use?
@@ -163,9 +161,6 @@
163161
;; The platform that Herbie will evaluate with.
164162
(define *platform-name* (make-parameter (if (equal? (system-type 'os) 'windows) "c-windows" "c")))
165163

166-
;; Plugins loaded locally rather than through Racket.
167-
(define *loose-plugins* (make-parameter '()))
168-
169164
;; Sets the number of total points for Herbie to sample.
170165
(define *reeval-pts* (make-parameter 8000))
171166

src/core/regimes.rkt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
(cond
4141
[(null? alts) '()]
4242
; Only return one option if not pareto mode
43-
[(and (not (*pareto-mode*)) (not (equal? alts sorted))) '()]
4443
[else
4544
(define-values (opt new-errs)
4645
(infer-splitpoints branch-exprs alts err-lsts #:errs errs ctx pcontext))

src/main.rkt

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -99,23 +99,12 @@
9999
during sampling. May fix \"Cannot sample enough valid points\" but will slow."
100100
(format "[Default: ~a iterations]" (*max-find-range-depth*)))
101101
(*max-find-range-depth* (string->number num))]
102-
[("--no-pareto")
103-
("Disables Pareto-Herbie (Pherbie). Pareto-mode performs accuracy and expression cost
104-
optimization and extracts multiple output expressions that are Pareto-optimal. Disabling
105-
this feature forces Herbie to extract a single, most-accurate output expression."
106-
"[Default: Pareto-Herbie enabled]")
107-
(*pareto-mode* #f)]
108102
[("--profile") "Whether to profile each run (no-op, always on)" (void)]
109-
#:multi [("--plugin")
110-
path
111-
("Path to a Herbie plugin." "Allows for dynamic loading of \"loose\" plugins.")
112-
(dynamic-require path #f)
113-
(*loose-plugins* (cons path (*loose-plugins*)))]
114-
[("-o" "--disable")
115-
flag
116-
("Disable a search flag (formatted category:name)."
117-
"See `+o/--enable` for the full list of search flags.")
118-
(apply disable-flag! (string->flag flag))]
103+
#:multi [("-o" "--disable")
104+
flag
105+
("Disable a search flag (formatted category:name)."
106+
"See `+o/--enable` for the full list of search flags.")
107+
(apply disable-flag! (string->flag flag))]
119108
[("+o" "--enable")
120109
flag
121110
("Enable a search flag (formatted category:name)."

src/reports/make-graph.rkt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,12 @@
9292
(format-accuracy (apply max (map ulps->bits end-error)) repr #:unit "%")))
9393
,(render-large "Time" (format-time time))
9494
,(render-large "Alternatives" (~a (length end-exprs)))
95-
,(if (*pareto-mode*)
96-
(render-large "Speedup"
97-
(if speedup
98-
(~r speedup #:precision '(= 1))
99-
"N/A")
100-
"×"
101-
#:title "Relative speed of fastest alternative that improves accuracy.")
102-
""))
95+
,(render-large "Speedup"
96+
(if speedup
97+
(~r speedup #:precision '(= 1))
98+
"N/A")
99+
"×"
100+
#:title "Relative speed of fastest alternative that improves accuracy."))
103101
,(render-warnings warnings)
104102
,(render-specification test)
105103
(figure ([id "graphs"])

www/doc.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ <h2>Documentation</h2>
3636
<li><a href="doc/latest/input.html">Input format</a>: what sorts of expressions Herbie supports.</li>
3737
<li><a href="doc/latest/options.html">Command-line flags</a>: modifying Herbie's behavior.</li>
3838
<li><a href="doc/latest/error.html">What is error?</a>: how Herbie measures floating-point error.</li>
39-
<li><a href="doc/latest/faq.html">FAQ</a>: troubleshooting Herbie.</li>
39+
<li><a href="doc/latest/faq.html">Warnings and Errors</a>: troubleshooting Herbie.</li>
40+
<li><a href="doc/latest/platforms.html">Platforms</a>: how to write a new Herbie compilation target.</li>
4041
<li><a href="doc/latest/release-notes.html">Release Notes</a>: the biggest and latest changes to Herbie.</li>
4142
</ul>
4243

www/doc/2.2/input.html

Lines changed: 22 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,11 @@ <h2 id="sec1">FPCore format</h2>
4343
mathematical expressions. FPCore looks like this:</p>
4444

4545
<pre>(FPCore (<var>inputs ...</var>) <var>properties ...</var> <var>expression</var>)</pre>
46-
<pre>(FPCore <var>name</var> (<var>inputs ...</var>) <var>properties ...</var> <var>expression</var>)</pre>
4746

4847
<p>
4948
Each <var>input</var> is a variable name, like <code>x</code>,
5049
used in the <var>expression</var>. Properties are used to specify
5150
additional information about the <var>expression</var>'s context.
52-
If <var>name</var> is specified, the function can be referenced in
53-
subsequent FPCore declarations in the file.
5451
</p>
5552

5653
<p>
@@ -63,17 +60,12 @@ <h2 id="sec1">FPCore format</h2>
6360

6461
<p>
6562
The semicolon (<kbd>;</kbd>) character introduces a line comment.
66-
We recommend the <code>.fpcore</code> file extension for Herbie input files.
63+
We recommend the <code>.fpcore</code> file extension for FPCore files.
6764
</p>
6865

6966
<h2>Supported functions</h2>
7067

71-
<p>
72-
Herbie supports all functions
73-
from <a href="http://pubs.opengroup.org/onlinepubs/7908799/xsh/math.h.html">math.h</a>
74-
with floating-point-only inputs and outputs. The best supported
75-
functions include:
76-
</p>
68+
<p>FPCore expressions can use any of the following functions:</p>
7769

7870
<dl class="function-list">
7971
<dt><code>+</code>, <code>-</code>, <code>*</code>, <code>/</code>, <code>fabs</code></dt>
@@ -95,13 +87,12 @@ <h2>Supported functions</h2>
9587
</dl>
9688

9789
<p>Herbie also supports the constants <code>PI</code>
98-
and <code>E</code>. Use <code>-</code> for both subtraction and negation.</p>
90+
and <code>E</code>. Use <code>-</code> for both subtraction and
91+
negation.</p>
9992

100-
<p>Herbie links against your computer's <code>libm</code> to
101-
evaluate these functions. So, each function has the same behavior in
102-
Herbie as in your code. You can instead use
103-
the <a href="#precisions"><code>racket</code> precision</a> if you
104-
instead want reproducible behavior.</p>
93+
<p>However, how Herbie evaluates these functions, their cost, and
94+
what additional functions are available depends on
95+
the <a href="platforms.rkt">platform</a> you select.</p>
10596

10697
<h2 id="conditionals">Conditionals</h2>
10798

@@ -122,7 +113,7 @@ <h2 id="conditionals">Conditionals</h2>
122113
<dd>The two boolean values</dd>
123114
</dl>
124115

125-
<p>The comparison functions support chained comparisons with more than two arguments;
116+
<p>The comparison operators support chained comparisons with more than two arguments;
126117
for example <code>(&lt; 1 x 10)</code> means <code>1 < x < 10</code>.</p>
127118

128119
<h2 id="intermediates">Intermediate variables</h2>
@@ -157,8 +148,9 @@ <h2 id="intermediates">Intermediate variables</h2>
157148

158149
<p>Internally, Herbie treats intermediate values only as a
159150
notational convenience, and inlines their values before improving
160-
the formula's accuracy. Using intermediate variables will therefore
161-
not produce a more accurate result or help Herbie run faster.</p>
151+
the formula&apos;s accuracy. Using intermediate variables will
152+
therefore not produce a more accurate result or help Herbie run
153+
faster.</p>
162154

163155
<h2 id="specs">Specifications</h2>
164156

@@ -175,8 +167,9 @@ <h2 id="specs">Specifications</h2>
175167
:spec (sin (/ 1 x))
176168
(+ (/ 1 x) (/ 1 (* 6 (pow x 3)))))</pre>
177169

178-
<p>Herbie will only use the <code>:spec</code> expression to
179-
evaluate error, not to search for accurate expressions.</p>
170+
<p>Herbie will use the <code>:spec</code> expression to evaluate
171+
error, but use body expression as a starting-point for finding
172+
more accurate expressions.</p>
180173

181174
<h2 id="preconditions">Preconditions</h2>
182175

@@ -205,39 +198,25 @@ <h2 id="precisions">Precisions</h2>
205198
<dd>Single-precision IEEE-754 floating point</dd>
206199
<dt><code>binary64</code></dt>
207200
<dd>Double-precision IEEE-754 floating point</dd>
208-
<dt><code>racket</code></dt>
209-
<dd>Like <code>binary64</code>, but using Racket math functions
210-
rather than your computer's <code>libm</code>.</dd>
211201
</dl>
212202

213-
<p>By default, <code>binary64</code> is assumed. Herbie also has
214-
a <a href="plugins.html">plugin system</a> to load additional
203+
<p><a href="platforms.html">Platforms<a/> can also add additional
215204
precisions.</p>
216205

217-
<p>Herbie won't produce mixed-precision code unless you allow it to
218-
do so, using the <code>:herbie-conversions</code> property:</p>
219-
220-
<dl class="function-list">
221-
<dt><code>:herbie-conversions<br/>([<var>prec1</var> <var>prec2</var>] ...)</code></dt>
222-
<dd>Expressions in precision <code>prec1</code>, can be rewriten
223-
to use precision <code>prec2</code>, and vice versa.</dd>
224-
</dl>
225-
226-
<p>All conversions are assumed to be bidirectional. For example, if
227-
you specify <code>:herbie-conversions ([binary64 binary32])</code>,
228-
Herbie will be able to add conversions between single- and
229-
double-precision floating-point.</p>
230-
231206
<h2 id="properties">Miscellaneous Input Properties</h2>
232207

208+
<p>A <var>name</var> can be provided before the argument list to
209+
name an FPCore. That FPCore can then be called in other, later
210+
FPCores.</p>
211+
233212
<p>Herbie uses the <code>:name</code> property to name FPCores in
234213
its UI. Its value ought to be a string.</p>
235214

236215
<p>Herbie allows <code>:alt</code> properties to specify additional
237-
"developer targets"; these might be other alternatives you've tried
238-
that you want to compare against.</p>
216+
"developer targets"; these might be other alternatives you&apos;ve
217+
tried that you want to compare against.</p>
239218

240-
<p>Herbie's benchmark suite also uses properties for continuous
219+
<p>Herbie&apos;s benchmark suite also uses properties for continuous
241220
integration, but these are not officially supported and their use is
242221
discouraged.</p>
243222

0 commit comments

Comments
 (0)