overloading
overloading

Reputation: 1200

Explicit casting in openCL

I have a problem casting a float8 var into a double8 for sincos function in openCL. So I have tried the following:

float8 a,b,c;

a = convert_float8(sin(convert_double8(a))); // worked
a = convert_float8(sincos(convert_double8(b),convert_double8(&c))); // failed

and it would throw an openCL error saying fail to build program. At first I thought sincos doesn't take in double8 type but it also works if I simply pass in a double8 var, however when I tried to cast a float8 into double8, it would just fail like the code above.

float8 a;
double8 b,c;

a = convert_float8(sincos((b),(&c))); //worked

Does anyone know why/how to cast it properly?

Thanks.

Upvotes: 0

Views: 1092

Answers (1)

reima
reima

Reputation: 2126

In your first code example, &c is of type float8*, i.e. it's a memory address pointing to a float8 value. You cannot use convert_double to convert this address to a pointer to double8 (which is what sincos expects as its second argument in this context). I can't think of any sensible way in which this should work.

You have to explicitly create a temporary variable of the correct type:

float8 a,b,c;
double8 c_double;
a = convert_float8(sincos(convert_double8(b), &c_double));
c = convert_float8(c_double);

Upvotes: 1

Related Questions