< prev index next >
test/jdk/jdk/incubator/vector/Long64VectorTests.java
Print this page
@@ -239,10 +239,22 @@
} 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,10 +266,28 @@
} 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,10 +1402,30 @@
}
}
assertArraysEquals(a, b, r, Long64VectorTests::OR);
}
+ static long or(long a, long b) {
+ return (long)(a | b);
+ }
+
+ @Test(dataProvider = "longBinaryOpProvider")
+ static void orLong64VectorTests(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, Long64VectorTests::or);
+ }
@Test(dataProvider = "longBinaryOpMaskProvider")
static void ORLong64VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
@@ -1440,10 +1490,193 @@
assertArraysEquals(a, b, r, mask, Long64VectorTests::XOR);
}
+ @Test(dataProvider = "longBinaryOpProvider")
+ static void addLong64VectorTestsBroadcastSmokeTest(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, Long64VectorTests::add);
+ }
+
+ @Test(dataProvider = "longBinaryOpMaskProvider")
+ static void addLong64VectorTestsBroadcastMaskedSmokeTest(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, Long64VectorTests::add);
+ }
+
+ @Test(dataProvider = "longBinaryOpProvider")
+ static void subLong64VectorTestsBroadcastSmokeTest(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, Long64VectorTests::sub);
+ }
+
+ @Test(dataProvider = "longBinaryOpMaskProvider")
+ static void subLong64VectorTestsBroadcastMaskedSmokeTest(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, Long64VectorTests::sub);
+ }
+
+ @Test(dataProvider = "longBinaryOpProvider")
+ static void mulLong64VectorTestsBroadcastSmokeTest(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, Long64VectorTests::mul);
+ }
+
+ @Test(dataProvider = "longBinaryOpMaskProvider")
+ static void mulLong64VectorTestsBroadcastMaskedSmokeTest(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, Long64VectorTests::mul);
+ }
+
+
+
+
+ @Test(dataProvider = "longBinaryOpProvider")
+ static void divLong64VectorTestsBroadcastSmokeTest(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, Long64VectorTests::div);
+ }
+
+
+
+ @Test(dataProvider = "longBinaryOpMaskProvider")
+ static void divLong64VectorTestsBroadcastMaskedSmokeTest(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, Long64VectorTests::div);
+ }
+
+
+
+ @Test(dataProvider = "longBinaryOpProvider")
+ static void ORLong64VectorTestsBroadcastSmokeTest(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, Long64VectorTests::OR);
+ }
+
+ @Test(dataProvider = "longBinaryOpProvider")
+ static void orLong64VectorTestsBroadcastSmokeTest(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, Long64VectorTests::or);
+ }
+
+
+
+ @Test(dataProvider = "longBinaryOpMaskProvider")
+ static void ORLong64VectorTestsBroadcastMaskedSmokeTest(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, Long64VectorTests::OR);
+ }
+
+
static long LSHL(long a, long b) {
return (long)((a << b));
}
@Test(dataProvider = "longBinaryOpProvider")
@@ -1802,10 +2035,66 @@
}
assertArraysEquals(a, b, r, Long64VectorTests::max);
}
+ @Test(dataProvider = "longBinaryOpProvider")
+ static void MINLong64VectorTestsBroadcastSmokeTest(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, Long64VectorTests::MIN);
+ }
+
+ @Test(dataProvider = "longBinaryOpProvider")
+ static void minLong64VectorTestsBroadcastSmokeTest(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, Long64VectorTests::min);
+ }
+
+ @Test(dataProvider = "longBinaryOpProvider")
+ static void MAXLong64VectorTestsBroadcastSmokeTest(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, Long64VectorTests::MAX);
+ }
+
+ @Test(dataProvider = "longBinaryOpProvider")
+ static void maxLong64VectorTestsBroadcastSmokeTest(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, Long64VectorTests::max);
+ }
+
static long AND(long[] a, int idx) {
long res = -1;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res &= a[i];
}
@@ -3246,10 +3535,14 @@
static long NEG(long a) {
return (long)(-((long)a));
}
+ static long neg(long a) {
+ return (long)(-((long)a));
+ }
+
@Test(dataProvider = "longUnaryOpProvider")
static void NEGLong64VectorTests(IntFunction<long[]> fa) {
long[] a = fa.apply(SPECIES.length());
long[] r = fr.apply(SPECIES.length());
@@ -3261,10 +3554,25 @@
}
assertArraysEquals(a, r, Long64VectorTests::NEG);
}
+ @Test(dataProvider = "longUnaryOpProvider")
+ static void negLong64VectorTests(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, Long64VectorTests::neg);
+ }
+
@Test(dataProvider = "longUnaryOpMaskProvider")
static void NEGMaskedLong64VectorTests(IntFunction<long[]> fa,
IntFunction<boolean[]> fm) {
long[] a = fa.apply(SPECIES.length());
long[] r = fr.apply(SPECIES.length());
@@ -3340,10 +3648,14 @@
static long NOT(long a) {
return (long)(~((long)a));
}
+ static long not(long a) {
+ return (long)(~((long)a));
+ }
+
@Test(dataProvider = "longUnaryOpProvider")
static void NOTLong64VectorTests(IntFunction<long[]> fa) {
long[] a = fa.apply(SPECIES.length());
@@ -3357,10 +3669,25 @@
}
assertArraysEquals(a, r, Long64VectorTests::NOT);
}
+ @Test(dataProvider = "longUnaryOpProvider")
+ static void notLong64VectorTests(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, Long64VectorTests::not);
+ }
+
@Test(dataProvider = "longUnaryOpMaskProvider")
static void NOTMaskedLong64VectorTests(IntFunction<long[]> fa,
IntFunction<boolean[]> fm) {
< prev index next >