--- old/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java 2020-05-27 18:21:05.384670683 -0700 +++ new/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java 2020-05-27 18:21:05.168670683 -0700 @@ -246,6 +246,17 @@ } } + 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 +272,21 @@ } } + 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 +1405,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 +1493,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 +2038,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 +3538,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 +3557,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 +3651,10 @@ return (long)(~((long)a)); } + static long not(long a) { + return (long)(~((long)a)); + } + @Test(dataProvider = "longUnaryOpProvider") @@ -3364,6 +3672,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")