如何将数组传递给 OpenCL 中的函数?我收到错误“..argument of type "_global float *" is incompatible with type of parameter of type "float *" in line c[n]=FindIndexFromArray(a,3) ;
float FindIndexFromArray(float myArray[], float Key)
{
// simple looping to find the index
for (int i=0;i<sizeof(myArray);i++)
if (myArray[i]==Key)
return i;
}
kernel void ProcessArray(
global read_only float* myArray,
global read_only float* Key,
global write_only float* c )
{
int index = get_global_id(0);
c[index] = FindIndexFromArray(myArray, Key); // How do I pass myArray parameter?
}
我编辑的源代码:
float FindIndexFromArray(__global read_only float* myArray[], __global read_only float* Key)
{
// simple looping to find the index
for (int i=0;i<sizeof(myArray);i++)
if (myArray[i]==Key)
return i;
}
kernel void ProcessArray(
__global read_only float* myArray,
__global read_only float* Key,
__global write_only float* c )
{
int index = get_global_id(0);
c[index] = FindIndexFromArray(myArray, Key); // How do I pass myArray parameter?
}