Hello,
I’m trying to pass a parameter by reference to a function (see below) which will be called from a kernel. However, during compilation I get the following error messages:
OpenCL Build Log: :60: error: expected ‘)’
bool RayBoxIntersection(float4 rS,float4 rV, float4 bmin, float4 bmax, float &tnear , float &tfar , float minT)
^
:60: note: to match this ‘(’
bool RayBoxIntersection(float4 rS,float4 rV, float4 bmin, float4 bmax, float &tnear , float &tfar , float minT)
^
:60: error: parameter name omitted
bool RayBoxIntersection(float4 rS,float4 rV, float4 bmin, float4 bmax, float &tnear , float &tfar , float minT)
^
:85: error: use of undeclared identifier ‘tnear’
tnear = tn;
^
:86: error: use of undeclared identifier ‘tfar’
tfar = tf;
^
:88: error: use of undeclared identifier ‘minT’
return ((tn<tf) & (tf>0.0f) & (tn<minT));
^
OpenCL Device Info
==================
MAX_COMPUTE_UNITS: 24
MAX_CLOCK_FREQUENCY: 1242
GLOBAL_MEM_SIZE: 1980647610
DEVICE_NAME: GeForce GTX 260
DEVICE_VENDOR: NVIDIA Corporation
DEVICE_VERSION: OpenCL 1.0
DRIVER_VERSION: 190.89
==================
Is there anything I’m missing? Why isn’t it working? My fault or compiler bug? I have looked through all available documents, but found nothing which says I can’t do this.
Here’s the code I’m trying to compile:
[codebox]bool RayBoxIntersection(float4 rS,float4 rV, float4 bmin, float4 bmax, float &tnear , float &tfar , float minT)
{
float4 tmint,tmaxt;
tmint.x = (bmin.x - rS.x)/(rV.x);
tmint.y = (bmin.y - rS.y)/(rV.y);
tmint.z = (bmin.z - rS.z)/(rV.z);
tmaxt.x = (bmax.x - rS.x)/(rV.x);
tmaxt.y = (bmax.y - rS.y)/(rV.y);
tmaxt.z = (bmax.z - rS.z)/(rV.z);
float4 tmin,tmax;
tmin.x = fmin(tmint.x, tmaxt.x);
tmin.y = fmin(tmint.y, tmaxt.y);
tmin.z = fmin(tmint.z, tmaxt.z);
tmin.w = 0.0f;
tmax.x = fmax(tmint.x, tmaxt.x);
tmax.y = fmax(tmint.y, tmaxt.y);
tmax.z = fmax(tmint.z, tmaxt.z);
tmax.w =0.0f;
float tn = fmax(tmin.x, fmax(tmin.y, tmin.z));
float tf = fmin(tmax.x, fmin(tmax.y, tmax.z));
tnear = tn;
tfar = tf;
return ((tn<tf) & (tf>0.0f) & (tn<minT));
}
__kernel void TestKernel(__global const float *A)
{
int nIndex = get_global_id(0);
}
[/codebox]
Can you try with pointers instead of references? I’m not to clear on C99 vs C++, but might not include references.
good luck,
Jan
Blubb42
November 11, 2009, 12:11pm
3
Thanks for your reply, it’s working with pointers. Seems like references aren’t supported in C99…
Since I’m here already, another question. What does
mean? It only happpens when I call a certain function, but the function arguments match everywhere.
Here’s the ptx-code: