spill register to shared mem

My kernel’s register usage is 45 which kills occupancy. But I have a good amount of unused shared memory.
If I try to limit register usage to 32, I get lots of lmem usage. Is it possible to force nvcc to use the vast amount
of left over shared memory instead of lmem ? If I have to do that myself, how do I go about it ? Maybe declare an array
on shared memory for each variable I want to put on shared mem, but sounds complicated…
Thanks

That’s the way to go, if you want to use shared memory instead of registers (and don’t have any variables whose values are identical over all threads).

Spare a moment though to think about whether improved occupancy really is what you want.

Thanks tera. There are some big objects (structs) that I can put in shared mem and pass a reference to.

That does not need changing the code much and that way I was able to save 6 registers on my first try.

My occupancy on 1.1 capabiliy was 17% which is too low, even though it goes upto 50% on latest hardware.

My kernels benefit from not using global memory a lot.

Edit: I see the paper you gave a link to discourages use of shared memory. That is interesting.

I need to make tests and see if it makes my application slower.