--- old/test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java 2020-05-27 18:20:58.984670677 -0700 +++ new/test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java 2020-05-27 18:20:58.804670677 -0700 @@ -246,6 +246,17 @@ } } + 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 +272,21 @@ } } + 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 +1296,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 +1544,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 +3214,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 +3233,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) {