我想在两个内核之间的 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/