cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

spectral
Adept II

float3.x address ?

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

0 Likes
6 Replies
himanshu_gautam
Grandmaster

hi view01,

use val.x or val.s[0].

You can refer to the openCL Spec for more details.

Thanks

0 Likes

val is a pointer to a float3 !!!

So I have to use val->x, then &(val->x) !!!

0 Likes

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.

0 Likes

In this case, since val is a pointer, it may be required to reference the pointer first:

(*val).x

 

(*val).x

0 Likes

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

0 Likes

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); }

0 Likes