简体   繁体   English

OPENCL 警告:不兼容的指针类型将 'float __global[16]' 传递给 '__global float4 * 类型的参数

[英]OPENCL warning: incompatible pointer types passing 'float __global[16]' to parameter of type '__global float4 *

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.我在 C++ 中定义了一个结构,在循环中构建了一个向量并使用 clCreateBuffer() function 创建了它的缓冲区,然后将其传递给我的 CL Z50484C19F1AFDAF3841A0D821ED393D2 My kernel code calls funcA where the buffer is passed as an argument.我的 kernel 代码调用 funcA ,其中缓冲区作为参数传递。 I am then using the buffer and calling funcB giving array as an argument.然后我使用缓冲区并调用 funcB 给数组作为参数。

    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 *'".我收到“警告:不兼容的指针类型将'float __global [16]'传递给'__global float4 *'类型的参数”。 How do I resolve this?我该如何解决这个问题? How can I typecast here?我怎样才能在这里打字?

For float4 the array should be of 4 elements: float array[4] .对于float4数组应该有 4 个元素: float array[4] You could use cl_float4 from CL/cl_platform.h which will define that properly for you.您可以使用CL/cl_platform.h cl_float4的 cl_float4,它将为您正确定义。 See more about OpenCL vector types here . 在此处查看有关 OpenCL 矢量类型的更多信息。

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 .如果警告仍然存在,那么您也需要使用float4而不是float array[4]cl_float4在 cl 文件中定义结构。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM