Skip to content

Commit c4f1e90

Browse files
committed
make pbrt binary32 again
1 parent 4903a0e commit c4f1e90

File tree

5 files changed

+35
-44
lines changed

5 files changed

+35
-44
lines changed

bench/pbrt.fpcore

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
22
:name "HairBSDF, Mp, upper"
3-
:precision binary64
3+
:precision binary32
44
:pre (and (<= -1 cosTheta_i 1) (<= -1 cosTheta_O 1)
55
(<= -1 sinTheta_i 1) (<= -1 sinTheta_O 1)
66
(< 0.1 v) (<= v 1.5707964))
@@ -10,7 +10,7 @@
1010

1111
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
1212
:name "HairBSDF, Mp, lower"
13-
:precision binary64
13+
:precision binary32
1414
:pre (and (<= -1 cosTheta_i 1) (<= -1 cosTheta_O 1)
1515
(<= -1 sinTheta_i 1) (<= -1 sinTheta_O 1)
1616
(<= -1.5707964 v 0.1))
@@ -20,13 +20,13 @@
2020

2121
(FPCore (u v)
2222
:name "HairBSDF, sample_f, cosTheta"
23-
:precision binary64
23+
:precision binary32
2424
:pre (and (<= 1e-5 u 1) (<= 0 v 109.746574))
2525
(+ 1 (* v (log (+ u (* (- 1 u) (exp (/ -2 v))))))))
2626

2727
(FPCore (sinTheta_O h eta)
2828
:name "HairBSDF, gamma for a refracted ray"
29-
:precision binary64
29+
:precision binary32
3030
:pre (and (<= -1 sinTheta_O 1)
3131
(<= -1 h 1)
3232
(<= 0 eta 10))
@@ -38,7 +38,7 @@
3838

3939
(FPCore (ux uy maxCos)
4040
:name "UniformSampleCone, x"
41-
:precision binary64
41+
:precision binary32
4242
:pre (and (<= 2.328306437e-10 ux 1)
4343
(<= 2.328306437e-10 uy 1)
4444
(<= 0 maxCos 1))
@@ -49,7 +49,7 @@
4949

5050
(FPCore (ux uy maxCos)
5151
:name "UniformSampleCone, y"
52-
:precision binary64
52+
:precision binary32
5353
:pre (and (<= 2.328306437e-10 ux 1)
5454
(<= 2.328306437e-10 uy 1)
5555
(<= 0 maxCos 1))
@@ -60,7 +60,7 @@
6060

6161
(FPCore (ux uy maxCos)
6262
:name "UniformSampleCone, z"
63-
:precision binary64
63+
:precision binary32
6464
:pre (and (<= 2.328306437e-10 ux 1)
6565
(<= 2.328306437e-10 uy 1)
6666
(<= 0 maxCos 1))
@@ -72,7 +72,7 @@
7272
;; Unsure on reasonable bounds for xi, yi, zi
7373
(FPCore (xi yi zi ux uy maxCos)
7474
:name "UniformSampleCone 2"
75-
:precision binary64
75+
:precision binary32
7676
:pre (and (<= -1e4 xi 1e4) (<= -1e4 yi 1e4) (<= -1e4 zi 1e4)
7777
(<= 2.328306437e-10 ux 1) (<= 2.328306437e-10 uy 1)
7878
(<= 0 maxCos 1))
@@ -85,7 +85,7 @@
8585

8686
(FPCore (normAngle u n0_i n1_i)
8787
:name "Curve intersection, scale width based on ribbon orientation"
88-
:precision binary64
88+
:precision binary32
8989
:pre (and (<= 0 normAngle (/ PI 2))
9090
(<= -1 n0_i 1) (<= -1 n1_i 1)
9191
(<= 2.328306437e-10 u 1))
@@ -96,15 +96,15 @@
9696

9797
(FPCore (x tau)
9898
:name "Lanczos kernel"
99-
:precision binary64
99+
:precision binary32
100100
:pre (and (<= 1e-5 x 1) (<= 1 tau 5))
101101
(let ([xp (* x PI)])
102102
(* (/ (sin (* xp tau)) (* xp tau))
103103
(/ (sin xp) xp))))
104104

105105
(FPCore (cosTheta_i u1 u2)
106106
:name "Beckmann Sample, near normal, slope_x"
107-
:precision binary64
107+
:precision binary32
108108
:pre (and (> cosTheta_i 0.9999) (<= cosTheta_i 1)
109109
(<= 2.328306437e-10 u1 1) (<= 2.328306437e-10 u2 1))
110110
(let ([r (sqrt (- (log (- 1 u1))))]
@@ -114,7 +114,7 @@
114114

115115
(FPCore (cosTheta_i u1 u2)
116116
:name "Beckmann Sample, near normal, slope_y"
117-
:precision binary64
117+
:precision binary32
118118
:pre (and (> cosTheta_i 0.9999) (<= cosTheta_i 1)
119119
(<= 2.328306437e-10 u1 1) (<= 2.328306437e-10 u2 1))
120120
(let ([r (sqrt (- (log (- 1 u1))))]
@@ -124,7 +124,7 @@
124124

125125
(FPCore (cosTheta_i u1 u2)
126126
:name "Trowbridge-Reitz Sample, near normal, slope_x"
127-
:precision binary64
127+
:precision binary32
128128
:pre (and (> cosTheta_i 0.9999) (<= cosTheta_i 1)
129129
(<= 2.328306437e-10 u1 1) (<= 2.328306437e-10 u2 1))
130130
(let ([r (sqrt (/ u1 (- 1 u1)))]
@@ -133,7 +133,7 @@
133133

134134
(FPCore (cosTheta_i u1 u2)
135135
:name "Trowbridge-Reitz Sample, near normal, slope_y"
136-
:precision binary64
136+
:precision binary32
137137
:pre (and (> cosTheta_i 0.9999) (<= cosTheta_i 1)
138138
(<= 2.328306437e-10 u1 1) (<= 2.328306437e-10 u2 1))
139139
(let ([r (sqrt (/ u1 (- 1 u1)))]
@@ -142,7 +142,7 @@
142142

143143
(FPCore (u0 u1 alphax alphay)
144144
:name "Trowbridge-Reitz Sample, sample surface normal, cosTheta"
145-
:precision binary64
145+
:precision binary32
146146
:pre (and (<= 2.328306437e-10 u0 1)
147147
(<= 2.328306437e-10 u1 0.5)
148148
(<= 0.0001 alphax 1)
@@ -158,20 +158,20 @@
158158

159159
(FPCore (x s)
160160
:name "Logistic distribution"
161-
:precision binary64
161+
:precision binary32
162162
:pre (<= 0 s 1.0651631)
163163
(let ([e (exp (/ (- (fabs x)) s))])
164164
(/ e (* s (+ 1 e) (+ 1 e)))))
165165

166166
(FPCore (x s)
167167
:name "Logistic function"
168-
:precision binary64
168+
:precision binary32
169169
:pre (<= 0 s 1.0651631)
170170
(/ 1 (+ 1 (exp (/ (- x) s)))))
171171

172172
(FPCore (u s)
173173
:name "Sample trimmed logistic on [-pi, pi]"
174-
:precision binary64
174+
:precision binary32
175175
:pre (and (<= 2.328306437e-10 u 1) (<= 0 s 1.0651631))
176176
(let* ([lcdf_lo (/ 1 (+ 1 (exp (/ PI s))))]
177177
[lcdf_hi (/ 1 (+ 1 (exp (/ (- PI) s))))]
@@ -180,21 +180,21 @@
180180

181181
(FPCore (cosTheta c)
182182
:name "Beckmann Sample, normalization factor"
183-
:precision binary64
183+
:precision binary32
184184
:pre (and (< 0 cosTheta 0.9999) (< -1 c 1))
185185
(let* ([sinTheta (sqrt (- 1 cosTheta cosTheta))]
186186
[tanTheta (/ sinTheta cosTheta)])
187187
(/ 1 (+ 1 c (* (/ 1 (sqrt PI)) tanTheta (exp (* (- cosTheta) cosTheta)))))))
188188

189189
(FPCore (alpha u0)
190190
:name "Beckmann Distribution sample, tan2theta, alphax == alphay"
191-
:precision binary64
191+
:precision binary32
192192
:pre (and (<= 0.0001 alpha 1) (<= 2.328306437e-10 u0 1))
193193
(* (- alpha) alpha (log (- 1 u0))))
194194

195195
(FPCore (alphax alphay u0 cos2phi sin2phi)
196196
:name "Beckmann Distribution sample, tan2theta, alphax != alphay, u1 <= 0.5"
197-
:precision binary64
197+
:precision binary32
198198
:pre (and (<= 0.0001 alphax 1) (<= 0.0001 alphay 1) (<= 2.328306437e-10 u0 1)
199199
(<= 0 cos2phi 1) (<= 0 sin2phi))
200200
(let ([alphax2 (* alphax alphax)]
@@ -205,26 +205,26 @@
205205

206206
(FPCore (s r)
207207
:name "Disney BSSRDF, PDF of scattering profile"
208-
:precision binary64
208+
:precision binary32
209209
:pre (and (<= 0 s 256) (< 1e-6 r 1e6))
210210
(+ (/ (* 0.25 (exp (/ (- r) s))) (* 2 PI s r))
211211
(/ (* 0.75 (exp (/ (- r) (* 3 s)))) (* 6 PI s r))))
212212

213213
(FPCore (s u)
214214
:name "Disney BSSRDF, sample scattering profile, lower"
215-
:precision binary64
215+
:precision binary32
216216
:pre (and (<= 0 s 256) (<= 2.328306437e-10 u 0.25))
217217
(* s (log (/ 1 (- 1 (* 4 u))))))
218218

219219
(FPCore (s u)
220220
:name "Disney BSSRDF, sample scattering profile, upper"
221-
:precision binary64
221+
:precision binary32
222222
:pre (and (<= 0 s 256) (<= 0.25 u 1))
223223
(* 3 s (log (/ 1 (- 1 (/ (- u 0.25) 0.75))))))
224224

225225
(FPCore (cosTheta alpha)
226226
:name "GTR1 distribution"
227-
:precision binary64
227+
:precision binary32
228228
:pre (and (<= 0 cosTheta 1) (<= 0.0001 alpha 1))
229229
(let ([alpha2 (* alpha alpha)])
230230
(/ (- alpha2 1) (* PI (log alpha2) (+ 1 (* (- alpha2 1) cosTheta cosTheta))))))

src/egglog/egraph-conversion.rkt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
(require "../syntax/syntax.rkt" "../syntax/types.rkt"
44
"../programs.rkt" "../errors.rkt")
55
(provide egg-expr->expr egg-exprs->exprs
6-
expr->egg-expr expr->egglog egglog->expr (struct-out egraph-data))
6+
expr->egglog egglog->expr (struct-out egraph-data))
77

88
(struct egraph-data (egg->herbie-dict herbie->egg-dict) #:prefab)
99

@@ -136,16 +136,12 @@
136136
[else
137137
(error (format "Unrecognized egg expression ~a" parsed))]))
138138

139-
;; returns a pair of the string representing an egg expr, and updates the hash tables in the egraph
140-
(define (expr->egg-expr ctx expr egg-data)
141-
(define egg->herbie-dict (egraph-data-egg->herbie-dict egg-data))
142-
(define herbie->egg-dict (egraph-data-herbie->egg-dict egg-data))
143-
(format "~s" (car (expr->egg-expr-helper ctx expr egg->herbie-dict herbie->egg-dict))))
144-
145139
(define (expr->egglog ctx expr egg-data)
146140
(define egg->herbie-dict (egraph-data-egg->herbie-dict egg-data))
147141
(define herbie->egg-dict (egraph-data-herbie->egg-dict egg-data))
148-
(car (expr->egg-expr-helper ctx expr egg->herbie-dict herbie->egg-dict)))
142+
(define res (car (expr->egg-expr-helper ctx expr egg->herbie-dict herbie->egg-dict)))
143+
res
144+
)
149145

150146
;; Needs the vartypes so we can look up var types
151147
(define (expr->egg-expr-helper ctx expr egg->herbie-dict herbie->egg-dict)

src/egglog/run-egglog.rkt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
(define egg-if-match-limit 10000)
2020
(define HIGH-COST 100000000)
2121
;; Number of egraphs to run (independent samples)
22-
(define egg-num-egraphs 1)
22+
(define egg-num-egraphs 2)
2323
;; local error threshold for search
2424
(define ERROR-THRESHOLD 0.0)
2525

@@ -1811,13 +1811,9 @@
18111811
(econfig ctx pctx exprs
18121812
(egraph-data (make-hash)
18131813
(make-hash))
1814-
(> i 0)
1815-
(if (> i 0)
1816-
1
1817-
4)
1818-
(if (> i 0)
1819-
0
1820-
num-variants)
1814+
#f
1815+
1
1816+
num-variants
18211817
(random-area ctx pctx)
18221818
))))))
18231819

src/mainloop.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@
328328
(timeline-event! 'preprocess)
329329

330330
;; If the specification is given, it is used for sampling points
331-
(define sortable (connected-components specification))
331+
(define sortable (connected-components specification (*context*)))
332332

333333
(define new-preprocess
334334
(for/list ([sortable-variables (in-list sortable)]

src/symmetry.rkt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@
1818
#:when (equal? swap* orig))
1919
swap))
2020

21-
(define (connected-components expr)
21+
(define (connected-components expr ctx)
2222
(define vars (program-variables expr))
23-
(define ctx (context vars (get-representation 'binary64) (map (λ (v) (get-representation 'binary64)) vars)))
2423
(define body (program-body expr))
2524

2625
(define swaps (get-swaps ctx vars body))

0 commit comments

Comments
 (0)