In kernel convert int register into float still keep same register number?

Hi! I want to reuse a int register in my kernel function, so I want to use __int_as_float(a) to convert it into float.

I mean, if I define a new float, and even do not use previous int, register number will increase, right?

So my question is, the int convert into float, int takes one register, and float also takes only one register, right?

Thank you!!!

In the GPU a register is a register is a register. It can hold any 32-bit quantity, e.g. a float or an int. The assignment of variables to registers is fluent throughout a kernel: the same variable may be held in more than one register over the lifetime of a kernel, and the same register may hold more than one variable over the lifetime of a kernel.

The register allocation mechanism in the backend of the compiler (ptxas) will assign registers to any variable that is “live” at any given point. The total register amount needed for a kernel will go up only if the number of live variables increases at the “fattest” point (the part of the program with the highest number of live registers).

The easiest way to check on the register use of a kernel is to add -Xptxas -v to the nvcc invocation and check register use statistics before and after a program change. Note that, generally speaking, register allocation interacts with instruction scheduling (also performed by pxtas) and therefore register count can go up and down when restructing code even when the number of variables does not change.

1 Like

Register liveness info may also be of interest.

Thank you! A 32-bit register can save a float or a int. OK!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.