|
166 | 166 | [out-dr? (in-vector slackvec)] |
167 | 167 | #:when (>= root-reg varc) |
168 | 168 | #:when out-dr?) |
169 | | - (vector-set! vprecs-new (- root-reg varc) (get-slack))) |
| 169 | + (vector-set! vprecs-new (- root-reg varc) (get-slack current-iter))) |
170 | 170 |
|
171 | 171 | ; Step 1b. Checking if a operation should be computed again at all |
172 | 172 | ; This step traverses instructions top-down and check whether a reevaluation is needed |
|
188 | 188 | [else (path-reduction vrepeats vregs varc instr i #:reexec-val #f)])) |
189 | 189 |
|
190 | 190 | ; Step 2. Precision tuning |
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) |
| 191 | + (define hit-max? |
| 192 | + (precision-tuning (rival-machine-max-precision machine) |
| 193 | + ivec |
| 194 | + vregs |
| 195 | + vprecs-new |
| 196 | + varc |
| 197 | + vstart-precs |
| 198 | + vrepeats |
| 199 | + vhint |
| 200 | + constants-lookup |
| 201 | + current-iter)) |
200 | 202 |
|
201 | 203 | ; Step 3. Repeating precisions check + Assigning if a operation should be computed again at all |
202 | 204 | ; vrepeats[i] = #t if the node has the same precision as an iteration before and children have #t flag as well |
|
235 | 237 | ; clean progress of the current tuning pass and start over |
236 | 238 | (vector-fill! vprecs-new 0) |
237 | 239 | (vector-fill! vrepeats #f) |
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) |
| 240 | + (define hit-max2? |
| 241 | + (precision-tuning (rival-machine-max-precision machine) |
| 242 | + ivec |
| 243 | + vregs |
| 244 | + vprecs-new |
| 245 | + varc |
| 246 | + vstart-precs |
| 247 | + vrepeats |
| 248 | + vhint |
| 249 | + constants-lookup |
| 250 | + current-iter)) |
| 251 | + (set! hit-max? (or hit-max? hit-max2?)) |
247 | 252 | (repeats)) ; do repeats again |
248 | 253 |
|
249 | 254 | ; Step 5. Copying new precisions into vprecs |
250 | | - (vector-copy! vprecs 0 vprecs-new)) |
| 255 | + (vector-copy! vprecs 0 vprecs-new) |
| 256 | + hit-max?) |
251 | 257 |
|
252 | 258 | ; Usually, add-bang instructions have a pointer to itself that is needed to be dropped |
253 | 259 | (define (drop-self-pointer tail-regs n) |
|
269 | 275 | vstart-precs |
270 | 276 | vrepeats |
271 | 277 | vhint |
272 | | - constants) |
| 278 | + constants |
| 279 | + iter) |
273 | 280 | (define vprecs-min (make-vector (vector-length ivec) 0)) |
| 281 | + (define hit-max? #f) |
274 | 282 | (for ([instr (in-vector ivec (- (vector-length ivec) 1) -1 -1)] |
275 | 283 | [repeat? (in-vector vrepeats (- (vector-length vrepeats) 1) -1 -1)] |
276 | 284 | [n (in-range (- (vector-length vregs) 1) -1 -1)] |
|
296 | 304 | (match (*lower-bound-early-stopping*) |
297 | 305 | [#t |
298 | 306 | (when (>= min-prec machine-max-precision) |
299 | | - (*sampling-iteration* (*rival-max-iterations*)))] |
| 307 | + (set! hit-max? #t))] |
300 | 308 | [#f |
301 | 309 | (when (equal? final-precision machine-max-precision) |
302 | | - (*sampling-iteration* (*rival-max-iterations*)))]) |
| 310 | + (set! hit-max? #t))]) |
303 | 311 |
|
304 | 312 | ; Precision propogation for each tail instruction |
305 | | - (define ampl-bounds (get-bounds op output srcs)) ; amplification bounds for children instructions |
| 313 | + (define ampl-bounds |
| 314 | + (get-bounds op output srcs iter)) ; amplification bounds for children instructions |
306 | 315 | (for ([x (in-list tail-registers)] |
307 | 316 | [bound (in-list ampl-bounds)] |
308 | 317 | #:when (>= x varc)) ; when tail register is not a variable |
|
316 | 325 | ; Lower precision bound propogation |
317 | 326 | (vector-set! vprecs-min |
318 | 327 | (- x varc) |
319 | | - (max (vector-ref vprecs-min (- x varc)) (+ min-prec (max 0 lo-bound))))))) |
| 328 | + (max (vector-ref vprecs-min (- x varc)) (+ min-prec (max 0 lo-bound)))))) |
| 329 | + hit-max?) |
0 commit comments