< prev index next >
test/jdk/jdk/incubator/vector/Double64VectorTests.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(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));
}
static void assertArraysEquals(double[] a, double[] b, double[] 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(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;
try {
for (; j < a.length; j += SPECIES.length()) {
@@ -1263,10 +1293,142 @@
+ @Test(dataProvider = "doubleBinaryOpProvider")
+ static void addDouble64VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> 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, Double64VectorTests::add);
+ }
+
+ @Test(dataProvider = "doubleBinaryOpMaskProvider")
+ static void addDouble64VectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
+ IntFunction<boolean[]> 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<Double> 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, Double64VectorTests::add);
+ }
+
+ @Test(dataProvider = "doubleBinaryOpProvider")
+ static void subDouble64VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> 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, Double64VectorTests::sub);
+ }
+
+ @Test(dataProvider = "doubleBinaryOpMaskProvider")
+ static void subDouble64VectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
+ IntFunction<boolean[]> 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<Double> 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, Double64VectorTests::sub);
+ }
+
+ @Test(dataProvider = "doubleBinaryOpProvider")
+ static void mulDouble64VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> 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, Double64VectorTests::mul);
+ }
+
+ @Test(dataProvider = "doubleBinaryOpMaskProvider")
+ static void mulDouble64VectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
+ IntFunction<boolean[]> 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<Double> 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, Double64VectorTests::mul);
+ }
+
+
+ @Test(dataProvider = "doubleBinaryOpProvider")
+ static void divDouble64VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> 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, Double64VectorTests::div);
+ }
+
+
+
+ @Test(dataProvider = "doubleBinaryOpMaskProvider")
+ static void divDouble64VectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
+ IntFunction<boolean[]> 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<Double> 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, Double64VectorTests::div);
+ }
+
+
+
+
+
+
@@ -1379,10 +1541,66 @@
}
assertArraysEquals(a, b, r, Double64VectorTests::max);
}
+ @Test(dataProvider = "doubleBinaryOpProvider")
+ static void MINDouble64VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> 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, Double64VectorTests::MIN);
+ }
+
+ @Test(dataProvider = "doubleBinaryOpProvider")
+ static void minDouble64VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> 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, Double64VectorTests::min);
+ }
+
+ @Test(dataProvider = "doubleBinaryOpProvider")
+ static void MAXDouble64VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> 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, Double64VectorTests::MAX);
+ }
+
+ @Test(dataProvider = "doubleBinaryOpProvider")
+ static void maxDouble64VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> 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, Double64VectorTests::max);
+ }
+
@@ -2993,10 +3211,14 @@
static double NEG(double a) {
return (double)(-((double)a));
}
+ static double neg(double a) {
+ return (double)(-((double)a));
+ }
+
@Test(dataProvider = "doubleUnaryOpProvider")
static void NEGDouble64VectorTests(IntFunction<double[]> fa) {
double[] a = fa.apply(SPECIES.length());
double[] r = fr.apply(SPECIES.length());
@@ -3008,10 +3230,25 @@
}
assertArraysEquals(a, r, Double64VectorTests::NEG);
}
+ @Test(dataProvider = "doubleUnaryOpProvider")
+ static void negDouble64VectorTests(IntFunction<double[]> 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, Double64VectorTests::neg);
+ }
+
@Test(dataProvider = "doubleUnaryOpMaskProvider")
static void NEGMaskedDouble64VectorTests(IntFunction<double[]> fa,
IntFunction<boolean[]> fm) {
double[] a = fa.apply(SPECIES.length());
double[] r = fr.apply(SPECIES.length());
< prev index next >