Vector API Questions
John Rose
john.r.rose at oracle.com
Sun Sep 5 22:27:22 UTC 2021
I think those are hardware specialized shuffles, right? So try a shuffle. We should try to recognize fixed shuffles that can be handled by special instructions. That’s the basic approach. It doesn’t need a new primitive but maybe some convenience functions and better instruction selection.
> On Sep 5, 2021, at 1:09 PM, Scott Palmer <swpalmer at gmail.com> wrote:
>
> Is this list appropriate for questions involving the Vector API? (I scanned the list at https://mail.openjdk.java.net/mailman/listinfo but didn’t see anything)
>
> E.g. questions such as,
>
> Are there plans to support operation XXX?
>
> I’m looking for something like: https://www.felixcloutier.com/x86/punpcklbw:punpcklwd:punpckldq:punpcklqdq
>
> Or performance related queries?
>
> I tried to convert this simple operation to use the Vector API (on 2MB source buffers) and the result iI got was 15x slower than this byte-wise loop:
>
> void widen(ByteBuffer srcBuff , ByteBuffer dstBuff ) {
> while (srcBuff.hasRemaining()) {
> dstBuff.putShort((short) (srcBuff.get() << 8));
> }
> }
>
>
> My attempt using JDK 16 on macOS (Intel) looked like:
>
> final int BYTE_PREFERRED_SPECIES_LENGTH = ByteVector.SPECIES_PREFERRED.length();
> final int loopBound = ByteVector.SPECIES_PREFERRED.loopBound(srcBuff.remaining());
> int si = 0;
> int di = 0;
> for (; si < loopBound; si += BYTE_PREFERRED_SPECIES_LENGTH) {
> ByteVector srcVec = ByteVector.fromByteBuffer(ByteVector.SPECIES_PREFERRED, srcBuff, si, NATIVE_ORDER);
> srcVec.convert(VectorOperators.B2S, 0)
> .lanewise(VectorOperators.LSHL, 8)
> .intoByteBuffer(dstBuff, di, NATIVE_ORDER);
> di += BYTE_PREFERRED_SPECIES_LENGTH;
>
> srcVec.convert(VectorOperators.B2S, 1)
> .lanewise(VectorOperators.LSHL, 8)
> .intoByteBuffer(dstBuff, PD_di, NATIVE_ORDER);
> di += BYTE_PREFERRED_SPECIES_LENGTH;
> }
>
> If this is the wrong place for these kinds of questions, please point me in the right direction.
>
> Thanks,
>
> Scott
More information about the panama-dev
mailing list