Skip to content

Commit a7fdb0e

Browse files
committed
fmt
1 parent 304cb95 commit a7fdb0e

File tree

3 files changed

+35
-29
lines changed

3 files changed

+35
-29
lines changed

eval/optimal.rkt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@
8181
(vector-set! optimal-precs idx (rival-machine-search-precision machine pt optimal-precs idx)))
8282

8383
; Time run with optimal precisions
84-
(define optimal-time (time-min (lambda () (rival-machine-test-precision machine pt optimal-precs))))
84+
(define optimal-time
85+
(time-min (lambda () (rival-machine-test-precision machine pt optimal-precs))))
8586

8687
; Return both ratios and precision vectors
8788
(list optimal-precs optimal-time max-precs final-time)]
88-
[else
89-
#f]))
89+
[else #f]))

infra/optimize.rkt

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@
2121
(rival-compile exprs vars discs)))
2222

2323
(define results
24-
(filter identity
25-
(for/list ([pt* (in-list (hash-ref rec 'points))]
26-
[pt-id (in-naturals)])
27-
(match-define (list pt _sollya-exs _sollya-status _sollya-apply-time) pt*)
28-
(define pt-vec
29-
(parameterize ([bf-precision 53])
30-
(list->vector (map bf pt))))
31-
(define result (rival-machine-find-optimal-precisions machine pt-vec))
32-
(match result
33-
[(list optimal-precs optimal-time cur-precs cur-time)
34-
(list pt-id pt optimal-time cur-time)]
35-
[#f
36-
(eprintf "; Benchmark ~a point ~a, failure to optimize\n" bench-id pt-id)
37-
#f]))))
24+
(filter
25+
identity
26+
(for/list ([pt* (in-list (hash-ref rec 'points))]
27+
[pt-id (in-naturals)])
28+
(match-define (list pt _sollya-exs _sollya-status _sollya-apply-time) pt*)
29+
(define pt-vec
30+
(parameterize ([bf-precision 53])
31+
(list->vector (map bf pt))))
32+
(define result (rival-machine-find-optimal-precisions machine pt-vec))
33+
(match result
34+
[(list optimal-precs optimal-time cur-precs cur-time) (list pt-id pt optimal-time cur-time)]
35+
[#f
36+
(eprintf "; Benchmark ~a point ~a, failure to optimize\n" bench-id pt-id)
37+
#f]))))
3838

3939
(define (bad-pt? rec)
4040
(match-define (list pt-id pt opt-time cur-time) rec)
@@ -44,7 +44,9 @@
4444
(define dt (* 1000 (- (apply + (map fourth results)) (apply + (map third results)))))
4545
(define valid-results (sort (filter bad-pt? results) > #:key fourth)) ; Sort by cur-time
4646
(eprintf "; Benchmark ~a, total ~aµs available, ~a bad points\n"
47-
bench-id (~r dt #:precision '(= 1)) (length valid-results))
47+
bench-id
48+
(~r dt #:precision '(= 1))
49+
(length valid-results))
4850
(unless (empty? valid-results)
4951
(fprintf output-port "; Benchmark ~a, total ~aµs available\n" bench-id (~r dt #:precision '(= 1)))
5052
(fprintf output-port
@@ -64,13 +66,14 @@
6466
(define min-speedup (make-parameter 1.2))
6567
(command-line
6668
#:once-each [("--min") n "Minimum speedup to report" (min-speedup (string->number n))]
67-
#:args ([points-file "infra/points.json"]
68-
[output-file "optimaize.rival"])
69+
#:args ([points-file "infra/points.json"] [output-file "optimaize.rival"])
6970
(printf "Analyzing points bad precision assignment (min speedup: ~a)...\n\n" (min-speedup))
70-
(call-with-output-file output-file #:exists 'replace
71-
(λ (out-port)
72-
(call-with-input-file points-file
73-
(λ (input)
74-
(for ([rec (in-port read-json input)]
75-
[bench-id (in-naturals)])
76-
(analyze-program rec bench-id (min-speedup) out-port))))))))
71+
(call-with-output-file
72+
output-file
73+
#:exists 'replace
74+
(λ (out-port)
75+
(call-with-input-file points-file
76+
(λ (input)
77+
(for ([rec (in-port read-json input)]
78+
[bench-id (in-naturals)])
79+
(analyze-program rec bench-id (min-speedup) out-port))))))))

repl.rkt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,13 +232,16 @@
232232
(printf "~a optimal ~aµs faster (~a×)\n"
233233
name
234234
(~r (* 1000 (- cur-time optimal-time)) #:precision '(= 1))
235-
(if (zero? optimal-time) "" (~r (/ cur-time optimal-time) #:precision '(= 3))))
235+
(if (zero? optimal-time)
236+
""
237+
(~r (/ cur-time optimal-time) #:precision '(= 3))))
236238
(define ivec (rival-machine-instructions machine))
237239
(for ([instr (in-vector ivec)]
238240
[final (in-vector cur-precs)]
239241
[optimal (in-vector optimal-precs)])
240242
(define instr-name (normalize-function-name (~a (object-name (car instr)))))
241-
(printf "~a ~a ~a\n" (~a instr-name #:width 20 #:align 'left)
243+
(printf "~a ~a ~a\n"
244+
(~a instr-name #:width 20 #:align 'left)
242245
(~a final #:width 6 #:align 'right)
243246
(~a optimal #:width 6 #:align 'right)))
244247
(newline))]

0 commit comments

Comments
 (0)