< prev index next > test/jdk/jdk/incubator/vector/Byte256VectorTests.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(byte[] r, byte[] 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], (byte)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], (byte)0, "at index #" + idx);
+ }
+ }
+ }
+
+ static void assertexpandArraysEquals(byte[] r, byte[] 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], (byte)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], (byte)0, "at index #" + idx);
+ }
+ }
+ }
+
static void assertSelectFromArraysEquals(byte[] r, byte[] a, byte[] 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 byte bits(byte e) {
return e;
}
static final List<IntFunction<byte[]>> BYTE_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<byte[]>> BYTE_COMPARE_GENERATORS = List.of(
withToString("byte[i]", (int s) -> {
return fill(s * BUFFER_REPS,
i -> (byte)i);
}),
static byte ROR_scalar(byte a, byte b) {
return (byte)(((((byte)a) & 0xFF) >>> (b & 7)) | ((((byte)a) & 0xFF) << (8 - (b & 7))));
}
+ static byte TRAILING_ZEROS_COUNT_scalar(byte a) {
+ return (byte) (a != 0 ? Integer.numberOfTrailingZeros(a) : 8);
+ }
+
+ static byte LEADING_ZEROS_COUNT_scalar(byte a) {
+ return (byte) (a >= 0 ? Integer.numberOfLeadingZeros(a) - 24 : 0);
+ }
+
+ static byte REVERSE_scalar(byte a) {
+ byte b = (byte) ROL_scalar(a, (byte) 4);
+ b = (byte) (((b & 0x55) << 1) | ((b & 0xAA) >>> 1));
+ b = (byte) (((b & 0x33) << 2) | ((b & 0xCC) >>> 2));
+ return b;
+ }
+
static boolean eq(byte a, byte b) {
return a == b;
}
static boolean neq(byte a, byte b) {
a.div(b, m);
Assert.fail();
} catch (ArithmeticException e) {
}
}
+
static byte ADD(byte a, byte b) {
return (byte)(a + b);
}
@Test(dataProvider = "byteBinaryOpProvider")
}
}
assertArraysEquals(r, a, b, Byte256VectorTests::ADD);
}
+
static byte add(byte a, byte b) {
return (byte)(a + b);
}
@Test(dataProvider = "byteBinaryOpProvider")
av.add(bv, vmask).intoArray(r, i);
}
assertArraysEquals(r, a, b, mask, Byte256VectorTests::add);
}
+
static byte SUB(byte a, byte b) {
return (byte)(a - b);
}
@Test(dataProvider = "byteBinaryOpProvider")
}
}
assertArraysEquals(r, a, b, Byte256VectorTests::SUB);
}
+
static byte sub(byte a, byte b) {
return (byte)(a - b);
}
@Test(dataProvider = "byteBinaryOpProvider")
av.sub(bv, vmask).intoArray(r, i);
}
assertArraysEquals(r, a, b, mask, Byte256VectorTests::sub);
}
+
static byte MUL(byte a, byte b) {
return (byte)(a * b);
}
@Test(dataProvider = "byteBinaryOpProvider")
}
}
assertArraysEquals(r, a, b, Byte256VectorTests::MUL);
}
+
static byte mul(byte a, byte b) {
return (byte)(a * b);
}
@Test(dataProvider = "byteBinaryOpProvider")
}
assertArraysEquals(r, a, b, mask, Byte256VectorTests::mul);
}
-
-
static byte DIV(byte a, byte b) {
return (byte)(a / b);
}
@Test(dataProvider = "byteBinaryOpProvider")
}
}
assertArraysEquals(r, a, b, Byte256VectorTests::DIV);
}
+
static byte div(byte a, byte b) {
return (byte)(a / b);
}
@Test(dataProvider = "byteBinaryOpProvider")
}
assertArraysEquals(r, a, b, Byte256VectorTests::div);
}
-
-
@Test(dataProvider = "byteBinaryOpMaskProvider")
static void DIVByte256VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
}
assertArraysEquals(r, a, b, Byte256VectorTests::AND);
}
+
static byte and(byte a, byte b) {
return (byte)(a & b);
}
@Test(dataProvider = "byteBinaryOpProvider")
}
assertArraysEquals(r, a, b, Byte256VectorTests::and);
}
-
-
@Test(dataProvider = "byteBinaryOpMaskProvider")
static void ANDByte256VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
assertArraysEquals(r, a, b, mask, Byte256VectorTests::AND);
}
-
static byte AND_NOT(byte a, byte b) {
return (byte)(a & ~b);
}
@Test(dataProvider = "byteBinaryOpProvider")
}
assertArraysEquals(r, a, b, Byte256VectorTests::AND_NOT);
}
-
-
@Test(dataProvider = "byteBinaryOpMaskProvider")
static void AND_NOTByte256VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
assertArraysEquals(r, a, b, mask, Byte256VectorTests::AND_NOT);
}
-
static byte OR(byte a, byte b) {
return (byte)(a | b);
}
@Test(dataProvider = "byteBinaryOpProvider")
}
}
assertArraysEquals(r, a, b, Byte256VectorTests::OR);
}
+
static byte or(byte a, byte b) {
return (byte)(a | b);
}
@Test(dataProvider = "byteBinaryOpProvider")
}
assertArraysEquals(r, a, b, Byte256VectorTests::or);
}
-
-
@Test(dataProvider = "byteBinaryOpMaskProvider")
static void ORByte256VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
assertArraysEquals(r, a, b, mask, Byte256VectorTests::OR);
}
-
static byte XOR(byte a, byte b) {
return (byte)(a ^ b);
}
@Test(dataProvider = "byteBinaryOpProvider")
}
assertArraysEquals(r, a, b, Byte256VectorTests::XOR);
}
-
-
@Test(dataProvider = "byteBinaryOpMaskProvider")
static void XORByte256VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
assertArraysEquals(r, a, b, mask, Byte256VectorTests::XOR);
}
-
@Test(dataProvider = "byteBinaryOpProvider")
static void addByte256VectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
}
assertBroadcastArraysEquals(r, a, b, mask, Byte256VectorTests::mul);
}
-
-
-
@Test(dataProvider = "byteBinaryOpProvider")
static void divByte256VectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
}
assertBroadcastArraysEquals(r, a, b, Byte256VectorTests::div);
}
-
-
@Test(dataProvider = "byteBinaryOpMaskProvider")
static void divByte256VectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
assertBroadcastArraysEquals(r, a, b, mask, Byte256VectorTests::div);
}
-
-
@Test(dataProvider = "byteBinaryOpProvider")
static void ORByte256VectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
}
assertBroadcastArraysEquals(r, a, b, Byte256VectorTests::or);
}
-
-
@Test(dataProvider = "byteBinaryOpMaskProvider")
static void ORByte256VectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
assertBroadcastArraysEquals(r, a, b, mask, Byte256VectorTests::OR);
}
-
-
@Test(dataProvider = "byteBinaryOpProvider")
static void ANDByte256VectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
}
assertBroadcastArraysEquals(r, a, b, Byte256VectorTests::and);
}
-
-
@Test(dataProvider = "byteBinaryOpMaskProvider")
static void ANDByte256VectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
assertBroadcastArraysEquals(r, a, b, mask, Byte256VectorTests::AND);
}
-
-
@Test(dataProvider = "byteBinaryOpProvider")
static void ORByte256VectorTestsBroadcastLongSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
}
assertBroadcastLongArraysEquals(r, a, b, Byte256VectorTests::OR);
}
-
-
@Test(dataProvider = "byteBinaryOpMaskProvider")
static void ORByte256VectorTestsBroadcastMaskedLongSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
assertBroadcastLongArraysEquals(r, a, b, mask, Byte256VectorTests::OR);
}
-
@Test(dataProvider = "byteBinaryOpProvider")
static void ADDByte256VectorTestsBroadcastLongSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
}
assertBroadcastLongArraysEquals(r, a, b, mask, Byte256VectorTests::ADD);
}
-
-
static byte LSHL(byte a, byte b) {
return (byte)((a << (b & 0x7)));
}
@Test(dataProvider = "byteBinaryOpProvider")
}
assertArraysEquals(r, a, b, Byte256VectorTests::LSHL);
}
-
-
@Test(dataProvider = "byteBinaryOpMaskProvider")
static void LSHLByte256VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
assertArraysEquals(r, a, b, mask, Byte256VectorTests::LSHL);
}
-
-
-
-
-
static byte ASHR(byte a, byte b) {
return (byte)((a >> (b & 0x7)));
}
@Test(dataProvider = "byteBinaryOpProvider")
}
assertArraysEquals(r, a, b, Byte256VectorTests::ASHR);
}
-
-
@Test(dataProvider = "byteBinaryOpMaskProvider")
static void ASHRByte256VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
assertArraysEquals(r, a, b, mask, Byte256VectorTests::ASHR);
}
-
-
-
-
-
static byte LSHR(byte a, byte b) {
return (byte)(((a & 0xFF) >>> (b & 0x7)));
}
@Test(dataProvider = "byteBinaryOpProvider")
}
assertArraysEquals(r, a, b, Byte256VectorTests::LSHR);
}
-
-
@Test(dataProvider = "byteBinaryOpMaskProvider")
static void LSHRByte256VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
assertArraysEquals(r, a, b, mask, Byte256VectorTests::LSHR);
}
-
-
-
-
-
static byte LSHL_unary(byte a, byte b) {
return (byte)((a << (b & 7)));
}
@Test(dataProvider = "byteBinaryOpProvider")
}
assertShiftArraysEquals(r, a, b, Byte256VectorTests::LSHL_unary);
}
-
-
@Test(dataProvider = "byteBinaryOpMaskProvider")
static void LSHLByte256VectorTestsScalarShiftMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
assertShiftArraysEquals(r, a, b, mask, Byte256VectorTests::LSHL_unary);
}
-
-
-
-
-
static byte LSHR_unary(byte a, byte b) {
return (byte)(((a & 0xFF) >>> (b & 7)));
}
@Test(dataProvider = "byteBinaryOpProvider")
}
assertShiftArraysEquals(r, a, b, Byte256VectorTests::LSHR_unary);
}
-
-
@Test(dataProvider = "byteBinaryOpMaskProvider")
static void LSHRByte256VectorTestsScalarShiftMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
assertShiftArraysEquals(r, a, b, mask, Byte256VectorTests::LSHR_unary);
}
-
-
-
-
-
static byte ASHR_unary(byte a, byte b) {
return (byte)((a >> (b & 7)));
}
@Test(dataProvider = "byteBinaryOpProvider")
}
assertShiftArraysEquals(r, a, b, Byte256VectorTests::ASHR_unary);
}
-
-
@Test(dataProvider = "byteBinaryOpMaskProvider")
static void ASHRByte256VectorTestsScalarShiftMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
assertShiftArraysEquals(r, a, b, mask, Byte256VectorTests::ASHR_unary);
}
-
-
-
static byte ROR(byte a, byte b) {
return (byte)(ROR_scalar(a,b));
}
@Test(dataProvider = "byteBinaryOpProvider")
}
assertArraysEquals(r, a, b, Byte256VectorTests::ROR);
}
-
-
@Test(dataProvider = "byteBinaryOpMaskProvider")
static void RORByte256VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
assertArraysEquals(r, a, b, mask, Byte256VectorTests::ROR);
}
-
static byte ROL(byte a, byte b) {
return (byte)(ROL_scalar(a,b));
}
@Test(dataProvider = "byteBinaryOpProvider")
}
assertArraysEquals(r, a, b, Byte256VectorTests::ROL);
}
-
-
@Test(dataProvider = "byteBinaryOpMaskProvider")
static void ROLByte256VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
assertArraysEquals(r, a, b, mask, Byte256VectorTests::ROL);
}
-
static byte ROR_unary(byte a, byte b) {
return (byte)(ROR_scalar(a, b));
}
@Test(dataProvider = "byteBinaryOpProvider")
}
assertShiftArraysEquals(r, a, b, Byte256VectorTests::ROR_unary);
}
-
-
@Test(dataProvider = "byteBinaryOpMaskProvider")
static void RORByte256VectorTestsScalarShiftMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
assertShiftArraysEquals(r, a, b, mask, Byte256VectorTests::ROR_unary);
}
-
static byte ROL_unary(byte a, byte b) {
return (byte)(ROL_scalar(a, b));
}
@Test(dataProvider = "byteBinaryOpProvider")
}
assertShiftArraysEquals(r, a, b, Byte256VectorTests::ROL_unary);
}
-
-
@Test(dataProvider = "byteBinaryOpMaskProvider")
static void ROLByte256VectorTestsScalarShiftMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
}
assertShiftArraysEquals(r, a, b, mask, Byte256VectorTests::ROL_unary);
}
-
-
-
-
static byte LSHR_binary_const(byte a) {
return (byte)(((a & 0xFF) >>> CONST_SHIFT));
}
@Test(dataProvider = "byteUnaryOpProvider")
}
assertShiftConstEquals(r, a, Byte256VectorTests::LSHR_binary_const);
}
-
-
@Test(dataProvider = "byteUnaryOpMaskProvider")
static void LSHRByte256VectorTestsScalarShiftMaskedConst(IntFunction<byte[]> fa,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
}
assertShiftConstEquals(r, a, mask, Byte256VectorTests::LSHR_binary_const);
}
-
-
-
-
static byte LSHL_binary_const(byte a) {
return (byte)((a << CONST_SHIFT));
}
@Test(dataProvider = "byteUnaryOpProvider")
}
assertShiftConstEquals(r, a, Byte256VectorTests::LSHL_binary_const);
}
-
-
@Test(dataProvider = "byteUnaryOpMaskProvider")
static void LSHLByte256VectorTestsScalarShiftMaskedConst(IntFunction<byte[]> fa,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
}
assertShiftConstEquals(r, a, mask, Byte256VectorTests::LSHL_binary_const);
}
-
-
static byte ASHR_binary_const(byte a) {
return (byte)((a >> CONST_SHIFT));
}
@Test(dataProvider = "byteUnaryOpProvider")
}
assertShiftConstEquals(r, a, Byte256VectorTests::ASHR_binary_const);
}
-
-
@Test(dataProvider = "byteUnaryOpMaskProvider")
static void ASHRByte256VectorTestsScalarShiftMaskedConst(IntFunction<byte[]> fa,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
}
assertShiftConstEquals(r, a, mask, Byte256VectorTests::ASHR_binary_const);
}
-
-
static byte ROR_binary_const(byte a) {
return (byte)(ROR_scalar(a, CONST_SHIFT));
}
@Test(dataProvider = "byteUnaryOpProvider")
}
assertShiftConstEquals(r, a, Byte256VectorTests::ROR_binary_const);
}
-
-
@Test(dataProvider = "byteUnaryOpMaskProvider")
static void RORByte256VectorTestsScalarShiftMaskedConst(IntFunction<byte[]> fa,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
}
assertShiftConstEquals(r, a, mask, Byte256VectorTests::ROR_binary_const);
}
-
-
static byte ROL_binary_const(byte a) {
return (byte)(ROL_scalar(a, CONST_SHIFT));
}
@Test(dataProvider = "byteUnaryOpProvider")
}
assertShiftConstEquals(r, a, Byte256VectorTests::ROL_binary_const);
}
-
-
@Test(dataProvider = "byteUnaryOpMaskProvider")
static void ROLByte256VectorTestsScalarShiftMaskedConst(IntFunction<byte[]> fa,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
}
}
assertArraysEquals(r, a, b, Byte256VectorTests::MIN);
}
+
static byte min(byte a, byte b) {
return (byte)(Math.min(a, b));
}
@Test(dataProvider = "byteBinaryOpProvider")
av.min(bv).intoArray(r, i);
}
assertArraysEquals(r, a, b, Byte256VectorTests::min);
}
+
static byte MAX(byte a, byte b) {
return (byte)(Math.max(a, b));
}
@Test(dataProvider = "byteBinaryOpProvider")
}
}
assertArraysEquals(r, a, b, Byte256VectorTests::MAX);
}
+
static byte max(byte a, byte b) {
return (byte)(Math.max(a, b));
}
@Test(dataProvider = "byteBinaryOpProvider")
}
return res;
}
-
@Test(dataProvider = "byteUnaryOpProvider")
static void ANDReduceByte256VectorTests(IntFunction<byte[]> fa) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
byte ra = -1;
assertReductionArraysEquals(r, ra, a,
Byte256VectorTests::ANDReduce, Byte256VectorTests::ANDReduceAll);
}
-
static byte ANDReduceMasked(byte[] a, int idx, boolean[] mask) {
byte res = -1;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res &= a[i];
}
return res;
}
-
@Test(dataProvider = "byteUnaryOpMaskProvider")
static void ANDReduceByte256VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
assertReductionArraysEqualsMasked(r, ra, a, mask,
Byte256VectorTests::ANDReduceMasked, Byte256VectorTests::ANDReduceAllMasked);
}
-
static byte ORReduce(byte[] a, int idx) {
byte res = 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res |= a[i];
}
}
return res;
}
-
@Test(dataProvider = "byteUnaryOpProvider")
static void ORReduceByte256VectorTests(IntFunction<byte[]> fa) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
byte ra = 0;
assertReductionArraysEquals(r, ra, a,
Byte256VectorTests::ORReduce, Byte256VectorTests::ORReduceAll);
}
-
static byte ORReduceMasked(byte[] a, int idx, boolean[] mask) {
byte res = 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res |= a[i];
}
return res;
}
-
@Test(dataProvider = "byteUnaryOpMaskProvider")
static void ORReduceByte256VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
assertReductionArraysEqualsMasked(r, ra, a, mask,
Byte256VectorTests::ORReduceMasked, Byte256VectorTests::ORReduceAllMasked);
}
-
static byte XORReduce(byte[] a, int idx) {
byte res = 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res ^= a[i];
}
}
return res;
}
-
@Test(dataProvider = "byteUnaryOpProvider")
static void XORReduceByte256VectorTests(IntFunction<byte[]> fa) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
byte ra = 0;
assertReductionArraysEquals(r, ra, a,
Byte256VectorTests::XORReduce, Byte256VectorTests::XORReduceAll);
}
-
static byte XORReduceMasked(byte[] a, int idx, boolean[] mask) {
byte res = 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res ^= a[i];
}
return res;
}
-
@Test(dataProvider = "byteUnaryOpMaskProvider")
static void XORReduceByte256VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
res += ADDReduce(a, i);
}
return res;
}
+
@Test(dataProvider = "byteUnaryOpProvider")
static void ADDReduceByte256VectorTests(IntFunction<byte[]> fa) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
byte ra = 0;
}
assertReductionArraysEquals(r, ra, a,
Byte256VectorTests::ADDReduce, Byte256VectorTests::ADDReduceAll);
}
+
static byte ADDReduceMasked(byte[] a, int idx, boolean[] mask) {
byte 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 = "byteUnaryOpMaskProvider")
static void ADDReduceByte256VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Byte256VectorTests::ADDReduceMasked, Byte256VectorTests::ADDReduceAllMasked);
}
+
static byte MULReduce(byte[] a, int idx) {
byte res = 1;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res *= a[i];
}
res *= MULReduce(a, i);
}
return res;
}
+
@Test(dataProvider = "byteUnaryOpProvider")
static void MULReduceByte256VectorTests(IntFunction<byte[]> fa) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
byte ra = 1;
}
assertReductionArraysEquals(r, ra, a,
Byte256VectorTests::MULReduce, Byte256VectorTests::MULReduceAll);
}
+
static byte MULReduceMasked(byte[] a, int idx, boolean[] mask) {
byte 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 = "byteUnaryOpMaskProvider")
static void MULReduceByte256VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Byte256VectorTests::MULReduceMasked, Byte256VectorTests::MULReduceAllMasked);
}
+
static byte MINReduce(byte[] a, int idx) {
byte res = Byte.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (byte) Math.min(res, a[i]);
}
res = (byte) Math.min(res, MINReduce(a, i));
}
return res;
}
+
@Test(dataProvider = "byteUnaryOpProvider")
static void MINReduceByte256VectorTests(IntFunction<byte[]> fa) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
byte ra = Byte.MAX_VALUE;
}
assertReductionArraysEquals(r, ra, a,
Byte256VectorTests::MINReduce, Byte256VectorTests::MINReduceAll);
}
+
static byte MINReduceMasked(byte[] a, int idx, boolean[] mask) {
byte res = Byte.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (byte) Math.min(res, a[i]);
res = (byte) Math.min(res, MINReduceMasked(a, i, mask));
}
return res;
}
+
@Test(dataProvider = "byteUnaryOpMaskProvider")
static void MINReduceByte256VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Byte256VectorTests::MINReduceMasked, Byte256VectorTests::MINReduceAllMasked);
}
+
static byte MAXReduce(byte[] a, int idx) {
byte res = Byte.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (byte) Math.max(res, a[i]);
}
res = (byte) Math.max(res, MAXReduce(a, i));
}
return res;
}
+
@Test(dataProvider = "byteUnaryOpProvider")
static void MAXReduceByte256VectorTests(IntFunction<byte[]> fa) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
byte ra = Byte.MIN_VALUE;
}
assertReductionArraysEquals(r, ra, a,
Byte256VectorTests::MAXReduce, Byte256VectorTests::MAXReduceAll);
}
+
static byte MAXReduceMasked(byte[] a, int idx, boolean[] mask) {
byte res = Byte.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (byte) Math.max(res, a[i]);
res = (byte) Math.max(res, MAXReduceMasked(a, i, mask));
}
return res;
}
+
@Test(dataProvider = "byteUnaryOpMaskProvider")
static void MAXReduceByte256VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Byte256VectorTests::MAXReduceMasked, Byte256VectorTests::MAXReduceAllMasked);
}
+
static byte FIRST_NONZEROReduce(byte[] a, int idx) {
byte res = (byte) 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 = "byteUnaryOpProvider")
static void FIRST_NONZEROReduceByte256VectorTests(IntFunction<byte[]> fa) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
byte ra = (byte) 0;
}
assertReductionArraysEquals(r, ra, a,
Byte256VectorTests::FIRST_NONZEROReduce, Byte256VectorTests::FIRST_NONZEROReduceAll);
}
+
static byte FIRST_NONZEROReduceMasked(byte[] a, int idx, boolean[] mask) {
byte res = (byte) 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 = "byteUnaryOpMaskProvider")
static void FIRST_NONZEROReduceByte256VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
}
return res;
}
-
@Test(dataProvider = "boolUnaryOpProvider")
static void anyTrueByte256VectorTests(IntFunction<boolean[]> fm) {
boolean[] mask = fm.apply(SPECIES.length());
boolean[] r = fmr.apply(SPECIES.length());
}
assertReductionBoolArraysEquals(r, mask, Byte256VectorTests::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 allTrueByte256VectorTests(IntFunction<boolean[]> fm) {
boolean[] mask = fm.apply(SPECIES.length());
boolean[] r = fmr.apply(SPECIES.length());
}
assertReductionBoolArraysEquals(r, mask, Byte256VectorTests::allTrue);
}
-
@Test(dataProvider = "byteUnaryOpProvider")
static void withByte256VectorTests(IntFunction<byte []> fa) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
assertInsertArraysEquals(r, a, (byte)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length());
}
}
+
static boolean testIS_DEFAULT(byte a) {
return bits(a)==0;
}
@Test(dataProvider = "byteTestOpProvider")
Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j]));
}
}
}
}
+
static boolean testIS_NEGATIVE(byte a) {
return bits(a)<0;
}
@Test(dataProvider = "byteTestOpProvider")
}
}
}
}
-
-
-
@Test(dataProvider = "byteCompareOpProvider")
static void LTByte256VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
}
}
}
-
@Test(dataProvider = "byteCompareOpProvider")
static void ltByte256VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
}
}
}
-
@Test(dataProvider = "byteCompareOpProvider")
static void GTByte256VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
}
}
}
-
@Test(dataProvider = "byteCompareOpProvider")
static void EQByte256VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
}
}
}
-
@Test(dataProvider = "byteCompareOpProvider")
static void eqByte256VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
}
}
}
-
@Test(dataProvider = "byteCompareOpProvider")
static void NEByte256VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
}
}
}
-
@Test(dataProvider = "byteCompareOpProvider")
static void LEByte256VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
}
}
}
-
@Test(dataProvider = "byteCompareOpProvider")
static void GEByte256VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
}
}
}
-
-
@Test(dataProvider = "byteCompareOpProvider")
static void UNSIGNED_LTByte256VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
}
}
}
-
-
@Test(dataProvider = "byteCompareOpMaskProvider")
static void UNSIGNED_LTByte256VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
}
}
}
-
-
-
@Test(dataProvider = "byteCompareOpProvider")
static void UNSIGNED_GTByte256VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
}
}
}
-
-
@Test(dataProvider = "byteCompareOpMaskProvider")
static void UNSIGNED_GTByte256VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
}
}
}
-
-
-
@Test(dataProvider = "byteCompareOpProvider")
static void UNSIGNED_LEByte256VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
}
}
}
-
-
@Test(dataProvider = "byteCompareOpMaskProvider")
static void UNSIGNED_LEByte256VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
}
}
}
-
-
-
@Test(dataProvider = "byteCompareOpProvider")
static void UNSIGNED_GEByte256VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
}
}
}
-
-
@Test(dataProvider = "byteCompareOpMaskProvider")
static void UNSIGNED_GEByte256VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
}
}
}
-
-
@Test(dataProvider = "byteCompareOpProvider")
static void LTByte256VectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
}
}
}
-
@Test(dataProvider = "byteCompareOpMaskProvider")
static void LTByte256VectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa,
IntFunction<byte[]> fb, IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (byte)((long)b[i]));
}
}
}
-
@Test(dataProvider = "byteCompareOpMaskProvider")
static void LTByte256VectorTestsBroadcastLongMaskedSmokeTest(IntFunction<byte[]> fa,
IntFunction<byte[]> fb, IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);
}
}
}
-
@Test(dataProvider = "byteCompareOpMaskProvider")
static void EQByte256VectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa,
IntFunction<byte[]> fb, IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (byte)((long)b[i]));
}
}
}
-
@Test(dataProvider = "byteCompareOpMaskProvider")
static void EQByte256VectorTestsBroadcastLongMaskedSmokeTest(IntFunction<byte[]> fa,
IntFunction<byte[]> fb, IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] 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 = "byteUnaryOpMaskProvider")
+ static void compressByte256VectorTests(IntFunction<byte[]> fa,
+ IntFunction<boolean[]> fm) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ av.compress(vmask).intoArray(r, i);
+ }
+ }
+
+ assertcompressArraysEquals(r, a, mask, SPECIES.length());
+ }
+
+ @Test(dataProvider = "byteUnaryOpMaskProvider")
+ static void expandByte256VectorTests(IntFunction<byte[]> fa,
+ IntFunction<boolean[]> fm) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ av.expand(vmask).intoArray(r, i);
+ }
+ }
+
+ assertexpandArraysEquals(r, a, mask, SPECIES.length());
+ }
+
@Test(dataProvider = "byteUnaryOpProvider")
static void getByte256VectorTests(IntFunction<byte[]> fa) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
}
assertBroadcastArraysEquals(r, a);
}
-
-
-
-
@Test(dataProvider = "byteUnaryOpProvider")
static void ZeroByte256VectorTests(IntFunction<byte[]> fa) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = new byte[a.length];
}
Assert.assertEquals(a, r);
}
-
-
-
static byte[] sliceUnary(byte[] a, int origin, int idx) {
byte[] res = new byte[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, Byte256VectorTests::sliceUnary);
}
+
static byte[] sliceBinary(byte[] a, byte[] b, int origin, int idx) {
byte[] res = new byte[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, Byte256VectorTests::sliceBinary);
}
+
static byte[] slice(byte[] a, byte[] b, int origin, boolean[] mask, int idx) {
byte[] res = new byte[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] : (byte)0;
}
}
assertArraysEquals(r, a, b, origin, mask, Byte256VectorTests::slice);
}
+
static byte[] unsliceUnary(byte[] a, int origin, int idx) {
byte[] res = new byte[SPECIES.length()];
for (int i = 0, j = 0; i < SPECIES.length(); i++){
if(i < origin)
res[i] = (byte)0;
}
}
assertArraysEquals(r, a, origin, Byte256VectorTests::unsliceUnary);
}
+
static byte[] unsliceBinary(byte[] a, byte[] b, int origin, int part, int idx) {
byte[] res = new byte[SPECIES.length()];
for (int i = 0, j = 0; i < SPECIES.length(); i++){
if (part == 0) {
if (i < origin)
}
}
assertArraysEquals(r, a, b, origin, part, Byte256VectorTests::unsliceBinary);
}
+
static byte[] unslice(byte[] a, byte[] b, int origin, int part, boolean[] mask, int idx) {
byte[] res = new byte[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, Byte256VectorTests::unslice);
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
static byte BITWISE_BLEND(byte a, byte b, byte c) {
return (byte)((a&~(c))|(b&c));
}
static byte bitwiseBlend(byte a, byte b, byte c) {
return (byte)((a&~(c))|(b&c));
}
-
@Test(dataProvider = "byteTernaryOpProvider")
static void BITWISE_BLENDByte256VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<byte[]> fc) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
byte[] c = fc.apply(SPECIES.length());
}
assertArraysEquals(r, a, b, origin, part, mask, Byte256VectorTests::unslice);
}
static byte BITWISE_BLEND(byte a, byte b, byte c) {
return (byte)((a&~(c))|(b&c));
}
+
static byte bitwiseBlend(byte a, byte b, byte c) {
return (byte)((a&~(c))|(b&c));
}
@Test(dataProvider = "byteTernaryOpProvider")
static void BITWISE_BLENDByte256VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<byte[]> fc) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
byte[] c = fc.apply(SPECIES.length());
}
}
assertArraysEquals(r, a, b, c, Byte256VectorTests::BITWISE_BLEND);
}
+
@Test(dataProvider = "byteTernaryOpProvider")
static void bitwiseBlendByte256VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<byte[]> fc) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
byte[] c = fc.apply(SPECIES.length());
}
assertArraysEquals(r, a, b, c, Byte256VectorTests::bitwiseBlend);
}
-
@Test(dataProvider = "byteTernaryOpMaskProvider")
static void BITWISE_BLENDByte256VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<byte[]> fc, IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
assertArraysEquals(r, a, b, c, mask, Byte256VectorTests::BITWISE_BLEND);
}
-
-
-
@Test(dataProvider = "byteTernaryOpProvider")
static void BITWISE_BLENDByte256VectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<byte[]> fc) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
byte[] c = fc.apply(SPECIES.length());
ByteVector cv = ByteVector.fromArray(SPECIES, c, i);
av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i);
}
assertAltBroadcastArraysEquals(r, a, b, c, Byte256VectorTests::BITWISE_BLEND);
}
+
@Test(dataProvider = "byteTernaryOpProvider")
static void bitwiseBlendByte256VectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<byte[]> fc) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
byte[] c = fc.apply(SPECIES.length());
av.bitwiseBlend(b[i], cv).intoArray(r, i);
}
assertAltBroadcastArraysEquals(r, a, b, c, Byte256VectorTests::bitwiseBlend);
}
-
@Test(dataProvider = "byteTernaryOpMaskProvider")
static void BITWISE_BLENDByte256VectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<byte[]> fc, IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
assertAltBroadcastArraysEquals(r, a, b, c, mask, Byte256VectorTests::BITWISE_BLEND);
}
-
-
-
@Test(dataProvider = "byteTernaryOpProvider")
static void BITWISE_BLENDByte256VectorTestsDoubleBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<byte[]> fc) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
byte[] c = fc.apply(SPECIES.length());
av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i);
}
assertDoubleBroadcastArraysEquals(r, a, b, c, Byte256VectorTests::BITWISE_BLEND);
}
+
@Test(dataProvider = "byteTernaryOpProvider")
static void bitwiseBlendByte256VectorTestsDoubleBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<byte[]> fc) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
byte[] c = fc.apply(SPECIES.length());
}
assertDoubleBroadcastArraysEquals(r, a, b, c, Byte256VectorTests::bitwiseBlend);
}
-
@Test(dataProvider = "byteTernaryOpMaskProvider")
static void BITWISE_BLENDByte256VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<byte[]> fc, IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Byte256VectorTests::BITWISE_BLEND);
}
-
static byte NEG(byte a) {
return (byte)(-((byte)a));
}
static byte neg(byte a) {
}
assertArraysEquals(r, a, mask, Byte256VectorTests::ABS);
}
-
static byte NOT(byte a) {
return (byte)(~((byte)a));
}
static byte not(byte a) {
return (byte)(~((byte)a));
}
-
-
@Test(dataProvider = "byteUnaryOpProvider")
static void NOTByte256VectorTests(IntFunction<byte[]> fa) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
}
assertArraysEquals(r, a, Byte256VectorTests::not);
}
-
-
@Test(dataProvider = "byteUnaryOpMaskProvider")
static void NOTMaskedByte256VectorTests(IntFunction<byte[]> fa,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
}
assertArraysEquals(r, a, mask, Byte256VectorTests::NOT);
}
-
-
static byte ZOMO(byte a) {
return (byte)((a==0?0:-1));
}
-
-
@Test(dataProvider = "byteUnaryOpProvider")
static void ZOMOByte256VectorTests(IntFunction<byte[]> fa) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
}
assertArraysEquals(r, a, Byte256VectorTests::ZOMO);
}
-
-
@Test(dataProvider = "byteUnaryOpMaskProvider")
static void ZOMOMaskedByte256VectorTests(IntFunction<byte[]> fa,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
}
assertArraysEquals(r, a, mask, Byte256VectorTests::ZOMO);
}
+ static byte BIT_COUNT(byte a) {
+ return (byte)(Integer.bitCount((int)a & 0xFF));
+ }
+
+ @Test(dataProvider = "byteUnaryOpProvider")
+ static void BIT_COUNTByte256VectorTests(IntFunction<byte[]> fa) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ av.lanewise(VectorOperators.BIT_COUNT).intoArray(r, i);
+ }
+ }
+
+ assertArraysEquals(r, a, Byte256VectorTests::BIT_COUNT);
+ }
+
+ @Test(dataProvider = "byteUnaryOpMaskProvider")
+ static void BIT_COUNTMaskedByte256VectorTests(IntFunction<byte[]> fa,
+ IntFunction<boolean[]> fm) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ av.lanewise(VectorOperators.BIT_COUNT, vmask).intoArray(r, i);
+ }
+ }
+
+ assertArraysEquals(r, a, mask, Byte256VectorTests::BIT_COUNT);
+ }
+
+ static byte TRAILING_ZEROS_COUNT(byte a) {
+ return (byte)(TRAILING_ZEROS_COUNT_scalar(a));
+ }
+
+ @Test(dataProvider = "byteUnaryOpProvider")
+ static void TRAILING_ZEROS_COUNTByte256VectorTests(IntFunction<byte[]> fa) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ av.lanewise(VectorOperators.TRAILING_ZEROS_COUNT).intoArray(r, i);
+ }
+ }
+
+ assertArraysEquals(r, a, Byte256VectorTests::TRAILING_ZEROS_COUNT);
+ }
+
+ @Test(dataProvider = "byteUnaryOpMaskProvider")
+ static void TRAILING_ZEROS_COUNTMaskedByte256VectorTests(IntFunction<byte[]> fa,
+ IntFunction<boolean[]> fm) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ av.lanewise(VectorOperators.TRAILING_ZEROS_COUNT, vmask).intoArray(r, i);
+ }
+ }
+
+ assertArraysEquals(r, a, mask, Byte256VectorTests::TRAILING_ZEROS_COUNT);
+ }
+
+ static byte LEADING_ZEROS_COUNT(byte a) {
+ return (byte)(LEADING_ZEROS_COUNT_scalar(a));
+ }
+
+ @Test(dataProvider = "byteUnaryOpProvider")
+ static void LEADING_ZEROS_COUNTByte256VectorTests(IntFunction<byte[]> fa) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ av.lanewise(VectorOperators.LEADING_ZEROS_COUNT).intoArray(r, i);
+ }
+ }
+
+ assertArraysEquals(r, a, Byte256VectorTests::LEADING_ZEROS_COUNT);
+ }
+
+ @Test(dataProvider = "byteUnaryOpMaskProvider")
+ static void LEADING_ZEROS_COUNTMaskedByte256VectorTests(IntFunction<byte[]> fa,
+ IntFunction<boolean[]> fm) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ av.lanewise(VectorOperators.LEADING_ZEROS_COUNT, vmask).intoArray(r, i);
+ }
+ }
+
+ assertArraysEquals(r, a, mask, Byte256VectorTests::LEADING_ZEROS_COUNT);
+ }
+
+ static byte REVERSE(byte a) {
+ return (byte)(REVERSE_scalar(a));
+ }
+
+ @Test(dataProvider = "byteUnaryOpProvider")
+ static void REVERSEByte256VectorTests(IntFunction<byte[]> fa) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ av.lanewise(VectorOperators.REVERSE).intoArray(r, i);
+ }
+ }
+
+ assertArraysEquals(r, a, Byte256VectorTests::REVERSE);
+ }
+
+ @Test(dataProvider = "byteUnaryOpMaskProvider")
+ static void REVERSEMaskedByte256VectorTests(IntFunction<byte[]> fa,
+ IntFunction<boolean[]> fm) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ av.lanewise(VectorOperators.REVERSE, vmask).intoArray(r, i);
+ }
+ }
+
+ assertArraysEquals(r, a, mask, Byte256VectorTests::REVERSE);
+ }
+
+ static byte REVERSE_BYTES(byte a) {
+ return (byte)(a);
+ }
+ @Test(dataProvider = "byteUnaryOpProvider")
+ static void REVERSE_BYTESByte256VectorTests(IntFunction<byte[]> fa) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ av.lanewise(VectorOperators.REVERSE_BYTES).intoArray(r, i);
+ }
+ }
+ assertArraysEquals(r, a, Byte256VectorTests::REVERSE_BYTES);
+ }
+
+ @Test(dataProvider = "byteUnaryOpMaskProvider")
+ static void REVERSE_BYTESMaskedByte256VectorTests(IntFunction<byte[]> fa,
+ IntFunction<boolean[]> fm) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ av.lanewise(VectorOperators.REVERSE_BYTES, vmask).intoArray(r, i);
+ }
+ }
+
+ assertArraysEquals(r, a, mask, Byte256VectorTests::REVERSE_BYTES);
+ }
@Test(dataProvider = "byteCompareOpProvider")
static void ltByte256VectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
}
assertMaskReductionArraysEquals(r, a, Byte256VectorTests::maskFirstTrue);
}
+ @Test(dataProvider = "maskProvider")
+ static void maskCompressByte256VectorTestsSmokeTest(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 indexInRangeLongByte256VectorTestsSmokeTest(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 loopBoundLongByte256VectorTestsSmokeTest(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 ElementSizeByte256VectorTestsSmokeTest() {
ByteVector av = ByteVector.zero(SPECIES);
int elsize = av.elementSize();
Assert.assertEquals(elsize, Byte.SIZE);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
Assert.assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length()));
}
}
}
-
< prev index next >