Register count in cubin

I tried to reduce the number of registers in my kernel code by reordering the instructions and reusing variables in my kernel code. So, I reduced number of float variables from 18 to 8. But the number of register count in the cubin file doesn’t change after this. Am I doing assuming anything wrong?


Reducing the number of variables won’t necessarily reduce the number of registers, unless you simplify your calculations. Registers are also used for intermediate results of calculations.

eg: “abcde” could potentially use up to 3 registers or more (depending on what else the compiler wants to do with code before/after this calculation, and where/how the calculation is being used).

You can ‘force’ the compiler to use no more than a set number of registers per kernel (for all kernels of a file) "–maxrregcount " (see the nvcc documentation for more details), however this will force the compiler to start using local memory for some registers (if it can’t compile your code to use the fixed number of hardware registers).

ptxas is very good & agressive at optimizing the amount of used registers. So you have been manually doing what ptxas is doing automatically for you.