Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"register" keyword in CUDA

Tags:

cuda

I have a large program that uses all the registers I allocated per thread (64) and spills to local memory. I would like to be able to tell the compiler which variables should remain in registers at all cost, and which ones I don't really care about. Does the "register" C/C++ keyword work in nvcc? Is there a different mechanism perhaps?

Thanks!

like image 873
Slava P Avatar asked Feb 18 '15 21:02

Slava P


People also ask

What are registers in CUDA?

In general all scalar variables defined in CUDA code are stored in registers. Registers are local to a thread, and each thread has exclusive access to its own registers: values in registers cannot be accessed by other threads, even from the same block, and are not available for the host.

What is the syntax to write kernel in CUDA?

When a kernel is called, its execution configuration is provided through <<<...>>> syntax, e.g. cuda_hello<<<1,1>>>() . In CUDA terminology, this is called "kernel launch".

What is function of global qualifier in CUDA program?

__global__ : 1. A qualifier added to standard C. This alerts the compiler that a function should be compiled to run on a device (GPU) instead of host (CPU). 2.


1 Answers

You can use register in CUDA C/C++ if you want to. In any context, it is only a hint to the compiler. It may be ignored. There is no stated guarantee that it does anything at all.

I think these statements are pretty much true for most language implementations of register.

I also think it's quite likely that the compiler can do a better job than you can of deciding what should be in registers, and appropriate priority.

The typical CUDA C/C++ mechanisms for controlling register usage work at a higher level, they are:

  1. the -maxrregcount compile switch
  2. the launch bounds directive.
like image 89
Robert Crovella Avatar answered Oct 10 '22 22:10

Robert Crovella