- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 = 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;
}
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 = 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
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 = 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;
}
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 = 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
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Denis,
Allowing a square bracket notation for indexing vectors means the components accessed are not known during compile time. So, the change is not just syntactic in nature - it would actually be a full-fledged feature.
Doron Singer
Allowing a square bracket notation for indexing vectors means the components accessed are not known during compile time. So, the change is not just syntactic in nature - it would actually be a full-fledged feature.
Doron Singer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Denis,
Allowing a square bracket notation for indexing vectors means the components accessed are not known during compile time. So, the change is not just syntactic in nature - it would actually be a full-fledged feature.
Doron Singer
Allowing a square bracket notation for indexing vectors means the components accessed are not known during compile time. So, the change is not just syntactic in nature - it would actually be a full-fledged feature.
Doron Singer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Denis,
Using operator [] to access a single vector element is not supported according to the OpenCL spec, and it's also inefficient. This usage will be disabled in subsequent versions of the Intel OpenCL SDK.
Thanks
Guy
Using operator [] to access a single vector element is not supported according to the OpenCL spec, and it's also inefficient. This usage will be disabled in subsequent versions of the Intel OpenCL SDK.
Thanks
Guy

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page