c - OpenCL:从 'int *' 到 '__generic int *__generic *' 的转换

标签 c opencl

我想在两个内核之间的 OpenCL 2.0 中实现一个管道。然而,由于参数转换,内核编译失败:

error: no matching function for call to 'write_pipe'
write_pipe(outputPipe, &value);
^~~~~~~~~~
note: candidate function not viable: no known conversion from 'int *' to '__generic int *__generic *' for 2nd argument
note: candidate function not viable: requires 4 arguments, but 2 were provided

生产者内核非常简单:

__kernel void pipe_kernel(__write_only pipe int *outputPipe) {
  int value = 1;
  write_pipe(outputPipe, &value);
}

write_kernel函数的接口(interface):

int write_pipe (pipe gentype p, const gentype  *ptr)

主机代码中的管道设置为使用整数:

cl_mem pipe = clCreatePipe(context, CL_MEM_READ_WRITE, sizeof(int), elements, NULL, &status);
clSetKernelArg(pipe_kernel, 0, sizeof(cl_mem), &pipe);

管道是否必须考虑通用地址空间?

最佳答案

问题在于您的 pipe 内核参数被声明为指针:

__write_only pipe int *outputPipe

应该是:

__write_only pipe int outputPipe

关于c - OpenCL:从 'int *' 到 '__generic int *__generic *' 的转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33546779/

相关文章:

c++ - 如何创建 NVIDIA OpenCL 项目

opencl - 如何启用 OpenCL 扩展?

c++ - 预处理器tomfoolery(字符串化#include)

c - 使用Visual Studio用Oracle 11g开发C程序,但我不知道如何一起设置所有程序

c - 使用 free() 时内存使用量不会减少

C 中的条件逻辑

opencv - OpenCV:使用OpenCL在GPU中分配内存

将字符串转换为 unsigned long int

c - 使用 memcpy() 将缓冲区的尾部移动到其开头? (重叠)

c++ - OpenCL 找不到 ATI 卡