Thanks for your post, saves me probably from code being broken at some future revision.
I could give you my code, of course, just out of curiosity. Afa Micah’s response, that was at first a bit baffling to me.
Here’s an excerpt from OpenCL spec 6.1.7:
[i]Elements of vector data types can also be accessed using a numeric index to refer to the
appropriate element in the vector. The numeric indices that can be used are given in the table
below:
Vector Components Numeric indices that can be used
2-component 0, 1
4-component 0, 1, 2, 3
8-component 0, 1, 2, 3, 4, 5, 6, 7
16-component 0, 1, 2, 3, 4, 5, 6, 7,8, 9, a, A, b, B, c, C, d, D, e, E,f, F
The numeric indices must be preceded by the letter s or S.[/i]
Only trouble is that appears to be illegal, heavens knows why. Instead of a[0] a.s0 is to be used.
So it is interesting to see if an int variable can be used as index.
This causes an error, as was to be expected:
:187: error: illegal vector component name 'i'
fl.si = anumber + i;
^~~
So it looks as if a loop cannot be used to sequentially assign components of a vector (without explicitily naming them).
You could still use an ordinary array of ints instead of a vector-type. Perhaps that makes no fundamental difference for your code?
You would declare unsigned int a[4], b[4]; ?
But I agree that it seems a frustrating omission if indexing vectorelements by means of a variable is not implemented. Maybe there is a good reason, but I don’t know it.
Jan