“Finds the size of the object associated with a CUDA symbol.”
“symbol is a variable that resides in global or constant memory space.”
Your dev_states variable doesn’t fit that description. A variable that resides in global space looks like:
__device__ int dev_var;
A variable that resides in constant memory space looks like:
__constant__ int const_var;
(your variable is a host variable, by that I mean it resides on the host/CPU thread stack)
I’m not really sure what you mean by the size of *dev_states. It is a pointer variable and it has a size of 8 (bytes). If you want to know what is the size of the allocation that that pointer variable points to, there isn’t an api that I know of that provides that (do you know of such an API in C or C++?) My suggestion would be to keep track of the size at the point of allocation.
Note that 1024 bytes is not the correct value for the size of the allocation that dev_states points to, nor is it the correct value for the size of dev_states itself. You already know the size of the allocation it points to, it is given by:
dev_states_n * sizeof(curandState_t)
and with a trivial piece of code you can confirm that value is not 1024.
If you want to know what is the size of the allocation that that pointer variable points to, there isn’t an api that I know of that provides that (do you know of such an API in C or C++?) My suggestion would be to keep track of the size at the point of allocation.
That was exactly my point. My intention was to get rid rid of one parameter passing from host to kernel. I was looking for a function which allows me to determine inside the kernel the allocated size of memory allocated by cudaMallocManaged(). So instead of …