cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

anilsharma92
Journeyman III

How to pass a pointer in a class to a kernel in opencl c++ and get pointer data.

Hi all,

The platform i am using is AMD radeon 200 series (sapphire 250 (GPU- Oland)

I am creating a class on host having a pointer as data member, and same class on kernel side too.

now if in kernel side, pointer is present in the class, build error( -11) arises. if we remove pointer on kernel side, code builds up.

there, the pointer value is copied to a global pointer and  dereference value comes to be zero.

My main objective is to access a pointer in a class on device side.

AMD SDK-3.0

opencl c++ version 1.2

any help would be appreciated.

0 Likes
1 Reply
dipak
Big Boss

Hi Anil,

In OpenCL, you cannot pass a struct that contains regular pointer(s). OpenCL 1.x doesn't support it. With OpenCL 2.x, Shared Virtual Memory (SVM) allows this kind of pointer passing however the pointer must be a SVM pointer.

There  are several ways to pass the data referred by the pointer.  You may create separate memory objects corresponding to the pointers and pass them to kernel as separate arguments. If the pointer refers to a particular element of an array, you can pass the whole array as a single buffer object and store the index of the element in the structure instead of the raw pointer.

Regards,

0 Likes