public class Simd
- Object
- Simd
Constructors
public Simd() |
Methods
Inherited methods
Constructor details
Simd
public Simd()Method details
get
public static Simd get()CN.getSimd();isSupported
public boolean isSupported()isByteShuffleAccelerated
public boolean isByteShuffleAccelerated()/O2 autovectorizer already matches the scalar path and
SSE2 has no 3-way interleave, so the codec should stay scalar there. This is
distinct from isSupported() – the fused whole-array image ops
(alpha/mask blends) win on every platform and are gated on isSupported(),
not on this flag. Defaults to false (the generic scalar Simd).allocByte
public byte[] allocByte(int size)new. Operations
on unaligned arrays might produce undefined results.allocInt
public int[] allocInt(int size)new. Operations
on unaligned arrays might produce undefined results.allocFloat
public float[] allocFloat(int size)new. Operations
on unaligned arrays might produce undefined results.allocaByte
public byte[] allocaByte(int size)allocByte(int)
for heap-backed arrays. The ParparVM lowering automatically falls back to a heap allocation
when the requested size would not fit safely on the per-thread stack, so this API is safe
to call with image-scale sizes - but using allocByte(int) directly is preferred when the
size is known to be large.allocaInt
public int[] allocaInt(int size)allocInt(int)
for heap-backed arrays. The ParparVM lowering automatically falls back to a heap allocation
when the requested size would not fit safely on the per-thread stack, so this API is safe
to call with image-scale sizes - but using allocInt(int) directly is preferred when the
size is known to be large.allocaFloat
public float[] allocaFloat(int size)allocFloat(int)
for heap-backed arrays. The ParparVM lowering automatically falls back to a heap allocation
when the requested size would not fit safely on the per-thread stack, so this API is safe
to call with image-scale sizes - but using allocFloat(int) directly is preferred when the
size is known to be large.allocaByteZeroed
public byte[] allocaByteZeroed(int size)allocaByte(int).allocaIntZeroed
public int[] allocaIntZeroed(int size)allocaInt(int).allocaFloatZeroed
public float[] allocaFloatZeroed(int size)allocaFloat(int).allocaByteFilled
public byte[] allocaByteFilled(int size, byte value)allocaByte(int).allocaIntFilled
public int[] allocaIntFilled(int size, int value)allocaInt(int).allocaFloatFilled
public float[] allocaFloatFilled(int size, float value)allocaFloat(int).lookupBytes
public void lookupBytes(byte[] table, byte[] indices, byte[] dst, int offset, int length)lookupBytes
public void lookupBytes(byte[] table, byte[] indices, int indicesOffset, byte[] dst, int dstOffset, int length)and
public void and(byte[] srcA, int srcAOffset, byte[] srcB, int srcBOffset, byte[] dst, int dstOffset, int length)or
public void or(byte[] srcA, int srcAOffset, byte[] srcB, int srcBOffset, byte[] dst, int dstOffset, int length)shl
public void shl(byte[] src, int srcOffset, int bits, byte[] dst, int dstOffset, int length)shrLogical
public void shrLogical(byte[] src, int srcOffset, int bits, byte[] dst, int dstOffset, int length)unpackBytesInterleaved3
public void unpackBytesInterleaved3(byte[] src, int srcOffset, byte[] dst, int dst0Offset, int dst1Offset, int dst2Offset, int length)add
public void add(byte[] srcA, byte[] srcB, byte[] dst, int offset, int length)sub
public void sub(byte[] srcA, byte[] srcB, byte[] dst, int offset, int length)mul
public void mul(byte[] srcA, byte[] srcB, byte[] dst, int offset, int length)min
public void min(byte[] srcA, byte[] srcB, byte[] dst, int offset, int length)max
public void max(byte[] srcA, byte[] srcB, byte[] dst, int offset, int length)abs
public void abs(byte[] src, byte[] dst, int offset, int length)clamp
public void clamp(byte[] src, byte[] dst, byte minValue, byte maxValue, int offset, int length)and
public void and(byte[] srcA, byte[] srcB, byte[] dst, int offset, int length)or
public void or(byte[] srcA, byte[] srcB, byte[] dst, int offset, int length)xor
public void xor(byte[] srcA, byte[] srcB, byte[] dst, int offset, int length)not
public void not(byte[] src, byte[] dst, int offset, int length)cmpEq
public void cmpEq(byte[] srcA, byte[] srcB, byte[] dstMask, int offset, int length)cmpEq
public void cmpEq(byte[] src, byte value, byte[] dstMask, int offset, int length)cmpLt
public void cmpLt(byte[] srcA, byte[] srcB, byte[] dstMask, int offset, int length)cmpLt
public void cmpLt(byte[] src, byte value, byte[] dstMask, int offset, int length)cmpGt
public void cmpGt(byte[] srcA, byte[] srcB, byte[] dstMask, int offset, int length)cmpRange
public void cmpRange(byte[] src, byte minValue, byte maxValue, byte[] dstMask, int offset, int length)select
public void select(byte[] mask, byte[] trueValues, byte[] falseValues, byte[] dst, int offset, int length)shl
public void shl(byte[] src, int bits, byte[] dst, int offset, int length)shrLogical
public void shrLogical(byte[] src, int bits, byte[] dst, int offset, int length)addWrapping
public void addWrapping(byte[] srcA, byte[] srcB, byte[] dst, int offset, int length)addWrapping
public void addWrapping(byte[] src, byte value, byte[] dst, int offset, int length)subWrapping
public void subWrapping(byte[] srcA, byte[] srcB, byte[] dst, int offset, int length)subWrapping
public void subWrapping(byte[] src, byte value, byte[] dst, int offset, int length)unpackUnsignedByteToInt
public void unpackUnsignedByteToInt(byte[] src, int[] dst, int offset, int length)unpackUnsignedByteToInt
public void unpackUnsignedByteToInt(byte[] src, int srcOffset, int[] dst, int dstOffset, int length)unpackUnsignedByteToIntInterleaved3
public void unpackUnsignedByteToIntInterleaved3(byte[] src, int srcOffset, int[] dst, int dst0Offset, int dst1Offset, int dst2Offset, int length)unpackBytesInterleaved3
public void unpackBytesInterleaved3(byte[] src, int srcOffset, byte[] dst0, byte[] dst1, byte[] dst2, int length)unpackBytesInterleaved4
public void unpackBytesInterleaved4(byte[] src, int srcOffset, byte[] dst0, byte[] dst1, byte[] dst2, byte[] dst3, int length)unpackBytesInterleaved4
public void unpackBytesInterleaved4(byte[] src, int srcOffset, byte[] dst, int dst0Offset, int dst1Offset, int dst2Offset, int dst3Offset, int length)unpackLookupBytesInterleaved4
public int unpackLookupBytesInterleaved4(byte[] table, byte[] src, int srcOffset, byte[] dst0, byte[] dst1, byte[] dst2, byte[] dst3, int length)unpackLookupBytesInterleaved4
public int unpackLookupBytesInterleaved4(byte[] table, byte[] src, int srcOffset, byte[] dst, int dst0Offset, int dst1Offset, int dst2Offset, int dst3Offset, int length)packIntToByteSaturating
public void packIntToByteSaturating(int[] src, byte[] dst, int offset, int length)packIntToByteTruncate
public void packIntToByteTruncate(int[] src, byte[] dst, int offset, int length)packIntToByteTruncate
public void packIntToByteTruncate(int[] src, int srcOffset, byte[] dst, int dstOffset, int length)packIntToByteTruncateInterleaved4
public void packIntToByteTruncateInterleaved4(int[] src, int src0Offset, int src1Offset, int src2Offset, int src3Offset, byte[] dst, int dstOffset, int length)packBytesInterleaved3
public void packBytesInterleaved3(byte[] src0, byte[] src1, byte[] src2, byte[] dst, int dstOffset, int length)packBytesInterleaved3
public void packBytesInterleaved3(byte[] src, int src0Offset, int src1Offset, int src2Offset, byte[] dst, int dstOffset, int length)packBytesInterleaved4
public void packBytesInterleaved4(byte[] src0, byte[] src1, byte[] src2, byte[] src3, byte[] dst, int dstOffset, int length)packBytesInterleaved4
public void packBytesInterleaved4(byte[] src, int src0Offset, int src1Offset, int src2Offset, int src3Offset, byte[] dst, int dstOffset, int length)permuteBytes
public void permuteBytes(byte[] src, byte[] indices, byte[] dst, int offset, int length)add
public void add(int[] srcA, int[] srcB, int[] dst, int offset, int length)add
public void add(int[] srcA, int srcAOffset, int[] srcB, int srcBOffset, int[] dst, int dstOffset, int length)sub
public void sub(int[] srcA, int[] srcB, int[] dst, int offset, int length)mul
public void mul(int[] srcA, int[] srcB, int[] dst, int offset, int length)min
public void min(int[] srcA, int[] srcB, int[] dst, int offset, int length)max
public void max(int[] srcA, int[] srcB, int[] dst, int offset, int length)abs
public void abs(int[] src, int[] dst, int offset, int length)clamp
public void clamp(int[] src, int[] dst, int minValue, int maxValue, int offset, int length)and
public void and(int[] srcA, int[] srcB, int[] dst, int offset, int length)and
public void and(int[] srcA, int srcAOffset, int[] srcB, int srcBOffset, int[] dst, int dstOffset, int length)or
public void or(int[] srcA, int[] srcB, int[] dst, int offset, int length)or
public void or(int[] srcA, int srcAOffset, int[] srcB, int srcBOffset, int[] dst, int dstOffset, int length)xor
public void xor(int[] srcA, int[] srcB, int[] dst, int offset, int length)not
public void not(int[] src, int[] dst, int offset, int length)shl
public void shl(int[] src, int bits, int[] dst, int offset, int length)shl
public void shl(int[] src, int srcOffset, int bits, int[] dst, int dstOffset, int length)shrLogical
public void shrLogical(int[] src, int bits, int[] dst, int offset, int length)shrLogical
public void shrLogical(int[] src, int srcOffset, int bits, int[] dst, int dstOffset, int length)shrArithmetic
public void shrArithmetic(int[] src, int bits, int[] dst, int offset, int length)cmpEq
public void cmpEq(int[] srcA, int[] srcB, byte[] dstMask, int offset, int length)cmpEq
public void cmpEq(int[] srcA, int srcAOffset, int[] srcB, int srcBOffset, byte[] dstMask, int dstOffset, int length)cmpLt
public void cmpLt(int[] srcA, int[] srcB, byte[] dstMask, int offset, int length)cmpLt
public void cmpLt(int[] srcA, int srcAOffset, int[] srcB, int srcBOffset, byte[] dstMask, int dstOffset, int length)cmpGt
public void cmpGt(int[] srcA, int[] srcB, byte[] dstMask, int offset, int length)select
public void select(byte[] mask, int[] trueValues, int[] falseValues, int[] dst, int offset, int length)select
public void select(byte[] mask, int maskOffset, int[] trueValues, int trueOffset, int[] falseValues, int falseOffset, int[] dst, int dstOffset, int length)sum
public int sum(int[] src, int offset, int length)dot
public int dot(int[] srcA, int[] srcB, int offset, int length)add
public void add(float[] srcA, float[] srcB, float[] dst, int offset, int length)sub
public void sub(float[] srcA, float[] srcB, float[] dst, int offset, int length)mul
public void mul(float[] srcA, float[] srcB, float[] dst, int offset, int length)min
public void min(float[] srcA, float[] srcB, float[] dst, int offset, int length)max
public void max(float[] srcA, float[] srcB, float[] dst, int offset, int length)abs
public void abs(float[] src, float[] dst, int offset, int length)clamp
public void clamp(float[] src, float[] dst, float minValue, float maxValue, int offset, int length)sum
public float sum(float[] src, int offset, int length)dot
public float dot(float[] srcA, float[] srcB, int offset, int length)and
public void and(int[] src, int srcOffset, int constant, int[] dst, int dstOffset, int length)or
public void or(int[] src, int srcOffset, int constant, int[] dst, int dstOffset, int length)xor
public void xor(int[] src, int srcOffset, int constant, int[] dst, int dstOffset, int length)cmpEq
public void cmpEq(int[] src, int srcOffset, int constant, byte[] dstMask, int dstOffset, int length)cmpLt
public void cmpLt(int[] src, int srcOffset, int constant, byte[] dstMask, int dstOffset, int length)cmpGt
public void cmpGt(int[] src, int srcOffset, int constant, byte[] dstMask, int dstOffset, int length)not
public void not(byte[] src, int srcOffset, byte[] dst, int dstOffset, int length)select
public void select(byte[] mask, int maskOffset, int trueConstant, int falseConstant, int[] dst, int dstOffset, int length)select
public void select(byte[] mask, int maskOffset, int[] trueValues, int trueOffset, int falseConstant, int[] dst, int dstOffset, int length)select
public void select(byte[] mask, int maskOffset, int trueConstant, int[] falseValues, int falseOffset, int[] dst, int dstOffset, int length)blendByMaskTestNonzero
public void blendByMaskTestNonzero(int[] src, int srcOffset, int testMask, int trueKeepMask, int trueOrValue, int[] dst, int dstOffset, int length)Fused single-pass conditional bit-blend driven by a masked-non-zero test of src against
testMask. For every element:
dst[i] = (src[i] & testMask) != 0 ? (src[i] & trueKeepMask) | trueOrValue : src[i]
This collapses a “test-then-modify-or-keep-source” pattern that would otherwise require
three or more separate primitive calls (and three or more passes over src) into a single
pass. It maps directly to one NEON / SSE vector loop on platforms that ship a vectorized
implementation. All arrays MUST be aligned/registered arrays.
blendByMaskTestNonzeroSubstituteOnKeepEq
public void blendByMaskTestNonzeroSubstituteOnKeepEq(int[] src, int srcOffset, int testMask, int trueKeepMask, int trueOrValue, int removeMatch, int removeValue, int[] dst, int dstOffset, int length)Fused single-pass extension of blendByMaskTestNonzero that additionally substitutes
removeValue whenever the post-mask result would equal removeMatch. For every element:
v = src[i]
if ((v & testMask) == 0) dst[i] = v
else if ((v & trueKeepMask) == removeMatch) dst[i] = removeValue
else dst[i] = (v & trueKeepMask) | trueOrValue
This collapses a blendByMaskTestNonzero + cmpEq + select chain (three passes over the
buffer plus two scratch allocations) into a single vector pass. It maps to one NEON / SSE
loop on platforms that ship a vectorized implementation. All arrays MUST be aligned /
registered arrays.
replaceTopByteFromUnsignedBytes
public void replaceTopByteFromUnsignedBytes(int[] rgbSrc, int rgbSrcOffset, byte[] alphaSrc, int alphaSrcOffset, int[] dst, int dstOffset, int length)Fused single-pass replacement of the top byte of every int in rgbSrc with the
corresponding unsigned byte from alphaSrc. For every element:
dst[i] = (rgbSrc[i] & 0x00ffffff) | ((alphaSrc[i] & 0xff) << 24)
Designed for the Image.applyMask hot path, which previously required four separate
primitive calls (unpackUnsignedByteToInt, shl, and, or) and two scratch
allocations. Maps to a single NEON / SSE vector loop (vmovl_u8 => vshlq_n_u32(24)
=> vorrq(vandq, ...)) on platforms that ship a vectorized implementation.
All arrays MUST be aligned / registered arrays.
validateBinaryByte
protected final void validateBinaryByte(byte[] srcA, byte[] srcB, byte[] dst, int offset, int length)validateMaskBinaryByte
protected final void validateMaskBinaryByte(byte[] srcA, byte[] srcB, byte[] dstMask, int offset, int length)validateRangeMaskByte
protected final void validateRangeMaskByte(byte[] src, byte[] dstMask, int offset, int length)validateSelectByte
protected final void validateSelectByte(byte[] mask, byte[] trueValues, byte[] falseValues, byte[] dst, int offset, int length)validateByteToInt
protected final void validateByteToInt(byte[] src, int[] dst, int offset, int length)validateIntToByte
protected final void validateIntToByte(int[] src, byte[] dst, int offset, int length)validatePermuteByte
protected final void validatePermuteByte(byte[] src, byte[] indices, byte[] dst, int offset, int length)validateUnaryByte
protected final void validateUnaryByte(byte[] src, byte[] dst, int offset, int length)validateBinaryInt
protected final void validateBinaryInt(int[] srcA, int[] srcB, int[] dst, int offset, int length)validateUnaryInt
protected final void validateUnaryInt(int[] src, int[] dst, int offset, int length)validateMaskBinaryInt
protected final void validateMaskBinaryInt(int[] srcA, int[] srcB, byte[] dstMask, int offset, int length)validateSelectInt
protected final void validateSelectInt(byte[] mask, int[] trueValues, int[] falseValues, int[] dst, int offset, int length)validateReductionInt
protected final void validateReductionInt(int[] src, int offset, int length)validateDotInt
protected final void validateDotInt(int[] srcA, int[] srcB, int offset, int length)validateBinaryFloat
protected final void validateBinaryFloat(float[] srcA, float[] srcB, float[] dst, int offset, int length)validateUnaryFloat
protected final void validateUnaryFloat(float[] src, float[] dst, int offset, int length)validateReductionFloat
protected final void validateReductionFloat(float[] src, int offset, int length)validateDotFloat
protected final void validateDotFloat(float[] srcA, float[] srcB, int offset, int length)validateNotNull
protected final void validateNotNull(Object o, String name)validateRange
protected final void validateRange(int arrayLength, int offset, int length, String name)