struct argument problem in OpenCL

Hi, everyone

I have a question regarding struct argument in OpenCL.
Is it possible to use a struct type as an argument which includes memory object types?
for example, in CUDA code

struct sample {
int n;
float4* memobj1;
float4* memobj2;
};

and memobj1, memobj2 are allocated by cudaMalloc.

global kernfunc(sample s)
{

}

I have found many cases in CUDA, and I need to port this to OpenCL.
It doesn’t seem to be possible in OpenCL, directly using this structure of code.
Should I break down the struct into seperate arguments?
I appreciate all your comments.

I tried this myself a while ago and could not find any way to do it. In the end I removed the memory objects from the struct and sent each memory object separately to the kernel as arguments.

edit:
One way to get structs with pointers in them is to have a filler kernel. Create a memory object that will hold your structures and a kernel that takes the memory objects you want to add to the struct and a pointer to the struct itself as arguments and then copies the pointers into the struct. Then pass the pointer to the struct memory object to the ‘real’ kernels.

If I understand you right, I accidentally made similar question of Khronos forums!

You will need to use clDevicePointer function to get the pointer from a cl_mem. ;)

There appears to be some confusion here. The thread preston mentions can be found here http://www.khronos.org/message_boards/view…f=37&t=2900. The function ‘clDevicePointer’ does not exist and was used only to clarify a use-case where the functionality discussed here would be useful.

You are right! My mistake :">

Or better say, I couldn’t believe that something like this is not implemented in OpenCL