Memory Questions


In which memory lies a kernel parameter, for example an int? Will it be stored to global memory or to the registers?


The kernel argument list is supplied to the running kernel in shared memory.

Thank you!

I have a second question:
ptxas info shows the following line:

Used 9 registers, 28+16 bytes smem, 12 bytes cmem[1]

So, I never used constant memory in my kernel, why do I have 12 bytes cmem[1]? And means the index of cmem? Are there more than 1 constant memory area?

Thanks in advance!

The compiler spills numerical constants to constant memory, which is cached and has a broadcast mechanism. There is only one constant memory area.

Ok! Thanks again!

And if I have declared a variable (not an array and used in each thread of a block) without the type qualifers shared or constant in a kernel it’s always stored in global memory? Than, it always must be the best to declare those as shared, isn’ t it? But than there are bank conflicts. Is there a trick to avoid them?

If I read a value which is stored in global memory two times in one kernel. Would it lie in a register after the first read, so that the second read access a register and not to global memory?


if you declared a variable inside kernel without the shared or const qualifiers, it is always stored in register (or sometime stored in local memory depend on size of your variable, the compiler will choice which memory will be used to store your variable. see cuda programming guide for more detail).

I don’t think so, but you can evaluated your program by using cuda visual profiler.

Thanks a lot! I will try it!