[vector] Mask and Shuffle construction

Paul Sandoz paul.sandoz at oracle.com
Thu May 24 23:46:31 UTC 2018


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