< prev index next >

test/jdk/jdk/incubator/vector/LongMaxVectorTests.java

Print this page

        

*** 244,253 **** --- 244,265 ---- } catch (AssertionError e) { Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } + 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)); } static void assertArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinMaskOp f) {
*** 259,268 **** --- 271,298 ---- } catch (AssertionError err) { Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } + static void assertBroadcastArraysEquals(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; try { for (; j < a.length; j += SPECIES.length()) {
*** 1377,1386 **** --- 1407,1436 ---- } } assertArraysEquals(a, b, r, LongMaxVectorTests::OR); } + static long or(long a, long b) { + return (long)(a | b); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void orLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> 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); + } @Test(dataProvider = "longBinaryOpMaskProvider") static void ORLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
*** 1445,1454 **** --- 1495,1687 ---- assertArraysEquals(a, b, r, mask, LongMaxVectorTests::XOR); } + @Test(dataProvider = "longBinaryOpProvider") + static void addLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> 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<long[]> fa, IntFunction<long[]> fb, + IntFunction<boolean[]> 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<Long> 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<long[]> fa, IntFunction<long[]> 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<long[]> fa, IntFunction<long[]> fb, + IntFunction<boolean[]> 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<Long> 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<long[]> fa, IntFunction<long[]> 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<long[]> fa, IntFunction<long[]> fb, + IntFunction<boolean[]> 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<Long> 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<long[]> fa, IntFunction<long[]> 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<long[]> fa, IntFunction<long[]> fb, + IntFunction<boolean[]> 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<Long> 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<long[]> fa, IntFunction<long[]> 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<long[]> fa, IntFunction<long[]> 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<long[]> fa, IntFunction<long[]> fb, + IntFunction<boolean[]> 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<Long> 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)); } @Test(dataProvider = "longBinaryOpProvider")
*** 1807,1816 **** --- 2040,2105 ---- } assertArraysEquals(a, b, r, LongMaxVectorTests::max); } + @Test(dataProvider = "longBinaryOpProvider") + static void MINLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> 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<long[]> fa, IntFunction<long[]> 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<long[]> fa, IntFunction<long[]> 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<long[]> fa, IntFunction<long[]> 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++) { res &= a[i]; }
*** 3251,3260 **** --- 3540,3553 ---- static long NEG(long a) { return (long)(-((long)a)); } + static long neg(long a) { + return (long)(-((long)a)); + } + @Test(dataProvider = "longUnaryOpProvider") static void NEGLongMaxVectorTests(IntFunction<long[]> fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length());
*** 3266,3275 **** --- 3559,3583 ---- } assertArraysEquals(a, r, LongMaxVectorTests::NEG); } + @Test(dataProvider = "longUnaryOpProvider") + static void negLongMaxVectorTests(IntFunction<long[]> 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<long[]> fa, IntFunction<boolean[]> fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length());
*** 3345,3354 **** --- 3653,3666 ---- static long NOT(long a) { return (long)(~((long)a)); } + static long not(long a) { + return (long)(~((long)a)); + } + @Test(dataProvider = "longUnaryOpProvider") static void NOTLongMaxVectorTests(IntFunction<long[]> fa) { long[] a = fa.apply(SPECIES.length());
*** 3362,3371 **** --- 3674,3698 ---- } assertArraysEquals(a, r, LongMaxVectorTests::NOT); } + @Test(dataProvider = "longUnaryOpProvider") + static void notLongMaxVectorTests(IntFunction<long[]> 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") static void NOTMaskedLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {
< prev index next >