Frage

I am having trouble in referencing a variable in opencl, because there are no clear examples which indicate if this can be done.

I have a variable, "double foo" and I have a pointer "double* fooptr". I want the pointer to hold foo's address. Is that possible in OpenCL ?

double foo=//some value
double* fooptr;
fooptr=&foo;

Can I do this in OpenCL ?

War es hilfreich?

Lösung

Pointers work in OpenCL but you cannot pass a pointer from the host code to the client code (what runs on the CL device). This makes sense because your GPU obviously cannot reference the memory of the CPU because it has its own dedicated memory - which has a completely different address space.

Where are you trying to perform this? It should work well in your kernel code.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top