Skip to content

Commit 5dc53ca

Browse files
committed
raco fmt + baseline updated with precision vector to match Rival for fairness in comparison
1 parent ddb7941 commit 5dc53ca

File tree

7 files changed

+65
-23
lines changed

7 files changed

+65
-23
lines changed

eval/run.rkt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
(require racket/match
44
racket/function
55
racket/flonum)
6+
67
(require "machine.rkt"
78
"adjust.rkt"
89
"../mpfr.rkt"
910
"../ops/all.rkt")
11+
1012
(provide rival-machine-load
1113
rival-machine-run
1214
rival-machine-return

infra/format-mathematica.rkt

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,18 +134,30 @@
134134
(define new-data
135135
(struct-copy mdata
136136
data
137-
[rival-samplable (if is-samplable (+ rival-samplable 1) rival-samplable)]
137+
[rival-samplable
138+
(if is-samplable
139+
(+ rival-samplable 1)
140+
rival-samplable)]
138141
[rival-movability
139-
(if (and rival-no-error is-immovable) (+ rival-movability 1) rival-movability)]
142+
(if (and rival-no-error is-immovable)
143+
(+ rival-movability 1)
144+
rival-movability)]
140145
[rival-possible
141146
(if (and rival-no-error (not is-samplable) (not is-immovable))
142147
(+ rival-possible 1)
143148
rival-possible)]
144149
[mathematica-samplable
145-
(if m-samplable? (+ mathematica-samplable 1) mathematica-samplable)]
150+
(if m-samplable?
151+
(+ mathematica-samplable 1)
152+
mathematica-samplable)]
146153
[mathematica-unsamplable
147-
(if (not m-samplable?) (+ mathematica-unsamplable 1) mathematica-unsamplable)]
148-
[mathematica-error (if m-error? (+ mathematica-error 1) mathematica-error)]))
154+
(if (not m-samplable?)
155+
(+ mathematica-unsamplable 1)
156+
mathematica-unsamplable)]
157+
[mathematica-error
158+
(if m-error?
159+
(+ mathematica-error 1)
160+
mathematica-error)]))
149161
(hash-set! bench-to-mdata suite new-data)
150162
(collect-mathematica port rival-port bench-to-mdata (+ sofar 1) examples-port)]
151163
[else bench-to-mdata]))

infra/generate-points.rkt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
(define bindings (map cons vars (map unfold-let vals)))
1616
(replace-vars bindings (unfold-let body))]
1717
[`(let* () ,body) (unfold-let body)]
18-
[`(let* ([,var ,val] ,rest ...) ,body)
18+
[`(let* ([,var ,val]
19+
,rest ...)
20+
,body)
1921
(replace-vars (list (cons var (unfold-let val))) (unfold-let `(let* ,rest ,body)))]
2022
[`(,head ,args ...) (cons head (map unfold-let args))]
2123
[x x]))
@@ -65,7 +67,10 @@
6567
(cons suite-name (rest result))))))
6668

6769
(define (load-tests path)
68-
(define path* (if (string? path) (string->path path) path))
70+
(define path*
71+
(if (string? path)
72+
(string->path path)
73+
path))
6974
(apply append
7075
(for/list ([fname (directory-list path* #:build? true)]
7176
#:when (or (directory-exists? fname)

infra/interval-evaluate.rkt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@
8989
[else (lambda xs #f)]))
9090

9191
(define (convert-number expression use-mpfi?)
92-
(if use-mpfi? (iv expression) (mk-ival (bf expression))))
92+
(if use-mpfi?
93+
(iv expression)
94+
(mk-ival (bf expression))))
9395

9496
(define (interval-evaluate expression variables point use-mpfi?)
9597
(cond

infra/report.rkt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,12 @@
5656
(apply min (map (lambda (d) (if (number? d) d +inf.0)) data)))
5757

5858
(define (get-bold-index data good)
59-
(define processed (map (lambda (d) (if (number? d) (exact->inexact d) d)) data))
59+
(define processed
60+
(map (lambda (d)
61+
(if (number? d)
62+
(exact->inexact d)
63+
d))
64+
data))
6065
(cond
6166
[(equal? good 'none) (length processed)]
6267
[(or (equal? good 'min) (equal? good 'max))
@@ -75,7 +80,9 @@
7580
(define strings (map latex-format-item data))
7681
(define-values (before after) (split-at strings bold-index))
7782
(define modified-after
78-
(if (> (length after) 0) (cons (make-latex-bold (first after)) (rest after)) empty))
83+
(if (> (length after) 0)
84+
(cons (make-latex-bold (first after)) (rest after))
85+
empty))
7986
(append before modified-after))
8087

8188
(define (make-latex-row data #:good [good 'none])
@@ -181,7 +188,10 @@
181188
(equal? bigfloat '+nan.bf))
182189

183190
(define (output-var name val port [comment ""])
184-
(define comment-string (if (equal? comment "") "" (format "% ~a" comment)))
191+
(define comment-string
192+
(if (equal? comment "")
193+
""
194+
(format "% ~a" comment)))
185195
(fprintf port "\\newcommand{\\~a}{~a\\xspace}~a\n" name val comment-string))
186196

187197
(define (round1 num)

infra/run-baseline.rkt

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
outputs
2222
discs
2323
registers
24+
precisions
2425
[profile-ptr #:mutable]
2526
profile-instruction
2627
profile-number
@@ -46,6 +47,7 @@
4647
roots
4748
discs
4849
registers
50+
precisions
4951
0
5052
(make-vector (*rival-profile-executions*))
5153
(make-vector (*rival-profile-executions*))
@@ -76,8 +78,11 @@
7678
(raise (exn:rival:unsamplable "Unsamplable input" (current-continuation-marks) pt))]
7779
[else (loop (* 2 prec))])))
7880

81+
(define (baseline-machine-adjust machine)
82+
(vector-fill! (baseline-machine-precisions machine) (bf-precision)))
83+
7984
(define (baseline-machine-full machine inputs)
80-
; no adjust here
85+
(baseline-machine-adjust machine)
8186
(baseline-machine-load machine inputs)
8287
(baseline-machine-run machine)
8388
(baseline-machine-return machine))
@@ -89,15 +94,17 @@
8994
(define ivec (baseline-machine-instructions machine))
9095
(define varc (vector-length (baseline-machine-arguments machine)))
9196
(define vregs (baseline-machine-registers machine))
92-
(define precision (bf-precision))
93-
94-
(parameterize ([bf-precision precision])
95-
(for ([instr (in-vector ivec)] [n (in-naturals varc)])
96-
(define start (current-inexact-milliseconds))
97-
(vector-set! vregs n (apply-instruction instr vregs))
98-
(define name (object-name (car instr)))
99-
(define time (- (current-inexact-milliseconds) start))
100-
(baseline-machine-record machine name n precision time))))
97+
(define precisions (baseline-machine-precisions machine))
98+
99+
(for ([instr (in-vector ivec)]
100+
[n (in-naturals varc)]
101+
[precision (in-vector precisions)])
102+
(define start (current-inexact-milliseconds))
103+
(parameterize ([bf-precision precision])
104+
(vector-set! vregs n (apply-instruction instr vregs)))
105+
(define name (object-name (car instr)))
106+
(define time (- (current-inexact-milliseconds) start))
107+
(baseline-machine-record machine name n precision time)))
101108

102109
(define (apply-instruction instr regs)
103110
;; By special-casing the 0-3 instruction case,
@@ -123,7 +130,9 @@
123130
(define stuck? #f)
124131
(define fvec
125132
(for/vector #:length (vector-length rootvec)
126-
([root (in-vector rootvec)] [disc (in-list discs)] [n (in-naturals)])
133+
([root (in-vector rootvec)]
134+
[disc (in-list discs)]
135+
[n (in-naturals)])
127136
(define out (vector-ref vregs root))
128137
(define lo ((discretization-convert disc) (ival-lo out)))
129138
(define hi ((discretization-convert disc) (ival-hi out)))

infra/run-sollya.rkt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,9 @@
221221
(match-define (list result sollya-time) (string-split s "\n"))
222222
(list dt
223223
(seconds->ms sollya-time)
224-
(if (string-contains? result "-") (fl -inf.0) (fl +inf.0))
224+
(if (string-contains? result "-")
225+
(fl -inf.0)
226+
(fl +inf.0))
225227
'valid))]
226228

227229
; Valid output

0 commit comments

Comments
 (0)