Open GoogleCodeExporter opened 8 years ago
Good catch. Affie, please confirm.
Original comment by dginsb...@upsamplesoftware.com
on 6 Aug 2011 at 9:36
The source of the confusion here stems from some irregularities in the
standard. Later on in the same chapter there's an example for reinerpreting
bits as different types. On page 122 the example states:
// Perform the operation f = f < g ? f : 0 for components of a
// vector
float4 f, g;
int4 is_less = f < g;
// Each component of the is_less vector will be 0 if result of <
// operation is false and will be -1 (i.e., all bits set) if
// the result of < operation is true.
This comment is correct, but the use of the word 'true' might imply that the
conversion was of the extended integer value for the boolean value true. This
is not the case. The < operator for vector types returns an intn type, not a
booln type (well, there's no booln type). I'm guessing C99 compatability for
this operator is the reason that -1 represets the condition to be true.
Maybe in OpenCL 1.2, the extended integer value for true should be -1, and not
1.
Original comment by wel...@gmail.com
on 6 Aug 2011 at 9:59
Reading back my last comment, and the specs for the behavior of the < operator,
I guess that what I call irregularities are actually intentional, since for
scalar types the returned value in case the condition was true is 1, whereas
for vector types it is defined as -1.
Aaftab, can you please explain why these choices were made?
Original comment by wel...@gmail.com
on 6 Aug 2011 at 11:14
Original issue reported on code.google.com by
wel...@gmail.com
on 6 Aug 2011 at 6:53