0
votes

I am defining a structure in C++, built a vector in a loop and created its buffer using clCreateBuffer() function, which is then passed to my CL kernel. My kernel code calls funcA where the buffer is passed as an argument. I am then using the buffer and calling funcB giving array as an argument.

    typedef struct a {
        float array[16];
        unsigned int id;
    } BUFFER_TYPE;

    float RD_INLINE funcB(__global float4* m)
    {
      ..
    }

    bool RD_INLINE funcA(__global BUFFER_TYPE* buffer)
   {
      ..
      float scale = funcB(buffer[0].array);
      ..
   }

I am getting " warning: incompatible pointer types passing 'float __global[16]' to parameter of type '__global float4 *'". How do I resolve this? How can I typecast here?

1
(__global float4*)buffer[0].array should work fine. - Mestkon

1 Answers

1
votes

For float4 the array should be of 4 elements: float array[4]. You could use cl_float4 from CL/cl_platform.h which will define that properly for you. See more about OpenCL vector types here.

If the warning still persists then you will need to define your struct in cl file too using float4 instead of float array[4] or cl_float4.