[vector] Mask and Shuffle construction

Paul Sandoz paul.sandoz at oracle.com
Fri May 25 21:56:05 UTC 2018


Having tried pushing on this a little bit i think we will likely need load/store intrinsics to access shuffle with int[] and mask with boolean[]. (We could overload support in the existing load/store intrinsics.)

It’s awkward to leverage ByteVector given the lower bound of length is 8, meaning we would need to create a mask to only load the required number of elements, which introduces a circularity for mask allocation (in addition we currently use blend for the masked load implementation).

Paul.

> On May 24, 2018, at 4:46 PM, Paul Sandoz <Paul.Sandoz at oracle.com> wrote:
> 
> It’s awkward because we need an obvious way to construct. One approach is to start from a Vector and test, which for Mask we can do now.
> 
> In fact… for Mask i think there may be a way out, since in HotSpot a boolean[] is internally represented as byte[] so it might be possible to piggy back off that representation.
> 
> For shuffle i am working on a Vector.toShuffle the current implementation is:
> 
> @Override
> @ForceInline
> public Shuffle<Byte, Shapes.S128Bit> toShuffle() {
>    byte[] a = toArray();
>    int[] sa = new int[a.length];
>    for (int i = 0; i < a.length; i++) {
>        sa[i] = (int) a[i] & (a.length - 1);
>    }
>    return SPECIES.shuffleFromValues(sa);
> }
> 
> Not particularly efficient but i wonder if we could also piggy back off byte[] or a ByteVector as the internal representation?
> 
> Note that the fromValues methods are just varargs whose implementations pass the array to the fromArray method, so its really the fromArray methods that would need to be optimized.
> 
> Paul.
> 
> 
>> On May 24, 2018, at 4:18 PM, Viswanathan, Sandhya <sandhya.viswanathan at intel.com> wrote:
>> 
>> Hi Paul,
>> 
>> Efficient optimized implementation for maskFromValues and shuffleFromValue is challenging so we should remove those two methods.
>> 
>> Best Regards,
>> Sandhya
>> 
>> 
>> -----Original Message-----
>> From: panama-dev [mailto:panama-dev-bounces at openjdk.java.net] On Behalf Of Paul Sandoz
>> Sent: Thursday, May 24, 2018 3:45 PM
>> To: panama-dev at openjdk.java.net
>> Subject: [vector] Mask and Shuffle construction
>> 
>> Hi,
>> 
>> What plans do we have to optimize construction of Mask and Shuffle? i cannot recall where we are on this.
>> 
>> As a summary here are the methods on Species:
>> 
>> public abstract Mask<E, S> maskFromValues(boolean... bits);
>> public abstract Mask<E, S> maskFromArray(boolean[] a, int i);
>> public abstract Shuffle<E, S> shuffleFromValues(int... indexes);
>> public abstract Shuffle<E, S> shuffleFromArray(int[] a, int i);
>> 
>> Thanks,
>> Paul.
>> 
>> 
> 



More information about the panama-dev mailing list