[vector] Shuffle
Paul Sandoz
paul.sandoz at oracle.com
Thu May 24 01:30:23 UTC 2018
> On May 23, 2018, at 5:52 PM, Paul Sandoz <paul.sandoz at oracle.com> wrote:
>
> Hi,
>
> Vivek’s patch has provoked a possible refinement of Shuffle (which should not block the patch being pushed).
>
> A Shuffle can be created from an array of int values, and the lane elements can be extracted as int values. There are currently no constraints on the range of the int values, only constraints when the values are used such as for swizzle if a value is < 0 or >= to the vector length.
>
> However, int is just a carrier type and the internal representation could be more compact, especially if we remove the constraints and mask with (vector length - 1) on Shuffle construction.
>
> A proposal:
>
> - Shuffle may not be the right name. Other names suggested are Reorder or Permutation.
>
> - update the specification and implementation of Shuffle construction to mask int values, and update swizzle/shuffle methods accordingly.
>
I just realized this will break the shuffle operation which operates on shuffle indexes in the range of [0, 2*vector.length).
One possible adjustment:
public abstract Vector<E, S> shuffle(Vector<E, S> v, Shuffle<E, S> s1, Shuffle<E, S> s2, Mask<E, S> m);
which i think could be implemented as:
this.swizzle(s1).blend(v.swizzle(s2), m);
but the signature seems a little monstrous to me.
Paul.
> - Shuffle is biased towards an IntVector representation with:
> IntVector.IntSpecies<S> intSpecies()
> IntVector<S> toVector();
> These methods will be removed.
> New methods will be added to the bitwise vectors to create a shuffle from a bitwise vector (masking values) e.g.
>
> Shuffle<E, S> toShuffle()
>
> A companion method can be added to go from Shuffle to bitwise Vector:
>
> Vector<E, S> toVector();
>
> and since the values in the shuffle are already masked there is no loss going from int to a smaller element value.
>
> - I am not comfortable with the reshape/resize/rebracket methods (nor for that matter am i comfortable with Mask equivalents).
> Transferring to the vector domain, reshape/resize/rebracket, then transferring back seems reasonable. So i am inclined to remove such methods.
> However, we have found it useful to transform a Mask for the same vector size and element size (i.e. length) and the same might apply to Shuffle.
> Perhaps such a method is called review(Species<F, S> s where s.length == v.length (as Shuffle or Mask values are unchanged).
>
> Thoughts?
>
> Paul.
>
>
>
More information about the panama-dev
mailing list