This code will compile fine on some systems but not on others:
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?
Other functions have more flexibility in their inputs, e.g.
So pow does look a bit inconsistent. Should this change?
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.
Ah, it's good to know that this issue has been fixed in 2.0 - thankyou.
The work-around is to do this:
float4 b = pow( a, (float4)2.0f );
Tags for this Thread