< prev index next >
test/jdk/jdk/incubator/vector/Double512VectorTests.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(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,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(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,1272 ****
--- 1293,1434 ----
+ @Test(dataProvider = "doubleBinaryOpProvider")
+ static void addDouble512VectorTestsBroadcastSmokeTest(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, Double512VectorTests::add);
+ }
+
+ @Test(dataProvider = "doubleBinaryOpMaskProvider")
+ static void addDouble512VectorTestsBroadcastMaskedSmokeTest(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, Double512VectorTests::add);
+ }
+
+ @Test(dataProvider = "doubleBinaryOpProvider")
+ static void subDouble512VectorTestsBroadcastSmokeTest(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, Double512VectorTests::sub);
+ }
+
+ @Test(dataProvider = "doubleBinaryOpMaskProvider")
+ static void subDouble512VectorTestsBroadcastMaskedSmokeTest(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, Double512VectorTests::sub);
+ }
+
+ @Test(dataProvider = "doubleBinaryOpProvider")
+ static void mulDouble512VectorTestsBroadcastSmokeTest(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, Double512VectorTests::mul);
+ }
+
+ @Test(dataProvider = "doubleBinaryOpMaskProvider")
+ static void mulDouble512VectorTestsBroadcastMaskedSmokeTest(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, Double512VectorTests::mul);
+ }
+
+
+ @Test(dataProvider = "doubleBinaryOpProvider")
+ static void divDouble512VectorTestsBroadcastSmokeTest(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, Double512VectorTests::div);
+ }
+
+
+
+ @Test(dataProvider = "doubleBinaryOpMaskProvider")
+ static void divDouble512VectorTestsBroadcastMaskedSmokeTest(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, Double512VectorTests::div);
+ }
+
+
+
+
+
+
*** 1379,1388 ****
--- 1541,1606 ----
}
assertArraysEquals(a, b, r, Double512VectorTests::max);
}
+ @Test(dataProvider = "doubleBinaryOpProvider")
+ static void MINDouble512VectorTestsBroadcastSmokeTest(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, Double512VectorTests::MIN);
+ }
+
+ @Test(dataProvider = "doubleBinaryOpProvider")
+ static void minDouble512VectorTestsBroadcastSmokeTest(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, Double512VectorTests::min);
+ }
+
+ @Test(dataProvider = "doubleBinaryOpProvider")
+ static void MAXDouble512VectorTestsBroadcastSmokeTest(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, Double512VectorTests::MAX);
+ }
+
+ @Test(dataProvider = "doubleBinaryOpProvider")
+ static void maxDouble512VectorTestsBroadcastSmokeTest(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, Double512VectorTests::max);
+ }
+
*** 2993,3002 ****
--- 3211,3224 ----
static double NEG(double a) {
return (double)(-((double)a));
}
+ static double neg(double a) {
+ return (double)(-((double)a));
+ }
+
@Test(dataProvider = "doubleUnaryOpProvider")
static void NEGDouble512VectorTests(IntFunction<double[]> fa) {
double[] a = fa.apply(SPECIES.length());
double[] r = fr.apply(SPECIES.length());
*** 3008,3017 ****
--- 3230,3254 ----
}
assertArraysEquals(a, r, Double512VectorTests::NEG);
}
+ @Test(dataProvider = "doubleUnaryOpProvider")
+ static void negDouble512VectorTests(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, Double512VectorTests::neg);
+ }
+
@Test(dataProvider = "doubleUnaryOpMaskProvider")
static void NEGMaskedDouble512VectorTests(IntFunction<double[]> fa,
IntFunction<boolean[]> fm) {
double[] a = fa.apply(SPECIES.length());
double[] r = fr.apply(SPECIES.length());
< prev index next >