Hi,
I try to use the address of a float3 element like this and I got an error, maybe it is not allowed ?
float3* val ...
mymethod(&val->x, &val->y);
where :
void mymethod(float* a, float * b) ...
and I got this message :
error: expression must
have pointer-to-struct-or-union type
hi view01,
use val.x or val.s[0].
You can refer to the openCL Spec for more details.
Thanks
val is a pointer to a float3 !!!
So I have to use val->x, then &(val->x) !!!
the '->' reference is valid for structs and unions. OpenCL implements vector literals that use the '.' reference with xyzw or s0123. Read page 162 of OpenCL 1.1 spec.
In this case, since val is a pointer, it may be required to reference the pointer first:
(*val).x
(*val).x
Yes, I will try this !
But maybe I cannot play like this with float4 !! because I use a 'float*'
mymethod(&(*val).x);
To set the .x of val !!!
Is it really allowed ??
Thanks
hi,
i tried this code it works.
#pragma OPENCL EXTENSION cl_amd_printf:enable float myfunction(float* A) { *(A)=100.125f; *(A+1)=100.125f; *(A+2)=100.125f; *(A+3)=100.125f; return *A; } void __kernel test_kernel(__global float* Input0, __global float* Input1, __global float* Output, int Length ) { int gx = get_global_id(0); float4 a; a.y=myfunction((float*)(&a)); printf("%f %f %f %f\n",a.x,a.y,a.z,a.w); }