cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

screw
Journeyman III

logical operators for build-in vector types

logical operators for build-in vector types should applied componet-wise

Hi,

I would like to to use operator && two int4 and expect a int4 as result. I get an error, please see attached message.

Have you any hints?

 

Thanks

screw

 

/tmp/OCLPevl34.cl(373): error: bad argument type to opencl convert_* function: expected src and dst have the same number of elements float4 f = convert_float4(((int4)1) && ((int4)0)); ^

0 Likes
3 Replies
omkaranathan
Adept I

As per OpenCL specification, 6.3(g),

 

For scalar types, the logical operators shall return 0 if the result of the operation is false and 1 if the result is true. For vector types, the logical operators shall return 0 if the result of the operation is false and –1 (i.e. all bits set) if the result is true.

 

As per Spec 6.2.3, explicit conversions need source  and destination vectors to be matching, which means convert_float4 is expecting a 4 element vector, but is getting a scalar value.

0 Likes

Originally posted by: omkaranathan As per OpenCL specification, 6.3(g),

 

For scalar types, the logical operators shall return 0 if the result of the operation is false and 1 if the result is true. For vector types, the logical operators shall return 0 if the result of the operation is false and –1 (i.e. all bits set) if the result is true.

Yes but:

For built-in vector types, the operators are applied component-wise.

So && between two int4 should return int4.

 

0 Likes

Eduardo,
Thanks for reporting this issue.
0 Likes