OpenCL vector relational operator support

Hi all,

I have a question about the support for relational operators in OpenCL.
According to the standard (section 6.3.d-e) comparing two vectors results in a
vector of int of the same size of the operands.
Intrinsic functions "all" and "any" (table 6.14) are thought to convert these
output vectors into boolean values.

Now consider this piece of code, taken from the AMD-APP BlackSholes application:

float4 X;
float4 zero;
// ...
result = (X < zero)? (one - y) : y;

In this case the output of the comparison is used directly as a boolean value,
as if applying the "all" function.

Do you think that it is necessary to enrich the semantics of the
ternary operator
or of the if statement to accept vectors of integers as operands?
Or you think that it is better to rely on builtin functions like "all" ?

Thank you,

Hi Alberto,
Please note, that according to the OpenCL 1.1 spec section 6.3.i, the (?:slight_smile: ternary operation is equivalent to calling the select built-in function (but only when the expected return value is a vector). The operator doesn't apply "all" or "any" - this would be illegal, as implicit conversions of vector values are illegal in OpenCL.