How to determine resoure usage of a kernel?

Hi Experts,

       I have developed a kernel. I want to know how much resources ([b]per thread local memory, per thread block shared memory, per thread registers[/b]) will be used by my kernel. Is there any way to figure it out?

Add the following to the compilation line of nvcc:

–ptxas-options=“-mem”

eyal

k.Thanks Mr.eyalhir.

I have added --ptxas-options=“-mem”. But could not figure it out any difference.Please give more details… :unsure:

Sorry, probably needs the -v option :)

/usr/local/cuda/bin/nvcc --ptxas-options="-v "  -arch sm_20  --compiler-options="-fno-strict-aliasing -fPIC" -I ~build/NVIDIA_CUDA_SDK/common/inc/ -I /home/build/build -I /home/build/build -I. -I /usr/local/include -I /usr/include -I /usr/local/cuda/include -O3 -DUNIX -o a.o -c a.cu

And this is what you should see:

ptxas info	: Compiling entry function 'xxxxxxxxx' for 'sm_20'

ptxas info	: Used 30 registers, 3168+0 bytes smem, 136 bytes cmem[0], 27368 bytes cmem[2], 4 bytes cmem[16]

Raj…,

The best way to look @ resources is “CUBIN” file. Compile with “-keep” option - This one retains lot of intermediate files – one such file is a “.cubin” file.

If you compiled x.cu, then you get x.cubin… The CUBIN file tells you the amount of “registers” used per thread, + smem, cmem etc… Check out

Except that in CUDA 3.0 and later, cubins are binary ELF files that don’t contain any of that (or if they do it isn’t human readable). The only way to see it with newer versions of the toolchain is to pass -v flag to ptxas during compilation.

There is an easier way–and it shows you the resources really used for a particular GPU (you have to have the GPU in question). If you use the demonstration license (free) of the Kappa Library, the Quick Start Guides demonstrate loading a CUDA module file (from the ‘.cu’ file–if necessary, Kappa will invoke nvcc to compile to PTX automatically and then JIT compile it in memory). This shows how it was actually compiled for use on the GPU. You can, of course do this with the CUDA driver API, but it is easier using Kappa (and free for just this sort of use).

Hi Guys

Thank you for ur replies… :)
I have tried everything but could not getting any thing.but now i am using cuda 2.3 only. I wll update to cuda3.0 and then comeback to you.

Note : I am using VS2008 to develop cuda.i am changing the command line in the custom build of .cu files.Is it correct? :unsure:

Quick question: I understand that cmem means constant memory, however what is the meaning for cmem[0], cmem[2] and cmem[16] ? Thanks

Hello Mr.Sarnath,

Now I got GT220 graphics card.I have included the option “-keep” in command line of custom build of .cu file. Now i got “.cubin” file in my working directory. But if i use notepad or wordpad to open that file…It comes on unknown format…So, please help me how to see the contents of the file…? :unsure:

Hello Mr.Sarnath,

Now I got GT220 graphics card.I have included the option “-keep” in command line of custom build of .cu file. Now i got “.cubin” file in my working directory. But if i use notepad or wordpad to open that file…It comes on unknown format…So, please help me how to see the contents of the file…? :unsure:

cubin file is a text file. YOu can open with notepad or wordpad or any text editor…

If nothng works, just say “type xxx.cubin” from cmd prompt… Good old dos will print anything and everyting… Pipe it to “more” for controlled output

cubin file is a text file. YOu can open with notepad or wordpad or any text editor…

If nothng works, just say “type xxx.cubin” from cmd prompt… Good old dos will print anything and everyting… Pipe it to “more” for controlled output

For the second time in this thread - no cubin files are not text files in CUDA 3.0 and later. The toolchain switched to using ELF internally, and the cubin files produced by ptxas are not human readable any more.

For the second time in this thread - no cubin files are not text files in CUDA 3.0 and later. The toolchain switched to using ELF internally, and the cubin files produced by ptxas are not human readable any more.

K.Thank You guys… I got