--- old/test/jdk/jdk/incubator/vector/Byte128VectorTests.java 2020-05-28 14:30:37.500740214 -0700 +++ new/test/jdk/jdk/incubator/vector/Byte128VectorTests.java 2020-05-28 14:30:37.324740213 -0700 @@ -241,6 +241,18 @@ } } + 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)); } @@ -256,6 +268,24 @@ } } + 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; @@ -1369,6 +1399,26 @@ assertArraysEquals(a, b, r, Byte128VectorTests::OR); } + static byte or(byte a, byte b) { + return (byte)(a | b); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void orByte128VectorTests(IntFunction fa, IntFunction 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, Byte128VectorTests::or); + } @@ -1437,6 +1487,189 @@ } + @Test(dataProvider = "byteBinaryOpProvider") + static void addByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, Byte128VectorTests::add); + } + + @Test(dataProvider = "byteBinaryOpMaskProvider") + static void addByte128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction 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 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, Byte128VectorTests::add); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void subByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, Byte128VectorTests::sub); + } + + @Test(dataProvider = "byteBinaryOpMaskProvider") + static void subByte128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction 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 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, Byte128VectorTests::sub); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void mulByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, Byte128VectorTests::mul); + } + + @Test(dataProvider = "byteBinaryOpMaskProvider") + static void mulByte128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction 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 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, Byte128VectorTests::mul); + } + + + + + @Test(dataProvider = "byteBinaryOpProvider") + static void divByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, Byte128VectorTests::div); + } + + + + @Test(dataProvider = "byteBinaryOpMaskProvider") + static void divByte128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction 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 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, Byte128VectorTests::div); + } + + + + @Test(dataProvider = "byteBinaryOpProvider") + static void ORByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, Byte128VectorTests::OR); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void orByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, Byte128VectorTests::or); + } + + + + @Test(dataProvider = "byteBinaryOpMaskProvider") + static void ORByte128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction 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 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, Byte128VectorTests::OR); + } + + static byte LSHL(byte a, byte b) { @@ -1799,6 +2032,62 @@ assertArraysEquals(a, b, r, Byte128VectorTests::max); } + @Test(dataProvider = "byteBinaryOpProvider") + static void MINByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, Byte128VectorTests::MIN); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void minByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, Byte128VectorTests::min); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void MAXByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, Byte128VectorTests::MAX); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void maxByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, Byte128VectorTests::max); + } + static byte AND(byte[] a, int idx) { byte res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { @@ -3243,6 +3532,10 @@ return (byte)(-((byte)a)); } + static byte neg(byte a) { + return (byte)(-((byte)a)); + } + @Test(dataProvider = "byteUnaryOpProvider") static void NEGByte128VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); @@ -3258,6 +3551,21 @@ assertArraysEquals(a, r, Byte128VectorTests::NEG); } + @Test(dataProvider = "byteUnaryOpProvider") + static void negByte128VectorTests(IntFunction 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, Byte128VectorTests::neg); + } + @Test(dataProvider = "byteUnaryOpMaskProvider") static void NEGMaskedByte128VectorTests(IntFunction fa, IntFunction fm) { @@ -3337,6 +3645,10 @@ return (byte)(~((byte)a)); } + static byte not(byte a) { + return (byte)(~((byte)a)); + } + @Test(dataProvider = "byteUnaryOpProvider") @@ -3354,6 +3666,21 @@ assertArraysEquals(a, r, Byte128VectorTests::NOT); } + @Test(dataProvider = "byteUnaryOpProvider") + static void notByte128VectorTests(IntFunction 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, Byte128VectorTests::not); + } + @Test(dataProvider = "byteUnaryOpMaskProvider") --- old/test/jdk/jdk/incubator/vector/Byte256VectorTests.java 2020-05-28 14:30:37.868740214 -0700 +++ new/test/jdk/jdk/incubator/vector/Byte256VectorTests.java 2020-05-28 14:30:37.692740214 -0700 @@ -241,6 +241,18 @@ } } + 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)); } @@ -256,6 +268,24 @@ } } + 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; @@ -1369,6 +1399,26 @@ assertArraysEquals(a, b, r, Byte256VectorTests::OR); } + static byte or(byte a, byte b) { + return (byte)(a | b); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void orByte256VectorTests(IntFunction fa, IntFunction 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, Byte256VectorTests::or); + } @@ -1437,6 +1487,189 @@ } + @Test(dataProvider = "byteBinaryOpProvider") + static void addByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, Byte256VectorTests::add); + } + + @Test(dataProvider = "byteBinaryOpMaskProvider") + static void addByte256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction 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 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, Byte256VectorTests::add); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void subByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, Byte256VectorTests::sub); + } + + @Test(dataProvider = "byteBinaryOpMaskProvider") + static void subByte256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction 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 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, Byte256VectorTests::sub); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void mulByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, Byte256VectorTests::mul); + } + + @Test(dataProvider = "byteBinaryOpMaskProvider") + static void mulByte256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction 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 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, Byte256VectorTests::mul); + } + + + + + @Test(dataProvider = "byteBinaryOpProvider") + static void divByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, Byte256VectorTests::div); + } + + + + @Test(dataProvider = "byteBinaryOpMaskProvider") + static void divByte256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction 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 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, Byte256VectorTests::div); + } + + + + @Test(dataProvider = "byteBinaryOpProvider") + static void ORByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, Byte256VectorTests::OR); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void orByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, Byte256VectorTests::or); + } + + + + @Test(dataProvider = "byteBinaryOpMaskProvider") + static void ORByte256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction 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 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, Byte256VectorTests::OR); + } + + static byte LSHL(byte a, byte b) { @@ -1799,6 +2032,62 @@ assertArraysEquals(a, b, r, Byte256VectorTests::max); } + @Test(dataProvider = "byteBinaryOpProvider") + static void MINByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, Byte256VectorTests::MIN); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void minByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, Byte256VectorTests::min); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void MAXByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, Byte256VectorTests::MAX); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void maxByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, Byte256VectorTests::max); + } + static byte AND(byte[] a, int idx) { byte res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { @@ -3243,6 +3532,10 @@ return (byte)(-((byte)a)); } + static byte neg(byte a) { + return (byte)(-((byte)a)); + } + @Test(dataProvider = "byteUnaryOpProvider") static void NEGByte256VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); @@ -3258,6 +3551,21 @@ assertArraysEquals(a, r, Byte256VectorTests::NEG); } + @Test(dataProvider = "byteUnaryOpProvider") + static void negByte256VectorTests(IntFunction 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, Byte256VectorTests::neg); + } + @Test(dataProvider = "byteUnaryOpMaskProvider") static void NEGMaskedByte256VectorTests(IntFunction fa, IntFunction fm) { @@ -3337,6 +3645,10 @@ return (byte)(~((byte)a)); } + static byte not(byte a) { + return (byte)(~((byte)a)); + } + @Test(dataProvider = "byteUnaryOpProvider") @@ -3354,6 +3666,21 @@ assertArraysEquals(a, r, Byte256VectorTests::NOT); } + @Test(dataProvider = "byteUnaryOpProvider") + static void notByte256VectorTests(IntFunction 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, Byte256VectorTests::not); + } + @Test(dataProvider = "byteUnaryOpMaskProvider") --- old/test/jdk/jdk/incubator/vector/Byte512VectorTests.java 2020-05-28 14:30:38.240740214 -0700 +++ new/test/jdk/jdk/incubator/vector/Byte512VectorTests.java 2020-05-28 14:30:38.064740214 -0700 @@ -241,6 +241,18 @@ } } + 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)); } @@ -256,6 +268,24 @@ } } + 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; @@ -1369,6 +1399,26 @@ assertArraysEquals(a, b, r, Byte512VectorTests::OR); } + static byte or(byte a, byte b) { + return (byte)(a | b); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void orByte512VectorTests(IntFunction fa, IntFunction 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, Byte512VectorTests::or); + } @@ -1437,6 +1487,189 @@ } + @Test(dataProvider = "byteBinaryOpProvider") + static void addByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, Byte512VectorTests::add); + } + + @Test(dataProvider = "byteBinaryOpMaskProvider") + static void addByte512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction 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 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, Byte512VectorTests::add); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void subByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, Byte512VectorTests::sub); + } + + @Test(dataProvider = "byteBinaryOpMaskProvider") + static void subByte512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction 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 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, Byte512VectorTests::sub); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void mulByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, Byte512VectorTests::mul); + } + + @Test(dataProvider = "byteBinaryOpMaskProvider") + static void mulByte512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction 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 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, Byte512VectorTests::mul); + } + + + + + @Test(dataProvider = "byteBinaryOpProvider") + static void divByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, Byte512VectorTests::div); + } + + + + @Test(dataProvider = "byteBinaryOpMaskProvider") + static void divByte512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction 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 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, Byte512VectorTests::div); + } + + + + @Test(dataProvider = "byteBinaryOpProvider") + static void ORByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, Byte512VectorTests::OR); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void orByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, Byte512VectorTests::or); + } + + + + @Test(dataProvider = "byteBinaryOpMaskProvider") + static void ORByte512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction 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 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, Byte512VectorTests::OR); + } + + static byte LSHL(byte a, byte b) { @@ -1799,6 +2032,62 @@ assertArraysEquals(a, b, r, Byte512VectorTests::max); } + @Test(dataProvider = "byteBinaryOpProvider") + static void MINByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, Byte512VectorTests::MIN); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void minByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, Byte512VectorTests::min); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void MAXByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, Byte512VectorTests::MAX); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void maxByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, Byte512VectorTests::max); + } + static byte AND(byte[] a, int idx) { byte res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { @@ -3243,6 +3532,10 @@ return (byte)(-((byte)a)); } + static byte neg(byte a) { + return (byte)(-((byte)a)); + } + @Test(dataProvider = "byteUnaryOpProvider") static void NEGByte512VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); @@ -3258,6 +3551,21 @@ assertArraysEquals(a, r, Byte512VectorTests::NEG); } + @Test(dataProvider = "byteUnaryOpProvider") + static void negByte512VectorTests(IntFunction 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, Byte512VectorTests::neg); + } + @Test(dataProvider = "byteUnaryOpMaskProvider") static void NEGMaskedByte512VectorTests(IntFunction fa, IntFunction fm) { @@ -3337,6 +3645,10 @@ return (byte)(~((byte)a)); } + static byte not(byte a) { + return (byte)(~((byte)a)); + } + @Test(dataProvider = "byteUnaryOpProvider") @@ -3354,6 +3666,21 @@ assertArraysEquals(a, r, Byte512VectorTests::NOT); } + @Test(dataProvider = "byteUnaryOpProvider") + static void notByte512VectorTests(IntFunction 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, Byte512VectorTests::not); + } + @Test(dataProvider = "byteUnaryOpMaskProvider") --- old/test/jdk/jdk/incubator/vector/Byte64VectorTests.java 2020-05-28 14:30:38.612740215 -0700 +++ new/test/jdk/jdk/incubator/vector/Byte64VectorTests.java 2020-05-28 14:30:38.432740215 -0700 @@ -241,6 +241,18 @@ } } + 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)); } @@ -256,6 +268,24 @@ } } + 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; @@ -1369,6 +1399,26 @@ assertArraysEquals(a, b, r, Byte64VectorTests::OR); } + static byte or(byte a, byte b) { + return (byte)(a | b); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void orByte64VectorTests(IntFunction fa, IntFunction 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); + } @@ -1437,6 +1487,189 @@ } + @Test(dataProvider = "byteBinaryOpProvider") + static void addByte64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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 fa, IntFunction fb, + IntFunction 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 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 fa, IntFunction 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 fa, IntFunction fb, + IntFunction 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 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 fa, IntFunction 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 fa, IntFunction fb, + IntFunction 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 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 fa, IntFunction 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 fa, IntFunction fb, + IntFunction 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 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 fa, IntFunction 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 fa, IntFunction 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 fa, IntFunction fb, + IntFunction 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 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) { @@ -1799,6 +2032,62 @@ assertArraysEquals(a, b, r, Byte64VectorTests::max); } + @Test(dataProvider = "byteBinaryOpProvider") + static void MINByte64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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 fa, IntFunction 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 fa, IntFunction 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 fa, IntFunction 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++) { @@ -3243,6 +3532,10 @@ return (byte)(-((byte)a)); } + static byte neg(byte a) { + return (byte)(-((byte)a)); + } + @Test(dataProvider = "byteUnaryOpProvider") static void NEGByte64VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); @@ -3258,6 +3551,21 @@ assertArraysEquals(a, r, Byte64VectorTests::NEG); } + @Test(dataProvider = "byteUnaryOpProvider") + static void negByte64VectorTests(IntFunction 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 fa, IntFunction fm) { @@ -3337,6 +3645,10 @@ return (byte)(~((byte)a)); } + static byte not(byte a) { + return (byte)(~((byte)a)); + } + @Test(dataProvider = "byteUnaryOpProvider") @@ -3354,6 +3666,21 @@ assertArraysEquals(a, r, Byte64VectorTests::NOT); } + @Test(dataProvider = "byteUnaryOpProvider") + static void notByte64VectorTests(IntFunction 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") --- old/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java 2020-05-28 14:30:38.980740215 -0700 +++ new/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java 2020-05-28 14:30:38.804740215 -0700 @@ -246,6 +246,18 @@ } } + 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)); } @@ -261,6 +273,24 @@ } } + 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; @@ -1374,6 +1404,26 @@ assertArraysEquals(a, b, r, ByteMaxVectorTests::OR); } + static byte or(byte a, byte b) { + return (byte)(a | b); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void orByteMaxVectorTests(IntFunction fa, IntFunction 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, ByteMaxVectorTests::or); + } @@ -1442,6 +1492,189 @@ } + @Test(dataProvider = "byteBinaryOpProvider") + static void addByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, ByteMaxVectorTests::add); + } + + @Test(dataProvider = "byteBinaryOpMaskProvider") + static void addByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction 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 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, ByteMaxVectorTests::add); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void subByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, ByteMaxVectorTests::sub); + } + + @Test(dataProvider = "byteBinaryOpMaskProvider") + static void subByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction 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 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, ByteMaxVectorTests::sub); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void mulByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, ByteMaxVectorTests::mul); + } + + @Test(dataProvider = "byteBinaryOpMaskProvider") + static void mulByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction 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 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, ByteMaxVectorTests::mul); + } + + + + + @Test(dataProvider = "byteBinaryOpProvider") + static void divByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, ByteMaxVectorTests::div); + } + + + + @Test(dataProvider = "byteBinaryOpMaskProvider") + static void divByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction 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 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, ByteMaxVectorTests::div); + } + + + + @Test(dataProvider = "byteBinaryOpProvider") + static void ORByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, ByteMaxVectorTests::OR); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void orByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, ByteMaxVectorTests::or); + } + + + + @Test(dataProvider = "byteBinaryOpMaskProvider") + static void ORByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction 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 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, ByteMaxVectorTests::OR); + } + + static byte LSHL(byte a, byte b) { @@ -1804,6 +2037,62 @@ assertArraysEquals(a, b, r, ByteMaxVectorTests::max); } + @Test(dataProvider = "byteBinaryOpProvider") + static void MINByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, ByteMaxVectorTests::MIN); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void minByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, ByteMaxVectorTests::min); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void MAXByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, ByteMaxVectorTests::MAX); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void maxByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction 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, ByteMaxVectorTests::max); + } + static byte AND(byte[] a, int idx) { byte res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { @@ -3248,6 +3537,10 @@ return (byte)(-((byte)a)); } + static byte neg(byte a) { + return (byte)(-((byte)a)); + } + @Test(dataProvider = "byteUnaryOpProvider") static void NEGByteMaxVectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); @@ -3263,6 +3556,21 @@ assertArraysEquals(a, r, ByteMaxVectorTests::NEG); } + @Test(dataProvider = "byteUnaryOpProvider") + static void negByteMaxVectorTests(IntFunction 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, ByteMaxVectorTests::neg); + } + @Test(dataProvider = "byteUnaryOpMaskProvider") static void NEGMaskedByteMaxVectorTests(IntFunction fa, IntFunction fm) { @@ -3342,6 +3650,10 @@ return (byte)(~((byte)a)); } + static byte not(byte a) { + return (byte)(~((byte)a)); + } + @Test(dataProvider = "byteUnaryOpProvider") @@ -3359,6 +3671,21 @@ assertArraysEquals(a, r, ByteMaxVectorTests::NOT); } + @Test(dataProvider = "byteUnaryOpProvider") + static void notByteMaxVectorTests(IntFunction 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, ByteMaxVectorTests::not); + } + @Test(dataProvider = "byteUnaryOpMaskProvider") --- old/test/jdk/jdk/incubator/vector/Double128VectorTests.java 2020-05-28 14:30:39.348740215 -0700 +++ new/test/jdk/jdk/incubator/vector/Double128VectorTests.java 2020-05-28 14:30:39.176740215 -0700 @@ -241,6 +241,18 @@ } } + static void assertBroadcastArraysEquals(double[] a, double[] b, double[] 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(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) { assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); } @@ -256,6 +268,24 @@ } } + static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals(double[] a, double[] b, double[] 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(double[] a, double[] b, double[] r, FBinOp f) { int i = 0; int j = 0; @@ -1265,6 +1295,138 @@ + @Test(dataProvider = "doubleBinaryOpProvider") + static void addDouble128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.add(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Double128VectorTests::add); + } + + @Test(dataProvider = "doubleBinaryOpMaskProvider") + static void addDouble128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.add(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Double128VectorTests::add); + } + + @Test(dataProvider = "doubleBinaryOpProvider") + static void subDouble128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.sub(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Double128VectorTests::sub); + } + + @Test(dataProvider = "doubleBinaryOpMaskProvider") + static void subDouble128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.sub(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Double128VectorTests::sub); + } + + @Test(dataProvider = "doubleBinaryOpProvider") + static void mulDouble128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.mul(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Double128VectorTests::mul); + } + + @Test(dataProvider = "doubleBinaryOpMaskProvider") + static void mulDouble128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.mul(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Double128VectorTests::mul); + } + + + @Test(dataProvider = "doubleBinaryOpProvider") + static void divDouble128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.div(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Double128VectorTests::div); + } + + + + @Test(dataProvider = "doubleBinaryOpMaskProvider") + static void divDouble128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.div(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Double128VectorTests::div); + } + + + + + + @@ -1381,6 +1543,62 @@ assertArraysEquals(a, b, r, Double128VectorTests::max); } + @Test(dataProvider = "doubleBinaryOpProvider") + static void MINDouble128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Double128VectorTests::MIN); + } + + @Test(dataProvider = "doubleBinaryOpProvider") + static void minDouble128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.min(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Double128VectorTests::min); + } + + @Test(dataProvider = "doubleBinaryOpProvider") + static void MAXDouble128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Double128VectorTests::MAX); + } + + @Test(dataProvider = "doubleBinaryOpProvider") + static void maxDouble128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.max(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Double128VectorTests::max); + } + @@ -2995,6 +3213,10 @@ return (double)(-((double)a)); } + static double neg(double a) { + return (double)(-((double)a)); + } + @Test(dataProvider = "doubleUnaryOpProvider") static void NEGDouble128VectorTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); @@ -3010,6 +3232,21 @@ assertArraysEquals(a, r, Double128VectorTests::NEG); } + @Test(dataProvider = "doubleUnaryOpProvider") + static void negDouble128VectorTests(IntFunction fa) { + double[] a = fa.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.neg().intoArray(r, i); + } + } + + assertArraysEquals(a, r, Double128VectorTests::neg); + } + @Test(dataProvider = "doubleUnaryOpMaskProvider") static void NEGMaskedDouble128VectorTests(IntFunction fa, IntFunction fm) { --- old/test/jdk/jdk/incubator/vector/Double256VectorTests.java 2020-05-28 14:30:39.712740216 -0700 +++ new/test/jdk/jdk/incubator/vector/Double256VectorTests.java 2020-05-28 14:30:39.536740216 -0700 @@ -241,6 +241,18 @@ } } + static void assertBroadcastArraysEquals(double[] a, double[] b, double[] 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(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) { assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); } @@ -256,6 +268,24 @@ } } + static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals(double[] a, double[] b, double[] 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(double[] a, double[] b, double[] r, FBinOp f) { int i = 0; int j = 0; @@ -1265,6 +1295,138 @@ + @Test(dataProvider = "doubleBinaryOpProvider") + static void addDouble256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.add(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Double256VectorTests::add); + } + + @Test(dataProvider = "doubleBinaryOpMaskProvider") + static void addDouble256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.add(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Double256VectorTests::add); + } + + @Test(dataProvider = "doubleBinaryOpProvider") + static void subDouble256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.sub(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Double256VectorTests::sub); + } + + @Test(dataProvider = "doubleBinaryOpMaskProvider") + static void subDouble256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.sub(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Double256VectorTests::sub); + } + + @Test(dataProvider = "doubleBinaryOpProvider") + static void mulDouble256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.mul(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Double256VectorTests::mul); + } + + @Test(dataProvider = "doubleBinaryOpMaskProvider") + static void mulDouble256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.mul(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Double256VectorTests::mul); + } + + + @Test(dataProvider = "doubleBinaryOpProvider") + static void divDouble256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.div(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Double256VectorTests::div); + } + + + + @Test(dataProvider = "doubleBinaryOpMaskProvider") + static void divDouble256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.div(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Double256VectorTests::div); + } + + + + + + @@ -1381,6 +1543,62 @@ assertArraysEquals(a, b, r, Double256VectorTests::max); } + @Test(dataProvider = "doubleBinaryOpProvider") + static void MINDouble256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Double256VectorTests::MIN); + } + + @Test(dataProvider = "doubleBinaryOpProvider") + static void minDouble256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.min(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Double256VectorTests::min); + } + + @Test(dataProvider = "doubleBinaryOpProvider") + static void MAXDouble256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Double256VectorTests::MAX); + } + + @Test(dataProvider = "doubleBinaryOpProvider") + static void maxDouble256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.max(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Double256VectorTests::max); + } + @@ -2995,6 +3213,10 @@ return (double)(-((double)a)); } + static double neg(double a) { + return (double)(-((double)a)); + } + @Test(dataProvider = "doubleUnaryOpProvider") static void NEGDouble256VectorTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); @@ -3010,6 +3232,21 @@ assertArraysEquals(a, r, Double256VectorTests::NEG); } + @Test(dataProvider = "doubleUnaryOpProvider") + static void negDouble256VectorTests(IntFunction fa) { + double[] a = fa.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.neg().intoArray(r, i); + } + } + + assertArraysEquals(a, r, Double256VectorTests::neg); + } + @Test(dataProvider = "doubleUnaryOpMaskProvider") static void NEGMaskedDouble256VectorTests(IntFunction fa, IntFunction fm) { --- old/test/jdk/jdk/incubator/vector/Double512VectorTests.java 2020-05-28 14:30:40.080740216 -0700 +++ new/test/jdk/jdk/incubator/vector/Double512VectorTests.java 2020-05-28 14:30:39.900740216 -0700 @@ -241,6 +241,18 @@ } } + static void assertBroadcastArraysEquals(double[] a, double[] b, double[] 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(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) { assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); } @@ -256,6 +268,24 @@ } } + static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals(double[] a, double[] b, double[] 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(double[] a, double[] b, double[] r, FBinOp f) { int i = 0; int j = 0; @@ -1265,6 +1295,138 @@ + @Test(dataProvider = "doubleBinaryOpProvider") + static void addDouble512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.add(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Double512VectorTests::add); + } + + @Test(dataProvider = "doubleBinaryOpMaskProvider") + static void addDouble512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.add(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Double512VectorTests::add); + } + + @Test(dataProvider = "doubleBinaryOpProvider") + static void subDouble512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.sub(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Double512VectorTests::sub); + } + + @Test(dataProvider = "doubleBinaryOpMaskProvider") + static void subDouble512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.sub(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Double512VectorTests::sub); + } + + @Test(dataProvider = "doubleBinaryOpProvider") + static void mulDouble512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.mul(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Double512VectorTests::mul); + } + + @Test(dataProvider = "doubleBinaryOpMaskProvider") + static void mulDouble512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.mul(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Double512VectorTests::mul); + } + + + @Test(dataProvider = "doubleBinaryOpProvider") + static void divDouble512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.div(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Double512VectorTests::div); + } + + + + @Test(dataProvider = "doubleBinaryOpMaskProvider") + static void divDouble512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.div(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Double512VectorTests::div); + } + + + + + + @@ -1381,6 +1543,62 @@ assertArraysEquals(a, b, r, Double512VectorTests::max); } + @Test(dataProvider = "doubleBinaryOpProvider") + static void MINDouble512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Double512VectorTests::MIN); + } + + @Test(dataProvider = "doubleBinaryOpProvider") + static void minDouble512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.min(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Double512VectorTests::min); + } + + @Test(dataProvider = "doubleBinaryOpProvider") + static void MAXDouble512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Double512VectorTests::MAX); + } + + @Test(dataProvider = "doubleBinaryOpProvider") + static void maxDouble512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.max(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Double512VectorTests::max); + } + @@ -2995,6 +3213,10 @@ return (double)(-((double)a)); } + static double neg(double a) { + return (double)(-((double)a)); + } + @Test(dataProvider = "doubleUnaryOpProvider") static void NEGDouble512VectorTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); @@ -3010,6 +3232,21 @@ assertArraysEquals(a, r, Double512VectorTests::NEG); } + @Test(dataProvider = "doubleUnaryOpProvider") + static void negDouble512VectorTests(IntFunction fa) { + double[] a = fa.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.neg().intoArray(r, i); + } + } + + assertArraysEquals(a, r, Double512VectorTests::neg); + } + @Test(dataProvider = "doubleUnaryOpMaskProvider") static void NEGMaskedDouble512VectorTests(IntFunction fa, IntFunction fm) { --- old/test/jdk/jdk/incubator/vector/Double64VectorTests.java 2020-05-28 14:30:40.452740216 -0700 +++ new/test/jdk/jdk/incubator/vector/Double64VectorTests.java 2020-05-28 14:30:40.276740216 -0700 @@ -241,6 +241,18 @@ } } + static void assertBroadcastArraysEquals(double[] a, double[] b, double[] 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(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) { assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); } @@ -256,6 +268,24 @@ } } + static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals(double[] a, double[] b, double[] 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(double[] a, double[] b, double[] r, FBinOp f) { int i = 0; int j = 0; @@ -1265,6 +1295,138 @@ + @Test(dataProvider = "doubleBinaryOpProvider") + static void addDouble64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.add(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Double64VectorTests::add); + } + + @Test(dataProvider = "doubleBinaryOpMaskProvider") + static void addDouble64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.add(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Double64VectorTests::add); + } + + @Test(dataProvider = "doubleBinaryOpProvider") + static void subDouble64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.sub(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Double64VectorTests::sub); + } + + @Test(dataProvider = "doubleBinaryOpMaskProvider") + static void subDouble64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.sub(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Double64VectorTests::sub); + } + + @Test(dataProvider = "doubleBinaryOpProvider") + static void mulDouble64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.mul(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Double64VectorTests::mul); + } + + @Test(dataProvider = "doubleBinaryOpMaskProvider") + static void mulDouble64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.mul(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Double64VectorTests::mul); + } + + + @Test(dataProvider = "doubleBinaryOpProvider") + static void divDouble64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.div(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Double64VectorTests::div); + } + + + + @Test(dataProvider = "doubleBinaryOpMaskProvider") + static void divDouble64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.div(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Double64VectorTests::div); + } + + + + + + @@ -1381,6 +1543,62 @@ assertArraysEquals(a, b, r, Double64VectorTests::max); } + @Test(dataProvider = "doubleBinaryOpProvider") + static void MINDouble64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Double64VectorTests::MIN); + } + + @Test(dataProvider = "doubleBinaryOpProvider") + static void minDouble64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.min(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Double64VectorTests::min); + } + + @Test(dataProvider = "doubleBinaryOpProvider") + static void MAXDouble64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Double64VectorTests::MAX); + } + + @Test(dataProvider = "doubleBinaryOpProvider") + static void maxDouble64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.max(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Double64VectorTests::max); + } + @@ -2995,6 +3213,10 @@ return (double)(-((double)a)); } + static double neg(double a) { + return (double)(-((double)a)); + } + @Test(dataProvider = "doubleUnaryOpProvider") static void NEGDouble64VectorTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); @@ -3010,6 +3232,21 @@ assertArraysEquals(a, r, Double64VectorTests::NEG); } + @Test(dataProvider = "doubleUnaryOpProvider") + static void negDouble64VectorTests(IntFunction fa) { + double[] a = fa.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.neg().intoArray(r, i); + } + } + + assertArraysEquals(a, r, Double64VectorTests::neg); + } + @Test(dataProvider = "doubleUnaryOpMaskProvider") static void NEGMaskedDouble64VectorTests(IntFunction fa, IntFunction fm) { --- old/test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java 2020-05-28 14:30:40.824740217 -0700 +++ new/test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java 2020-05-28 14:30:40.648740217 -0700 @@ -246,6 +246,18 @@ } } + static void assertBroadcastArraysEquals(double[] a, double[] b, double[] 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(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) { assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); } @@ -261,6 +273,24 @@ } } + static void assertBroadcastArraysEquals(double[] a, double[] b, double[] r, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals(double[] a, double[] b, double[] 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(double[] a, double[] b, double[] r, FBinOp f) { int i = 0; int j = 0; @@ -1270,6 +1300,138 @@ + @Test(dataProvider = "doubleBinaryOpProvider") + static void addDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.add(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, DoubleMaxVectorTests::add); + } + + @Test(dataProvider = "doubleBinaryOpMaskProvider") + static void addDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.add(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, DoubleMaxVectorTests::add); + } + + @Test(dataProvider = "doubleBinaryOpProvider") + static void subDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.sub(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, DoubleMaxVectorTests::sub); + } + + @Test(dataProvider = "doubleBinaryOpMaskProvider") + static void subDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.sub(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, DoubleMaxVectorTests::sub); + } + + @Test(dataProvider = "doubleBinaryOpProvider") + static void mulDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.mul(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, DoubleMaxVectorTests::mul); + } + + @Test(dataProvider = "doubleBinaryOpMaskProvider") + static void mulDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.mul(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, DoubleMaxVectorTests::mul); + } + + + @Test(dataProvider = "doubleBinaryOpProvider") + static void divDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.div(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, DoubleMaxVectorTests::div); + } + + + + @Test(dataProvider = "doubleBinaryOpMaskProvider") + static void divDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.div(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, DoubleMaxVectorTests::div); + } + + + + + + @@ -1386,6 +1548,62 @@ assertArraysEquals(a, b, r, DoubleMaxVectorTests::max); } + @Test(dataProvider = "doubleBinaryOpProvider") + static void MINDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, DoubleMaxVectorTests::MIN); + } + + @Test(dataProvider = "doubleBinaryOpProvider") + static void minDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.min(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, DoubleMaxVectorTests::min); + } + + @Test(dataProvider = "doubleBinaryOpProvider") + static void MAXDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, DoubleMaxVectorTests::MAX); + } + + @Test(dataProvider = "doubleBinaryOpProvider") + static void maxDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.max(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, DoubleMaxVectorTests::max); + } + @@ -3000,6 +3218,10 @@ return (double)(-((double)a)); } + static double neg(double a) { + return (double)(-((double)a)); + } + @Test(dataProvider = "doubleUnaryOpProvider") static void NEGDoubleMaxVectorTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); @@ -3015,6 +3237,21 @@ assertArraysEquals(a, r, DoubleMaxVectorTests::NEG); } + @Test(dataProvider = "doubleUnaryOpProvider") + static void negDoubleMaxVectorTests(IntFunction fa) { + double[] a = fa.apply(SPECIES.length()); + double[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); + av.neg().intoArray(r, i); + } + } + + assertArraysEquals(a, r, DoubleMaxVectorTests::neg); + } + @Test(dataProvider = "doubleUnaryOpMaskProvider") static void NEGMaskedDoubleMaxVectorTests(IntFunction fa, IntFunction fm) { --- old/test/jdk/jdk/incubator/vector/Float128VectorTests.java 2020-05-28 14:30:41.196740217 -0700 +++ new/test/jdk/jdk/incubator/vector/Float128VectorTests.java 2020-05-28 14:30:41.020740217 -0700 @@ -241,6 +241,18 @@ } } + static void assertBroadcastArraysEquals(float[] a, float[] b, float[] 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(float[] a, float[] b, float[] r, boolean[] mask, FBinOp f) { assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); } @@ -256,6 +268,24 @@ } } + static void assertBroadcastArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals(float[] a, float[] b, float[] 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(float[] a, float[] b, float[] r, FBinOp f) { int i = 0; int j = 0; @@ -1265,6 +1295,138 @@ + @Test(dataProvider = "floatBinaryOpProvider") + static void addFloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.add(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Float128VectorTests::add); + } + + @Test(dataProvider = "floatBinaryOpMaskProvider") + static void addFloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.add(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Float128VectorTests::add); + } + + @Test(dataProvider = "floatBinaryOpProvider") + static void subFloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.sub(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Float128VectorTests::sub); + } + + @Test(dataProvider = "floatBinaryOpMaskProvider") + static void subFloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.sub(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Float128VectorTests::sub); + } + + @Test(dataProvider = "floatBinaryOpProvider") + static void mulFloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.mul(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Float128VectorTests::mul); + } + + @Test(dataProvider = "floatBinaryOpMaskProvider") + static void mulFloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.mul(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Float128VectorTests::mul); + } + + + @Test(dataProvider = "floatBinaryOpProvider") + static void divFloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.div(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Float128VectorTests::div); + } + + + + @Test(dataProvider = "floatBinaryOpMaskProvider") + static void divFloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.div(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Float128VectorTests::div); + } + + + + + + @@ -1381,6 +1543,62 @@ assertArraysEquals(a, b, r, Float128VectorTests::max); } + @Test(dataProvider = "floatBinaryOpProvider") + static void MINFloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Float128VectorTests::MIN); + } + + @Test(dataProvider = "floatBinaryOpProvider") + static void minFloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.min(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Float128VectorTests::min); + } + + @Test(dataProvider = "floatBinaryOpProvider") + static void MAXFloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Float128VectorTests::MAX); + } + + @Test(dataProvider = "floatBinaryOpProvider") + static void maxFloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.max(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Float128VectorTests::max); + } + @@ -2981,6 +3199,10 @@ return (float)(-((float)a)); } + static float neg(float a) { + return (float)(-((float)a)); + } + @Test(dataProvider = "floatUnaryOpProvider") static void NEGFloat128VectorTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); @@ -2996,6 +3218,21 @@ assertArraysEquals(a, r, Float128VectorTests::NEG); } + @Test(dataProvider = "floatUnaryOpProvider") + static void negFloat128VectorTests(IntFunction fa) { + float[] a = fa.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.neg().intoArray(r, i); + } + } + + assertArraysEquals(a, r, Float128VectorTests::neg); + } + @Test(dataProvider = "floatUnaryOpMaskProvider") static void NEGMaskedFloat128VectorTests(IntFunction fa, IntFunction fm) { --- old/test/jdk/jdk/incubator/vector/Float256VectorTests.java 2020-05-28 14:30:41.568740218 -0700 +++ new/test/jdk/jdk/incubator/vector/Float256VectorTests.java 2020-05-28 14:30:41.392740217 -0700 @@ -241,6 +241,18 @@ } } + static void assertBroadcastArraysEquals(float[] a, float[] b, float[] 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(float[] a, float[] b, float[] r, boolean[] mask, FBinOp f) { assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); } @@ -256,6 +268,24 @@ } } + static void assertBroadcastArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals(float[] a, float[] b, float[] 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(float[] a, float[] b, float[] r, FBinOp f) { int i = 0; int j = 0; @@ -1265,6 +1295,138 @@ + @Test(dataProvider = "floatBinaryOpProvider") + static void addFloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.add(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Float256VectorTests::add); + } + + @Test(dataProvider = "floatBinaryOpMaskProvider") + static void addFloat256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.add(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Float256VectorTests::add); + } + + @Test(dataProvider = "floatBinaryOpProvider") + static void subFloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.sub(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Float256VectorTests::sub); + } + + @Test(dataProvider = "floatBinaryOpMaskProvider") + static void subFloat256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.sub(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Float256VectorTests::sub); + } + + @Test(dataProvider = "floatBinaryOpProvider") + static void mulFloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.mul(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Float256VectorTests::mul); + } + + @Test(dataProvider = "floatBinaryOpMaskProvider") + static void mulFloat256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.mul(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Float256VectorTests::mul); + } + + + @Test(dataProvider = "floatBinaryOpProvider") + static void divFloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.div(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Float256VectorTests::div); + } + + + + @Test(dataProvider = "floatBinaryOpMaskProvider") + static void divFloat256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.div(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Float256VectorTests::div); + } + + + + + + @@ -1381,6 +1543,62 @@ assertArraysEquals(a, b, r, Float256VectorTests::max); } + @Test(dataProvider = "floatBinaryOpProvider") + static void MINFloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Float256VectorTests::MIN); + } + + @Test(dataProvider = "floatBinaryOpProvider") + static void minFloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.min(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Float256VectorTests::min); + } + + @Test(dataProvider = "floatBinaryOpProvider") + static void MAXFloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Float256VectorTests::MAX); + } + + @Test(dataProvider = "floatBinaryOpProvider") + static void maxFloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.max(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Float256VectorTests::max); + } + @@ -2981,6 +3199,10 @@ return (float)(-((float)a)); } + static float neg(float a) { + return (float)(-((float)a)); + } + @Test(dataProvider = "floatUnaryOpProvider") static void NEGFloat256VectorTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); @@ -2996,6 +3218,21 @@ assertArraysEquals(a, r, Float256VectorTests::NEG); } + @Test(dataProvider = "floatUnaryOpProvider") + static void negFloat256VectorTests(IntFunction fa) { + float[] a = fa.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.neg().intoArray(r, i); + } + } + + assertArraysEquals(a, r, Float256VectorTests::neg); + } + @Test(dataProvider = "floatUnaryOpMaskProvider") static void NEGMaskedFloat256VectorTests(IntFunction fa, IntFunction fm) { --- old/test/jdk/jdk/incubator/vector/Float512VectorTests.java 2020-05-28 14:30:41.940740218 -0700 +++ new/test/jdk/jdk/incubator/vector/Float512VectorTests.java 2020-05-28 14:30:41.764740218 -0700 @@ -241,6 +241,18 @@ } } + static void assertBroadcastArraysEquals(float[] a, float[] b, float[] 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(float[] a, float[] b, float[] r, boolean[] mask, FBinOp f) { assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); } @@ -256,6 +268,24 @@ } } + static void assertBroadcastArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals(float[] a, float[] b, float[] 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(float[] a, float[] b, float[] r, FBinOp f) { int i = 0; int j = 0; @@ -1265,6 +1295,138 @@ + @Test(dataProvider = "floatBinaryOpProvider") + static void addFloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.add(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Float512VectorTests::add); + } + + @Test(dataProvider = "floatBinaryOpMaskProvider") + static void addFloat512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.add(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Float512VectorTests::add); + } + + @Test(dataProvider = "floatBinaryOpProvider") + static void subFloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.sub(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Float512VectorTests::sub); + } + + @Test(dataProvider = "floatBinaryOpMaskProvider") + static void subFloat512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.sub(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Float512VectorTests::sub); + } + + @Test(dataProvider = "floatBinaryOpProvider") + static void mulFloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.mul(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Float512VectorTests::mul); + } + + @Test(dataProvider = "floatBinaryOpMaskProvider") + static void mulFloat512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.mul(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Float512VectorTests::mul); + } + + + @Test(dataProvider = "floatBinaryOpProvider") + static void divFloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.div(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Float512VectorTests::div); + } + + + + @Test(dataProvider = "floatBinaryOpMaskProvider") + static void divFloat512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.div(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Float512VectorTests::div); + } + + + + + + @@ -1381,6 +1543,62 @@ assertArraysEquals(a, b, r, Float512VectorTests::max); } + @Test(dataProvider = "floatBinaryOpProvider") + static void MINFloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Float512VectorTests::MIN); + } + + @Test(dataProvider = "floatBinaryOpProvider") + static void minFloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.min(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Float512VectorTests::min); + } + + @Test(dataProvider = "floatBinaryOpProvider") + static void MAXFloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Float512VectorTests::MAX); + } + + @Test(dataProvider = "floatBinaryOpProvider") + static void maxFloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.max(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Float512VectorTests::max); + } + @@ -2981,6 +3199,10 @@ return (float)(-((float)a)); } + static float neg(float a) { + return (float)(-((float)a)); + } + @Test(dataProvider = "floatUnaryOpProvider") static void NEGFloat512VectorTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); @@ -2996,6 +3218,21 @@ assertArraysEquals(a, r, Float512VectorTests::NEG); } + @Test(dataProvider = "floatUnaryOpProvider") + static void negFloat512VectorTests(IntFunction fa) { + float[] a = fa.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.neg().intoArray(r, i); + } + } + + assertArraysEquals(a, r, Float512VectorTests::neg); + } + @Test(dataProvider = "floatUnaryOpMaskProvider") static void NEGMaskedFloat512VectorTests(IntFunction fa, IntFunction fm) { --- old/test/jdk/jdk/incubator/vector/Float64VectorTests.java 2020-05-28 14:30:42.308740218 -0700 +++ new/test/jdk/jdk/incubator/vector/Float64VectorTests.java 2020-05-28 14:30:42.132740218 -0700 @@ -241,6 +241,18 @@ } } + static void assertBroadcastArraysEquals(float[] a, float[] b, float[] 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(float[] a, float[] b, float[] r, boolean[] mask, FBinOp f) { assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); } @@ -256,6 +268,24 @@ } } + static void assertBroadcastArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals(float[] a, float[] b, float[] 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(float[] a, float[] b, float[] r, FBinOp f) { int i = 0; int j = 0; @@ -1265,6 +1295,138 @@ + @Test(dataProvider = "floatBinaryOpProvider") + static void addFloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.add(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Float64VectorTests::add); + } + + @Test(dataProvider = "floatBinaryOpMaskProvider") + static void addFloat64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.add(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Float64VectorTests::add); + } + + @Test(dataProvider = "floatBinaryOpProvider") + static void subFloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.sub(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Float64VectorTests::sub); + } + + @Test(dataProvider = "floatBinaryOpMaskProvider") + static void subFloat64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.sub(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Float64VectorTests::sub); + } + + @Test(dataProvider = "floatBinaryOpProvider") + static void mulFloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.mul(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Float64VectorTests::mul); + } + + @Test(dataProvider = "floatBinaryOpMaskProvider") + static void mulFloat64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.mul(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Float64VectorTests::mul); + } + + + @Test(dataProvider = "floatBinaryOpProvider") + static void divFloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.div(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Float64VectorTests::div); + } + + + + @Test(dataProvider = "floatBinaryOpMaskProvider") + static void divFloat64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.div(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Float64VectorTests::div); + } + + + + + + @@ -1381,6 +1543,62 @@ assertArraysEquals(a, b, r, Float64VectorTests::max); } + @Test(dataProvider = "floatBinaryOpProvider") + static void MINFloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Float64VectorTests::MIN); + } + + @Test(dataProvider = "floatBinaryOpProvider") + static void minFloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.min(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Float64VectorTests::min); + } + + @Test(dataProvider = "floatBinaryOpProvider") + static void MAXFloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Float64VectorTests::MAX); + } + + @Test(dataProvider = "floatBinaryOpProvider") + static void maxFloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.max(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Float64VectorTests::max); + } + @@ -2981,6 +3199,10 @@ return (float)(-((float)a)); } + static float neg(float a) { + return (float)(-((float)a)); + } + @Test(dataProvider = "floatUnaryOpProvider") static void NEGFloat64VectorTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); @@ -2996,6 +3218,21 @@ assertArraysEquals(a, r, Float64VectorTests::NEG); } + @Test(dataProvider = "floatUnaryOpProvider") + static void negFloat64VectorTests(IntFunction fa) { + float[] a = fa.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.neg().intoArray(r, i); + } + } + + assertArraysEquals(a, r, Float64VectorTests::neg); + } + @Test(dataProvider = "floatUnaryOpMaskProvider") static void NEGMaskedFloat64VectorTests(IntFunction fa, IntFunction fm) { --- old/test/jdk/jdk/incubator/vector/FloatMaxVectorTests.java 2020-05-28 14:30:42.676740219 -0700 +++ new/test/jdk/jdk/incubator/vector/FloatMaxVectorTests.java 2020-05-28 14:30:42.500740218 -0700 @@ -246,6 +246,18 @@ } } + static void assertBroadcastArraysEquals(float[] a, float[] b, float[] 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(float[] a, float[] b, float[] r, boolean[] mask, FBinOp f) { assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); } @@ -261,6 +273,24 @@ } } + static void assertBroadcastArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals(float[] a, float[] b, float[] 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(float[] a, float[] b, float[] r, FBinOp f) { int i = 0; int j = 0; @@ -1270,6 +1300,138 @@ + @Test(dataProvider = "floatBinaryOpProvider") + static void addFloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.add(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, FloatMaxVectorTests::add); + } + + @Test(dataProvider = "floatBinaryOpMaskProvider") + static void addFloatMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.add(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, FloatMaxVectorTests::add); + } + + @Test(dataProvider = "floatBinaryOpProvider") + static void subFloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.sub(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, FloatMaxVectorTests::sub); + } + + @Test(dataProvider = "floatBinaryOpMaskProvider") + static void subFloatMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.sub(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, FloatMaxVectorTests::sub); + } + + @Test(dataProvider = "floatBinaryOpProvider") + static void mulFloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.mul(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, FloatMaxVectorTests::mul); + } + + @Test(dataProvider = "floatBinaryOpMaskProvider") + static void mulFloatMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.mul(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, FloatMaxVectorTests::mul); + } + + + @Test(dataProvider = "floatBinaryOpProvider") + static void divFloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.div(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, FloatMaxVectorTests::div); + } + + + + @Test(dataProvider = "floatBinaryOpMaskProvider") + static void divFloatMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.div(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, FloatMaxVectorTests::div); + } + + + + + + @@ -1386,6 +1548,62 @@ assertArraysEquals(a, b, r, FloatMaxVectorTests::max); } + @Test(dataProvider = "floatBinaryOpProvider") + static void MINFloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, FloatMaxVectorTests::MIN); + } + + @Test(dataProvider = "floatBinaryOpProvider") + static void minFloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.min(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, FloatMaxVectorTests::min); + } + + @Test(dataProvider = "floatBinaryOpProvider") + static void MAXFloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, FloatMaxVectorTests::MAX); + } + + @Test(dataProvider = "floatBinaryOpProvider") + static void maxFloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.max(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, FloatMaxVectorTests::max); + } + @@ -2986,6 +3204,10 @@ return (float)(-((float)a)); } + static float neg(float a) { + return (float)(-((float)a)); + } + @Test(dataProvider = "floatUnaryOpProvider") static void NEGFloatMaxVectorTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); @@ -3001,6 +3223,21 @@ assertArraysEquals(a, r, FloatMaxVectorTests::NEG); } + @Test(dataProvider = "floatUnaryOpProvider") + static void negFloatMaxVectorTests(IntFunction fa) { + float[] a = fa.apply(SPECIES.length()); + float[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + FloatVector av = FloatVector.fromArray(SPECIES, a, i); + av.neg().intoArray(r, i); + } + } + + assertArraysEquals(a, r, FloatMaxVectorTests::neg); + } + @Test(dataProvider = "floatUnaryOpMaskProvider") static void NEGMaskedFloatMaxVectorTests(IntFunction fa, IntFunction fm) { --- old/test/jdk/jdk/incubator/vector/Int128VectorTests.java 2020-05-28 14:30:43.048740219 -0700 +++ new/test/jdk/jdk/incubator/vector/Int128VectorTests.java 2020-05-28 14:30:42.868740219 -0700 @@ -241,6 +241,18 @@ } } + static void assertBroadcastArraysEquals(int[] a, int[] b, int[] 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(int[] a, int[] b, int[] r, boolean[] mask, FBinOp f) { assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); } @@ -256,6 +268,24 @@ } } + static void assertBroadcastArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals(int[] a, int[] b, int[] 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(int[] a, int[] b, int[] r, FBinOp f) { int i = 0; int j = 0; @@ -1374,6 +1404,26 @@ assertArraysEquals(a, b, r, Int128VectorTests::OR); } + static int or(int a, int b) { + return (int)(a | b); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void orInt128VectorTests(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.or(bv).intoArray(r, i); + } + } + + assertArraysEquals(a, b, r, Int128VectorTests::or); + } @@ -1442,6 +1492,189 @@ } + @Test(dataProvider = "intBinaryOpProvider") + static void addInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.add(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int128VectorTests::add); + } + + @Test(dataProvider = "intBinaryOpMaskProvider") + static void addInt128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.add(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Int128VectorTests::add); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void subInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.sub(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int128VectorTests::sub); + } + + @Test(dataProvider = "intBinaryOpMaskProvider") + static void subInt128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.sub(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Int128VectorTests::sub); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void mulInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.mul(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int128VectorTests::mul); + } + + @Test(dataProvider = "intBinaryOpMaskProvider") + static void mulInt128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.mul(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Int128VectorTests::mul); + } + + + + + @Test(dataProvider = "intBinaryOpProvider") + static void divInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + replaceZero(b, (int) 1); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.div(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int128VectorTests::div); + } + + + + @Test(dataProvider = "intBinaryOpMaskProvider") + static void divInt128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + replaceZero(b, (int) 1); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.div(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Int128VectorTests::div); + } + + + + @Test(dataProvider = "intBinaryOpProvider") + static void ORInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int128VectorTests::OR); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void orInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.or(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int128VectorTests::or); + } + + + + @Test(dataProvider = "intBinaryOpMaskProvider") + static void ORInt128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Int128VectorTests::OR); + } + + static int LSHL(int a, int b) { return (int)((a << b)); } @@ -1804,6 +2037,62 @@ assertArraysEquals(a, b, r, Int128VectorTests::max); } + @Test(dataProvider = "intBinaryOpProvider") + static void MINInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int128VectorTests::MIN); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void minInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.min(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int128VectorTests::min); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void MAXInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int128VectorTests::MAX); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void maxInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.max(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int128VectorTests::max); + } + static int AND(int[] a, int idx) { int res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { @@ -3248,6 +3537,10 @@ return (int)(-((int)a)); } + static int neg(int a) { + return (int)(-((int)a)); + } + @Test(dataProvider = "intUnaryOpProvider") static void NEGInt128VectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); @@ -3263,6 +3556,21 @@ assertArraysEquals(a, r, Int128VectorTests::NEG); } + @Test(dataProvider = "intUnaryOpProvider") + static void negInt128VectorTests(IntFunction fa) { + int[] a = fa.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.neg().intoArray(r, i); + } + } + + assertArraysEquals(a, r, Int128VectorTests::neg); + } + @Test(dataProvider = "intUnaryOpMaskProvider") static void NEGMaskedInt128VectorTests(IntFunction fa, IntFunction fm) { @@ -3342,6 +3650,10 @@ return (int)(~((int)a)); } + static int not(int a) { + return (int)(~((int)a)); + } + @Test(dataProvider = "intUnaryOpProvider") @@ -3359,6 +3671,21 @@ assertArraysEquals(a, r, Int128VectorTests::NOT); } + @Test(dataProvider = "intUnaryOpProvider") + static void notInt128VectorTests(IntFunction fa) { + int[] a = fa.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.not().intoArray(r, i); + } + } + + assertArraysEquals(a, r, Int128VectorTests::not); + } + @Test(dataProvider = "intUnaryOpMaskProvider") --- old/test/jdk/jdk/incubator/vector/Int256VectorTests.java 2020-05-28 14:30:43.424740219 -0700 +++ new/test/jdk/jdk/incubator/vector/Int256VectorTests.java 2020-05-28 14:30:43.244740219 -0700 @@ -241,6 +241,18 @@ } } + static void assertBroadcastArraysEquals(int[] a, int[] b, int[] 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(int[] a, int[] b, int[] r, boolean[] mask, FBinOp f) { assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); } @@ -256,6 +268,24 @@ } } + static void assertBroadcastArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals(int[] a, int[] b, int[] 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(int[] a, int[] b, int[] r, FBinOp f) { int i = 0; int j = 0; @@ -1374,6 +1404,26 @@ assertArraysEquals(a, b, r, Int256VectorTests::OR); } + static int or(int a, int b) { + return (int)(a | b); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void orInt256VectorTests(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.or(bv).intoArray(r, i); + } + } + + assertArraysEquals(a, b, r, Int256VectorTests::or); + } @@ -1442,6 +1492,189 @@ } + @Test(dataProvider = "intBinaryOpProvider") + static void addInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.add(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int256VectorTests::add); + } + + @Test(dataProvider = "intBinaryOpMaskProvider") + static void addInt256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.add(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Int256VectorTests::add); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void subInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.sub(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int256VectorTests::sub); + } + + @Test(dataProvider = "intBinaryOpMaskProvider") + static void subInt256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.sub(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Int256VectorTests::sub); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void mulInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.mul(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int256VectorTests::mul); + } + + @Test(dataProvider = "intBinaryOpMaskProvider") + static void mulInt256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.mul(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Int256VectorTests::mul); + } + + + + + @Test(dataProvider = "intBinaryOpProvider") + static void divInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + replaceZero(b, (int) 1); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.div(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int256VectorTests::div); + } + + + + @Test(dataProvider = "intBinaryOpMaskProvider") + static void divInt256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + replaceZero(b, (int) 1); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.div(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Int256VectorTests::div); + } + + + + @Test(dataProvider = "intBinaryOpProvider") + static void ORInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int256VectorTests::OR); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void orInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.or(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int256VectorTests::or); + } + + + + @Test(dataProvider = "intBinaryOpMaskProvider") + static void ORInt256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Int256VectorTests::OR); + } + + static int LSHL(int a, int b) { return (int)((a << b)); } @@ -1804,6 +2037,62 @@ assertArraysEquals(a, b, r, Int256VectorTests::max); } + @Test(dataProvider = "intBinaryOpProvider") + static void MINInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int256VectorTests::MIN); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void minInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.min(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int256VectorTests::min); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void MAXInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int256VectorTests::MAX); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void maxInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.max(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int256VectorTests::max); + } + static int AND(int[] a, int idx) { int res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { @@ -3248,6 +3537,10 @@ return (int)(-((int)a)); } + static int neg(int a) { + return (int)(-((int)a)); + } + @Test(dataProvider = "intUnaryOpProvider") static void NEGInt256VectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); @@ -3263,6 +3556,21 @@ assertArraysEquals(a, r, Int256VectorTests::NEG); } + @Test(dataProvider = "intUnaryOpProvider") + static void negInt256VectorTests(IntFunction fa) { + int[] a = fa.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.neg().intoArray(r, i); + } + } + + assertArraysEquals(a, r, Int256VectorTests::neg); + } + @Test(dataProvider = "intUnaryOpMaskProvider") static void NEGMaskedInt256VectorTests(IntFunction fa, IntFunction fm) { @@ -3342,6 +3650,10 @@ return (int)(~((int)a)); } + static int not(int a) { + return (int)(~((int)a)); + } + @Test(dataProvider = "intUnaryOpProvider") @@ -3359,6 +3671,21 @@ assertArraysEquals(a, r, Int256VectorTests::NOT); } + @Test(dataProvider = "intUnaryOpProvider") + static void notInt256VectorTests(IntFunction fa) { + int[] a = fa.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.not().intoArray(r, i); + } + } + + assertArraysEquals(a, r, Int256VectorTests::not); + } + @Test(dataProvider = "intUnaryOpMaskProvider") --- old/test/jdk/jdk/incubator/vector/Int512VectorTests.java 2020-05-28 14:30:43.796740220 -0700 +++ new/test/jdk/jdk/incubator/vector/Int512VectorTests.java 2020-05-28 14:30:43.620740219 -0700 @@ -241,6 +241,18 @@ } } + static void assertBroadcastArraysEquals(int[] a, int[] b, int[] 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(int[] a, int[] b, int[] r, boolean[] mask, FBinOp f) { assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); } @@ -256,6 +268,24 @@ } } + static void assertBroadcastArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals(int[] a, int[] b, int[] 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(int[] a, int[] b, int[] r, FBinOp f) { int i = 0; int j = 0; @@ -1374,6 +1404,26 @@ assertArraysEquals(a, b, r, Int512VectorTests::OR); } + static int or(int a, int b) { + return (int)(a | b); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void orInt512VectorTests(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.or(bv).intoArray(r, i); + } + } + + assertArraysEquals(a, b, r, Int512VectorTests::or); + } @@ -1442,6 +1492,189 @@ } + @Test(dataProvider = "intBinaryOpProvider") + static void addInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.add(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int512VectorTests::add); + } + + @Test(dataProvider = "intBinaryOpMaskProvider") + static void addInt512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.add(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Int512VectorTests::add); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void subInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.sub(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int512VectorTests::sub); + } + + @Test(dataProvider = "intBinaryOpMaskProvider") + static void subInt512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.sub(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Int512VectorTests::sub); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void mulInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.mul(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int512VectorTests::mul); + } + + @Test(dataProvider = "intBinaryOpMaskProvider") + static void mulInt512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.mul(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Int512VectorTests::mul); + } + + + + + @Test(dataProvider = "intBinaryOpProvider") + static void divInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + replaceZero(b, (int) 1); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.div(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int512VectorTests::div); + } + + + + @Test(dataProvider = "intBinaryOpMaskProvider") + static void divInt512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + replaceZero(b, (int) 1); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.div(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Int512VectorTests::div); + } + + + + @Test(dataProvider = "intBinaryOpProvider") + static void ORInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int512VectorTests::OR); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void orInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.or(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int512VectorTests::or); + } + + + + @Test(dataProvider = "intBinaryOpMaskProvider") + static void ORInt512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Int512VectorTests::OR); + } + + static int LSHL(int a, int b) { return (int)((a << b)); } @@ -1804,6 +2037,62 @@ assertArraysEquals(a, b, r, Int512VectorTests::max); } + @Test(dataProvider = "intBinaryOpProvider") + static void MINInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int512VectorTests::MIN); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void minInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.min(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int512VectorTests::min); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void MAXInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int512VectorTests::MAX); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void maxInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.max(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int512VectorTests::max); + } + static int AND(int[] a, int idx) { int res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { @@ -3248,6 +3537,10 @@ return (int)(-((int)a)); } + static int neg(int a) { + return (int)(-((int)a)); + } + @Test(dataProvider = "intUnaryOpProvider") static void NEGInt512VectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); @@ -3263,6 +3556,21 @@ assertArraysEquals(a, r, Int512VectorTests::NEG); } + @Test(dataProvider = "intUnaryOpProvider") + static void negInt512VectorTests(IntFunction fa) { + int[] a = fa.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.neg().intoArray(r, i); + } + } + + assertArraysEquals(a, r, Int512VectorTests::neg); + } + @Test(dataProvider = "intUnaryOpMaskProvider") static void NEGMaskedInt512VectorTests(IntFunction fa, IntFunction fm) { @@ -3342,6 +3650,10 @@ return (int)(~((int)a)); } + static int not(int a) { + return (int)(~((int)a)); + } + @Test(dataProvider = "intUnaryOpProvider") @@ -3359,6 +3671,21 @@ assertArraysEquals(a, r, Int512VectorTests::NOT); } + @Test(dataProvider = "intUnaryOpProvider") + static void notInt512VectorTests(IntFunction fa) { + int[] a = fa.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.not().intoArray(r, i); + } + } + + assertArraysEquals(a, r, Int512VectorTests::not); + } + @Test(dataProvider = "intUnaryOpMaskProvider") --- old/test/jdk/jdk/incubator/vector/Int64VectorTests.java 2020-05-28 14:30:44.168740220 -0700 +++ new/test/jdk/jdk/incubator/vector/Int64VectorTests.java 2020-05-28 14:30:43.992740220 -0700 @@ -241,6 +241,18 @@ } } + static void assertBroadcastArraysEquals(int[] a, int[] b, int[] 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(int[] a, int[] b, int[] r, boolean[] mask, FBinOp f) { assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); } @@ -256,6 +268,24 @@ } } + static void assertBroadcastArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals(int[] a, int[] b, int[] 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(int[] a, int[] b, int[] r, FBinOp f) { int i = 0; int j = 0; @@ -1374,6 +1404,26 @@ assertArraysEquals(a, b, r, Int64VectorTests::OR); } + static int or(int a, int b) { + return (int)(a | b); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void orInt64VectorTests(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.or(bv).intoArray(r, i); + } + } + + assertArraysEquals(a, b, r, Int64VectorTests::or); + } @@ -1442,6 +1492,189 @@ } + @Test(dataProvider = "intBinaryOpProvider") + static void addInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.add(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int64VectorTests::add); + } + + @Test(dataProvider = "intBinaryOpMaskProvider") + static void addInt64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.add(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Int64VectorTests::add); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void subInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.sub(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int64VectorTests::sub); + } + + @Test(dataProvider = "intBinaryOpMaskProvider") + static void subInt64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.sub(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Int64VectorTests::sub); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void mulInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.mul(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int64VectorTests::mul); + } + + @Test(dataProvider = "intBinaryOpMaskProvider") + static void mulInt64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.mul(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Int64VectorTests::mul); + } + + + + + @Test(dataProvider = "intBinaryOpProvider") + static void divInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + replaceZero(b, (int) 1); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.div(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int64VectorTests::div); + } + + + + @Test(dataProvider = "intBinaryOpMaskProvider") + static void divInt64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + replaceZero(b, (int) 1); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.div(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Int64VectorTests::div); + } + + + + @Test(dataProvider = "intBinaryOpProvider") + static void ORInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int64VectorTests::OR); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void orInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.or(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int64VectorTests::or); + } + + + + @Test(dataProvider = "intBinaryOpMaskProvider") + static void ORInt64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Int64VectorTests::OR); + } + + static int LSHL(int a, int b) { return (int)((a << b)); } @@ -1804,6 +2037,62 @@ assertArraysEquals(a, b, r, Int64VectorTests::max); } + @Test(dataProvider = "intBinaryOpProvider") + static void MINInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int64VectorTests::MIN); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void minInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.min(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int64VectorTests::min); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void MAXInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int64VectorTests::MAX); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void maxInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.max(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Int64VectorTests::max); + } + static int AND(int[] a, int idx) { int res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { @@ -3248,6 +3537,10 @@ return (int)(-((int)a)); } + static int neg(int a) { + return (int)(-((int)a)); + } + @Test(dataProvider = "intUnaryOpProvider") static void NEGInt64VectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); @@ -3263,6 +3556,21 @@ assertArraysEquals(a, r, Int64VectorTests::NEG); } + @Test(dataProvider = "intUnaryOpProvider") + static void negInt64VectorTests(IntFunction fa) { + int[] a = fa.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.neg().intoArray(r, i); + } + } + + assertArraysEquals(a, r, Int64VectorTests::neg); + } + @Test(dataProvider = "intUnaryOpMaskProvider") static void NEGMaskedInt64VectorTests(IntFunction fa, IntFunction fm) { @@ -3342,6 +3650,10 @@ return (int)(~((int)a)); } + static int not(int a) { + return (int)(~((int)a)); + } + @Test(dataProvider = "intUnaryOpProvider") @@ -3359,6 +3671,21 @@ assertArraysEquals(a, r, Int64VectorTests::NOT); } + @Test(dataProvider = "intUnaryOpProvider") + static void notInt64VectorTests(IntFunction fa) { + int[] a = fa.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.not().intoArray(r, i); + } + } + + assertArraysEquals(a, r, Int64VectorTests::not); + } + @Test(dataProvider = "intUnaryOpMaskProvider") --- old/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java 2020-05-28 14:30:44.536740220 -0700 +++ new/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java 2020-05-28 14:30:44.360740220 -0700 @@ -246,6 +246,18 @@ } } + static void assertBroadcastArraysEquals(int[] a, int[] b, int[] 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(int[] a, int[] b, int[] r, boolean[] mask, FBinOp f) { assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); } @@ -261,6 +273,24 @@ } } + static void assertBroadcastArraysEquals(int[] a, int[] b, int[] r, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals(int[] a, int[] b, int[] 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(int[] a, int[] b, int[] r, FBinOp f) { int i = 0; int j = 0; @@ -1379,6 +1409,26 @@ assertArraysEquals(a, b, r, IntMaxVectorTests::OR); } + static int or(int a, int b) { + return (int)(a | b); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void orIntMaxVectorTests(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.or(bv).intoArray(r, i); + } + } + + assertArraysEquals(a, b, r, IntMaxVectorTests::or); + } @@ -1447,6 +1497,189 @@ } + @Test(dataProvider = "intBinaryOpProvider") + static void addIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.add(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, IntMaxVectorTests::add); + } + + @Test(dataProvider = "intBinaryOpMaskProvider") + static void addIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.add(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, IntMaxVectorTests::add); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void subIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.sub(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, IntMaxVectorTests::sub); + } + + @Test(dataProvider = "intBinaryOpMaskProvider") + static void subIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.sub(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, IntMaxVectorTests::sub); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void mulIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.mul(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, IntMaxVectorTests::mul); + } + + @Test(dataProvider = "intBinaryOpMaskProvider") + static void mulIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.mul(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, IntMaxVectorTests::mul); + } + + + + + @Test(dataProvider = "intBinaryOpProvider") + static void divIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + replaceZero(b, (int) 1); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.div(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, IntMaxVectorTests::div); + } + + + + @Test(dataProvider = "intBinaryOpMaskProvider") + static void divIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + replaceZero(b, (int) 1); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.div(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, IntMaxVectorTests::div); + } + + + + @Test(dataProvider = "intBinaryOpProvider") + static void ORIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, IntMaxVectorTests::OR); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void orIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.or(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, IntMaxVectorTests::or); + } + + + + @Test(dataProvider = "intBinaryOpMaskProvider") + static void ORIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, IntMaxVectorTests::OR); + } + + static int LSHL(int a, int b) { return (int)((a << b)); } @@ -1809,6 +2042,62 @@ assertArraysEquals(a, b, r, IntMaxVectorTests::max); } + @Test(dataProvider = "intBinaryOpProvider") + static void MINIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, IntMaxVectorTests::MIN); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void minIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.min(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, IntMaxVectorTests::min); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void MAXIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, IntMaxVectorTests::MAX); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void maxIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.max(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, IntMaxVectorTests::max); + } + static int AND(int[] a, int idx) { int res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { @@ -3253,6 +3542,10 @@ return (int)(-((int)a)); } + static int neg(int a) { + return (int)(-((int)a)); + } + @Test(dataProvider = "intUnaryOpProvider") static void NEGIntMaxVectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); @@ -3268,6 +3561,21 @@ assertArraysEquals(a, r, IntMaxVectorTests::NEG); } + @Test(dataProvider = "intUnaryOpProvider") + static void negIntMaxVectorTests(IntFunction fa) { + int[] a = fa.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.neg().intoArray(r, i); + } + } + + assertArraysEquals(a, r, IntMaxVectorTests::neg); + } + @Test(dataProvider = "intUnaryOpMaskProvider") static void NEGMaskedIntMaxVectorTests(IntFunction fa, IntFunction fm) { @@ -3347,6 +3655,10 @@ return (int)(~((int)a)); } + static int not(int a) { + return (int)(~((int)a)); + } + @Test(dataProvider = "intUnaryOpProvider") @@ -3364,6 +3676,21 @@ assertArraysEquals(a, r, IntMaxVectorTests::NOT); } + @Test(dataProvider = "intUnaryOpProvider") + static void notIntMaxVectorTests(IntFunction fa) { + int[] a = fa.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + av.not().intoArray(r, i); + } + } + + assertArraysEquals(a, r, IntMaxVectorTests::not); + } + @Test(dataProvider = "intUnaryOpMaskProvider") --- old/test/jdk/jdk/incubator/vector/Long128VectorTests.java 2020-05-28 14:30:44.904740221 -0700 +++ new/test/jdk/jdk/incubator/vector/Long128VectorTests.java 2020-05-28 14:30:44.728740221 -0700 @@ -241,6 +241,18 @@ } } + static void assertBroadcastArraysEquals(long[] a, long[] b, long[] 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(long[] a, long[] b, long[] r, boolean[] mask, FBinOp f) { assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); } @@ -256,6 +268,24 @@ } } + static void assertBroadcastArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals(long[] a, long[] b, long[] 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(long[] a, long[] b, long[] r, FBinOp f) { int i = 0; int j = 0; @@ -1374,6 +1404,26 @@ assertArraysEquals(a, b, r, Long128VectorTests::OR); } + static long or(long a, long b) { + return (long)(a | b); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void orLong128VectorTests(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.or(bv).intoArray(r, i); + } + } + + assertArraysEquals(a, b, r, Long128VectorTests::or); + } @@ -1442,6 +1492,189 @@ } + @Test(dataProvider = "longBinaryOpProvider") + static void addLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.add(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long128VectorTests::add); + } + + @Test(dataProvider = "longBinaryOpMaskProvider") + static void addLong128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.add(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Long128VectorTests::add); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void subLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.sub(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long128VectorTests::sub); + } + + @Test(dataProvider = "longBinaryOpMaskProvider") + static void subLong128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.sub(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Long128VectorTests::sub); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void mulLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.mul(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long128VectorTests::mul); + } + + @Test(dataProvider = "longBinaryOpMaskProvider") + static void mulLong128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.mul(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Long128VectorTests::mul); + } + + + + + @Test(dataProvider = "longBinaryOpProvider") + static void divLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + replaceZero(b, (long) 1); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.div(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long128VectorTests::div); + } + + + + @Test(dataProvider = "longBinaryOpMaskProvider") + static void divLong128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + replaceZero(b, (long) 1); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.div(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Long128VectorTests::div); + } + + + + @Test(dataProvider = "longBinaryOpProvider") + static void ORLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long128VectorTests::OR); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void orLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.or(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long128VectorTests::or); + } + + + + @Test(dataProvider = "longBinaryOpMaskProvider") + static void ORLong128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Long128VectorTests::OR); + } + + static long LSHL(long a, long b) { return (long)((a << b)); } @@ -1804,6 +2037,62 @@ assertArraysEquals(a, b, r, Long128VectorTests::max); } + @Test(dataProvider = "longBinaryOpProvider") + static void MINLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long128VectorTests::MIN); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void minLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.min(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long128VectorTests::min); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void MAXLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long128VectorTests::MAX); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void maxLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.max(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long128VectorTests::max); + } + static long AND(long[] a, int idx) { long res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { @@ -3248,6 +3537,10 @@ return (long)(-((long)a)); } + static long neg(long a) { + return (long)(-((long)a)); + } + @Test(dataProvider = "longUnaryOpProvider") static void NEGLong128VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); @@ -3263,6 +3556,21 @@ assertArraysEquals(a, r, Long128VectorTests::NEG); } + @Test(dataProvider = "longUnaryOpProvider") + static void negLong128VectorTests(IntFunction fa) { + long[] a = fa.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.neg().intoArray(r, i); + } + } + + assertArraysEquals(a, r, Long128VectorTests::neg); + } + @Test(dataProvider = "longUnaryOpMaskProvider") static void NEGMaskedLong128VectorTests(IntFunction fa, IntFunction fm) { @@ -3342,6 +3650,10 @@ return (long)(~((long)a)); } + static long not(long a) { + return (long)(~((long)a)); + } + @Test(dataProvider = "longUnaryOpProvider") @@ -3359,6 +3671,21 @@ assertArraysEquals(a, r, Long128VectorTests::NOT); } + @Test(dataProvider = "longUnaryOpProvider") + static void notLong128VectorTests(IntFunction fa) { + long[] a = fa.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.not().intoArray(r, i); + } + } + + assertArraysEquals(a, r, Long128VectorTests::not); + } + @Test(dataProvider = "longUnaryOpMaskProvider") --- old/test/jdk/jdk/incubator/vector/Long256VectorTests.java 2020-05-28 14:30:45.280740221 -0700 +++ new/test/jdk/jdk/incubator/vector/Long256VectorTests.java 2020-05-28 14:30:45.104740221 -0700 @@ -241,6 +241,18 @@ } } + static void assertBroadcastArraysEquals(long[] a, long[] b, long[] 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(long[] a, long[] b, long[] r, boolean[] mask, FBinOp f) { assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); } @@ -256,6 +268,24 @@ } } + static void assertBroadcastArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals(long[] a, long[] b, long[] 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(long[] a, long[] b, long[] r, FBinOp f) { int i = 0; int j = 0; @@ -1374,6 +1404,26 @@ assertArraysEquals(a, b, r, Long256VectorTests::OR); } + static long or(long a, long b) { + return (long)(a | b); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void orLong256VectorTests(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.or(bv).intoArray(r, i); + } + } + + assertArraysEquals(a, b, r, Long256VectorTests::or); + } @@ -1442,6 +1492,189 @@ } + @Test(dataProvider = "longBinaryOpProvider") + static void addLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.add(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long256VectorTests::add); + } + + @Test(dataProvider = "longBinaryOpMaskProvider") + static void addLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.add(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Long256VectorTests::add); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void subLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.sub(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long256VectorTests::sub); + } + + @Test(dataProvider = "longBinaryOpMaskProvider") + static void subLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.sub(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Long256VectorTests::sub); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void mulLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.mul(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long256VectorTests::mul); + } + + @Test(dataProvider = "longBinaryOpMaskProvider") + static void mulLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.mul(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Long256VectorTests::mul); + } + + + + + @Test(dataProvider = "longBinaryOpProvider") + static void divLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + replaceZero(b, (long) 1); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.div(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long256VectorTests::div); + } + + + + @Test(dataProvider = "longBinaryOpMaskProvider") + static void divLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + replaceZero(b, (long) 1); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.div(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Long256VectorTests::div); + } + + + + @Test(dataProvider = "longBinaryOpProvider") + static void ORLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long256VectorTests::OR); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void orLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.or(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long256VectorTests::or); + } + + + + @Test(dataProvider = "longBinaryOpMaskProvider") + static void ORLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Long256VectorTests::OR); + } + + static long LSHL(long a, long b) { return (long)((a << b)); } @@ -1804,6 +2037,62 @@ assertArraysEquals(a, b, r, Long256VectorTests::max); } + @Test(dataProvider = "longBinaryOpProvider") + static void MINLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long256VectorTests::MIN); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void minLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.min(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long256VectorTests::min); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void MAXLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long256VectorTests::MAX); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void maxLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.max(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long256VectorTests::max); + } + static long AND(long[] a, int idx) { long res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { @@ -3248,6 +3537,10 @@ return (long)(-((long)a)); } + static long neg(long a) { + return (long)(-((long)a)); + } + @Test(dataProvider = "longUnaryOpProvider") static void NEGLong256VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); @@ -3263,6 +3556,21 @@ assertArraysEquals(a, r, Long256VectorTests::NEG); } + @Test(dataProvider = "longUnaryOpProvider") + static void negLong256VectorTests(IntFunction fa) { + long[] a = fa.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.neg().intoArray(r, i); + } + } + + assertArraysEquals(a, r, Long256VectorTests::neg); + } + @Test(dataProvider = "longUnaryOpMaskProvider") static void NEGMaskedLong256VectorTests(IntFunction fa, IntFunction fm) { @@ -3342,6 +3650,10 @@ return (long)(~((long)a)); } + static long not(long a) { + return (long)(~((long)a)); + } + @Test(dataProvider = "longUnaryOpProvider") @@ -3359,6 +3671,21 @@ assertArraysEquals(a, r, Long256VectorTests::NOT); } + @Test(dataProvider = "longUnaryOpProvider") + static void notLong256VectorTests(IntFunction fa) { + long[] a = fa.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.not().intoArray(r, i); + } + } + + assertArraysEquals(a, r, Long256VectorTests::not); + } + @Test(dataProvider = "longUnaryOpMaskProvider") --- old/test/jdk/jdk/incubator/vector/Long512VectorTests.java 2020-05-28 14:30:45.648740221 -0700 +++ new/test/jdk/jdk/incubator/vector/Long512VectorTests.java 2020-05-28 14:30:45.472740221 -0700 @@ -241,6 +241,18 @@ } } + static void assertBroadcastArraysEquals(long[] a, long[] b, long[] 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(long[] a, long[] b, long[] r, boolean[] mask, FBinOp f) { assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); } @@ -256,6 +268,24 @@ } } + static void assertBroadcastArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals(long[] a, long[] b, long[] 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(long[] a, long[] b, long[] r, FBinOp f) { int i = 0; int j = 0; @@ -1374,6 +1404,26 @@ assertArraysEquals(a, b, r, Long512VectorTests::OR); } + static long or(long a, long b) { + return (long)(a | b); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void orLong512VectorTests(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.or(bv).intoArray(r, i); + } + } + + assertArraysEquals(a, b, r, Long512VectorTests::or); + } @@ -1442,6 +1492,189 @@ } + @Test(dataProvider = "longBinaryOpProvider") + static void addLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.add(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long512VectorTests::add); + } + + @Test(dataProvider = "longBinaryOpMaskProvider") + static void addLong512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.add(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Long512VectorTests::add); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void subLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.sub(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long512VectorTests::sub); + } + + @Test(dataProvider = "longBinaryOpMaskProvider") + static void subLong512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.sub(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Long512VectorTests::sub); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void mulLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.mul(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long512VectorTests::mul); + } + + @Test(dataProvider = "longBinaryOpMaskProvider") + static void mulLong512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.mul(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Long512VectorTests::mul); + } + + + + + @Test(dataProvider = "longBinaryOpProvider") + static void divLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + replaceZero(b, (long) 1); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.div(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long512VectorTests::div); + } + + + + @Test(dataProvider = "longBinaryOpMaskProvider") + static void divLong512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + replaceZero(b, (long) 1); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.div(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Long512VectorTests::div); + } + + + + @Test(dataProvider = "longBinaryOpProvider") + static void ORLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long512VectorTests::OR); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void orLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.or(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long512VectorTests::or); + } + + + + @Test(dataProvider = "longBinaryOpMaskProvider") + static void ORLong512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Long512VectorTests::OR); + } + + static long LSHL(long a, long b) { return (long)((a << b)); } @@ -1804,6 +2037,62 @@ assertArraysEquals(a, b, r, Long512VectorTests::max); } + @Test(dataProvider = "longBinaryOpProvider") + static void MINLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long512VectorTests::MIN); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void minLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.min(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long512VectorTests::min); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void MAXLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long512VectorTests::MAX); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void maxLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.max(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long512VectorTests::max); + } + static long AND(long[] a, int idx) { long res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { @@ -3248,6 +3537,10 @@ return (long)(-((long)a)); } + static long neg(long a) { + return (long)(-((long)a)); + } + @Test(dataProvider = "longUnaryOpProvider") static void NEGLong512VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); @@ -3263,6 +3556,21 @@ assertArraysEquals(a, r, Long512VectorTests::NEG); } + @Test(dataProvider = "longUnaryOpProvider") + static void negLong512VectorTests(IntFunction fa) { + long[] a = fa.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.neg().intoArray(r, i); + } + } + + assertArraysEquals(a, r, Long512VectorTests::neg); + } + @Test(dataProvider = "longUnaryOpMaskProvider") static void NEGMaskedLong512VectorTests(IntFunction fa, IntFunction fm) { @@ -3342,6 +3650,10 @@ return (long)(~((long)a)); } + static long not(long a) { + return (long)(~((long)a)); + } + @Test(dataProvider = "longUnaryOpProvider") @@ -3359,6 +3671,21 @@ assertArraysEquals(a, r, Long512VectorTests::NOT); } + @Test(dataProvider = "longUnaryOpProvider") + static void notLong512VectorTests(IntFunction fa) { + long[] a = fa.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.not().intoArray(r, i); + } + } + + assertArraysEquals(a, r, Long512VectorTests::not); + } + @Test(dataProvider = "longUnaryOpMaskProvider") --- old/test/jdk/jdk/incubator/vector/Long64VectorTests.java 2020-05-28 14:30:46.016740222 -0700 +++ new/test/jdk/jdk/incubator/vector/Long64VectorTests.java 2020-05-28 14:30:45.840740222 -0700 @@ -241,6 +241,18 @@ } } + static void assertBroadcastArraysEquals(long[] a, long[] b, long[] 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(long[] a, long[] b, long[] r, boolean[] mask, FBinOp f) { assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); } @@ -256,6 +268,24 @@ } } + static void assertBroadcastArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals(long[] a, long[] b, long[] 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(long[] a, long[] b, long[] r, FBinOp f) { int i = 0; int j = 0; @@ -1374,6 +1404,26 @@ assertArraysEquals(a, b, r, Long64VectorTests::OR); } + static long or(long a, long b) { + return (long)(a | b); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void orLong64VectorTests(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.or(bv).intoArray(r, i); + } + } + + assertArraysEquals(a, b, r, Long64VectorTests::or); + } @@ -1442,6 +1492,189 @@ } + @Test(dataProvider = "longBinaryOpProvider") + static void addLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.add(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long64VectorTests::add); + } + + @Test(dataProvider = "longBinaryOpMaskProvider") + static void addLong64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.add(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Long64VectorTests::add); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void subLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.sub(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long64VectorTests::sub); + } + + @Test(dataProvider = "longBinaryOpMaskProvider") + static void subLong64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.sub(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Long64VectorTests::sub); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void mulLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.mul(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long64VectorTests::mul); + } + + @Test(dataProvider = "longBinaryOpMaskProvider") + static void mulLong64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.mul(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Long64VectorTests::mul); + } + + + + + @Test(dataProvider = "longBinaryOpProvider") + static void divLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + replaceZero(b, (long) 1); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.div(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long64VectorTests::div); + } + + + + @Test(dataProvider = "longBinaryOpMaskProvider") + static void divLong64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + replaceZero(b, (long) 1); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.div(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Long64VectorTests::div); + } + + + + @Test(dataProvider = "longBinaryOpProvider") + static void ORLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long64VectorTests::OR); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void orLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.or(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long64VectorTests::or); + } + + + + @Test(dataProvider = "longBinaryOpMaskProvider") + static void ORLong64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Long64VectorTests::OR); + } + + static long LSHL(long a, long b) { return (long)((a << b)); } @@ -1804,6 +2037,62 @@ assertArraysEquals(a, b, r, Long64VectorTests::max); } + @Test(dataProvider = "longBinaryOpProvider") + static void MINLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long64VectorTests::MIN); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void minLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.min(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long64VectorTests::min); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void MAXLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long64VectorTests::MAX); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void maxLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.max(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Long64VectorTests::max); + } + static long AND(long[] a, int idx) { long res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { @@ -3248,6 +3537,10 @@ return (long)(-((long)a)); } + static long neg(long a) { + return (long)(-((long)a)); + } + @Test(dataProvider = "longUnaryOpProvider") static void NEGLong64VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); @@ -3263,6 +3556,21 @@ assertArraysEquals(a, r, Long64VectorTests::NEG); } + @Test(dataProvider = "longUnaryOpProvider") + static void negLong64VectorTests(IntFunction fa) { + long[] a = fa.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.neg().intoArray(r, i); + } + } + + assertArraysEquals(a, r, Long64VectorTests::neg); + } + @Test(dataProvider = "longUnaryOpMaskProvider") static void NEGMaskedLong64VectorTests(IntFunction fa, IntFunction fm) { @@ -3342,6 +3650,10 @@ return (long)(~((long)a)); } + static long not(long a) { + return (long)(~((long)a)); + } + @Test(dataProvider = "longUnaryOpProvider") @@ -3359,6 +3671,21 @@ assertArraysEquals(a, r, Long64VectorTests::NOT); } + @Test(dataProvider = "longUnaryOpProvider") + static void notLong64VectorTests(IntFunction fa) { + long[] a = fa.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.not().intoArray(r, i); + } + } + + assertArraysEquals(a, r, Long64VectorTests::not); + } + @Test(dataProvider = "longUnaryOpMaskProvider") --- old/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java 2020-05-28 14:30:46.388740222 -0700 +++ new/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java 2020-05-28 14:30:46.212740222 -0700 @@ -246,6 +246,18 @@ } } + static void assertBroadcastArraysEquals(long[] a, long[] b, long[] 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(long[] a, long[] b, long[] r, boolean[] mask, FBinOp f) { assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); } @@ -261,6 +273,24 @@ } } + static void assertBroadcastArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals(long[] a, long[] b, long[] 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(long[] a, long[] b, long[] r, FBinOp f) { int i = 0; int j = 0; @@ -1379,6 +1409,26 @@ assertArraysEquals(a, b, r, LongMaxVectorTests::OR); } + static long or(long a, long b) { + return (long)(a | b); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void orLongMaxVectorTests(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.or(bv).intoArray(r, i); + } + } + + assertArraysEquals(a, b, r, LongMaxVectorTests::or); + } @@ -1447,6 +1497,189 @@ } + @Test(dataProvider = "longBinaryOpProvider") + static void addLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.add(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, LongMaxVectorTests::add); + } + + @Test(dataProvider = "longBinaryOpMaskProvider") + static void addLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.add(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, LongMaxVectorTests::add); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void subLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.sub(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, LongMaxVectorTests::sub); + } + + @Test(dataProvider = "longBinaryOpMaskProvider") + static void subLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.sub(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, LongMaxVectorTests::sub); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void mulLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.mul(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, LongMaxVectorTests::mul); + } + + @Test(dataProvider = "longBinaryOpMaskProvider") + static void mulLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.mul(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, LongMaxVectorTests::mul); + } + + + + + @Test(dataProvider = "longBinaryOpProvider") + static void divLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + replaceZero(b, (long) 1); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.div(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, LongMaxVectorTests::div); + } + + + + @Test(dataProvider = "longBinaryOpMaskProvider") + static void divLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + replaceZero(b, (long) 1); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.div(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, LongMaxVectorTests::div); + } + + + + @Test(dataProvider = "longBinaryOpProvider") + static void ORLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, LongMaxVectorTests::OR); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void orLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.or(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, LongMaxVectorTests::or); + } + + + + @Test(dataProvider = "longBinaryOpMaskProvider") + static void ORLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, LongMaxVectorTests::OR); + } + + static long LSHL(long a, long b) { return (long)((a << b)); } @@ -1809,6 +2042,62 @@ assertArraysEquals(a, b, r, LongMaxVectorTests::max); } + @Test(dataProvider = "longBinaryOpProvider") + static void MINLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, LongMaxVectorTests::MIN); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void minLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.min(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, LongMaxVectorTests::min); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void MAXLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, LongMaxVectorTests::MAX); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void maxLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.max(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, LongMaxVectorTests::max); + } + static long AND(long[] a, int idx) { long res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { @@ -3253,6 +3542,10 @@ return (long)(-((long)a)); } + static long neg(long a) { + return (long)(-((long)a)); + } + @Test(dataProvider = "longUnaryOpProvider") static void NEGLongMaxVectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); @@ -3268,6 +3561,21 @@ assertArraysEquals(a, r, LongMaxVectorTests::NEG); } + @Test(dataProvider = "longUnaryOpProvider") + static void negLongMaxVectorTests(IntFunction fa) { + long[] a = fa.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.neg().intoArray(r, i); + } + } + + assertArraysEquals(a, r, LongMaxVectorTests::neg); + } + @Test(dataProvider = "longUnaryOpMaskProvider") static void NEGMaskedLongMaxVectorTests(IntFunction fa, IntFunction fm) { @@ -3347,6 +3655,10 @@ return (long)(~((long)a)); } + static long not(long a) { + return (long)(~((long)a)); + } + @Test(dataProvider = "longUnaryOpProvider") @@ -3364,6 +3676,21 @@ assertArraysEquals(a, r, LongMaxVectorTests::NOT); } + @Test(dataProvider = "longUnaryOpProvider") + static void notLongMaxVectorTests(IntFunction fa) { + long[] a = fa.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + av.not().intoArray(r, i); + } + } + + assertArraysEquals(a, r, LongMaxVectorTests::not); + } + @Test(dataProvider = "longUnaryOpMaskProvider") --- old/test/jdk/jdk/incubator/vector/Short128VectorTests.java 2020-05-28 14:30:46.756740222 -0700 +++ new/test/jdk/jdk/incubator/vector/Short128VectorTests.java 2020-05-28 14:30:46.580740222 -0700 @@ -241,6 +241,18 @@ } } + static void assertBroadcastArraysEquals(short[] a, short[] b, short[] 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(short[] a, short[] b, short[] r, boolean[] mask, FBinOp f) { assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); } @@ -256,6 +268,24 @@ } } + static void assertBroadcastArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals(short[] a, short[] b, short[] 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(short[] a, short[] b, short[] r, FBinOp f) { int i = 0; int j = 0; @@ -1369,6 +1399,26 @@ assertArraysEquals(a, b, r, Short128VectorTests::OR); } + static short or(short a, short b) { + return (short)(a | b); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void orShort128VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.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); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.or(bv).intoArray(r, i); + } + } + + assertArraysEquals(a, b, r, Short128VectorTests::or); + } @@ -1437,6 +1487,189 @@ } + @Test(dataProvider = "shortBinaryOpProvider") + static void addShort128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.add(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short128VectorTests::add); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void addShort128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.add(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Short128VectorTests::add); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void subShort128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.sub(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short128VectorTests::sub); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void subShort128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.sub(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Short128VectorTests::sub); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void mulShort128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.mul(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short128VectorTests::mul); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void mulShort128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.mul(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Short128VectorTests::mul); + } + + + + + @Test(dataProvider = "shortBinaryOpProvider") + static void divShort128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + replaceZero(b, (short) 1); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.div(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short128VectorTests::div); + } + + + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void divShort128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + replaceZero(b, (short) 1); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.div(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Short128VectorTests::div); + } + + + + @Test(dataProvider = "shortBinaryOpProvider") + static void ORShort128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short128VectorTests::OR); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void orShort128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.or(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short128VectorTests::or); + } + + + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void ORShort128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Short128VectorTests::OR); + } + + @@ -1799,6 +2032,62 @@ assertArraysEquals(a, b, r, Short128VectorTests::max); } + @Test(dataProvider = "shortBinaryOpProvider") + static void MINShort128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short128VectorTests::MIN); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void minShort128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.min(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short128VectorTests::min); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void MAXShort128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short128VectorTests::MAX); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void maxShort128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.max(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short128VectorTests::max); + } + static short AND(short[] a, int idx) { short res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { @@ -3243,6 +3532,10 @@ return (short)(-((short)a)); } + static short neg(short a) { + return (short)(-((short)a)); + } + @Test(dataProvider = "shortUnaryOpProvider") static void NEGShort128VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); @@ -3258,6 +3551,21 @@ assertArraysEquals(a, r, Short128VectorTests::NEG); } + @Test(dataProvider = "shortUnaryOpProvider") + static void negShort128VectorTests(IntFunction 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.neg().intoArray(r, i); + } + } + + assertArraysEquals(a, r, Short128VectorTests::neg); + } + @Test(dataProvider = "shortUnaryOpMaskProvider") static void NEGMaskedShort128VectorTests(IntFunction fa, IntFunction fm) { @@ -3337,6 +3645,10 @@ return (short)(~((short)a)); } + static short not(short a) { + return (short)(~((short)a)); + } + @Test(dataProvider = "shortUnaryOpProvider") @@ -3354,6 +3666,21 @@ assertArraysEquals(a, r, Short128VectorTests::NOT); } + @Test(dataProvider = "shortUnaryOpProvider") + static void notShort128VectorTests(IntFunction 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.not().intoArray(r, i); + } + } + + assertArraysEquals(a, r, Short128VectorTests::not); + } + @Test(dataProvider = "shortUnaryOpMaskProvider") --- old/test/jdk/jdk/incubator/vector/Short256VectorTests.java 2020-05-28 14:30:47.128740223 -0700 +++ new/test/jdk/jdk/incubator/vector/Short256VectorTests.java 2020-05-28 14:30:46.952740223 -0700 @@ -241,6 +241,18 @@ } } + static void assertBroadcastArraysEquals(short[] a, short[] b, short[] 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(short[] a, short[] b, short[] r, boolean[] mask, FBinOp f) { assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); } @@ -256,6 +268,24 @@ } } + static void assertBroadcastArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals(short[] a, short[] b, short[] 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(short[] a, short[] b, short[] r, FBinOp f) { int i = 0; int j = 0; @@ -1369,6 +1399,26 @@ assertArraysEquals(a, b, r, Short256VectorTests::OR); } + static short or(short a, short b) { + return (short)(a | b); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void orShort256VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.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); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.or(bv).intoArray(r, i); + } + } + + assertArraysEquals(a, b, r, Short256VectorTests::or); + } @@ -1437,6 +1487,189 @@ } + @Test(dataProvider = "shortBinaryOpProvider") + static void addShort256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.add(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short256VectorTests::add); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void addShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.add(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Short256VectorTests::add); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void subShort256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.sub(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short256VectorTests::sub); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void subShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.sub(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Short256VectorTests::sub); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void mulShort256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.mul(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short256VectorTests::mul); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void mulShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.mul(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Short256VectorTests::mul); + } + + + + + @Test(dataProvider = "shortBinaryOpProvider") + static void divShort256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + replaceZero(b, (short) 1); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.div(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short256VectorTests::div); + } + + + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void divShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + replaceZero(b, (short) 1); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.div(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Short256VectorTests::div); + } + + + + @Test(dataProvider = "shortBinaryOpProvider") + static void ORShort256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short256VectorTests::OR); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void orShort256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.or(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short256VectorTests::or); + } + + + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void ORShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Short256VectorTests::OR); + } + + @@ -1799,6 +2032,62 @@ assertArraysEquals(a, b, r, Short256VectorTests::max); } + @Test(dataProvider = "shortBinaryOpProvider") + static void MINShort256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short256VectorTests::MIN); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void minShort256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.min(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short256VectorTests::min); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void MAXShort256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short256VectorTests::MAX); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void maxShort256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.max(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short256VectorTests::max); + } + static short AND(short[] a, int idx) { short res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { @@ -3243,6 +3532,10 @@ return (short)(-((short)a)); } + static short neg(short a) { + return (short)(-((short)a)); + } + @Test(dataProvider = "shortUnaryOpProvider") static void NEGShort256VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); @@ -3258,6 +3551,21 @@ assertArraysEquals(a, r, Short256VectorTests::NEG); } + @Test(dataProvider = "shortUnaryOpProvider") + static void negShort256VectorTests(IntFunction 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.neg().intoArray(r, i); + } + } + + assertArraysEquals(a, r, Short256VectorTests::neg); + } + @Test(dataProvider = "shortUnaryOpMaskProvider") static void NEGMaskedShort256VectorTests(IntFunction fa, IntFunction fm) { @@ -3337,6 +3645,10 @@ return (short)(~((short)a)); } + static short not(short a) { + return (short)(~((short)a)); + } + @Test(dataProvider = "shortUnaryOpProvider") @@ -3354,6 +3666,21 @@ assertArraysEquals(a, r, Short256VectorTests::NOT); } + @Test(dataProvider = "shortUnaryOpProvider") + static void notShort256VectorTests(IntFunction 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.not().intoArray(r, i); + } + } + + assertArraysEquals(a, r, Short256VectorTests::not); + } + @Test(dataProvider = "shortUnaryOpMaskProvider") --- old/test/jdk/jdk/incubator/vector/Short512VectorTests.java 2020-05-28 14:30:47.500740223 -0700 +++ new/test/jdk/jdk/incubator/vector/Short512VectorTests.java 2020-05-28 14:30:47.320740223 -0700 @@ -241,6 +241,18 @@ } } + static void assertBroadcastArraysEquals(short[] a, short[] b, short[] 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(short[] a, short[] b, short[] r, boolean[] mask, FBinOp f) { assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); } @@ -256,6 +268,24 @@ } } + static void assertBroadcastArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals(short[] a, short[] b, short[] 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(short[] a, short[] b, short[] r, FBinOp f) { int i = 0; int j = 0; @@ -1369,6 +1399,26 @@ assertArraysEquals(a, b, r, Short512VectorTests::OR); } + static short or(short a, short b) { + return (short)(a | b); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void orShort512VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.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); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.or(bv).intoArray(r, i); + } + } + + assertArraysEquals(a, b, r, Short512VectorTests::or); + } @@ -1437,6 +1487,189 @@ } + @Test(dataProvider = "shortBinaryOpProvider") + static void addShort512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.add(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short512VectorTests::add); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void addShort512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.add(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Short512VectorTests::add); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void subShort512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.sub(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short512VectorTests::sub); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void subShort512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.sub(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Short512VectorTests::sub); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void mulShort512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.mul(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short512VectorTests::mul); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void mulShort512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.mul(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Short512VectorTests::mul); + } + + + + + @Test(dataProvider = "shortBinaryOpProvider") + static void divShort512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + replaceZero(b, (short) 1); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.div(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short512VectorTests::div); + } + + + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void divShort512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + replaceZero(b, (short) 1); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.div(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Short512VectorTests::div); + } + + + + @Test(dataProvider = "shortBinaryOpProvider") + static void ORShort512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short512VectorTests::OR); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void orShort512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.or(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short512VectorTests::or); + } + + + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void ORShort512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Short512VectorTests::OR); + } + + @@ -1799,6 +2032,62 @@ assertArraysEquals(a, b, r, Short512VectorTests::max); } + @Test(dataProvider = "shortBinaryOpProvider") + static void MINShort512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short512VectorTests::MIN); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void minShort512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.min(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short512VectorTests::min); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void MAXShort512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short512VectorTests::MAX); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void maxShort512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.max(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short512VectorTests::max); + } + static short AND(short[] a, int idx) { short res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { @@ -3243,6 +3532,10 @@ return (short)(-((short)a)); } + static short neg(short a) { + return (short)(-((short)a)); + } + @Test(dataProvider = "shortUnaryOpProvider") static void NEGShort512VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); @@ -3258,6 +3551,21 @@ assertArraysEquals(a, r, Short512VectorTests::NEG); } + @Test(dataProvider = "shortUnaryOpProvider") + static void negShort512VectorTests(IntFunction 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.neg().intoArray(r, i); + } + } + + assertArraysEquals(a, r, Short512VectorTests::neg); + } + @Test(dataProvider = "shortUnaryOpMaskProvider") static void NEGMaskedShort512VectorTests(IntFunction fa, IntFunction fm) { @@ -3337,6 +3645,10 @@ return (short)(~((short)a)); } + static short not(short a) { + return (short)(~((short)a)); + } + @Test(dataProvider = "shortUnaryOpProvider") @@ -3354,6 +3666,21 @@ assertArraysEquals(a, r, Short512VectorTests::NOT); } + @Test(dataProvider = "shortUnaryOpProvider") + static void notShort512VectorTests(IntFunction 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.not().intoArray(r, i); + } + } + + assertArraysEquals(a, r, Short512VectorTests::not); + } + @Test(dataProvider = "shortUnaryOpMaskProvider") --- old/test/jdk/jdk/incubator/vector/Short64VectorTests.java 2020-05-28 14:30:47.872740224 -0700 +++ new/test/jdk/jdk/incubator/vector/Short64VectorTests.java 2020-05-28 14:30:47.692740223 -0700 @@ -241,6 +241,18 @@ } } + static void assertBroadcastArraysEquals(short[] a, short[] b, short[] 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(short[] a, short[] b, short[] r, boolean[] mask, FBinOp f) { assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); } @@ -256,6 +268,24 @@ } } + static void assertBroadcastArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals(short[] a, short[] b, short[] 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(short[] a, short[] b, short[] r, FBinOp f) { int i = 0; int j = 0; @@ -1369,6 +1399,26 @@ assertArraysEquals(a, b, r, Short64VectorTests::OR); } + static short or(short a, short b) { + return (short)(a | b); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void orShort64VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.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); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.or(bv).intoArray(r, i); + } + } + + assertArraysEquals(a, b, r, Short64VectorTests::or); + } @@ -1437,6 +1487,189 @@ } + @Test(dataProvider = "shortBinaryOpProvider") + static void addShort64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.add(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short64VectorTests::add); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void addShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.add(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Short64VectorTests::add); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void subShort64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.sub(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short64VectorTests::sub); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void subShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.sub(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Short64VectorTests::sub); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void mulShort64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.mul(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short64VectorTests::mul); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void mulShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.mul(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Short64VectorTests::mul); + } + + + + + @Test(dataProvider = "shortBinaryOpProvider") + static void divShort64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + replaceZero(b, (short) 1); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.div(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short64VectorTests::div); + } + + + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void divShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + replaceZero(b, (short) 1); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.div(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Short64VectorTests::div); + } + + + + @Test(dataProvider = "shortBinaryOpProvider") + static void ORShort64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short64VectorTests::OR); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void orShort64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.or(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short64VectorTests::or); + } + + + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void ORShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, Short64VectorTests::OR); + } + + @@ -1799,6 +2032,62 @@ assertArraysEquals(a, b, r, Short64VectorTests::max); } + @Test(dataProvider = "shortBinaryOpProvider") + static void MINShort64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short64VectorTests::MIN); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void minShort64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.min(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short64VectorTests::min); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void MAXShort64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short64VectorTests::MAX); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void maxShort64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.max(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, Short64VectorTests::max); + } + static short AND(short[] a, int idx) { short res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { @@ -3243,6 +3532,10 @@ return (short)(-((short)a)); } + static short neg(short a) { + return (short)(-((short)a)); + } + @Test(dataProvider = "shortUnaryOpProvider") static void NEGShort64VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); @@ -3258,6 +3551,21 @@ assertArraysEquals(a, r, Short64VectorTests::NEG); } + @Test(dataProvider = "shortUnaryOpProvider") + static void negShort64VectorTests(IntFunction 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.neg().intoArray(r, i); + } + } + + assertArraysEquals(a, r, Short64VectorTests::neg); + } + @Test(dataProvider = "shortUnaryOpMaskProvider") static void NEGMaskedShort64VectorTests(IntFunction fa, IntFunction fm) { @@ -3337,6 +3645,10 @@ return (short)(~((short)a)); } + static short not(short a) { + return (short)(~((short)a)); + } + @Test(dataProvider = "shortUnaryOpProvider") @@ -3354,6 +3666,21 @@ assertArraysEquals(a, r, Short64VectorTests::NOT); } + @Test(dataProvider = "shortUnaryOpProvider") + static void notShort64VectorTests(IntFunction 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.not().intoArray(r, i); + } + } + + assertArraysEquals(a, r, Short64VectorTests::not); + } + @Test(dataProvider = "shortUnaryOpMaskProvider") --- old/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java 2020-05-28 14:30:48.244740224 -0700 +++ new/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java 2020-05-28 14:30:48.068740224 -0700 @@ -246,6 +246,18 @@ } } + static void assertBroadcastArraysEquals(short[] a, short[] b, short[] 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(short[] a, short[] b, short[] r, boolean[] mask, FBinOp f) { assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); } @@ -261,6 +273,24 @@ } } + static void assertBroadcastArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals(short[] a, short[] b, short[] 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(short[] a, short[] b, short[] r, FBinOp f) { int i = 0; int j = 0; @@ -1374,6 +1404,26 @@ assertArraysEquals(a, b, r, ShortMaxVectorTests::OR); } + static short or(short a, short b) { + return (short)(a | b); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void orShortMaxVectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.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); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.or(bv).intoArray(r, i); + } + } + + assertArraysEquals(a, b, r, ShortMaxVectorTests::or); + } @@ -1442,6 +1492,189 @@ } + @Test(dataProvider = "shortBinaryOpProvider") + static void addShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.add(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, ShortMaxVectorTests::add); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void addShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.add(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, ShortMaxVectorTests::add); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void subShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.sub(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, ShortMaxVectorTests::sub); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void subShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.sub(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, ShortMaxVectorTests::sub); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void mulShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.mul(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, ShortMaxVectorTests::mul); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void mulShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.mul(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, ShortMaxVectorTests::mul); + } + + + + + @Test(dataProvider = "shortBinaryOpProvider") + static void divShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + replaceZero(b, (short) 1); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.div(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, ShortMaxVectorTests::div); + } + + + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void divShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + replaceZero(b, (short) 1); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.div(b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, ShortMaxVectorTests::div); + } + + + + @Test(dataProvider = "shortBinaryOpProvider") + static void ORShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, ShortMaxVectorTests::OR); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void orShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.or(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, ShortMaxVectorTests::or); + } + + + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void ORShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, mask, ShortMaxVectorTests::OR); + } + + @@ -1804,6 +2037,62 @@ assertArraysEquals(a, b, r, ShortMaxVectorTests::max); } + @Test(dataProvider = "shortBinaryOpProvider") + static void MINShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, ShortMaxVectorTests::MIN); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void minShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.min(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, ShortMaxVectorTests::min); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void MAXShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, ShortMaxVectorTests::MAX); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void maxShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + av.max(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(a, b, r, ShortMaxVectorTests::max); + } + static short AND(short[] a, int idx) { short res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { @@ -3248,6 +3537,10 @@ return (short)(-((short)a)); } + static short neg(short a) { + return (short)(-((short)a)); + } + @Test(dataProvider = "shortUnaryOpProvider") static void NEGShortMaxVectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); @@ -3263,6 +3556,21 @@ assertArraysEquals(a, r, ShortMaxVectorTests::NEG); } + @Test(dataProvider = "shortUnaryOpProvider") + static void negShortMaxVectorTests(IntFunction 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.neg().intoArray(r, i); + } + } + + assertArraysEquals(a, r, ShortMaxVectorTests::neg); + } + @Test(dataProvider = "shortUnaryOpMaskProvider") static void NEGMaskedShortMaxVectorTests(IntFunction fa, IntFunction fm) { @@ -3342,6 +3650,10 @@ return (short)(~((short)a)); } + static short not(short a) { + return (short)(~((short)a)); + } + @Test(dataProvider = "shortUnaryOpProvider") @@ -3359,6 +3671,21 @@ assertArraysEquals(a, r, ShortMaxVectorTests::NOT); } + @Test(dataProvider = "shortUnaryOpProvider") + static void notShortMaxVectorTests(IntFunction 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.not().intoArray(r, i); + } + } + + assertArraysEquals(a, r, ShortMaxVectorTests::not); + } + @Test(dataProvider = "shortUnaryOpMaskProvider") --- old/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Byte128Vector.java 2020-05-28 14:30:48.612740224 -0700 +++ new/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Byte128Vector.java 2020-05-28 14:30:48.436740224 -0700 @@ -1230,7 +1230,7 @@ } @Benchmark - public void extract(Blackhole bh) { + public void laneextract(Blackhole bh) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); --- old/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Byte256Vector.java 2020-05-28 14:30:48.964740225 -0700 +++ new/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Byte256Vector.java 2020-05-28 14:30:48.788740224 -0700 @@ -1230,7 +1230,7 @@ } @Benchmark - public void extract(Blackhole bh) { + public void laneextract(Blackhole bh) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); --- old/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Byte512Vector.java 2020-05-28 14:30:49.320740225 -0700 +++ new/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Byte512Vector.java 2020-05-28 14:30:49.144740225 -0700 @@ -1230,7 +1230,7 @@ } @Benchmark - public void extract(Blackhole bh) { + public void laneextract(Blackhole bh) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); --- old/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Byte64Vector.java 2020-05-28 14:30:49.676740225 -0700 +++ new/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Byte64Vector.java 2020-05-28 14:30:49.500740225 -0700 @@ -1230,7 +1230,7 @@ } @Benchmark - public void extract(Blackhole bh) { + public void laneextract(Blackhole bh) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); --- old/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/ByteMaxVector.java 2020-05-28 14:30:50.032740226 -0700 +++ new/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/ByteMaxVector.java 2020-05-28 14:30:49.852740225 -0700 @@ -1230,7 +1230,7 @@ } @Benchmark - public void extract(Blackhole bh) { + public void laneextract(Blackhole bh) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); --- old/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Double128Vector.java 2020-05-28 14:30:50.384740226 -0700 +++ new/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Double128Vector.java 2020-05-28 14:30:50.208740226 -0700 @@ -760,7 +760,7 @@ } @Benchmark - public void extract(Blackhole bh) { + public void laneextract(Blackhole bh) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); --- old/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Double256Vector.java 2020-05-28 14:30:50.740740226 -0700 +++ new/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Double256Vector.java 2020-05-28 14:30:50.564740226 -0700 @@ -760,7 +760,7 @@ } @Benchmark - public void extract(Blackhole bh) { + public void laneextract(Blackhole bh) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); --- old/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Double512Vector.java 2020-05-28 14:30:51.092740227 -0700 +++ new/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Double512Vector.java 2020-05-28 14:30:50.912740226 -0700 @@ -760,7 +760,7 @@ } @Benchmark - public void extract(Blackhole bh) { + public void laneextract(Blackhole bh) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); --- old/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Double64Vector.java 2020-05-28 14:30:51.440740227 -0700 +++ new/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Double64Vector.java 2020-05-28 14:30:51.264740227 -0700 @@ -760,7 +760,7 @@ } @Benchmark - public void extract(Blackhole bh) { + public void laneextract(Blackhole bh) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); --- old/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/DoubleMaxVector.java 2020-05-28 14:30:51.792740227 -0700 +++ new/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/DoubleMaxVector.java 2020-05-28 14:30:51.616740227 -0700 @@ -760,7 +760,7 @@ } @Benchmark - public void extract(Blackhole bh) { + public void laneextract(Blackhole bh) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); --- old/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Float128Vector.java 2020-05-28 14:30:52.144740228 -0700 +++ new/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Float128Vector.java 2020-05-28 14:30:51.968740227 -0700 @@ -760,7 +760,7 @@ } @Benchmark - public void extract(Blackhole bh) { + public void laneextract(Blackhole bh) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); --- old/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Float256Vector.java 2020-05-28 14:30:52.500740228 -0700 +++ new/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Float256Vector.java 2020-05-28 14:30:52.324740228 -0700 @@ -760,7 +760,7 @@ } @Benchmark - public void extract(Blackhole bh) { + public void laneextract(Blackhole bh) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); --- old/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Float512Vector.java 2020-05-28 14:30:52.856740228 -0700 +++ new/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Float512Vector.java 2020-05-28 14:30:52.680740228 -0700 @@ -760,7 +760,7 @@ } @Benchmark - public void extract(Blackhole bh) { + public void laneextract(Blackhole bh) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); --- old/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Float64Vector.java 2020-05-28 14:30:53.212740229 -0700 +++ new/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Float64Vector.java 2020-05-28 14:30:53.036740229 -0700 @@ -760,7 +760,7 @@ } @Benchmark - public void extract(Blackhole bh) { + public void laneextract(Blackhole bh) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); --- old/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/FloatMaxVector.java 2020-05-28 14:30:53.568740229 -0700 +++ new/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/FloatMaxVector.java 2020-05-28 14:30:53.392740229 -0700 @@ -760,7 +760,7 @@ } @Benchmark - public void extract(Blackhole bh) { + public void laneextract(Blackhole bh) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); --- old/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Int128Vector.java 2020-05-28 14:30:53.920740229 -0700 +++ new/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Int128Vector.java 2020-05-28 14:30:53.744740229 -0700 @@ -1230,7 +1230,7 @@ } @Benchmark - public void extract(Blackhole bh) { + public void laneextract(Blackhole bh) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); --- old/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Int256Vector.java 2020-05-28 14:30:54.268740230 -0700 +++ new/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Int256Vector.java 2020-05-28 14:30:54.096740230 -0700 @@ -1230,7 +1230,7 @@ } @Benchmark - public void extract(Blackhole bh) { + public void laneextract(Blackhole bh) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); --- old/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Int512Vector.java 2020-05-28 14:30:54.620740230 -0700 +++ new/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Int512Vector.java 2020-05-28 14:30:54.444740230 -0700 @@ -1230,7 +1230,7 @@ } @Benchmark - public void extract(Blackhole bh) { + public void laneextract(Blackhole bh) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); --- old/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Int64Vector.java 2020-05-28 14:30:54.972740230 -0700 +++ new/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Int64Vector.java 2020-05-28 14:30:54.796740230 -0700 @@ -1230,7 +1230,7 @@ } @Benchmark - public void extract(Blackhole bh) { + public void laneextract(Blackhole bh) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); --- old/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/IntMaxVector.java 2020-05-28 14:30:55.324740231 -0700 +++ new/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/IntMaxVector.java 2020-05-28 14:30:55.148740231 -0700 @@ -1230,7 +1230,7 @@ } @Benchmark - public void extract(Blackhole bh) { + public void laneextract(Blackhole bh) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); --- old/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Long128Vector.java 2020-05-28 14:30:55.676740231 -0700 +++ new/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Long128Vector.java 2020-05-28 14:30:55.500740231 -0700 @@ -1230,7 +1230,7 @@ } @Benchmark - public void extract(Blackhole bh) { + public void laneextract(Blackhole bh) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); --- old/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Long256Vector.java 2020-05-28 14:30:56.028740231 -0700 +++ new/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Long256Vector.java 2020-05-28 14:30:55.852740231 -0700 @@ -1230,7 +1230,7 @@ } @Benchmark - public void extract(Blackhole bh) { + public void laneextract(Blackhole bh) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); --- old/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Long512Vector.java 2020-05-28 14:30:56.384740232 -0700 +++ new/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Long512Vector.java 2020-05-28 14:30:56.208740232 -0700 @@ -1230,7 +1230,7 @@ } @Benchmark - public void extract(Blackhole bh) { + public void laneextract(Blackhole bh) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); --- old/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Long64Vector.java 2020-05-28 14:30:56.736740232 -0700 +++ new/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Long64Vector.java 2020-05-28 14:30:56.560740232 -0700 @@ -1230,7 +1230,7 @@ } @Benchmark - public void extract(Blackhole bh) { + public void laneextract(Blackhole bh) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); --- old/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/LongMaxVector.java 2020-05-28 14:30:57.088740232 -0700 +++ new/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/LongMaxVector.java 2020-05-28 14:30:56.912740232 -0700 @@ -1230,7 +1230,7 @@ } @Benchmark - public void extract(Blackhole bh) { + public void laneextract(Blackhole bh) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); --- old/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Short128Vector.java 2020-05-28 14:30:57.440740233 -0700 +++ new/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Short128Vector.java 2020-05-28 14:30:57.264740233 -0700 @@ -1230,7 +1230,7 @@ } @Benchmark - public void extract(Blackhole bh) { + public void laneextract(Blackhole bh) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); --- old/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Short256Vector.java 2020-05-28 14:30:57.792740233 -0700 +++ new/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Short256Vector.java 2020-05-28 14:30:57.620740233 -0700 @@ -1230,7 +1230,7 @@ } @Benchmark - public void extract(Blackhole bh) { + public void laneextract(Blackhole bh) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); --- old/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Short512Vector.java 2020-05-28 14:30:58.144740233 -0700 +++ new/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Short512Vector.java 2020-05-28 14:30:57.972740233 -0700 @@ -1230,7 +1230,7 @@ } @Benchmark - public void extract(Blackhole bh) { + public void laneextract(Blackhole bh) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); --- old/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Short64Vector.java 2020-05-28 14:30:58.504740234 -0700 +++ new/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Short64Vector.java 2020-05-28 14:30:58.328740234 -0700 @@ -1230,7 +1230,7 @@ } @Benchmark - public void extract(Blackhole bh) { + public void laneextract(Blackhole bh) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); --- old/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/ShortMaxVector.java 2020-05-28 14:30:58.856740234 -0700 +++ new/test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/ShortMaxVector.java 2020-05-28 14:30:58.680740234 -0700 @@ -1230,7 +1230,7 @@ } @Benchmark - public void extract(Blackhole bh) { + public void laneextract(Blackhole bh) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); --- old/test/jdk/jdk/incubator/vector/gen-template.sh 2020-05-28 14:30:59.204740234 -0700 +++ new/test/jdk/jdk/incubator/vector/gen-template.sh 2020-05-28 14:30:59.032740234 -0700 @@ -40,6 +40,8 @@ ternary_scalar="Ternary-Scalar-op" binary="Binary-op" binary_masked="Binary-Masked-op" +binary_broadcast="Binary-Broadcast-op" +binary_broadcast_masked="Binary-Broadcast-Masked-op" binary_scalar="Binary-Scalar-op" blend="Blend-op" test_template="Test" @@ -105,10 +107,17 @@ local test_func="" local withMask="" local tests=($(awk -F+ '{$1=$1} 1' <<< $test)) - if [ "${tests[1]}" != "" ]; then + if [ "${tests[2]}" == "withMask" ]; then test=${tests[0]} test_func=${tests[1]} withMask=${tests[2]} + elif [ "${tests[1]}" == "withMask" ]; then + test="" + test_func=${tests[0]} + withMask=${tests[1]} + elif [ "${tests[1]}" != "" ]; then + test=${tests[0]} + test_func=${tests[1]} fi sed_prog=" @@ -133,7 +142,9 @@ if [ "$guard" != "" ]; then echo -e "#if[${guard}]\n" >> $output fi - sed -e "$sed_prog" < ${filename}.current >> $output + if [ "$test" != "" ]; then + sed -e "$sed_prog" < ${filename}.current >> $output + fi # If we also have a dedicated function for the operation then use 2nd sed expression if [[ "$filename" == *"Unit"* ]] && [ "$test_func" != "" ]; then if [ "$masked" == "" ] || [ "$withMask" != "" ]; then @@ -188,7 +199,11 @@ # Replace template variables in unit test files (if any) replace_variables $unit_filename $unit_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" - if [ $generate_perf_tests == true ]; then + local gen_perf_tests=$generate_perf_tests + if [[ $template == *"-Broadcast-"* ]]; then + gen_perf_tests=false + fi + if [ $gen_perf_tests == true ]; then # Replace template variables in performance test files (if any) local perf_wrapper_filename="${TEMPLATE_FOLDER}/Perf-wrapper.template" local perf_vector_filename="${TEMPLATE_FOLDER}/Perf-${template}.template" @@ -216,6 +231,12 @@ gen_op_tmpl $binary_masked "$@" } +function gen_binary_alu_bcst_op { + echo "Generating binary broadcast op $1 ($2)..." + gen_op_tmpl $binary_broadcast "$@" + gen_op_tmpl $binary_broadcast_masked "$@" +} + function gen_shift_cst_op { echo "Generating Shift constant op $1 ($2)..." gen_op_tmpl $shift_template "$@" @@ -249,6 +270,11 @@ gen_op_tmpl $binary "$@" } +function gen_binary_bcst_op_no_masked { + echo "Generating binary op $1 ($2)..." + gen_op_tmpl $binary_broadcast "$@" +} + function gen_reduction_op { echo "Generating reduction op $1 ($2)..." gen_op_tmpl $reduction_scalar "$@" @@ -331,9 +357,17 @@ gen_binary_alu_op "FIRST_NONZERO" "{#if[FP]?Double.doubleToLongBits}(a)!=0?a:b" gen_binary_alu_op "AND+and" "a \& b" "BITWISE" gen_binary_alu_op "AND_NOT" "a \& ~b" "BITWISE" -gen_binary_alu_op "OR" "a | b" "BITWISE" +gen_binary_alu_op "OR+or" "a | b" "BITWISE" # Missing: "OR_UNCHECKED" gen_binary_alu_op "XOR" "a ^ b" "BITWISE" +# Generate the broadcast versions +gen_binary_alu_bcst_op "add+withMask" "a + b" +gen_binary_alu_bcst_op "sub+withMask" "a - b" +gen_binary_alu_bcst_op "mul+withMask" "a \* b" +gen_binary_alu_bcst_op "div+withMask" "a \/ b" "FP" +gen_op_tmpl "Binary-Broadcast-op_bitwise-div" "div+withMask" "a \/ b" "BITWISE" +gen_op_tmpl "Binary-Broadcast-Masked-op_bitwise-div" "div+withMask" "a \/ b" "BITWISE" +gen_binary_alu_bcst_op "OR+or" "a | b" "BITWISE" # Shifts gen_binary_alu_op "LSHL" "(a << b)" "intOrLong" @@ -358,6 +392,8 @@ # Masked reductions. gen_binary_op_no_masked "MIN+min" "Math.min(a, b)" gen_binary_op_no_masked "MAX+max" "Math.max(a, b)" +gen_binary_bcst_op_no_masked "MIN+min" "Math.min(a, b)" +gen_binary_bcst_op_no_masked "MAX+max" "Math.max(a, b)" # Reductions. gen_reduction_op "AND" "\&" "BITWISE" "-1" @@ -398,7 +434,7 @@ gen_op_tmpl $rearrange_template "rearrange" "" # Get -gen_get_op "" "" +gen_get_op "lane" "" # Broadcast gen_op_tmpl $broadcast_template "broadcast" "" @@ -441,9 +477,9 @@ gen_ternary_alu_op "BITWISE_BLEND" "(a\&~(c))|(b\&c)" "BITWISE" # Unary operations. -gen_unary_alu_op "NEG" "-((\$type\$)a)" +gen_unary_alu_op "NEG+neg" "-((\$type\$)a)" gen_unary_alu_op "ABS+abs" "Math.abs((\$type\$)a)" -gen_unary_alu_op "NOT" "~((\$type\$)a)" "BITWISE" +gen_unary_alu_op "NOT+not" "~((\$type\$)a)" "BITWISE" gen_unary_alu_op "ZOMO" "(a==0?0:-1)" "BITWISE" gen_unary_alu_op "SQRT" "Math.sqrt((double)a)" "FP" --- old/test/jdk/jdk/incubator/vector/templates/Unit-header.template 2020-05-28 14:30:59.552740235 -0700 +++ new/test/jdk/jdk/incubator/vector/templates/Unit-header.template 2020-05-28 14:30:59.376740235 -0700 @@ -270,6 +270,18 @@ } } + static void assertBroadcastArraysEquals($type$[] a, $type$[] b, $type$[] 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($type$[] a, $type$[] b, $type$[] r, boolean[] mask, FBinOp f) { assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); } @@ -285,6 +297,24 @@ } } + static void assertBroadcastArraysEquals($type$[] a, $type$[] b, $type$[] r, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals($type$[] a, $type$[] b, $type$[] 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($type$[] a, $type$[] b, $type$[] r, FBinOp f) { int i = 0; int j = 0; --- /dev/null 2020-02-06 15:35:06.751096717 -0800 +++ new/test/jdk/jdk/incubator/vector/templates/Kernel-Binary-Broadcast-Masked-op.template 2020-05-28 14:30:59.728740235 -0700 @@ -0,0 +1,10 @@ + $type$[] a = fa.apply(SPECIES.length()); + $type$[] b = fb.apply(SPECIES.length()); + $type$[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask<$Wideboxtype$> vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.[[TEST]], b[i], vmask).intoArray(r, i); + } --- /dev/null 2020-02-06 15:35:06.751096717 -0800 +++ new/test/jdk/jdk/incubator/vector/templates/Kernel-Binary-Broadcast-Masked-op_bitwise-div.template 2020-05-28 14:31:00.088740235 -0700 @@ -0,0 +1,12 @@ + $type$[] a = fa.apply(SPECIES.length()); + $type$[] b = fb.apply(SPECIES.length()); + $type$[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask<$Wideboxtype$> vmask = VectorMask.fromArray(SPECIES, mask, 0); + + replaceZero(b, ($type$) 1); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.[[TEST]], b[i], vmask).intoArray(r, i); + } --- /dev/null 2020-02-06 15:35:06.751096717 -0800 +++ new/test/jdk/jdk/incubator/vector/templates/Kernel-Binary-Broadcast-op.template 2020-05-28 14:31:00.452740236 -0700 @@ -0,0 +1,8 @@ + $type$[] a = fa.apply(SPECIES.length()); + $type$[] b = fb.apply(SPECIES.length()); + $type$[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.[[TEST]], b[i]).intoArray(r, i); + } --- /dev/null 2020-02-06 15:35:06.751096717 -0800 +++ new/test/jdk/jdk/incubator/vector/templates/Kernel-Binary-Broadcast-op_bitwise-div.template 2020-05-28 14:31:00.812740236 -0700 @@ -0,0 +1,10 @@ + $type$[] a = fa.apply(SPECIES.length()); + $type$[] b = fb.apply(SPECIES.length()); + $type$[] r = fr.apply(SPECIES.length()); + + replaceZero(b, ($type$) 1); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.[[TEST]], b[i]).intoArray(r, i); + } --- /dev/null 2020-02-06 15:35:06.751096717 -0800 +++ new/test/jdk/jdk/incubator/vector/templates/Unit-Binary-Broadcast-Masked-op.template 2020-05-28 14:31:01.180740236 -0700 @@ -0,0 +1,7 @@ + + @Test(dataProvider = "$type$BinaryOpMaskProvider") + static void [[TEST]]$vectorteststype$BroadcastMaskedSmokeTest(IntFunction<$type$[]> fa, IntFunction<$type$[]> fb, + IntFunction fm) { +[[KERNEL]] + assertBroadcastArraysEquals(a, b, r, mask, $vectorteststype$::[[TEST]]); + } --- /dev/null 2020-02-06 15:35:06.751096717 -0800 +++ new/test/jdk/jdk/incubator/vector/templates/Unit-Binary-Broadcast-op.template 2020-05-28 14:31:01.540740237 -0700 @@ -0,0 +1,6 @@ + + @Test(dataProvider = "$type$BinaryOpProvider") + static void [[TEST]]$vectorteststype$BroadcastSmokeTest(IntFunction<$type$[]> fa, IntFunction<$type$[]> fb) { +[[KERNEL]] + assertBroadcastArraysEquals(a, b, r, $vectorteststype$::[[TEST]]); + }