< prev index next >
test/jdk/jdk/incubator/vector/Long256VectorTests.java
Print this page
*** 239,248 ****
--- 239,260 ----
} catch (AssertionError e) {
Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i);
}
}
+ static void assertBroadcastArraysEquals(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) {
*** 254,263 ****
--- 266,293 ----
} catch (AssertionError err) {
Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]);
}
}
+ static void assertBroadcastArraysEquals(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()) {
*** 1372,1381 ****
--- 1402,1431 ----
}
}
assertArraysEquals(a, b, r, Long256VectorTests::OR);
}
+ static long or(long a, long b) {
+ return (long)(a | b);
+ }
+
+ @Test(dataProvider = "longBinaryOpProvider")
+ static void orLong256VectorTests(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, Long256VectorTests::or);
+ }
@Test(dataProvider = "longBinaryOpMaskProvider")
static void ORLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
*** 1440,1449 ****
--- 1490,1682 ----
assertArraysEquals(a, b, r, mask, Long256VectorTests::XOR);
}
+ @Test(dataProvider = "longBinaryOpProvider")
+ static void addLong256VectorTestsBroadcastSmokeTest(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, Long256VectorTests::add);
+ }
+
+ @Test(dataProvider = "longBinaryOpMaskProvider")
+ static void addLong256VectorTestsBroadcastMaskedSmokeTest(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, Long256VectorTests::add);
+ }
+
+ @Test(dataProvider = "longBinaryOpProvider")
+ static void subLong256VectorTestsBroadcastSmokeTest(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, Long256VectorTests::sub);
+ }
+
+ @Test(dataProvider = "longBinaryOpMaskProvider")
+ static void subLong256VectorTestsBroadcastMaskedSmokeTest(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, Long256VectorTests::sub);
+ }
+
+ @Test(dataProvider = "longBinaryOpProvider")
+ static void mulLong256VectorTestsBroadcastSmokeTest(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, Long256VectorTests::mul);
+ }
+
+ @Test(dataProvider = "longBinaryOpMaskProvider")
+ static void mulLong256VectorTestsBroadcastMaskedSmokeTest(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, Long256VectorTests::mul);
+ }
+
+
+
+
+ @Test(dataProvider = "longBinaryOpProvider")
+ static void divLong256VectorTestsBroadcastSmokeTest(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, Long256VectorTests::div);
+ }
+
+
+
+ @Test(dataProvider = "longBinaryOpMaskProvider")
+ static void divLong256VectorTestsBroadcastMaskedSmokeTest(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, Long256VectorTests::div);
+ }
+
+
+
+ @Test(dataProvider = "longBinaryOpProvider")
+ static void ORLong256VectorTestsBroadcastSmokeTest(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, Long256VectorTests::OR);
+ }
+
+ @Test(dataProvider = "longBinaryOpProvider")
+ static void orLong256VectorTestsBroadcastSmokeTest(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, Long256VectorTests::or);
+ }
+
+
+
+ @Test(dataProvider = "longBinaryOpMaskProvider")
+ static void ORLong256VectorTestsBroadcastMaskedSmokeTest(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, Long256VectorTests::OR);
+ }
+
+
static long LSHL(long a, long b) {
return (long)((a << b));
}
@Test(dataProvider = "longBinaryOpProvider")
*** 1802,1811 ****
--- 2035,2100 ----
}
assertArraysEquals(a, b, r, Long256VectorTests::max);
}
+ @Test(dataProvider = "longBinaryOpProvider")
+ static void MINLong256VectorTestsBroadcastSmokeTest(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, Long256VectorTests::MIN);
+ }
+
+ @Test(dataProvider = "longBinaryOpProvider")
+ static void minLong256VectorTestsBroadcastSmokeTest(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, Long256VectorTests::min);
+ }
+
+ @Test(dataProvider = "longBinaryOpProvider")
+ static void MAXLong256VectorTestsBroadcastSmokeTest(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, Long256VectorTests::MAX);
+ }
+
+ @Test(dataProvider = "longBinaryOpProvider")
+ static void maxLong256VectorTestsBroadcastSmokeTest(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, Long256VectorTests::max);
+ }
+
static long AND(long[] a, int idx) {
long res = -1;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res &= a[i];
}
*** 3246,3255 ****
--- 3535,3548 ----
static long NEG(long a) {
return (long)(-((long)a));
}
+ static long neg(long a) {
+ return (long)(-((long)a));
+ }
+
@Test(dataProvider = "longUnaryOpProvider")
static void NEGLong256VectorTests(IntFunction<long[]> fa) {
long[] a = fa.apply(SPECIES.length());
long[] r = fr.apply(SPECIES.length());
*** 3261,3270 ****
--- 3554,3578 ----
}
assertArraysEquals(a, r, Long256VectorTests::NEG);
}
+ @Test(dataProvider = "longUnaryOpProvider")
+ static void negLong256VectorTests(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, Long256VectorTests::neg);
+ }
+
@Test(dataProvider = "longUnaryOpMaskProvider")
static void NEGMaskedLong256VectorTests(IntFunction<long[]> fa,
IntFunction<boolean[]> fm) {
long[] a = fa.apply(SPECIES.length());
long[] r = fr.apply(SPECIES.length());
*** 3340,3349 ****
--- 3648,3661 ----
static long NOT(long a) {
return (long)(~((long)a));
}
+ static long not(long a) {
+ return (long)(~((long)a));
+ }
+
@Test(dataProvider = "longUnaryOpProvider")
static void NOTLong256VectorTests(IntFunction<long[]> fa) {
long[] a = fa.apply(SPECIES.length());
*** 3357,3366 ****
--- 3669,3693 ----
}
assertArraysEquals(a, r, Long256VectorTests::NOT);
}
+ @Test(dataProvider = "longUnaryOpProvider")
+ static void notLong256VectorTests(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, Long256VectorTests::not);
+ }
+
@Test(dataProvider = "longUnaryOpMaskProvider")
static void NOTMaskedLong256VectorTests(IntFunction<long[]> fa,
IntFunction<boolean[]> fm) {
< prev index next >