[cfe-dev] OpenCL vector relational operator support

Benyei, Guy guy.benyei at intel.com
Wed Jan 18 00:18:43 PST 2012

Hi Alberto,
Please note, that according to the OpenCL 1.1 spec section 6.3.i, the (?:) 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.


-----Original Message-----
From: cfe-dev-bounces at cs.uiuc.edu [mailto:cfe-dev-bounces at cs.uiuc.edu] On Behalf Of Alberto Magni
Sent: Tuesday, January 17, 2012 12:22
To: clang-dev Developers
Subject: [cfe-dev] 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,
cfe-dev mailing list
cfe-dev at cs.uiuc.edu
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

More information about the cfe-dev mailing list