|
148 | 148 | (define vbest-precs (rival-machine-best-known-precisions machine)) |
149 | 149 | (define current-iter (rival-machine-iteration machine)) |
150 | 150 | (define bumps (rival-machine-bumps machine)) |
| 151 | + (define vinfo (rival-machine-tuning-info machine)) |
151 | 152 |
|
152 | 153 | (define varc (vector-length args)) |
153 | 154 | (define vprecs-new (make-vector (vector-length ivec) 0)) ; new vprecs vector |
|
178 | 179 | (vector-set! vrepeats (- arg varc) #f))])) |
179 | 180 |
|
180 | 181 | ; Step 2. Precision tuning |
181 | | - (precision-tuning ivec vregs vprecs-new varc vstart-precs vrepeats vhint) |
| 182 | + (precision-tuning ivec vregs vprecs-new varc vstart-precs vrepeats vhint vinfo) |
182 | 183 |
|
183 | 184 | ; Step 3. Repeating precisions check + Assigning if a operation should be computed again at all |
184 | 185 | ; vrepeats[i] = #t if the node has the same precision as an iteration before and children have #t flag as well |
|
217 | 218 | ; clean progress of the current tuning pass and start over |
218 | 219 | (vector-fill! vprecs-new 0) |
219 | 220 | (vector-fill! vrepeats #f) |
220 | | - (precision-tuning ivec vregs vprecs-new varc vstart-precs vrepeats vhint) |
| 221 | + (precision-tuning ivec vregs vprecs-new varc vstart-precs vrepeats vhint vinfo) |
221 | 222 | (repeats)) ; do repeats again |
222 | 223 |
|
223 | 224 | ; Step 5. Copying new precisions into vprecs |
224 | 225 | (vector-copy! vprecs 0 vprecs-new)) |
225 | 226 |
|
| 227 | +(define (get-info! vinfo vregs) |
| 228 | + (for ([reg (in-vector vregs)] |
| 229 | + [n (in-naturals)]) |
| 230 | + (vector-set! vinfo n (ival-info reg)))) |
| 231 | + |
226 | 232 | ; Usually, add-bang instructions have a pointer to itself that is needed to be dropped |
227 | 233 | (define (drop-self-pointer tail-regs n) |
228 | 234 | (if (empty? tail-regs) |
|
235 | 241 | ; Roughly speaking, the upper precision bound is calculated as: |
236 | 242 | ; vprecs-max[i] = (+ max-prec vstart-precs[i]), where min-prec < (+ max-prec vstart-precs[i]) < max-prec |
237 | 243 | ; max-prec = (car (get-bounds parent)) |
238 | | -(define (precision-tuning ivec vregs vprecs-max varc vstart-precs vrepeats vhint) |
| 244 | +(define (precision-tuning ivec vregs vprecs-max varc vstart-precs vrepeats vhint vinfo) |
| 245 | + (get-info! vinfo vregs) |
239 | 246 | (define vprecs-min (make-vector (vector-length ivec) 0)) |
240 | | - |
241 | | - (define slack (get-slack)) |
242 | | - (define vinfo (vector-map (curryr ival+minlog+maxlog+logspan slack) vregs)) |
243 | | - |
244 | 247 | (for ([instr (in-vector ivec (- (vector-length ivec) 1) -1 -1)] |
245 | 248 | [repeat? (in-vector vrepeats (- (vector-length vrepeats) 1) -1 -1)] |
246 | | - [n (in-range (- (vector-length vregs) 1) -1 -1)] |
| 249 | + [n (in-range (- (vector-length vinfo) 1) -1 -1)] |
247 | 250 | [hint (in-vector vhint (- (vector-length vhint) 1) -1 -1)] |
248 | 251 | [output (in-vector vinfo (- (vector-length vinfo) 1) -1 -1)] |
249 | 252 | #:when (and hint (not repeat?))) |
|
0 commit comments