pow(float4,float)

Hello,

This code will compile fine on some systems but not on others:

float4 a;
// …
float4 b = pow( a, 2.0f );

The documentation says that the arguments have to be the same type, so I assume some systems are capable of implicitly widening the float to a float4?
http://www.khronos.org/registry/cl/sdk/1.0/docs/man/xhtml/pow.html

Other functions have more flexibility in their inputs, e.g.
http://www.khronos.org/registry/cl/sdk/1.0/docs/man/xhtml/clamp.html
So pow does look a bit inconsistent. Should this change?

Thanks,

Tim

Hi Tim,

There is indeed a gap in the current specification regarding implicit conversions from scalar to vector types, which results in undefined compiler behaviour for builtin functions. This has been addressed in OpenCL 2.0.

Best wishes,

James

Ah, it’s good to know that this issue has been fixed in 2.0 - thankyou.

Tim

The work-around is to do this:

float4 b = pow( a, (float4)2.0f );