How do i tell a kernel that a pointer points to device memory? At runtime, i read a pointer in a ker


in a kernel i read a pointer (int*) from memory, like:

int* ptr = str->val_ptr;

The kernel does not know that the pointer points to device memory.
How can i tell that to the kernel?

I pass that pointer within a struct (i have another post regardig this issue, but i think it is not too clearly described).

When compiling i get the message:
Warning: Cannot tell what pointer points to, assuming global memory space

It seems i can’t add the attribute device, neither in the code in the kernel, nor in the definition in the struct.
I allocated the memory that the pointer points to using cudaMalloc(&str->valptr, size)

str is a struct that contains a member:
int* valptr;

I’m not sure, i must be completely missing something, there must be a way to tell what the pointer points to? That must be a standard problem, right?

Thanks for any hints,

but, uh. Global memory is device memory. In your case it is safe to ignore that warning.

We always ignore such warnings - most of the time the compiler’s assumptions work well…

Thanks for your answers.

I also found out later that “global” is on the device.

Coming more from host “C” programming, i try to chase up the warnings and also try to get rid of them so i can see the dangerous output of the compiler.

The code works (at least that part) and the whole issue is not that important any more.

But i’d still be interested in a way to get rid of the warning.

Best regards,