Skip to content

Commit 7b830da

Browse files
committed
Many fixes
1 parent b5b9413 commit 7b830da

File tree

12 files changed

+26
-36
lines changed

12 files changed

+26
-36
lines changed

src/core/egg-herbie.rkt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@
310310

311311
(module+ test
312312
(require "../utils/float.rkt")
313+
(activate-platform! (*platform-name*))
313314
(define ctx (context '(x y z) <binary64> (make-list 3 <binary64>)))
314315

315316
(define test-exprs

src/core/egglog-herbie-tests.rkt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,10 @@
307307
"../syntax/types.rkt"
308308
"batch.rkt"
309309
"rules.rkt"
310-
"../config.rkt")
310+
"../config.rkt"
311+
"../syntax/platform.rkt"
312+
"../utils/float.rkt")
313+
(activate-platform! (*platform-name*))
311314

312315
(define batch
313316
(progs->batch (list '(-.f64 (sin.f64 (+.f64 x eps)) (sin.f64 x))

src/core/regimes.rkt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@
149149
(list-ref errs (si-cidx (findf (lambda (x) (< i (si-pidx x))) split-indices)))))
150150

151151
(module+ test
152+
(require "../syntax/platform.rkt")
153+
(activate-platform! (*platform-name*))
152154
(define ctx (context '(x) <binary64> (list <binary64>)))
153155
(define pctx (mk-pcontext '(#(0.5) #(4.0)) '(1.0 1.0)))
154156
(define alts (map make-alt (list '(fmin.f64 x 1) '(fmax.f64 x 1))))

src/core/sampling.rkt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"../utils/float.rkt"
99
"../utils/timeline.rkt"
1010
"../syntax/types.rkt"
11-
(only-in "../syntax/platform.rkt" get-representation)
1211
"searchreals.rkt"
1312
"rival.rkt")
1413

@@ -33,6 +32,8 @@
3332

3433
(module+ test
3534
(require rackunit)
35+
(require "../syntax/platform.rkt")
36+
(activate-platform! (*platform-name*))
3637
(define binary64 (get-representation 'binary64))
3738
(define pre '(and (and (<= 0 a) (<= a 1)) (and (<= 0 b) (<= b 1))))
3839

src/core/test-rules.rkt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
"../syntax/platform.rkt"
1111
"sampling.rkt")
1212

13+
(activate-platform! (*platform-name*))
14+
1315
(define num-test-points (make-parameter 100))
1416
(define double-repr (get-representation 'binary64))
1517

src/platforms/c.rkt

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"runtime/libm.rkt" ; libm wrapper
99
"../utils/float.rkt" ; for shift/unshift
1010
"../syntax/platform.rkt")
11+
(provide platform)
1112

1213
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; EMPTY PLATFORM ;;;;;;;;;;;;;;;;;;;;;;;;
1314

@@ -22,16 +23,7 @@
2223

2324
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; representation ;;;;;;;;;;;;;;;;;;;;;;;;
2425

25-
(define bool
26-
(make-representation #:name 'bool
27-
#:type 'bool
28-
#:repr? boolean?
29-
#:bf->repr identity
30-
#:repr->bf identity
31-
#:ordinal->repr (λ (x) (= x 0))
32-
#:repr->ordinal (λ (x) (if x 1 0))
33-
#:total-bits 1
34-
#:special-value? (const #f)))
26+
(define bool <bool>)
3527

3628
(platform-register-representation! platform #:repr bool #:cost boolean-move-cost)
3729

@@ -59,16 +51,7 @@
5951

6052
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; representation ;;;;;;;;;;;;;;;;;;;;;;;;
6153

62-
(define binary32
63-
(make-representation #:name 'binary32
64-
#:type 'real
65-
#:repr? flonum?
66-
#:bf->repr bigfloat->float32
67-
#:repr->bf bf
68-
#:ordinal->repr (shift 31 ordinal->float32)
69-
#:repr->ordinal (unshift 31 float32->ordinal)
70-
#:total-bits 32
71-
#:special-value? nan?))
54+
(define binary32 <binary32>)
7255

7356
(platform-register-representation! platform #:repr binary32 #:cost 32bit-move-cost)
7457

@@ -166,16 +149,7 @@
166149

167150
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; representation ;;;;;;;;;;;;;;;;;;;;;;;;
168151

169-
(define binary64
170-
(make-representation #:name 'binary64
171-
#:type 'real
172-
#:repr? flonum?
173-
#:bf->repr bigfloat->flonum
174-
#:repr->bf bf
175-
#:ordinal->repr (shift 63 ordinal->flonum)
176-
#:repr->ordinal (unshift 63 flonum->ordinal)
177-
#:total-bits 64
178-
#:special-value? nan?))
152+
(define binary64 <binary64>)
179153

180154
(platform-register-representation! platform #:repr binary64 #:cost 64bit-move-cost)
181155

src/syntax/platform.rkt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
(define-runtime-path platform-dir "../platforms/")
7070

7171
(define (load-platform! name)
72-
(eprintf "Loading platform ~a\n" name)
7372
(if (or (string-contains? name "/") (string-contains? name "."))
7473
(dynamic-require name 'platform)
7574
(dynamic-require (build-path platform-dir (format "~a.rkt" name)) 'platform)))

src/syntax/read.rkt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@
282282
(require rackunit
283283
"../utils/float.rkt")
284284

285+
(activate-platform! (*platform-name*))
285286
(define precision 'binary64)
286287
(define ctx (context '(x y z a) <binary64> (make-list 4 <binary64>)))
287288

src/syntax/syntax-check.rkt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@
199199
;; testing FPCore format
200200
(module+ test
201201
(require rackunit)
202+
(activate-platform! (*platform-name*))
202203

203204
(define (get-errs stx)
204205
(reap [sow]

src/syntax/test-syntax.rkt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77

88
(module+ test
99
(require rackunit
10-
math/bigfloat)
10+
math/bigfloat
11+
"../config.rkt")
1112

12-
(load-herbie-builtins)
13+
(activate-platform! (*platform-name*))
1314
(define platform (platform-copy (*active-platform*)))
1415
(define binary64 (get-representation 'binary64))
1516
; log1pmd(x) = log1p(x) - log1p(-x)

0 commit comments

Comments
 (0)