< prev index next > test/jdk/jdk/incubator/vector/Short128VectorTests.java
Print this page
int idx = i + j;
Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]);
}
}
+ static void assertcompressArraysEquals(short[] r, short[] a, boolean[] m, int vector_len) {
+ int i = 0, j = 0, k = 0;
+ try {
+ for (; i < a.length; i += vector_len) {
+ k = 0;
+ for (j = 0; j < vector_len; j++) {
+ if (m[(i + j) % SPECIES.length()]) {
+ Assert.assertEquals(r[i + k], a[i + j]);
+ k++;
+ }
+ }
+ for (; k < vector_len; k++) {
+ Assert.assertEquals(r[i + k], (short)0);
+ }
+ }
+ } catch (AssertionError e) {
+ int idx = i + k;
+ if (m[(i + j) % SPECIES.length()]) {
+ Assert.assertEquals(r[idx], a[i + j], "at index #" + idx);
+ } else {
+ Assert.assertEquals(r[idx], (short)0, "at index #" + idx);
+ }
+ }
+ }
+
+ static void assertexpandArraysEquals(short[] r, short[] a, boolean[] m, int vector_len) {
+ int i = 0, j = 0, k = 0;
+ try {
+ for (; i < a.length; i += vector_len) {
+ k = 0;
+ for (j = 0; j < vector_len; j++) {
+ if (m[(i + j) % SPECIES.length()]) {
+ Assert.assertEquals(r[i + j], a[i + k]);
+ k++;
+ } else {
+ Assert.assertEquals(r[i + j], (short)0);
+ }
+ }
+ }
+ } catch (AssertionError e) {
+ int idx = i + j;
+ if (m[idx % SPECIES.length()]) {
+ Assert.assertEquals(r[idx], a[i + k], "at index #" + idx);
+ } else {
+ Assert.assertEquals(r[idx], (short)0, "at index #" + idx);
+ }
+ }
+ }
+
static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, int vector_len) {
int i = 0, j = 0;
try {
for (; i < a.length; i += vector_len) {
for (j = 0; j < vector_len; j++) {
} catch (AssertionError e) {
Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
}
}
-
static short bits(short e) {
return e;
}
static final List<IntFunction<short[]>> SHORT_GENERATORS = List.of(
return new Object[] {fa, fm};
})).
toArray(Object[][]::new);
}
-
-
@DataProvider
public Object[][] maskProvider() {
return BOOLEAN_MASK_GENERATORS.stream().
map(f -> new Object[]{f}).
toArray(Object[][]::new);
return new Object[] {fa, fs, fm};
}))).
toArray(Object[][]::new);
}
-
static final List<IntFunction<short[]>> SHORT_COMPARE_GENERATORS = List.of(
withToString("short[i]", (int s) -> {
return fill(s * BUFFER_REPS,
i -> (short)i);
}),
static short ROR_scalar(short a, short b) {
return (short)(((((short)a) & 0xFFFF) >>> (b & 15)) | ((((short)a) & 0xFFFF) << (16 - (b & 15))));
}
+ static short TRAILING_ZEROS_COUNT_scalar(short a) {
+ return (short) (a != 0 ? Integer.numberOfTrailingZeros(a) : 16);
+ }
+
+ static short LEADING_ZEROS_COUNT_scalar(short a) {
+ return (short) (a >= 0 ? Integer.numberOfLeadingZeros(a) - 16 : 0);
+ }
+
+ static short REVERSE_scalar(short a) {
+ short b = ROL_scalar(a, (short) 8);
+ b = (short) (((b & 0x5555) << 1) | ((b & 0xAAAA) >>> 1));
+ b = (short) (((b & 0x3333) << 2) | ((b & 0xCCCC) >>> 2));
+ b = (short) (((b & 0x0F0F) << 4) | ((b & 0xF0F0) >>> 4));
+ return b;
+ }
+
static boolean eq(short a, short b) {
return a == b;
}
static boolean neq(short a, short b) {
a.div(b, m);
Assert.fail();
} catch (ArithmeticException e) {
}
}
+
static short ADD(short a, short b) {
return (short)(a + b);
}
@Test(dataProvider = "shortBinaryOpProvider")
}
}
assertArraysEquals(r, a, b, Short128VectorTests::ADD);
}
+
static short add(short a, short b) {
return (short)(a + b);
}
@Test(dataProvider = "shortBinaryOpProvider")
av.add(bv, vmask).intoArray(r, i);
}
assertArraysEquals(r, a, b, mask, Short128VectorTests::add);
}
+
static short SUB(short a, short b) {
return (short)(a - b);
}
@Test(dataProvider = "shortBinaryOpProvider")
}
}
assertArraysEquals(r, a, b, Short128VectorTests::SUB);
}
+
static short sub(short a, short b) {
return (short)(a - b);
}
@Test(dataProvider = "shortBinaryOpProvider")
av.sub(bv, vmask).intoArray(r, i);
}
assertArraysEquals(r, a, b, mask, Short128VectorTests::sub);
}
+
static short MUL(short a, short b) {
return (short)(a * b);
}
@Test(dataProvider = "shortBinaryOpProvider")
}
}
assertArraysEquals(r, a, b, Short128VectorTests::MUL);
}
+
static short mul(short a, short b) {
return (short)(a * b);
}
@Test(dataProvider = "shortBinaryOpProvider")
}
assertArraysEquals(r, a, b, mask, Short128VectorTests::mul);
}
-
-
static short DIV(short a, short b) {
return (short)(a / b);
}
@Test(dataProvider = "shortBinaryOpProvider")
}
}
assertArraysEquals(r, a, b, Short128VectorTests::DIV);
}
+
static short div(short a, short b) {
return (short)(a / b);
}
@Test(dataProvider = "shortBinaryOpProvider")
}
assertArraysEquals(r, a, b, Short128VectorTests::div);
}
-
-
@Test(dataProvider = "shortBinaryOpMaskProvider")
static void DIVShort128VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
}
assertArraysEquals(r, a, b, Short128VectorTests::AND);
}
+
static short and(short a, short b) {
return (short)(a & b);
}
@Test(dataProvider = "shortBinaryOpProvider")
}
assertArraysEquals(r, a, b, Short128VectorTests::and);
}
-
-
@Test(dataProvider = "shortBinaryOpMaskProvider")
static void ANDShort128VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
assertArraysEquals(r, a, b, mask, Short128VectorTests::AND);
}
-
static short AND_NOT(short a, short b) {
return (short)(a & ~b);
}
@Test(dataProvider = "shortBinaryOpProvider")
}
assertArraysEquals(r, a, b, Short128VectorTests::AND_NOT);
}
-
-
@Test(dataProvider = "shortBinaryOpMaskProvider")
static void AND_NOTShort128VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
assertArraysEquals(r, a, b, mask, Short128VectorTests::AND_NOT);
}
-
static short OR(short a, short b) {
return (short)(a | b);
}
@Test(dataProvider = "shortBinaryOpProvider")
}
}
assertArraysEquals(r, a, b, Short128VectorTests::OR);
}
+
static short or(short a, short b) {
return (short)(a | b);
}
@Test(dataProvider = "shortBinaryOpProvider")
}
assertArraysEquals(r, a, b, Short128VectorTests::or);
}
-
-
@Test(dataProvider = "shortBinaryOpMaskProvider")
static void ORShort128VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
assertArraysEquals(r, a, b, mask, Short128VectorTests::OR);
}
-
static short XOR(short a, short b) {
return (short)(a ^ b);
}
@Test(dataProvider = "shortBinaryOpProvider")
}
assertArraysEquals(r, a, b, Short128VectorTests::XOR);
}
-
-
@Test(dataProvider = "shortBinaryOpMaskProvider")
static void XORShort128VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
assertArraysEquals(r, a, b, mask, Short128VectorTests::XOR);
}
-
@Test(dataProvider = "shortBinaryOpProvider")
static void addShort128VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
}
assertBroadcastArraysEquals(r, a, b, mask, Short128VectorTests::mul);
}
-
-
-
@Test(dataProvider = "shortBinaryOpProvider")
static void divShort128VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
}
assertBroadcastArraysEquals(r, a, b, Short128VectorTests::div);
}
-
-
@Test(dataProvider = "shortBinaryOpMaskProvider")
static void divShort128VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
assertBroadcastArraysEquals(r, a, b, mask, Short128VectorTests::div);
}
-
-
@Test(dataProvider = "shortBinaryOpProvider")
static void ORShort128VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
}
assertBroadcastArraysEquals(r, a, b, Short128VectorTests::or);
}
-
-
@Test(dataProvider = "shortBinaryOpMaskProvider")
static void ORShort128VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
assertBroadcastArraysEquals(r, a, b, mask, Short128VectorTests::OR);
}
-
-
@Test(dataProvider = "shortBinaryOpProvider")
static void ANDShort128VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
}
assertBroadcastArraysEquals(r, a, b, Short128VectorTests::and);
}
-
-
@Test(dataProvider = "shortBinaryOpMaskProvider")
static void ANDShort128VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
assertBroadcastArraysEquals(r, a, b, mask, Short128VectorTests::AND);
}
-
-
@Test(dataProvider = "shortBinaryOpProvider")
static void ORShort128VectorTestsBroadcastLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
}
assertBroadcastLongArraysEquals(r, a, b, Short128VectorTests::OR);
}
-
-
@Test(dataProvider = "shortBinaryOpMaskProvider")
static void ORShort128VectorTestsBroadcastMaskedLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
assertBroadcastLongArraysEquals(r, a, b, mask, Short128VectorTests::OR);
}
-
@Test(dataProvider = "shortBinaryOpProvider")
static void ADDShort128VectorTestsBroadcastLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
}
assertBroadcastLongArraysEquals(r, a, b, mask, Short128VectorTests::ADD);
}
-
-
-
-
static short LSHL(short a, short b) {
return (short)((a << (b & 0xF)));
}
@Test(dataProvider = "shortBinaryOpProvider")
}
assertArraysEquals(r, a, b, Short128VectorTests::LSHL);
}
-
-
@Test(dataProvider = "shortBinaryOpMaskProvider")
static void LSHLShort128VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
assertArraysEquals(r, a, b, mask, Short128VectorTests::LSHL);
}
-
-
-
-
-
static short ASHR(short a, short b) {
return (short)((a >> (b & 0xF)));
}
@Test(dataProvider = "shortBinaryOpProvider")
}
assertArraysEquals(r, a, b, Short128VectorTests::ASHR);
}
-
-
@Test(dataProvider = "shortBinaryOpMaskProvider")
static void ASHRShort128VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
assertArraysEquals(r, a, b, mask, Short128VectorTests::ASHR);
}
-
-
-
-
-
static short LSHR(short a, short b) {
return (short)(((a & 0xFFFF) >>> (b & 0xF)));
}
@Test(dataProvider = "shortBinaryOpProvider")
}
assertArraysEquals(r, a, b, Short128VectorTests::LSHR);
}
-
-
@Test(dataProvider = "shortBinaryOpMaskProvider")
static void LSHRShort128VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
assertArraysEquals(r, a, b, mask, Short128VectorTests::LSHR);
}
-
-
-
-
-
static short LSHL_unary(short a, short b) {
return (short)((a << (b & 15)));
}
@Test(dataProvider = "shortBinaryOpProvider")
}
assertShiftArraysEquals(r, a, b, Short128VectorTests::LSHL_unary);
}
-
-
@Test(dataProvider = "shortBinaryOpMaskProvider")
static void LSHLShort128VectorTestsScalarShiftMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
assertShiftArraysEquals(r, a, b, mask, Short128VectorTests::LSHL_unary);
}
-
-
-
-
-
static short LSHR_unary(short a, short b) {
return (short)(((a & 0xFFFF) >>> (b & 15)));
}
@Test(dataProvider = "shortBinaryOpProvider")
}
assertShiftArraysEquals(r, a, b, Short128VectorTests::LSHR_unary);
}
-
-
@Test(dataProvider = "shortBinaryOpMaskProvider")
static void LSHRShort128VectorTestsScalarShiftMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
assertShiftArraysEquals(r, a, b, mask, Short128VectorTests::LSHR_unary);
}
-
-
-
-
-
static short ASHR_unary(short a, short b) {
return (short)((a >> (b & 15)));
}
@Test(dataProvider = "shortBinaryOpProvider")
}
assertShiftArraysEquals(r, a, b, Short128VectorTests::ASHR_unary);
}
-
-
@Test(dataProvider = "shortBinaryOpMaskProvider")
static void ASHRShort128VectorTestsScalarShiftMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
assertShiftArraysEquals(r, a, b, mask, Short128VectorTests::ASHR_unary);
}
-
static short ROR(short a, short b) {
return (short)(ROR_scalar(a,b));
}
@Test(dataProvider = "shortBinaryOpProvider")
}
assertArraysEquals(r, a, b, Short128VectorTests::ROR);
}
-
-
@Test(dataProvider = "shortBinaryOpMaskProvider")
static void RORShort128VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
assertArraysEquals(r, a, b, mask, Short128VectorTests::ROR);
}
-
static short ROL(short a, short b) {
return (short)(ROL_scalar(a,b));
}
@Test(dataProvider = "shortBinaryOpProvider")
}
assertArraysEquals(r, a, b, Short128VectorTests::ROL);
}
-
-
@Test(dataProvider = "shortBinaryOpMaskProvider")
static void ROLShort128VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
assertArraysEquals(r, a, b, mask, Short128VectorTests::ROL);
}
-
static short ROR_unary(short a, short b) {
return (short)(ROR_scalar(a, b));
}
@Test(dataProvider = "shortBinaryOpProvider")
}
assertShiftArraysEquals(r, a, b, Short128VectorTests::ROR_unary);
}
-
-
@Test(dataProvider = "shortBinaryOpMaskProvider")
static void RORShort128VectorTestsScalarShiftMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
assertShiftArraysEquals(r, a, b, mask, Short128VectorTests::ROR_unary);
}
-
static short ROL_unary(short a, short b) {
return (short)(ROL_scalar(a, b));
}
@Test(dataProvider = "shortBinaryOpProvider")
}
assertShiftArraysEquals(r, a, b, Short128VectorTests::ROL_unary);
}
-
-
@Test(dataProvider = "shortBinaryOpMaskProvider")
static void ROLShort128VectorTestsScalarShiftMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
}
assertShiftArraysEquals(r, a, b, mask, Short128VectorTests::ROL_unary);
}
-
-
-
-
-
-
static short LSHR_binary_const(short a) {
return (short)(((a & 0xFFFF) >>> CONST_SHIFT));
}
@Test(dataProvider = "shortUnaryOpProvider")
}
assertShiftConstEquals(r, a, Short128VectorTests::LSHR_binary_const);
}
-
-
@Test(dataProvider = "shortUnaryOpMaskProvider")
static void LSHRShort128VectorTestsScalarShiftMaskedConst(IntFunction<short[]> fa,
IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
}
assertShiftConstEquals(r, a, mask, Short128VectorTests::LSHR_binary_const);
}
-
-
static short LSHL_binary_const(short a) {
return (short)((a << CONST_SHIFT));
}
@Test(dataProvider = "shortUnaryOpProvider")
}
assertShiftConstEquals(r, a, Short128VectorTests::LSHL_binary_const);
}
-
-
@Test(dataProvider = "shortUnaryOpMaskProvider")
static void LSHLShort128VectorTestsScalarShiftMaskedConst(IntFunction<short[]> fa,
IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
}
assertShiftConstEquals(r, a, mask, Short128VectorTests::LSHL_binary_const);
}
-
-
static short ASHR_binary_const(short a) {
return (short)((a >> CONST_SHIFT));
}
@Test(dataProvider = "shortUnaryOpProvider")
}
assertShiftConstEquals(r, a, Short128VectorTests::ASHR_binary_const);
}
-
-
@Test(dataProvider = "shortUnaryOpMaskProvider")
static void ASHRShort128VectorTestsScalarShiftMaskedConst(IntFunction<short[]> fa,
IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
}
assertShiftConstEquals(r, a, mask, Short128VectorTests::ASHR_binary_const);
}
-
-
static short ROR_binary_const(short a) {
return (short)(ROR_scalar(a, CONST_SHIFT));
}
@Test(dataProvider = "shortUnaryOpProvider")
}
assertShiftConstEquals(r, a, Short128VectorTests::ROR_binary_const);
}
-
-
@Test(dataProvider = "shortUnaryOpMaskProvider")
static void RORShort128VectorTestsScalarShiftMaskedConst(IntFunction<short[]> fa,
IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
}
assertShiftConstEquals(r, a, mask, Short128VectorTests::ROR_binary_const);
}
-
-
static short ROL_binary_const(short a) {
return (short)(ROL_scalar(a, CONST_SHIFT));
}
@Test(dataProvider = "shortUnaryOpProvider")
}
assertShiftConstEquals(r, a, Short128VectorTests::ROL_binary_const);
}
-
-
@Test(dataProvider = "shortUnaryOpMaskProvider")
static void ROLShort128VectorTestsScalarShiftMaskedConst(IntFunction<short[]> fa,
IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
}
}
assertArraysEquals(r, a, b, Short128VectorTests::MIN);
}
+
static short min(short a, short b) {
return (short)(Math.min(a, b));
}
@Test(dataProvider = "shortBinaryOpProvider")
av.min(bv).intoArray(r, i);
}
assertArraysEquals(r, a, b, Short128VectorTests::min);
}
+
static short MAX(short a, short b) {
return (short)(Math.max(a, b));
}
@Test(dataProvider = "shortBinaryOpProvider")
}
}
assertArraysEquals(r, a, b, Short128VectorTests::MAX);
}
+
static short max(short a, short b) {
return (short)(Math.max(a, b));
}
@Test(dataProvider = "shortBinaryOpProvider")
}
return res;
}
-
@Test(dataProvider = "shortUnaryOpProvider")
static void ANDReduceShort128VectorTests(IntFunction<short[]> fa) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
short ra = -1;
assertReductionArraysEquals(r, ra, a,
Short128VectorTests::ANDReduce, Short128VectorTests::ANDReduceAll);
}
-
static short ANDReduceMasked(short[] a, int idx, boolean[] mask) {
short res = -1;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res &= a[i];
}
return res;
}
-
@Test(dataProvider = "shortUnaryOpMaskProvider")
static void ANDReduceShort128VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
assertReductionArraysEqualsMasked(r, ra, a, mask,
Short128VectorTests::ANDReduceMasked, Short128VectorTests::ANDReduceAllMasked);
}
-
static short ORReduce(short[] a, int idx) {
short res = 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res |= a[i];
}
}
return res;
}
-
@Test(dataProvider = "shortUnaryOpProvider")
static void ORReduceShort128VectorTests(IntFunction<short[]> fa) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
short ra = 0;
assertReductionArraysEquals(r, ra, a,
Short128VectorTests::ORReduce, Short128VectorTests::ORReduceAll);
}
-
static short ORReduceMasked(short[] a, int idx, boolean[] mask) {
short res = 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res |= a[i];
}
return res;
}
-
@Test(dataProvider = "shortUnaryOpMaskProvider")
static void ORReduceShort128VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
assertReductionArraysEqualsMasked(r, ra, a, mask,
Short128VectorTests::ORReduceMasked, Short128VectorTests::ORReduceAllMasked);
}
-
static short XORReduce(short[] a, int idx) {
short res = 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res ^= a[i];
}
}
return res;
}
-
@Test(dataProvider = "shortUnaryOpProvider")
static void XORReduceShort128VectorTests(IntFunction<short[]> fa) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
short ra = 0;
assertReductionArraysEquals(r, ra, a,
Short128VectorTests::XORReduce, Short128VectorTests::XORReduceAll);
}
-
static short XORReduceMasked(short[] a, int idx, boolean[] mask) {
short res = 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res ^= a[i];
}
return res;
}
-
@Test(dataProvider = "shortUnaryOpMaskProvider")
static void XORReduceShort128VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
res += ADDReduce(a, i);
}
return res;
}
+
@Test(dataProvider = "shortUnaryOpProvider")
static void ADDReduceShort128VectorTests(IntFunction<short[]> fa) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
short ra = 0;
}
assertReductionArraysEquals(r, ra, a,
Short128VectorTests::ADDReduce, Short128VectorTests::ADDReduceAll);
}
+
static short ADDReduceMasked(short[] a, int idx, boolean[] mask) {
short res = 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res += a[i];
res += ADDReduceMasked(a, i, mask);
}
return res;
}
+
@Test(dataProvider = "shortUnaryOpMaskProvider")
static void ADDReduceShort128VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Short128VectorTests::ADDReduceMasked, Short128VectorTests::ADDReduceAllMasked);
}
+
static short MULReduce(short[] a, int idx) {
short res = 1;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res *= a[i];
}
res *= MULReduce(a, i);
}
return res;
}
+
@Test(dataProvider = "shortUnaryOpProvider")
static void MULReduceShort128VectorTests(IntFunction<short[]> fa) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
short ra = 1;
}
assertReductionArraysEquals(r, ra, a,
Short128VectorTests::MULReduce, Short128VectorTests::MULReduceAll);
}
+
static short MULReduceMasked(short[] a, int idx, boolean[] mask) {
short res = 1;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res *= a[i];
res *= MULReduceMasked(a, i, mask);
}
return res;
}
+
@Test(dataProvider = "shortUnaryOpMaskProvider")
static void MULReduceShort128VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Short128VectorTests::MULReduceMasked, Short128VectorTests::MULReduceAllMasked);
}
+
static short MINReduce(short[] a, int idx) {
short res = Short.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (short) Math.min(res, a[i]);
}
res = (short) Math.min(res, MINReduce(a, i));
}
return res;
}
+
@Test(dataProvider = "shortUnaryOpProvider")
static void MINReduceShort128VectorTests(IntFunction<short[]> fa) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
short ra = Short.MAX_VALUE;
}
assertReductionArraysEquals(r, ra, a,
Short128VectorTests::MINReduce, Short128VectorTests::MINReduceAll);
}
+
static short MINReduceMasked(short[] a, int idx, boolean[] mask) {
short res = Short.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (short) Math.min(res, a[i]);
res = (short) Math.min(res, MINReduceMasked(a, i, mask));
}
return res;
}
+
@Test(dataProvider = "shortUnaryOpMaskProvider")
static void MINReduceShort128VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Short128VectorTests::MINReduceMasked, Short128VectorTests::MINReduceAllMasked);
}
+
static short MAXReduce(short[] a, int idx) {
short res = Short.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (short) Math.max(res, a[i]);
}
res = (short) Math.max(res, MAXReduce(a, i));
}
return res;
}
+
@Test(dataProvider = "shortUnaryOpProvider")
static void MAXReduceShort128VectorTests(IntFunction<short[]> fa) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
short ra = Short.MIN_VALUE;
}
assertReductionArraysEquals(r, ra, a,
Short128VectorTests::MAXReduce, Short128VectorTests::MAXReduceAll);
}
+
static short MAXReduceMasked(short[] a, int idx, boolean[] mask) {
short res = Short.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (short) Math.max(res, a[i]);
res = (short) Math.max(res, MAXReduceMasked(a, i, mask));
}
return res;
}
+
@Test(dataProvider = "shortUnaryOpMaskProvider")
static void MAXReduceShort128VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Short128VectorTests::MAXReduceMasked, Short128VectorTests::MAXReduceAllMasked);
}
+
static short FIRST_NONZEROReduce(short[] a, int idx) {
short res = (short) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = firstNonZero(res, a[i]);
}
res = firstNonZero(res, FIRST_NONZEROReduce(a, i));
}
return res;
}
+
@Test(dataProvider = "shortUnaryOpProvider")
static void FIRST_NONZEROReduceShort128VectorTests(IntFunction<short[]> fa) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
short ra = (short) 0;
}
assertReductionArraysEquals(r, ra, a,
Short128VectorTests::FIRST_NONZEROReduce, Short128VectorTests::FIRST_NONZEROReduceAll);
}
+
static short FIRST_NONZEROReduceMasked(short[] a, int idx, boolean[] mask) {
short res = (short) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = firstNonZero(res, a[i]);
res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask));
}
return res;
}
+
@Test(dataProvider = "shortUnaryOpMaskProvider")
static void FIRST_NONZEROReduceShort128VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
}
return res;
}
-
@Test(dataProvider = "boolUnaryOpProvider")
static void anyTrueShort128VectorTests(IntFunction<boolean[]> fm) {
boolean[] mask = fm.apply(SPECIES.length());
boolean[] r = fmr.apply(SPECIES.length());
}
assertReductionBoolArraysEquals(r, mask, Short128VectorTests::anyTrue);
}
-
static boolean allTrue(boolean[] a, int idx) {
boolean res = true;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res &= a[i];
}
return res;
}
-
@Test(dataProvider = "boolUnaryOpProvider")
static void allTrueShort128VectorTests(IntFunction<boolean[]> fm) {
boolean[] mask = fm.apply(SPECIES.length());
boolean[] r = fmr.apply(SPECIES.length());
}
assertReductionBoolArraysEquals(r, mask, Short128VectorTests::allTrue);
}
-
@Test(dataProvider = "shortUnaryOpProvider")
static void withShort128VectorTests(IntFunction<short []> fa) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
assertInsertArraysEquals(r, a, (short)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length());
}
}
+
static boolean testIS_DEFAULT(short a) {
return bits(a)==0;
}
@Test(dataProvider = "shortTestOpProvider")
Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j]));
}
}
}
}
+
static boolean testIS_NEGATIVE(short a) {
return bits(a)<0;
}
@Test(dataProvider = "shortTestOpProvider")
}
}
}
}
-
-
-
@Test(dataProvider = "shortCompareOpProvider")
static void LTShort128VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
}
}
}
-
@Test(dataProvider = "shortCompareOpProvider")
static void ltShort128VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
}
}
}
-
@Test(dataProvider = "shortCompareOpProvider")
static void GTShort128VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
}
}
}
-
@Test(dataProvider = "shortCompareOpProvider")
static void EQShort128VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
}
}
}
-
@Test(dataProvider = "shortCompareOpProvider")
static void eqShort128VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
}
}
}
-
@Test(dataProvider = "shortCompareOpProvider")
static void NEShort128VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
}
}
}
-
@Test(dataProvider = "shortCompareOpProvider")
static void LEShort128VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
}
}
}
-
@Test(dataProvider = "shortCompareOpProvider")
static void GEShort128VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
}
}
}
-
-
@Test(dataProvider = "shortCompareOpProvider")
static void UNSIGNED_LTShort128VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
}
}
}
-
-
@Test(dataProvider = "shortCompareOpMaskProvider")
static void UNSIGNED_LTShort128VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
}
}
}
-
-
-
@Test(dataProvider = "shortCompareOpProvider")
static void UNSIGNED_GTShort128VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
}
}
}
-
-
@Test(dataProvider = "shortCompareOpMaskProvider")
static void UNSIGNED_GTShort128VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
}
}
}
-
-
-
@Test(dataProvider = "shortCompareOpProvider")
static void UNSIGNED_LEShort128VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
}
}
}
-
-
@Test(dataProvider = "shortCompareOpMaskProvider")
static void UNSIGNED_LEShort128VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
}
}
}
-
-
-
@Test(dataProvider = "shortCompareOpProvider")
static void UNSIGNED_GEShort128VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
}
}
}
-
-
@Test(dataProvider = "shortCompareOpMaskProvider")
static void UNSIGNED_GEShort128VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
}
}
}
-
-
@Test(dataProvider = "shortCompareOpProvider")
static void LTShort128VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
}
}
}
-
@Test(dataProvider = "shortCompareOpMaskProvider")
static void LTShort128VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa,
IntFunction<short[]> fb, IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (short)((long)b[i]));
}
}
}
-
@Test(dataProvider = "shortCompareOpMaskProvider")
static void LTShort128VectorTestsBroadcastLongMaskedSmokeTest(IntFunction<short[]> fa,
IntFunction<short[]> fb, IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);
}
}
}
-
@Test(dataProvider = "shortCompareOpMaskProvider")
static void EQShort128VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa,
IntFunction<short[]> fb, IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (short)((long)b[i]));
}
}
}
-
@Test(dataProvider = "shortCompareOpMaskProvider")
static void EQShort128VectorTestsBroadcastLongMaskedSmokeTest(IntFunction<short[]> fa,
IntFunction<short[]> fb, IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i);
}
assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length());
}
+
+ @Test(dataProvider = "shortUnaryOpMaskProvider")
+ static void compressShort128VectorTests(IntFunction<short[]> fa,
+ IntFunction<boolean[]> fm) {
+ short[] a = fa.apply(SPECIES.length());
+ short[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ av.compress(vmask).intoArray(r, i);
+ }
+ }
+
+ assertcompressArraysEquals(r, a, mask, SPECIES.length());
+ }
+
+ @Test(dataProvider = "shortUnaryOpMaskProvider")
+ static void expandShort128VectorTests(IntFunction<short[]> fa,
+ IntFunction<boolean[]> fm) {
+ short[] a = fa.apply(SPECIES.length());
+ short[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ av.expand(vmask).intoArray(r, i);
+ }
+ }
+
+ assertexpandArraysEquals(r, a, mask, SPECIES.length());
+ }
+
@Test(dataProvider = "shortUnaryOpProvider")
static void getShort128VectorTests(IntFunction<short[]> fa) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
}
assertBroadcastArraysEquals(r, a);
}
-
-
-
-
@Test(dataProvider = "shortUnaryOpProvider")
static void ZeroShort128VectorTests(IntFunction<short[]> fa) {
short[] a = fa.apply(SPECIES.length());
short[] r = new short[a.length];
}
Assert.assertEquals(a, r);
}
-
-
-
static short[] sliceUnary(short[] a, int origin, int idx) {
short[] res = new short[SPECIES.length()];
for (int i = 0; i < SPECIES.length(); i++){
if(i+origin < SPECIES.length())
res[i] = a[idx+i+origin];
}
}
assertArraysEquals(r, a, origin, Short128VectorTests::sliceUnary);
}
+
static short[] sliceBinary(short[] a, short[] b, int origin, int idx) {
short[] res = new short[SPECIES.length()];
for (int i = 0, j = 0; i < SPECIES.length(); i++){
if(i+origin < SPECIES.length())
res[i] = a[idx+i+origin];
}
}
assertArraysEquals(r, a, b, origin, Short128VectorTests::sliceBinary);
}
+
static short[] slice(short[] a, short[] b, int origin, boolean[] mask, int idx) {
short[] res = new short[SPECIES.length()];
for (int i = 0, j = 0; i < SPECIES.length(); i++){
if(i+origin < SPECIES.length())
res[i] = mask[i] ? a[idx+i+origin] : (short)0;
}
}
assertArraysEquals(r, a, b, origin, mask, Short128VectorTests::slice);
}
+
static short[] unsliceUnary(short[] a, int origin, int idx) {
short[] res = new short[SPECIES.length()];
for (int i = 0, j = 0; i < SPECIES.length(); i++){
if(i < origin)
res[i] = (short)0;
}
}
assertArraysEquals(r, a, origin, Short128VectorTests::unsliceUnary);
}
+
static short[] unsliceBinary(short[] a, short[] b, int origin, int part, int idx) {
short[] res = new short[SPECIES.length()];
for (int i = 0, j = 0; i < SPECIES.length(); i++){
if (part == 0) {
if (i < origin)
}
}
assertArraysEquals(r, a, b, origin, part, Short128VectorTests::unsliceBinary);
}
+
static short[] unslice(short[] a, short[] b, int origin, int part, boolean[] mask, int idx) {
short[] res = new short[SPECIES.length()];
for (int i = 0, j = 0; i < SPECIES.length(); i++){
if(i+origin < SPECIES.length())
res[i] = b[idx+i+origin];
}
assertArraysEquals(r, a, b, origin, part, mask, Short128VectorTests::unslice);
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
static short BITWISE_BLEND(short a, short b, short c) {
return (short)((a&~(c))|(b&c));
}
static short bitwiseBlend(short a, short b, short c) {
return (short)((a&~(c))|(b&c));
}
-
@Test(dataProvider = "shortTernaryOpProvider")
static void BITWISE_BLENDShort128VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
short[] c = fc.apply(SPECIES.length());
}
assertArraysEquals(r, a, b, origin, part, mask, Short128VectorTests::unslice);
}
static short BITWISE_BLEND(short a, short b, short c) {
return (short)((a&~(c))|(b&c));
}
+
static short bitwiseBlend(short a, short b, short c) {
return (short)((a&~(c))|(b&c));
}
@Test(dataProvider = "shortTernaryOpProvider")
static void BITWISE_BLENDShort128VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
short[] c = fc.apply(SPECIES.length());
}
}
assertArraysEquals(r, a, b, c, Short128VectorTests::BITWISE_BLEND);
}
+
@Test(dataProvider = "shortTernaryOpProvider")
static void bitwiseBlendShort128VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
short[] c = fc.apply(SPECIES.length());
}
assertArraysEquals(r, a, b, c, Short128VectorTests::bitwiseBlend);
}
-
@Test(dataProvider = "shortTernaryOpMaskProvider")
static void BITWISE_BLENDShort128VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
IntFunction<short[]> fc, IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
assertArraysEquals(r, a, b, c, mask, Short128VectorTests::BITWISE_BLEND);
}
-
-
-
@Test(dataProvider = "shortTernaryOpProvider")
static void BITWISE_BLENDShort128VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
short[] c = fc.apply(SPECIES.length());
ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i);
}
assertAltBroadcastArraysEquals(r, a, b, c, Short128VectorTests::BITWISE_BLEND);
}
+
@Test(dataProvider = "shortTernaryOpProvider")
static void bitwiseBlendShort128VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
short[] c = fc.apply(SPECIES.length());
av.bitwiseBlend(b[i], cv).intoArray(r, i);
}
assertAltBroadcastArraysEquals(r, a, b, c, Short128VectorTests::bitwiseBlend);
}
-
@Test(dataProvider = "shortTernaryOpMaskProvider")
static void BITWISE_BLENDShort128VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
IntFunction<short[]> fc, IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
assertAltBroadcastArraysEquals(r, a, b, c, mask, Short128VectorTests::BITWISE_BLEND);
}
-
-
-
@Test(dataProvider = "shortTernaryOpProvider")
static void BITWISE_BLENDShort128VectorTestsDoubleBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
short[] c = fc.apply(SPECIES.length());
av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i);
}
assertDoubleBroadcastArraysEquals(r, a, b, c, Short128VectorTests::BITWISE_BLEND);
}
+
@Test(dataProvider = "shortTernaryOpProvider")
static void bitwiseBlendShort128VectorTestsDoubleBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
short[] c = fc.apply(SPECIES.length());
}
assertDoubleBroadcastArraysEquals(r, a, b, c, Short128VectorTests::bitwiseBlend);
}
-
@Test(dataProvider = "shortTernaryOpMaskProvider")
static void BITWISE_BLENDShort128VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
IntFunction<short[]> fc, IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Short128VectorTests::BITWISE_BLEND);
}
-
static short NEG(short a) {
return (short)(-((short)a));
}
static short neg(short a) {
}
assertArraysEquals(r, a, mask, Short128VectorTests::ABS);
}
-
static short NOT(short a) {
return (short)(~((short)a));
}
static short not(short a) {
return (short)(~((short)a));
}
-
-
@Test(dataProvider = "shortUnaryOpProvider")
static void NOTShort128VectorTests(IntFunction<short[]> fa) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
}
assertArraysEquals(r, a, Short128VectorTests::not);
}
-
-
@Test(dataProvider = "shortUnaryOpMaskProvider")
static void NOTMaskedShort128VectorTests(IntFunction<short[]> fa,
IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
}
assertArraysEquals(r, a, mask, Short128VectorTests::NOT);
}
-
-
static short ZOMO(short a) {
return (short)((a==0?0:-1));
}
-
-
@Test(dataProvider = "shortUnaryOpProvider")
static void ZOMOShort128VectorTests(IntFunction<short[]> fa) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
}
assertArraysEquals(r, a, Short128VectorTests::ZOMO);
}
-
-
@Test(dataProvider = "shortUnaryOpMaskProvider")
static void ZOMOMaskedShort128VectorTests(IntFunction<short[]> fa,
IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
}
assertArraysEquals(r, a, mask, Short128VectorTests::ZOMO);
}
+ static short BIT_COUNT(short a) {
+ return (short)(Integer.bitCount((int)a & 0xFFFF));
+ }
+
+ @Test(dataProvider = "shortUnaryOpProvider")
+ static void BIT_COUNTShort128VectorTests(IntFunction<short[]> fa) {
+ short[] a = fa.apply(SPECIES.length());
+ short[] r = fr.apply(SPECIES.length());
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ av.lanewise(VectorOperators.BIT_COUNT).intoArray(r, i);
+ }
+ }
+
+ assertArraysEquals(r, a, Short128VectorTests::BIT_COUNT);
+ }
+
+ @Test(dataProvider = "shortUnaryOpMaskProvider")
+ static void BIT_COUNTMaskedShort128VectorTests(IntFunction<short[]> fa,
+ IntFunction<boolean[]> fm) {
+ short[] a = fa.apply(SPECIES.length());
+ short[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ av.lanewise(VectorOperators.BIT_COUNT, vmask).intoArray(r, i);
+ }
+ }
+
+ assertArraysEquals(r, a, mask, Short128VectorTests::BIT_COUNT);
+ }
+
+ static short TRAILING_ZEROS_COUNT(short a) {
+ return (short)(TRAILING_ZEROS_COUNT_scalar(a));
+ }
+
+ @Test(dataProvider = "shortUnaryOpProvider")
+ static void TRAILING_ZEROS_COUNTShort128VectorTests(IntFunction<short[]> fa) {
+ short[] a = fa.apply(SPECIES.length());
+ short[] r = fr.apply(SPECIES.length());
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ av.lanewise(VectorOperators.TRAILING_ZEROS_COUNT).intoArray(r, i);
+ }
+ }
+
+ assertArraysEquals(r, a, Short128VectorTests::TRAILING_ZEROS_COUNT);
+ }
+
+ @Test(dataProvider = "shortUnaryOpMaskProvider")
+ static void TRAILING_ZEROS_COUNTMaskedShort128VectorTests(IntFunction<short[]> fa,
+ IntFunction<boolean[]> fm) {
+ short[] a = fa.apply(SPECIES.length());
+ short[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ av.lanewise(VectorOperators.TRAILING_ZEROS_COUNT, vmask).intoArray(r, i);
+ }
+ }
+
+ assertArraysEquals(r, a, mask, Short128VectorTests::TRAILING_ZEROS_COUNT);
+ }
+
+ static short LEADING_ZEROS_COUNT(short a) {
+ return (short)(LEADING_ZEROS_COUNT_scalar(a));
+ }
+
+ @Test(dataProvider = "shortUnaryOpProvider")
+ static void LEADING_ZEROS_COUNTShort128VectorTests(IntFunction<short[]> fa) {
+ short[] a = fa.apply(SPECIES.length());
+ short[] r = fr.apply(SPECIES.length());
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ av.lanewise(VectorOperators.LEADING_ZEROS_COUNT).intoArray(r, i);
+ }
+ }
+
+ assertArraysEquals(r, a, Short128VectorTests::LEADING_ZEROS_COUNT);
+ }
+
+ @Test(dataProvider = "shortUnaryOpMaskProvider")
+ static void LEADING_ZEROS_COUNTMaskedShort128VectorTests(IntFunction<short[]> fa,
+ IntFunction<boolean[]> fm) {
+ short[] a = fa.apply(SPECIES.length());
+ short[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ av.lanewise(VectorOperators.LEADING_ZEROS_COUNT, vmask).intoArray(r, i);
+ }
+ }
+
+ assertArraysEquals(r, a, mask, Short128VectorTests::LEADING_ZEROS_COUNT);
+ }
+
+ static short REVERSE(short a) {
+ return (short)(REVERSE_scalar(a));
+ }
+
+ @Test(dataProvider = "shortUnaryOpProvider")
+ static void REVERSEShort128VectorTests(IntFunction<short[]> fa) {
+ short[] a = fa.apply(SPECIES.length());
+ short[] r = fr.apply(SPECIES.length());
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ av.lanewise(VectorOperators.REVERSE).intoArray(r, i);
+ }
+ }
+
+ assertArraysEquals(r, a, Short128VectorTests::REVERSE);
+ }
+
+ @Test(dataProvider = "shortUnaryOpMaskProvider")
+ static void REVERSEMaskedShort128VectorTests(IntFunction<short[]> fa,
+ IntFunction<boolean[]> fm) {
+ short[] a = fa.apply(SPECIES.length());
+ short[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ av.lanewise(VectorOperators.REVERSE, vmask).intoArray(r, i);
+ }
+ }
+
+ assertArraysEquals(r, a, mask, Short128VectorTests::REVERSE);
+ }
+
+ static short REVERSE_BYTES(short a) {
+ return (short)(Short.reverseBytes(a));
+ }
+ @Test(dataProvider = "shortUnaryOpProvider")
+ static void REVERSE_BYTESShort128VectorTests(IntFunction<short[]> fa) {
+ short[] a = fa.apply(SPECIES.length());
+ short[] r = fr.apply(SPECIES.length());
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ av.lanewise(VectorOperators.REVERSE_BYTES).intoArray(r, i);
+ }
+ }
+ assertArraysEquals(r, a, Short128VectorTests::REVERSE_BYTES);
+ }
+
+ @Test(dataProvider = "shortUnaryOpMaskProvider")
+ static void REVERSE_BYTESMaskedShort128VectorTests(IntFunction<short[]> fa,
+ IntFunction<boolean[]> fm) {
+ short[] a = fa.apply(SPECIES.length());
+ short[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ShortVector av = ShortVector.fromArray(SPECIES, a, i);
+ av.lanewise(VectorOperators.REVERSE_BYTES, vmask).intoArray(r, i);
+ }
+ }
+
+ assertArraysEquals(r, a, mask, Short128VectorTests::REVERSE_BYTES);
+ }
@Test(dataProvider = "shortCompareOpProvider")
static void ltShort128VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
short[] a = fa.apply(SPECIES.length());
short[] b = fb.apply(SPECIES.length());
}
assertMaskReductionArraysEquals(r, a, Short128VectorTests::maskFirstTrue);
}
+ @Test(dataProvider = "maskProvider")
+ static void maskCompressShort128VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
+ int trueCount = 0;
+ boolean[] a = fa.apply(SPECIES.length());
+
+ for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ var vmask = SPECIES.loadMask(a, i);
+ trueCount = vmask.trueCount();
+ var rmask = vmask.compress();
+ for (int j = 0; j < SPECIES.length(); j++) {
+ Assert.assertEquals(rmask.laneIsSet(j), j < trueCount);
+ }
+ }
+ }
+ }
+
@DataProvider
public static Object[][] longMaskProvider() {
return new Object[][]{
{0xFFFFFFFFFFFFFFFFL},
{0x0000000000000000L},
Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
}
}
}
+ @Test(dataProvider = "offsetProvider")
+ static void indexInRangeLongShort128VectorTestsSmokeTest(int offset) {
+ long limit = SPECIES.length() * BUFFER_REPS;
+ for (long i = 0; i < limit; i += SPECIES.length()) {
+ var actualMask = SPECIES.indexInRange(i + offset, limit);
+ var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);
+ assert(actualMask.equals(expectedMask));
+ for (int j = 0; j < SPECIES.length(); j++) {
+ long index = i + j + offset;
+ Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
+ }
+ }
+ }
+
@DataProvider
public static Object[][] lengthProvider() {
return new Object[][]{
{0},
{1},
int actualLoopBound = SPECIES.loopBound(length);
int expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
Assert.assertEquals(actualLoopBound, expectedLoopBound);
}
+ @Test(dataProvider = "lengthProvider")
+ static void loopBoundLongShort128VectorTestsSmokeTest(int _length) {
+ long length = _length;
+ long actualLoopBound = SPECIES.loopBound(length);
+ long expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
+ Assert.assertEquals(actualLoopBound, expectedLoopBound);
+ }
+
@Test
static void ElementSizeShort128VectorTestsSmokeTest() {
ShortVector av = ShortVector.zero(SPECIES);
int elsize = av.elementSize();
Assert.assertEquals(elsize, Short.SIZE);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
Assert.assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length()));
}
}
}
-
< prev index next >