How much Constant Space is used

I am looking for a way to find out how much constant space my project uses. Is there a simple way to do that, considering that I use several dozen cu files which are compiled into their own objects?

Best regards

It is my understanding so far that each kernel has its own 64kb page of (cached) constants. All constant variables declared in one .cu object reside in a page local to this particular kernel.


Oh really? I didnt know that.


Hmm, definitely not local to each kernel but local to the .cu file in which the constants have been declared.

Or, how about something like this:


cudaDeviceProp device;

cudaGetDeviceProperties(&device, 0);

cout << device.totalConstMem << endl;


Reference: cudaGetDeviceProperties

Edit: This won’t work; function returns the total amount of AVAILABLE constant memory.

This function reports 65536 bytes, no matter from which of the .cu modules I call it. Could be because it reports the total number of bytes available on the device, and not how much of it is actually used ;)

I have several .cu files linked together into one DLL that I think together consume more than 64kb of constant memory.


Oops! Yes, this function returns the constant memory available on the device in bytes.

I am still looking for a solution to this problem. How much constant space is used (in one *cu file).


nvcc reports usage statistics (registers, shared mem, constant mem) if you compile with ‘-Xptxas -v’. To find out that information at runtime, you have to load each module and tell the backend compiler to give back the same strings after it runs

Knowing the name(s) of your constant memory you could call cudaGetSymbolSize