Question

When I use .reg to declare registers.. where are they?

I mean: if I use .reg inside a device function registers are stored on the register file that each thread has... but what if I declare a .reg variable in the module in the global scope (not .global, simply global scope)?

Was it helpful?

Solution

Any .reg declaration winds up in the PTX register state space. How that maps to hardware features is determined by the assembler, but the usual rules of register or local memory hold true. You should be aware that register state space declarations at module scope are only supported in PTX 1.x and 2.x code and can't be used with the CUDA ABI. The PTX documentation notes:

Registers differ from the other state spaces in that they are not fully addressable, i.e., it is not possible to refer to the address of a register. When compiling to use the Application Binary Interface (ABI), register variables are restricted to function scope and may not be declared at module scope. When compiling legacy PTX code (ISA versions prior to 3.0) containing module scoped .reg variables, the compiler silently disables use of the ABI.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top