Hi,
After checking OpenCL 1.1, 1,2 specification (6.1.7 Vector Components)
http://www.khronos.org/registry/cl/specs/opencl-1.1.pdf
http://www.khronos.org/registry/cl/specs/opencl-1.2.pdf
I was unable to find that following vector component addressing construction is legal in OpenCL:
float4 var;
for(uint i=0; i<4; i++)
{
var[i] = 0.0f;
}
I can understand that for Intel creating overloaded operator [] could make some code elegant.
And personally as programmer, I would prefer to have it as well. Nowadays with OpenCL 1.1
sometimes you forced to write something like this:
float foo(float8 v)
{
float[8] v1;
v1[0] = v.s0; v1[1] = v.s1; v1[2] = v.s2; v1[3] = v.s3;
v1[4] = v.s4; v1[5] = v.s5; v1[6] = v.s6; v1[7] = v.s7;
// compute something using loop, just an example
float res;
for (uint i=0, i<8; i++)
{
res += v1[i];
}
return res;
}
But strictly saying, if that is not legal according to OpenCL 1.1 specification
standard, I would vote to remove this operator from Intel OpenCL as well.
The main argument would be that code become not portable to other platforms.
For example try it on NVidia or AMD OpenCL 1.1 and you will get en error like this:
Build Log:
:27:3: error: subscripted value is not an array, pointer, or vector
var[i] = 0.0f;
^ ~
It could be that I've missed some document.
Could you provide reference that such constructions are legal in OpenCL 1.1, 1.2?
Thanks,
-Denis


