пятница, 11 сентября 2026 г.

shrinking holes in SASS allocated registers

In my previous post I discovered that SASS register allocation can have holes - non-contiguous register indices allocated to a function where intermediate registers like R57 remain unused despite R56 and R58 being live/allocated

To estimate size of problem I wrote some code to collect statistics about number (and share) of functions having holes in register allocations:

  • libcublas.so.13.7.0.74.sm_90.cubin
    ; 34 holes in regs (784), 0.043367
    ; 3 holes in uregs (434), 0.006912
    ; 34 functions with holes (0.629630 from total)
  • libcublas.so.13.7.0.608.sm_90.cubin
    ; 41 holes in regs (8546), 0.004798
    ; 15 holes in uregs (2784), 0.005388
    ; 39 functions with holes (0.102632 from total)
  • libcublas.so.13.7.0.935.sm_90.cubin
    ; 19 holes in regs (5016), 0.003788
    ; 17 holes in uregs (2012), 0.008449
    ; 11 functions with holes (0.059783 from total)

As you can see holes occupy up to 4% of total registers (in average 0.3-0.5%) and it's very tempting to try reduce them. It would seem—what could be simpler? If we have something like that
; RHoles max 61: R56 R58

just remap in whole function R61 to R58 and R60 to R56, and then reduce EIATTR_REGCOUNT,right? Well, actually no