OpenCL Language Clarification

Hi,
I’m seeking clarification of section 6.3, clause g of the OpenCL spec 1.1 rev 36
Given the following kernel

__kernel void test()
{
float3 a;
if (a.s0 && a.s1 && a.s2)
{
}
}

should the line
if (a.s0 && a.s1 && a.s2)
compile or not? [due to section 6.3, clause g of the OpenCL spec 1.1 rev 36]

Intel say the above code is not valid. AMD say it is valid. I’m seeking clarification so that I know which bug report to pursue.

Thanks
Steve.

Intel is correct here. Section 6.3, item g states that “The logical operators and (&&), or (||) operate on all scalar and vector built-in types except the built-in scalar and vector float types”.

I would suggest the following change:

if (as_int(a.s0) && as_int(a.s1) && as_int(a.s2))
{

}

I’ve modified it to treat the float components as integers and then you can use the logical operators. This is supported and should work.

Thanks, that was my reading of the spec too.
I actually used

if ((a.s0 != 0) && (a.s1 != 0) && (a.s2 != 0))

I’ll go back to AMD with this clarification.

Thanks

Just a quick update for anyone that reads this going forwards:

I’ve had ongoing discussion with AMD on this issue and they have said

“After further discussing this internally, this will not be fixed. The reason is that OpenCL inherits from C and C defines this interaction very well and it is viewed as a cut&paste typo to include this restriction on the logical operators that wasn’t fixed in time before the OpenCL 1.1 spec was ratified. We view this as a spec error and will see about correcting it in future versions of the spec.”

Let’s hope there are no issues with this and the spec is changed accordingly.

Steve