OpenCLの関数に配列を渡すにはどうすればよいですか?エラー「..タイプ「_globalfloat*」の引数は、行c [n] = FindIndexFromArray(a、3) ;のタイプ「float*」のパラメーターと互換性がありません。
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?
}