[vector] Mask and Shuffle construction
Viswanathan, Sandhya
sandhya.viswanathan at intel.com
Fri May 25 00:38:19 UTC 2018
Hi Paul,
Thanks for correcting me on this, we should then keep both FromValues and FromArrays versions for now and hope to get to them for efficient backend implementation.
On your other question, a ByteVector or byte[] as internal representation for Shuffle would work if we implement shuffle() in terms of swizzle() as you proposed earlier. Looks like this will also reduce the intrinsic work upfront and we would just need optimized swizzle implementation which is already in place. The swizzle intrinsics would need to be adjusted slightly which we can do easily I think.
We look forward to the improved/cleaner Shuffle implementation per your new proposal.
Thanks,
Sandhya
-----Original Message-----
From: Paul Sandoz [mailto:paul.sandoz at oracle.com]
Sent: Thursday, May 24, 2018 4:47 PM
To: Viswanathan, Sandhya <sandhya.viswanathan at intel.com>
Cc: panama-dev at openjdk.java.net
Subject: Re: [vector] Mask and Shuffle construction
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