cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

registerme
Journeyman III

OpenCL Vector Element Shift

Is there a way to shif the elements in a vector. Say I have int4, want to shift 4 element to the right for one position, with the left most one 0. So if int4={1,2,3,4}, the result is {0,1,2,3}.

The reason I am doing this is, I want to do a vector add (or other operation), but the elements need to be shifted.

0 Likes
1 Solution

Use the shuffle functions that are part of the OpenCL specification.

View solution in original post

0 Likes
4 Replies
mikewolf_gkd
Journeyman III

I guess xx>>1;

0 Likes
nou
Exemplar

vec = (int4)(0, vec.xyz)

0 Likes

The shift will be dynamic, that is, I don't know how far it will be shifted, could be 1, 2, 3 elements away. Using xyzw does not quite help.

0 Likes

Use the shuffle functions that are part of the OpenCL specification.

0 Likes