3 Replies Latest reply on Nov 23, 2009 3:03 PM by MicahVillmow

    logical operators for build-in vector types

    screw
      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)); ^

        • logical operators for build-in vector types
          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.

           

          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.

            • logical operators for build-in vector types
              eduardoschardong

               

              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.

               

            • logical operators for build-in vector types
              MicahVillmow
              Eduardo,
              Thanks for reporting this issue.