int vs short vs char in kernels

If I know that my integer variable inside a kernel will never exceed [font=“Courier New”]char[/font] or [font=“Courier New”]short[/font] limit, does it
make sense to declare such variable as [font=“Courier New”]char[/font] or [font=“Courier New”]short[/font], respectively? Can it lead to better code, e. g.: smaller register usage; or when a variable spills out to local memory will making such variable smaller reduce memory traffic?

Same for kernel arguments: if an [font=“Courier New”]int[/font] argument never actually exceeds [font=“Courier New”]char[/font] or [font=“Courier New”]short[/font] limit, does it make sense to declare it correspondingly?

This only helps to conserve memory (or memory bandwidth or cache) in global, shared, or constant memory space.

Variables in registers always occupy a full register regardless of their size (with the exception of doubles or 64-bit pointers occupying two registers). Also local memory is optimized for 32-bit wide access.

I believe that according to the “CUDA Programing Best Practice Guide”, NOT using int could result in inferior optimizations by the compiler in some cases.

I would add the caveat that putting non 4-byte types in shared memory is a good way to get bank conflicts. This may or may not be a problem, dependent on your application.

And (mulling the question further), it is even safe for two threads to write to adjacent bytes in the same bank? It ought to be, but given how much shared memory likes 4 byte types, I’m suddenly worried.