Skip to content

Commit 9afee49

Browse files
authored
Merge pull request #103 from herbie-fp/sollya-caching
Sollya caching
2 parents d77f170 + d322a7f commit 9afee49

File tree

2 files changed

+46
-26
lines changed

2 files changed

+46
-26
lines changed

infra/points.json.xz

11.7 MB
Binary file not shown.

time.rkt

Lines changed: 46 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
(define (read-from-string s)
4949
(read (open-input-string s)))
5050

51-
(define (time-expr rec timeline)
51+
(define (time-expr rec timeline sollya-reeval)
5252
(define exprs (map read-from-string (hash-ref rec 'exprs)))
5353
(define vars (map read-from-string (hash-ref rec 'vars)))
5454
(unless (andmap symbol? vars)
@@ -79,7 +79,8 @@
7979

8080
(define tuned-bench #f)
8181
(define times
82-
(for/list ([pt (in-list (hash-ref rec 'points))])
82+
(for/list ([pt* (in-list (hash-ref rec 'points))])
83+
(match-define (list pt sollya-exs sollya-status sollya-apply-time) pt*)
8384
; --------------------------- Baseline execution ----------------------------------------------
8485
(define baseline-start-apply (current-inexact-milliseconds))
8586
(match-define (list baseline-status baseline-exs)
@@ -174,22 +175,41 @@
174175
; We treat Rival's results as the right ones since for some benchs Sollya has produced wrong results!
175176
(when (and (and rival-machine baseline-machine sollya-machine)
176177
(or (equal? rival-status 'valid) (equal? rival-status 'unsamplable)))
177-
178-
(define sollya-apply-time 0.0)
179-
(match-define (list sollya-status sollya-exs)
180-
(match sollya-machine
181-
[#f (list #f #f)] ; if sollya machine is not working for this benchmark
182-
[else
183-
(with-handlers ([exn:fail? (λ (e)
184-
(printf "Sollya failed")
185-
(printf "~a\n" e)
186-
(sollya-kill sollya-machine)
187-
(set! sollya-machine #f)
188-
(list #f #f))])
189-
(match-define (list internal-time external-time exs status)
190-
(sollya-apply sollya-machine pt #:timeout (*sampling-timeout*)))
191-
(set! sollya-apply-time external-time)
192-
(list status exs))]))
178+
(match sollya-reeval
179+
[#t
180+
(set! sollya-apply-time 0.0)
181+
(match sollya-machine
182+
[#f (list #f #f)] ; if sollya machine is not working for this benchmark
183+
[else
184+
(with-handlers ([exn:fail? (λ (e)
185+
(printf "Sollya failed")
186+
(printf "~a\n" e)
187+
(sollya-kill sollya-machine)
188+
(set! sollya-machine #f)
189+
(list #f #f))])
190+
(match-define (list internal-time external-time exs status)
191+
(sollya-apply sollya-machine pt #:timeout (*sampling-timeout*)))
192+
(set! sollya-apply-time external-time)
193+
(set! sollya-status status)
194+
(set! sollya-exs exs))])]
195+
[#f
196+
(set! sollya-exs
197+
(match sollya-exs
198+
["#f" #f]
199+
[#f #f]
200+
[_ (fl (string->number sollya-exs))]))
201+
202+
(set! sollya-status
203+
(match sollya-status
204+
["#f" 'invalid]
205+
[#f 'invalid]
206+
[_ (string->symbol sollya-status)]))
207+
208+
(set! sollya-apply-time
209+
(match sollya-apply-time
210+
["#f" 0.0]
211+
[#f 0.0]
212+
[_ sollya-apply-time]))])
193213

194214
; -------------------------------- Combining results ----------------------------------------
195215
; When all the machines have compiled and produced results - write the results to outcomes
@@ -220,7 +240,6 @@
220240
(equal? baseline-status 'valid))
221241
1
222242
0))
223-
224243
(cons rival-status (cons rival-apply-time rival-baseline-difference))))
225244

226245
; Zombie process
@@ -313,7 +332,7 @@
313332
(for/list ([(key value) (in-hash (hash-ref timeline 'density))])
314333
(list key value))))
315334

316-
(define (make-expression-table points test-id timeline-port)
335+
(define (make-expression-table points test-id timeline-port sollya-reeval)
317336
(newline)
318337
(define total-c 0.0)
319338
(define total-v 0.0)
@@ -342,7 +361,7 @@
342361
(pretty-print (map read-from-string (hash-ref rec 'exprs))))
343362

344363
(match-define (list c-time v-num v-time i-num i-time u-num u-time rival-baseline-diff)
345-
(time-exprs (time-expr rec timeline)))
364+
(time-exprs (time-expr rec timeline sollya-reeval)))
346365
(set! total-c (+ total-c c-time))
347366
(set! total-v (+ total-v v-time))
348367
(set! count-v (+ count-v v-num))
@@ -358,7 +377,6 @@
358377
(~r i-time #:precision '(= 3) #:min-width 8)
359378
(~r u-time #:precision '(= 3) #:min-width 8))
360379
(list i t-time c-time v-num v-time i-num i-time u-num u-time rival-baseline-diff)))
361-
362380
(printf "\nDATA:\n")
363381
(printf "\tNUMBER OF TUNED BENCHMARKS = ~a\n" (*num-tuned-benchmarks*))
364382
(printf "\tRIVAL TIMEOUTS = ~a\n" (*rival-timeout*))
@@ -433,12 +451,12 @@
433451
(fprintf port "<section id='profile'><h1>Profiling</h1>")
434452
(fprintf port "<p class='load-text'>Loading profile data...</p></section>")))
435453

436-
(define (run test-id p timeline-port)
454+
(define (run test-id p timeline-port sollya-reeval)
437455
(define operation-table
438456
(and (or (not test-id) (not (string->number test-id))) (make-operation-table test-id)))
439457
(define-values (expression-table expression-footer)
440458
(if (and p (or (not test-id) (string->number test-id)))
441-
(make-expression-table p test-id timeline-port)
459+
(make-expression-table p test-id timeline-port sollya-reeval)
442460
(values #f #f)))
443461
(list operation-table expression-table expression-footer))
444462

@@ -500,6 +518,7 @@
500518
(define html-port #f)
501519
(define timeline-port #f)
502520
(define profile-port #f)
521+
(define sollya-reeval #f)
503522
(define n #f)
504523
(command-line
505524
#:once-each
@@ -517,14 +536,15 @@
517536
"Produce a JSON profile"
518537
(set! profile-port (open-output-file fn #:mode 'text #:exists 'replace))]
519538
[("--id") ns "Run a single test" (set! n ns)]
539+
[("--sollya-reeval") "Reevaluate Sollya" (set! sollya-reeval #t)]
520540
#:args ([points "infra/points.json"])
521541
(match-define (list op-t ex-t ex-f)
522542
(if profile-port
523543
(profile #:order 'total
524544
#:delay 0.001
525545
#:render (profile-json-renderer profile-port)
526-
(run n (open-input-file points) timeline-port))
527-
(run n (open-input-file points) timeline-port)))
546+
(run n (open-input-file points) timeline-port sollya-reeval))
547+
(run n (open-input-file points) timeline-port sollya-reeval)))
528548
(when dir
529549
(generate-html html-port profile-port op-t ex-t ex-f dir))))
530550

0 commit comments

Comments
 (0)