[cfe-dev] OpenCL vector relational operator support

Alberto Magni alberto.magni86 at gmail.com
Tue Jan 17 02:22:24 PST 2012

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,

More information about the cfe-dev mailing list