Embedding cl_mem in a struct

We are trying to invoke an OpenCL kernel with a decorated pointer: i.e. a pointer with information about the data it references. Our plan was to embed the pointer in a struct:

struct DecoratedPtrHost {

  cl_mem ptr;

  int size;



struct DecoratedPtrDev {

  float *ptr;

  int size;



However, it appears that there is no way to make this structure on the host size. A pointer is normally passed as a cl_mem object, which on the host is a pointer to an anonymous structure (presumably containing information about the buffer). It appears that clSetKernelArg() does some magic to turn this into a pointer for the device.

Am I right to assume that the standard does not provision for passing a structure like this from the host to the kernel?

i even failed to set a float3 vector as kernel argument… or does anyone has a clue how to do this?

afaik there’s no such information in the opencl spec.:
“For all other kernel arguments, the arg_value entry must be a pointer to the actual data to be used as argument value.”
thus cl_mem objects are only allowed as direct arguments.

this would be a feature request to nvidia as a nvidia specific feature.

but according to the spec., my float3 vector has to be handled as a copy operation which does not work so far…

In 6.1.2 of the spec, it says only n=2,4,8,16 are supported for floatn. So maybe that’s the problem?

sorry. i meant float4.

(float3 is not supported in the compiler)

here’s my newest experience:

float4 vectors are working as kernel arguments.

(maybe i’ve tried a float[3] array on the earlier implementation).


Check my post on pointer of pointers here: http://forums.nvidia.com/index.php?showtop…mp;gopid=549084

Even the OpenCL forum says it cant be done…

Its pretty DUMB