|
188 | 188 | [else (path-reduction vrepeats vregs varc instr i #:reexec-val #f)])) |
189 | 189 |
|
190 | 190 | ; Step 2. Precision tuning |
191 | | - (precision-tuning ivec vregs vprecs-new varc vstart-precs vrepeats vhint constants-lookup) |
| 191 | + (precision-tuning (rival-machine-max-precision machine) |
| 192 | + ivec |
| 193 | + vregs |
| 194 | + vprecs-new |
| 195 | + varc |
| 196 | + vstart-precs |
| 197 | + vrepeats |
| 198 | + vhint |
| 199 | + constants-lookup) |
192 | 200 |
|
193 | 201 | ; Step 3. Repeating precisions check + Assigning if a operation should be computed again at all |
194 | 202 | ; vrepeats[i] = #t if the node has the same precision as an iteration before and children have #t flag as well |
|
227 | 235 | ; clean progress of the current tuning pass and start over |
228 | 236 | (vector-fill! vprecs-new 0) |
229 | 237 | (vector-fill! vrepeats #f) |
230 | | - (precision-tuning ivec vregs vprecs-new varc vstart-precs vrepeats vhint constants-lookup) |
| 238 | + (precision-tuning (rival-machine-max-precision machine) |
| 239 | + ivec |
| 240 | + vregs |
| 241 | + vprecs-new |
| 242 | + varc |
| 243 | + vstart-precs |
| 244 | + vrepeats |
| 245 | + vhint |
| 246 | + constants-lookup) |
231 | 247 | (repeats)) ; do repeats again |
232 | 248 |
|
233 | 249 | ; Step 5. Copying new precisions into vprecs |
|
245 | 261 | ; Roughly speaking, the upper precision bound is calculated as: |
246 | 262 | ; vprecs-max[i] = (+ max-prec vstart-precs[i]), where min-prec < (+ max-prec vstart-precs[i]) < max-prec |
247 | 263 | ; max-prec = (car (get-bounds parent)) |
248 | | -(define (precision-tuning ivec vregs vprecs-max varc vstart-precs vrepeats vhint constants) |
| 264 | +(define (precision-tuning machine-max-precision |
| 265 | + ivec |
| 266 | + vregs |
| 267 | + vprecs-max |
| 268 | + varc |
| 269 | + vstart-precs |
| 270 | + vrepeats |
| 271 | + vhint |
| 272 | + constants) |
249 | 273 | (define vprecs-min (make-vector (vector-length ivec) 0)) |
250 | 274 | (for ([instr (in-vector ivec (- (vector-length ivec) 1) -1 -1)] |
251 | 275 | [repeat? (in-vector vrepeats (- (vector-length vrepeats) 1) -1 -1)] |
|
258 | 282 | (define tail-registers (drop-self-pointer (cdr instr) n)) |
259 | 283 | (define srcs (append (map (lambda (x) (vector-ref vregs x)) tail-registers) constant)) |
260 | 284 |
|
261 | | - (define max-prec (vector-ref vprecs-max (- n varc))) ; upper precision bound given from parent |
| 285 | + (define parent-max-prec (vector-ref vprecs-max (- n varc))) ; upper precision bound given from parent |
262 | 286 | (define min-prec (vector-ref vprecs-min (- n varc))) ; lower precision bound given from parent |
263 | 287 |
|
264 | 288 | ; Final precision assignment based on the upper bound |
265 | 289 | (define final-precision |
266 | | - (min (max (+ max-prec (vector-ref vstart-precs (- n varc))) (*rival-min-precision*)) |
267 | | - (*rival-max-precision*))) |
| 290 | + (min (max (+ parent-max-prec (vector-ref vstart-precs (- n varc))) (*rival-min-precision*)) |
| 291 | + machine-max-precision)) |
268 | 292 | (vector-set! vprecs-max (- n varc) final-precision) |
269 | 293 |
|
270 | 294 | ; Early stopping |
271 | 295 | (match (*lower-bound-early-stopping*) |
272 | 296 | [#t |
273 | | - (when (>= min-prec (*rival-max-precision*)) |
| 297 | + (when (>= min-prec machine-max-precision) |
274 | 298 | (*sampling-iteration* (*rival-max-iterations*)))] |
275 | 299 | [#f |
276 | | - (when (equal? final-precision (*rival-max-precision*)) |
| 300 | + (when (equal? final-precision machine-max-precision) |
277 | 301 | (*sampling-iteration* (*rival-max-iterations*)))]) |
278 | 302 |
|
279 | 303 | ; Precision propogation for each tail instruction |
|
286 | 310 | ; Upper precision bound propogation |
287 | 311 | (vector-set! vprecs-max |
288 | 312 | (- x varc) |
289 | | - (max (vector-ref vprecs-max (- x varc)) (+ max-prec up-bound))) |
| 313 | + (max (vector-ref vprecs-max (- x varc)) (+ parent-max-prec up-bound))) |
290 | 314 |
|
291 | 315 | ; Lower precision bound propogation |
292 | 316 | (vector-set! vprecs-min |
|
0 commit comments