Passing a float4 as a pointer

Hi,

I need to pass a float4 pointer (a C++ reference would be better, but I think those are not compliant in OpenCL) to a local OpenCL function called by my kernel. The problem is that the compiler does not allow this (I’m using the NVIDIA OpenCL implementation). My funcion looks like this:


void calculateSomething(float4 xt, float4 yt, float4* zt) {
   zt->x = do something with xt and yt;
   zt->y = do something with xt and yt; 
   zt->z = do something with xt and yt; 
   zt->w = do something with xt and yt; 
}

even if I try this it does not compile:


void calculateSomething(float4 xt, float4 yt, float4* zt) {
   zt->x = 1;
   zt->y = 2; 
   zt->z = 3; 
   zt->w = 4; 
}

I would really appreciate any hint about this problem.

Thanks in advance,

Federico

hey :wink:

c++ like references are unfortunately not part of the c language/spec.
i also ran into this bug (?) and my solution was to just dereference the pointer, so try this:


void calculateSomething(float4 xt, float4 yt, float4* zt) {
   (*zt).x = 1;
   (*zt).y = 2; 
   (*zt).z = 3; 
   (*zt).w = 4; 
}