|
154 | 154 | (define vbest-precs (rival-machine-best-known-precisions machine)) |
155 | 155 | (define current-iter (rival-machine-iteration machine)) |
156 | 156 | (define bumps (rival-machine-bumps machine)) |
| 157 | + (define constants-lookup (rival-machine-constant-lookup machine)) |
157 | 158 |
|
158 | 159 | (define first-tuning-pass? (equal? 1 current-iter)) |
159 | 160 | (define varc (vector-length args)) |
|
187 | 188 | [else (path-reduction vrepeats vregs varc instr i #:reexec-val #f)])) |
188 | 189 |
|
189 | 190 | ; Step 2. Precision tuning |
190 | | - (precision-tuning ivec vregs vprecs-new varc vstart-precs vrepeats vhint) |
| 191 | + (precision-tuning ivec vregs vprecs-new varc vstart-precs vrepeats vhint constants-lookup) |
191 | 192 |
|
192 | 193 | ; Step 3. Repeating precisions check + Assigning if a operation should be computed again at all |
193 | 194 | ; vrepeats[i] = #t if the node has the same precision as an iteration before and children have #t flag as well |
|
226 | 227 | ; clean progress of the current tuning pass and start over |
227 | 228 | (vector-fill! vprecs-new 0) |
228 | 229 | (vector-fill! vrepeats #f) |
229 | | - (precision-tuning ivec vregs vprecs-new varc vstart-precs vrepeats vhint) |
| 230 | + (precision-tuning ivec vregs vprecs-new varc vstart-precs vrepeats vhint constants-lookup) |
230 | 231 | (repeats)) ; do repeats again |
231 | 232 |
|
232 | 233 | ; Step 5. Copying new precisions into vprecs |
|
244 | 245 | ; Roughly speaking, the upper precision bound is calculated as: |
245 | 246 | ; vprecs-max[i] = (+ max-prec vstart-precs[i]), where min-prec < (+ max-prec vstart-precs[i]) < max-prec |
246 | 247 | ; max-prec = (car (get-bounds parent)) |
247 | | -(define (precision-tuning ivec vregs vprecs-max varc vstart-precs vrepeats vhint) |
| 248 | +(define (precision-tuning ivec vregs vprecs-max varc vstart-precs vrepeats vhint constants) |
248 | 249 | (define vprecs-min (make-vector (vector-length ivec) 0)) |
249 | 250 | (for ([instr (in-vector ivec (- (vector-length ivec) 1) -1 -1)] |
250 | 251 | [repeat? (in-vector vrepeats (- (vector-length vrepeats) 1) -1 -1)] |
251 | 252 | [n (in-range (- (vector-length vregs) 1) -1 -1)] |
252 | 253 | [hint (in-vector vhint (- (vector-length vhint) 1) -1 -1)] |
253 | 254 | [output (in-vector vregs (- (vector-length vregs) 1) -1 -1)] |
| 255 | + [constant (in-vector constants (- (vector-length constants) 1) -1 -1)] |
254 | 256 | #:when (and hint (not repeat?))) |
255 | 257 | (define op (car instr)) |
256 | 258 | (define tail-registers (drop-self-pointer (cdr instr) n)) |
257 | | - (define srcs (map (lambda (x) (vector-ref vregs x)) tail-registers)) |
| 259 | + (define srcs (append (map (lambda (x) (vector-ref vregs x)) tail-registers) constant)) |
258 | 260 |
|
259 | 261 | (define max-prec (vector-ref vprecs-max (- n varc))) ; upper precision bound given from parent |
260 | 262 | (define min-prec (vector-ref vprecs-min (- n varc))) ; lower precision bound given from parent |
|
0 commit comments