Vector API Questions

Scott Palmer swpalmer at gmail.com
Sun Sep 5 20:09:07 UTC 2021


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