< prev index next >
test/jdk/jdk/incubator/vector/Byte64VectorTests.java
Print this page
*** 239,248 ****
--- 239,260 ----
} catch (AssertionError e) {
Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i);
}
}
+ static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) {
+ int i = 0;
+ try {
+ for (; i < a.length; i++) {
+ Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]));
+ }
+ } catch (AssertionError e) {
+ Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]),
+ "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i);
+ }
+ }
+
static void assertArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinOp f) {
assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f));
}
static void assertArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinMaskOp f) {
*** 254,263 ****
--- 266,293 ----
} catch (AssertionError err) {
Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]);
}
}
+ static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinOp f) {
+ assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f));
+ }
+
+ static void assertBroadcastArraysEquals(byte[] a, byte[] b, byte[] r, boolean[] mask, FBinMaskOp f) {
+ int i = 0;
+ try {
+ for (; i < a.length; i++) {
+ Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]));
+ }
+ } catch (AssertionError err) {
+ Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
+ mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] +
+ ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +
+ mask[i % SPECIES.length()]);
+ }
+ }
+
static void assertShiftArraysEquals(byte[] a, byte[] b, byte[] r, FBinOp f) {
int i = 0;
int j = 0;
try {
for (; j < a.length; j += SPECIES.length()) {
*** 1367,1376 ****
--- 1397,1426 ----
}
}
assertArraysEquals(a, b, r, Byte64VectorTests::OR);
}
+ static byte or(byte a, byte b) {
+ return (byte)(a | b);
+ }
+
+ @Test(dataProvider = "byteBinaryOpProvider")
+ static void orByte64VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] b = fb.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);
+ ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
+ av.or(bv).intoArray(r, i);
+ }
+ }
+
+ assertArraysEquals(a, b, r, Byte64VectorTests::or);
+ }
@Test(dataProvider = "byteBinaryOpMaskProvider")
static void ORByte64VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
*** 1435,1444 ****
--- 1485,1677 ----
assertArraysEquals(a, b, r, mask, Byte64VectorTests::XOR);
}
+ @Test(dataProvider = "byteBinaryOpProvider")
+ static void addByte64VectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] b = fb.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ av.add(b[i]).intoArray(r, i);
+ }
+
+ assertBroadcastArraysEquals(a, b, r, Byte64VectorTests::add);
+ }
+
+ @Test(dataProvider = "byteBinaryOpMaskProvider")
+ static void addByte64VectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
+ IntFunction<boolean[]> fm) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] b = fb.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 i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ av.add(b[i], vmask).intoArray(r, i);
+ }
+
+ assertBroadcastArraysEquals(a, b, r, mask, Byte64VectorTests::add);
+ }
+
+ @Test(dataProvider = "byteBinaryOpProvider")
+ static void subByte64VectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] b = fb.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ av.sub(b[i]).intoArray(r, i);
+ }
+
+ assertBroadcastArraysEquals(a, b, r, Byte64VectorTests::sub);
+ }
+
+ @Test(dataProvider = "byteBinaryOpMaskProvider")
+ static void subByte64VectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
+ IntFunction<boolean[]> fm) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] b = fb.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 i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ av.sub(b[i], vmask).intoArray(r, i);
+ }
+
+ assertBroadcastArraysEquals(a, b, r, mask, Byte64VectorTests::sub);
+ }
+
+ @Test(dataProvider = "byteBinaryOpProvider")
+ static void mulByte64VectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] b = fb.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ av.mul(b[i]).intoArray(r, i);
+ }
+
+ assertBroadcastArraysEquals(a, b, r, Byte64VectorTests::mul);
+ }
+
+ @Test(dataProvider = "byteBinaryOpMaskProvider")
+ static void mulByte64VectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
+ IntFunction<boolean[]> fm) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] b = fb.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 i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ av.mul(b[i], vmask).intoArray(r, i);
+ }
+
+ assertBroadcastArraysEquals(a, b, r, mask, Byte64VectorTests::mul);
+ }
+
+
+
+
+ @Test(dataProvider = "byteBinaryOpProvider")
+ static void divByte64VectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] b = fb.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+
+ replaceZero(b, (byte) 1);
+
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ av.div(b[i]).intoArray(r, i);
+ }
+
+ assertBroadcastArraysEquals(a, b, r, Byte64VectorTests::div);
+ }
+
+
+
+ @Test(dataProvider = "byteBinaryOpMaskProvider")
+ static void divByte64VectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
+ IntFunction<boolean[]> fm) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] b = fb.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
+
+ replaceZero(b, (byte) 1);
+
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ av.div(b[i], vmask).intoArray(r, i);
+ }
+
+ assertBroadcastArraysEquals(a, b, r, mask, Byte64VectorTests::div);
+ }
+
+
+
+ @Test(dataProvider = "byteBinaryOpProvider")
+ static void ORByte64VectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] b = fb.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i);
+ }
+
+ assertBroadcastArraysEquals(a, b, r, Byte64VectorTests::OR);
+ }
+
+ @Test(dataProvider = "byteBinaryOpProvider")
+ static void orByte64VectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] b = fb.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ av.or(b[i]).intoArray(r, i);
+ }
+
+ assertBroadcastArraysEquals(a, b, r, Byte64VectorTests::or);
+ }
+
+
+
+ @Test(dataProvider = "byteBinaryOpMaskProvider")
+ static void ORByte64VectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
+ IntFunction<boolean[]> fm) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] b = fb.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 i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i);
+ }
+
+ assertBroadcastArraysEquals(a, b, r, mask, Byte64VectorTests::OR);
+ }
+
+
static byte LSHL(byte a, byte b) {
return (byte)((a << (b & 0x7)));
}
*** 1797,1806 ****
--- 2030,2095 ----
}
assertArraysEquals(a, b, r, Byte64VectorTests::max);
}
+ @Test(dataProvider = "byteBinaryOpProvider")
+ static void MINByte64VectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] b = fb.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i);
+ }
+
+ assertBroadcastArraysEquals(a, b, r, Byte64VectorTests::MIN);
+ }
+
+ @Test(dataProvider = "byteBinaryOpProvider")
+ static void minByte64VectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] b = fb.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ av.min(b[i]).intoArray(r, i);
+ }
+
+ assertBroadcastArraysEquals(a, b, r, Byte64VectorTests::min);
+ }
+
+ @Test(dataProvider = "byteBinaryOpProvider")
+ static void MAXByte64VectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] b = fb.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i);
+ }
+
+ assertBroadcastArraysEquals(a, b, r, Byte64VectorTests::MAX);
+ }
+
+ @Test(dataProvider = "byteBinaryOpProvider")
+ static void maxByte64VectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
+ byte[] a = fa.apply(SPECIES.length());
+ byte[] b = fb.apply(SPECIES.length());
+ byte[] r = fr.apply(SPECIES.length());
+
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ ByteVector av = ByteVector.fromArray(SPECIES, a, i);
+ av.max(b[i]).intoArray(r, i);
+ }
+
+ assertBroadcastArraysEquals(a, b, r, Byte64VectorTests::max);
+ }
+
static byte AND(byte[] a, int idx) {
byte res = -1;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res &= a[i];
}
*** 3241,3250 ****
--- 3530,3543 ----
static byte NEG(byte a) {
return (byte)(-((byte)a));
}
+ static byte neg(byte a) {
+ return (byte)(-((byte)a));
+ }
+
@Test(dataProvider = "byteUnaryOpProvider")
static void NEGByte64VectorTests(IntFunction<byte[]> fa) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
*** 3256,3265 ****
--- 3549,3573 ----
}
assertArraysEquals(a, r, Byte64VectorTests::NEG);
}
+ @Test(dataProvider = "byteUnaryOpProvider")
+ static void negByte64VectorTests(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.neg().intoArray(r, i);
+ }
+ }
+
+ assertArraysEquals(a, r, Byte64VectorTests::neg);
+ }
+
@Test(dataProvider = "byteUnaryOpMaskProvider")
static void NEGMaskedByte64VectorTests(IntFunction<byte[]> fa,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
*** 3335,3344 ****
--- 3643,3656 ----
static byte NOT(byte a) {
return (byte)(~((byte)a));
}
+ static byte not(byte a) {
+ return (byte)(~((byte)a));
+ }
+
@Test(dataProvider = "byteUnaryOpProvider")
static void NOTByte64VectorTests(IntFunction<byte[]> fa) {
byte[] a = fa.apply(SPECIES.length());
*** 3352,3361 ****
--- 3664,3688 ----
}
assertArraysEquals(a, r, Byte64VectorTests::NOT);
}
+ @Test(dataProvider = "byteUnaryOpProvider")
+ static void notByte64VectorTests(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.not().intoArray(r, i);
+ }
+ }
+
+ assertArraysEquals(a, r, Byte64VectorTests::not);
+ }
+
@Test(dataProvider = "byteUnaryOpMaskProvider")
static void NOTMaskedByte64VectorTests(IntFunction<byte[]> fa,
IntFunction<boolean[]> fm) {
< prev index next >