< prev index next > test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java
Print this page
return VectorShape.S_Max_BIT;
}
private static final int Max = 256; // juts so we can do N/Max
- private static final double CONST_SHIFT = Double.SIZE / 2;
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max);
interface FUnOp {
double apply(double a);
int idx = i + j;
Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]);
}
}
+ static void assertcompressArraysEquals(double[] r, double[] a, boolean[] m, int vector_len) {
+ int i = 0, j = 0, k = 0;
+ try {
+ for (; i < a.length; i += vector_len) {
+ k = 0;
+ for (j = 0; j < vector_len; j++) {
+ if (m[(i + j) % SPECIES.length()]) {
+ Assert.assertEquals(r[i + k], a[i + j]);
+ k++;
+ }
+ }
+ for (; k < vector_len; k++) {
+ Assert.assertEquals(r[i + k], (double)0);
+ }
+ }
+ } catch (AssertionError e) {
+ int idx = i + k;
+ if (m[(i + j) % SPECIES.length()]) {
+ Assert.assertEquals(r[idx], a[i + j], "at index #" + idx);
+ } else {
+ Assert.assertEquals(r[idx], (double)0, "at index #" + idx);
+ }
+ }
+ }
+
+ static void assertexpandArraysEquals(double[] r, double[] a, boolean[] m, int vector_len) {
+ int i = 0, j = 0, k = 0;
+ try {
+ for (; i < a.length; i += vector_len) {
+ k = 0;
+ for (j = 0; j < vector_len; j++) {
+ if (m[(i + j) % SPECIES.length()]) {
+ Assert.assertEquals(r[i + j], a[i + k]);
+ k++;
+ } else {
+ Assert.assertEquals(r[i + j], (double)0);
+ }
+ }
+ }
+ } catch (AssertionError e) {
+ int idx = i + j;
+ if (m[idx % SPECIES.length()]) {
+ Assert.assertEquals(r[idx], a[i + k], "at index #" + idx);
+ } else {
+ Assert.assertEquals(r[idx], (double)0, "at index #" + idx);
+ }
+ }
+ }
+
static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, int vector_len) {
int i = 0, j = 0;
try {
for (; i < a.length; i += vector_len) {
for (j = 0; j < vector_len; j++) {
} catch (AssertionError e) {
Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
}
}
-
-
static long bits(double e) {
return Double.doubleToLongBits(e);
}
static final List<IntFunction<double[]>> DOUBLE_GENERATORS = List.of(
return new Object[] {fa, fs, fm};
}))).
toArray(Object[][]::new);
}
-
static final List<IntFunction<double[]>> DOUBLE_COMPARE_GENERATORS = List.of(
withToString("double[i]", (int s) -> {
return fill(s * BUFFER_REPS,
i -> (double)i);
}),
static final IntFunction<long[]> lfr = (vl) -> {
int length = BUFFER_REPS * vl;
return new long[length];
};
-
static boolean eq(double a, double b) {
return a == b;
}
static boolean neq(double a, double b) {
static boolean ge(double a, double b) {
return a >= b;
}
-
static double firstNonZero(double a, double b) {
return Double.compare(a, (double) 0) != 0 ? a : b;
}
@Test
}
}
assertArraysEquals(r, a, b, DoubleMaxVectorTests::ADD);
}
+
static double add(double a, double b) {
return (double)(a + b);
}
@Test(dataProvider = "doubleBinaryOpProvider")
av.add(bv, vmask).intoArray(r, i);
}
assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::add);
}
+
static double SUB(double a, double b) {
return (double)(a - b);
}
@Test(dataProvider = "doubleBinaryOpProvider")
}
}
assertArraysEquals(r, a, b, DoubleMaxVectorTests::SUB);
}
+
static double sub(double a, double b) {
return (double)(a - b);
}
@Test(dataProvider = "doubleBinaryOpProvider")
av.sub(bv, vmask).intoArray(r, i);
}
assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::sub);
}
+
static double MUL(double a, double b) {
return (double)(a * b);
}
@Test(dataProvider = "doubleBinaryOpProvider")
}
}
assertArraysEquals(r, a, b, DoubleMaxVectorTests::MUL);
}
+
static double mul(double a, double b) {
return (double)(a * b);
}
@Test(dataProvider = "doubleBinaryOpProvider")
}
}
assertArraysEquals(r, a, b, DoubleMaxVectorTests::DIV);
}
+
static double div(double a, double b) {
return (double)(a / b);
}
@Test(dataProvider = "doubleBinaryOpProvider")
}
assertArraysEquals(r, a, b, DoubleMaxVectorTests::div);
}
-
-
@Test(dataProvider = "doubleBinaryOpMaskProvider")
static void DIVDoubleMaxVectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
IntFunction<boolean[]> fm) {
double[] a = fa.apply(SPECIES.length());
double[] b = fb.apply(SPECIES.length());
}
assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::div);
}
-
-
static double FIRST_NONZERO(double a, double b) {
return (double)(Double.doubleToLongBits(a)!=0?a:b);
}
@Test(dataProvider = "doubleBinaryOpProvider")
}
assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::FIRST_NONZERO);
}
-
-
-
-
-
-
-
-
@Test(dataProvider = "doubleBinaryOpProvider")
static void addDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
double[] a = fa.apply(SPECIES.length());
double[] b = fb.apply(SPECIES.length());
double[] r = fr.apply(SPECIES.length());
}
assertBroadcastArraysEquals(r, a, b, mask, DoubleMaxVectorTests::mul);
}
-
@Test(dataProvider = "doubleBinaryOpProvider")
static void divDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
double[] a = fa.apply(SPECIES.length());
double[] b = fb.apply(SPECIES.length());
double[] r = fr.apply(SPECIES.length());
}
assertBroadcastArraysEquals(r, a, b, DoubleMaxVectorTests::div);
}
-
-
@Test(dataProvider = "doubleBinaryOpMaskProvider")
static void divDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
IntFunction<boolean[]> fm) {
double[] a = fa.apply(SPECIES.length());
double[] b = fb.apply(SPECIES.length());
}
assertBroadcastArraysEquals(r, a, b, mask, DoubleMaxVectorTests::div);
}
-
-
-
-
-
-
-
-
-
@Test(dataProvider = "doubleBinaryOpProvider")
static void ADDDoubleMaxVectorTestsBroadcastLongSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
double[] a = fa.apply(SPECIES.length());
double[] b = fb.apply(SPECIES.length());
double[] r = fr.apply(SPECIES.length());
}
assertBroadcastLongArraysEquals(r, a, b, mask, DoubleMaxVectorTests::ADD);
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
static double MIN(double a, double b) {
return (double)(Math.min(a, b));
}
@Test(dataProvider = "doubleBinaryOpProvider")
}
}
assertArraysEquals(r, a, b, DoubleMaxVectorTests::MIN);
}
+
static double min(double a, double b) {
return (double)(Math.min(a, b));
}
@Test(dataProvider = "doubleBinaryOpProvider")
av.min(bv).intoArray(r, i);
}
assertArraysEquals(r, a, b, DoubleMaxVectorTests::min);
}
+
static double MAX(double a, double b) {
return (double)(Math.max(a, b));
}
@Test(dataProvider = "doubleBinaryOpProvider")
}
}
assertArraysEquals(r, a, b, DoubleMaxVectorTests::MAX);
}
+
static double max(double a, double b) {
return (double)(Math.max(a, b));
}
@Test(dataProvider = "doubleBinaryOpProvider")
}
assertBroadcastArraysEquals(r, a, b, DoubleMaxVectorTests::max);
}
-
-
-
-
-
-
-
-
-
-
-
static double ADDReduce(double[] a, int idx) {
double res = 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res += a[i];
}
res += ADDReduce(a, i);
}
return res;
}
+
@Test(dataProvider = "doubleUnaryOpProvider")
static void ADDReduceDoubleMaxVectorTests(IntFunction<double[]> fa) {
double[] a = fa.apply(SPECIES.length());
double[] r = fr.apply(SPECIES.length());
double ra = 0;
}
assertReductionArraysEquals(r, ra, a,
DoubleMaxVectorTests::ADDReduce, DoubleMaxVectorTests::ADDReduceAll);
}
+
static double ADDReduceMasked(double[] a, int idx, boolean[] mask) {
double res = 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res += a[i];
res += ADDReduceMasked(a, i, mask);
}
return res;
}
+
@Test(dataProvider = "doubleUnaryOpMaskProvider")
static void ADDReduceDoubleMaxVectorTestsMasked(IntFunction<double[]> fa, IntFunction<boolean[]> fm) {
double[] a = fa.apply(SPECIES.length());
double[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
DoubleMaxVectorTests::ADDReduceMasked, DoubleMaxVectorTests::ADDReduceAllMasked);
}
+
static double MULReduce(double[] a, int idx) {
double res = 1;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res *= a[i];
}
res *= MULReduce(a, i);
}
return res;
}
+
@Test(dataProvider = "doubleUnaryOpProvider")
static void MULReduceDoubleMaxVectorTests(IntFunction<double[]> fa) {
double[] a = fa.apply(SPECIES.length());
double[] r = fr.apply(SPECIES.length());
double ra = 1;
}
assertReductionArraysEquals(r, ra, a,
DoubleMaxVectorTests::MULReduce, DoubleMaxVectorTests::MULReduceAll);
}
+
static double MULReduceMasked(double[] a, int idx, boolean[] mask) {
double res = 1;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res *= a[i];
res *= MULReduceMasked(a, i, mask);
}
return res;
}
+
@Test(dataProvider = "doubleUnaryOpMaskProvider")
static void MULReduceDoubleMaxVectorTestsMasked(IntFunction<double[]> fa, IntFunction<boolean[]> fm) {
double[] a = fa.apply(SPECIES.length());
double[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
DoubleMaxVectorTests::MULReduceMasked, DoubleMaxVectorTests::MULReduceAllMasked);
}
+
static double MINReduce(double[] a, int idx) {
double res = Double.POSITIVE_INFINITY;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (double) Math.min(res, a[i]);
}
res = (double) Math.min(res, MINReduce(a, i));
}
return res;
}
+
@Test(dataProvider = "doubleUnaryOpProvider")
static void MINReduceDoubleMaxVectorTests(IntFunction<double[]> fa) {
double[] a = fa.apply(SPECIES.length());
double[] r = fr.apply(SPECIES.length());
double ra = Double.POSITIVE_INFINITY;
}
assertReductionArraysEquals(r, ra, a,
DoubleMaxVectorTests::MINReduce, DoubleMaxVectorTests::MINReduceAll);
}
+
static double MINReduceMasked(double[] a, int idx, boolean[] mask) {
double res = Double.POSITIVE_INFINITY;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (double) Math.min(res, a[i]);
res = (double) Math.min(res, MINReduceMasked(a, i, mask));
}
return res;
}
+
@Test(dataProvider = "doubleUnaryOpMaskProvider")
static void MINReduceDoubleMaxVectorTestsMasked(IntFunction<double[]> fa, IntFunction<boolean[]> fm) {
double[] a = fa.apply(SPECIES.length());
double[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
DoubleMaxVectorTests::MINReduceMasked, DoubleMaxVectorTests::MINReduceAllMasked);
}
+
static double MAXReduce(double[] a, int idx) {
double res = Double.NEGATIVE_INFINITY;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (double) Math.max(res, a[i]);
}
res = (double) Math.max(res, MAXReduce(a, i));
}
return res;
}
+
@Test(dataProvider = "doubleUnaryOpProvider")
static void MAXReduceDoubleMaxVectorTests(IntFunction<double[]> fa) {
double[] a = fa.apply(SPECIES.length());
double[] r = fr.apply(SPECIES.length());
double ra = Double.NEGATIVE_INFINITY;
}
assertReductionArraysEquals(r, ra, a,
DoubleMaxVectorTests::MAXReduce, DoubleMaxVectorTests::MAXReduceAll);
}
+
static double MAXReduceMasked(double[] a, int idx, boolean[] mask) {
double res = Double.NEGATIVE_INFINITY;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (double) Math.max(res, a[i]);
res = (double) Math.max(res, MAXReduceMasked(a, i, mask));
}
return res;
}
+
@Test(dataProvider = "doubleUnaryOpMaskProvider")
static void MAXReduceDoubleMaxVectorTestsMasked(IntFunction<double[]> fa, IntFunction<boolean[]> fm) {
double[] a = fa.apply(SPECIES.length());
double[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
DoubleMaxVectorTests::MAXReduceMasked, DoubleMaxVectorTests::MAXReduceAllMasked);
}
+
static double FIRST_NONZEROReduce(double[] a, int idx) {
double res = (double) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = firstNonZero(res, a[i]);
}
res = firstNonZero(res, FIRST_NONZEROReduce(a, i));
}
return res;
}
+
@Test(dataProvider = "doubleUnaryOpProvider")
static void FIRST_NONZEROReduceDoubleMaxVectorTests(IntFunction<double[]> fa) {
double[] a = fa.apply(SPECIES.length());
double[] r = fr.apply(SPECIES.length());
double ra = (double) 0;
}
assertReductionArraysEquals(r, ra, a,
DoubleMaxVectorTests::FIRST_NONZEROReduce, DoubleMaxVectorTests::FIRST_NONZEROReduceAll);
}
+
static double FIRST_NONZEROReduceMasked(double[] a, int idx, boolean[] mask) {
double res = (double) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = firstNonZero(res, a[i]);
res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask));
}
return res;
}
+
@Test(dataProvider = "doubleUnaryOpMaskProvider")
static void FIRST_NONZEROReduceDoubleMaxVectorTestsMasked(IntFunction<double[]> fa, IntFunction<boolean[]> fm) {
double[] a = fa.apply(SPECIES.length());
double[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
assertReductionArraysEqualsMasked(r, ra, a, mask,
DoubleMaxVectorTests::FIRST_NONZEROReduceMasked, DoubleMaxVectorTests::FIRST_NONZEROReduceAllMasked);
}
-
-
-
-
@Test(dataProvider = "doubleUnaryOpProvider")
static void withDoubleMaxVectorTests(IntFunction<double []> fa) {
double[] a = fa.apply(SPECIES.length());
double[] r = fr.apply(SPECIES.length());
for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
assertInsertArraysEquals(r, a, (double)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length());
}
}
+
static boolean testIS_DEFAULT(double a) {
return bits(a)==0;
}
@Test(dataProvider = "doubleTestOpProvider")
Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j]));
}
}
}
}
+
static boolean testIS_NEGATIVE(double a) {
return bits(a)<0;
}
@Test(dataProvider = "doubleTestOpProvider")
}
}
}
}
-
static boolean testIS_NAN(double a) {
return Double.isNaN(a);
}
@Test(dataProvider = "doubleTestOpProvider")
}
}
}
}
-
static boolean testIS_INFINITE(double a) {
return Double.isInfinite(a);
}
@Test(dataProvider = "doubleTestOpProvider")
}
}
}
}
-
@Test(dataProvider = "doubleCompareOpProvider")
static void LTDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
double[] a = fa.apply(SPECIES.length());
double[] b = fb.apply(SPECIES.length());
}
}
}
}
-
@Test(dataProvider = "doubleCompareOpProvider")
static void ltDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
double[] a = fa.apply(SPECIES.length());
double[] b = fb.apply(SPECIES.length());
}
}
}
}
-
@Test(dataProvider = "doubleCompareOpProvider")
static void GTDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
double[] a = fa.apply(SPECIES.length());
double[] b = fb.apply(SPECIES.length());
}
}
}
}
-
@Test(dataProvider = "doubleCompareOpProvider")
static void EQDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
double[] a = fa.apply(SPECIES.length());
double[] b = fb.apply(SPECIES.length());
}
}
}
}
-
@Test(dataProvider = "doubleCompareOpProvider")
static void eqDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
double[] a = fa.apply(SPECIES.length());
double[] b = fb.apply(SPECIES.length());
}
}
}
}
-
@Test(dataProvider = "doubleCompareOpProvider")
static void NEDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
double[] a = fa.apply(SPECIES.length());
double[] b = fb.apply(SPECIES.length());
}
}
}
}
-
@Test(dataProvider = "doubleCompareOpProvider")
static void LEDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
double[] a = fa.apply(SPECIES.length());
double[] b = fb.apply(SPECIES.length());
}
}
}
}
-
@Test(dataProvider = "doubleCompareOpProvider")
static void GEDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
double[] a = fa.apply(SPECIES.length());
double[] b = fb.apply(SPECIES.length());
}
}
}
}
-
-
-
-
-
-
-
-
-
@Test(dataProvider = "doubleCompareOpProvider")
static void LTDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
double[] a = fa.apply(SPECIES.length());
double[] b = fb.apply(SPECIES.length());
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
}
}
}
-
@Test(dataProvider = "doubleCompareOpMaskProvider")
static void LTDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa,
IntFunction<double[]> fb, IntFunction<boolean[]> fm) {
double[] a = fa.apply(SPECIES.length());
double[] b = fb.apply(SPECIES.length());
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (double)((long)b[i]));
}
}
}
-
@Test(dataProvider = "doubleCompareOpMaskProvider")
static void LTDoubleMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction<double[]> fa,
IntFunction<double[]> fb, IntFunction<boolean[]> fm) {
double[] a = fa.apply(SPECIES.length());
double[] b = fb.apply(SPECIES.length());
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);
}
}
}
-
@Test(dataProvider = "doubleCompareOpMaskProvider")
static void EQDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa,
IntFunction<double[]> fb, IntFunction<boolean[]> fm) {
double[] a = fa.apply(SPECIES.length());
double[] b = fb.apply(SPECIES.length());
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (double)((long)b[i]));
}
}
}
-
@Test(dataProvider = "doubleCompareOpMaskProvider")
static void EQDoubleMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction<double[]> fa,
IntFunction<double[]> fb, IntFunction<boolean[]> fm) {
double[] a = fa.apply(SPECIES.length());
double[] b = fb.apply(SPECIES.length());
av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i);
}
assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length());
}
+
+ @Test(dataProvider = "doubleUnaryOpMaskProvider")
+ static void compressDoubleMaxVectorTests(IntFunction<double[]> fa,
+ IntFunction<boolean[]> fm) {
+ double[] a = fa.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 ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
+ av.compress(vmask).intoArray(r, i);
+ }
+ }
+
+ assertcompressArraysEquals(r, a, mask, SPECIES.length());
+ }
+
+ @Test(dataProvider = "doubleUnaryOpMaskProvider")
+ static void expandDoubleMaxVectorTests(IntFunction<double[]> fa,
+ IntFunction<boolean[]> fm) {
+ double[] a = fa.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 ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
+ av.expand(vmask).intoArray(r, i);
+ }
+ }
+
+ assertexpandArraysEquals(r, a, mask, SPECIES.length());
+ }
+
@Test(dataProvider = "doubleUnaryOpProvider")
static void getDoubleMaxVectorTests(IntFunction<double[]> fa) {
double[] a = fa.apply(SPECIES.length());
double[] r = fr.apply(SPECIES.length());
}
assertBroadcastArraysEquals(r, a);
}
-
-
-
-
@Test(dataProvider = "doubleUnaryOpProvider")
static void ZeroDoubleMaxVectorTests(IntFunction<double[]> fa) {
double[] a = fa.apply(SPECIES.length());
double[] r = new double[a.length];
}
Assert.assertEquals(a, r);
}
-
-
-
static double[] sliceUnary(double[] a, int origin, int idx) {
double[] res = new double[SPECIES.length()];
for (int i = 0; i < SPECIES.length(); i++){
if(i+origin < SPECIES.length())
res[i] = a[idx+i+origin];
}
}
assertArraysEquals(r, a, origin, DoubleMaxVectorTests::sliceUnary);
}
+
static double[] sliceBinary(double[] a, double[] b, int origin, int idx) {
double[] res = new double[SPECIES.length()];
for (int i = 0, j = 0; i < SPECIES.length(); i++){
if(i+origin < SPECIES.length())
res[i] = a[idx+i+origin];
}
}
assertArraysEquals(r, a, b, origin, DoubleMaxVectorTests::sliceBinary);
}
+
static double[] slice(double[] a, double[] b, int origin, boolean[] mask, int idx) {
double[] res = new double[SPECIES.length()];
for (int i = 0, j = 0; i < SPECIES.length(); i++){
if(i+origin < SPECIES.length())
res[i] = mask[i] ? a[idx+i+origin] : (double)0;
}
}
assertArraysEquals(r, a, b, origin, mask, DoubleMaxVectorTests::slice);
}
+
static double[] unsliceUnary(double[] a, int origin, int idx) {
double[] res = new double[SPECIES.length()];
for (int i = 0, j = 0; i < SPECIES.length(); i++){
if(i < origin)
res[i] = (double)0;
}
}
assertArraysEquals(r, a, origin, DoubleMaxVectorTests::unsliceUnary);
}
+
static double[] unsliceBinary(double[] a, double[] b, int origin, int part, int idx) {
double[] res = new double[SPECIES.length()];
for (int i = 0, j = 0; i < SPECIES.length(); i++){
if (part == 0) {
if (i < origin)
}
}
assertArraysEquals(r, a, b, origin, part, DoubleMaxVectorTests::unsliceBinary);
}
+
static double[] unslice(double[] a, double[] b, int origin, int part, boolean[] mask, int idx) {
double[] res = new double[SPECIES.length()];
for (int i = 0, j = 0; i < SPECIES.length(); i++){
if(i+origin < SPECIES.length())
res[i] = b[idx+i+origin];
}
assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::SIN, DoubleMaxVectorTests::strictSIN);
}
-
static double EXP(double a) {
return (double)(Math.exp((double)a));
}
static double strictEXP(double a) {
}
assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::EXP, DoubleMaxVectorTests::strictEXP);
}
-
static double LOG1P(double a) {
return (double)(Math.log1p((double)a));
}
static double strictLOG1P(double a) {
}
assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::LOG1P, DoubleMaxVectorTests::strictLOG1P);
}
-
static double LOG(double a) {
return (double)(Math.log((double)a));
}
static double strictLOG(double a) {
}
assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::LOG, DoubleMaxVectorTests::strictLOG);
}
-
static double LOG10(double a) {
return (double)(Math.log10((double)a));
}
static double strictLOG10(double a) {
}
assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::LOG10, DoubleMaxVectorTests::strictLOG10);
}
-
static double EXPM1(double a) {
return (double)(Math.expm1((double)a));
}
static double strictEXPM1(double a) {
}
assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::EXPM1, DoubleMaxVectorTests::strictEXPM1);
}
-
static double COS(double a) {
return (double)(Math.cos((double)a));
}
static double strictCOS(double a) {
}
assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::COS, DoubleMaxVectorTests::strictCOS);
}
-
static double TAN(double a) {
return (double)(Math.tan((double)a));
}
static double strictTAN(double a) {
}
assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::TAN, DoubleMaxVectorTests::strictTAN);
}
-
static double SINH(double a) {
return (double)(Math.sinh((double)a));
}
static double strictSINH(double a) {
}
assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::SINH, DoubleMaxVectorTests::strictSINH);
}
-
static double COSH(double a) {
return (double)(Math.cosh((double)a));
}
static double strictCOSH(double a) {
}
assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::COSH, DoubleMaxVectorTests::strictCOSH);
}
-
static double TANH(double a) {
return (double)(Math.tanh((double)a));
}
static double strictTANH(double a) {
}
assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::TANH, DoubleMaxVectorTests::strictTANH);
}
-
static double ASIN(double a) {
return (double)(Math.asin((double)a));
}
static double strictASIN(double a) {
}
assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::ASIN, DoubleMaxVectorTests::strictASIN);
}
-
static double ACOS(double a) {
return (double)(Math.acos((double)a));
}
static double strictACOS(double a) {
}
assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::ACOS, DoubleMaxVectorTests::strictACOS);
}
-
static double ATAN(double a) {
return (double)(Math.atan((double)a));
}
static double strictATAN(double a) {
}
assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::ATAN, DoubleMaxVectorTests::strictATAN);
}
-
static double CBRT(double a) {
return (double)(Math.cbrt((double)a));
}
static double strictCBRT(double a) {
}
assertArraysEqualsWithinOneUlp(r, a, DoubleMaxVectorTests::CBRT, DoubleMaxVectorTests::strictCBRT);
}
-
static double HYPOT(double a, double b) {
return (double)(Math.hypot((double)a, (double)b));
}
static double strictHYPOT(double a, double b) {
assertArraysEqualsWithinOneUlp(r, a, b, DoubleMaxVectorTests::HYPOT, DoubleMaxVectorTests::strictHYPOT);
}
-
static double POW(double a, double b) {
return (double)(Math.pow((double)a, (double)b));
}
static double strictPOW(double a, double b) {
}
assertArraysEqualsWithinOneUlp(r, a, b, DoubleMaxVectorTests::POW, DoubleMaxVectorTests::strictPOW);
}
+
static double pow(double a, double b) {
return (double)(Math.pow((double)a, (double)b));
}
static double strictpow(double a, double b) {
assertArraysEqualsWithinOneUlp(r, a, b, DoubleMaxVectorTests::pow, DoubleMaxVectorTests::strictpow);
}
-
static double ATAN2(double a, double b) {
return (double)(Math.atan2((double)a, (double)b));
}
static double strictATAN2(double a, double b) {
assertArraysEqualsWithinOneUlp(r, a, b, DoubleMaxVectorTests::ATAN2, DoubleMaxVectorTests::strictATAN2);
}
-
@Test(dataProvider = "doubleBinaryOpProvider")
static void POWDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
double[] a = fa.apply(SPECIES.length());
double[] b = fb.apply(SPECIES.length());
double[] r = fr.apply(SPECIES.length());
}
assertBroadcastArraysEqualsWithinOneUlp(r, a, b, DoubleMaxVectorTests::POW, DoubleMaxVectorTests::strictPOW);
}
+
@Test(dataProvider = "doubleBinaryOpProvider")
static void powDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
double[] a = fa.apply(SPECIES.length());
double[] b = fb.apply(SPECIES.length());
double[] r = fr.apply(SPECIES.length());
assertBroadcastArraysEqualsWithinOneUlp(r, a, b, DoubleMaxVectorTests::pow, DoubleMaxVectorTests::strictpow);
}
-
static double FMA(double a, double b, double c) {
return (double)(Math.fma(a, b, c));
}
static double fma(double a, double b, double c) {
return (double)(Math.fma(a, b, c));
}
-
@Test(dataProvider = "doubleTernaryOpProvider")
static void FMADoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
int count = INVOC_COUNT;
switch ("FMA") {
case "fma": case "lanewise_FMA":
assertBroadcastArraysEqualsWithinOneUlp(r, a, b, DoubleMaxVectorTests::pow, DoubleMaxVectorTests::strictpow);
}
static double FMA(double a, double b, double c) {
return (double)(Math.fma(a, b, c));
}
+
static double fma(double a, double b, double c) {
return (double)(Math.fma(a, b, c));
}
@Test(dataProvider = "doubleTernaryOpProvider")
static void FMADoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
int count = INVOC_COUNT;
switch ("FMA") {
case "fma": case "lanewise_FMA":
}
}
assertArraysEquals(r, a, b, c, DoubleMaxVectorTests::FMA);
}
+
@Test(dataProvider = "doubleTernaryOpProvider")
static void fmaDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
int count = INVOC_COUNT;
switch ("fma") {
case "fma": case "lanewise_FMA":
}
assertArraysEquals(r, a, b, c, DoubleMaxVectorTests::fma);
}
-
@Test(dataProvider = "doubleTernaryOpMaskProvider")
static void FMADoubleMaxVectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
IntFunction<double[]> fc, IntFunction<boolean[]> fm) {
int count = INVOC_COUNT;
switch ("FMA") {
}
assertArraysEquals(r, a, b, c, mask, DoubleMaxVectorTests::FMA);
}
-
-
-
-
@Test(dataProvider = "doubleTernaryOpProvider")
static void FMADoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
double[] a = fa.apply(SPECIES.length());
double[] b = fb.apply(SPECIES.length());
double[] c = fc.apply(SPECIES.length());
av.lanewise(VectorOperators.FMA, b[i], cv).intoArray(r, i);
}
assertAltBroadcastArraysEquals(r, a, b, c, DoubleMaxVectorTests::FMA);
}
-
@Test(dataProvider = "doubleTernaryOpMaskProvider")
static void FMADoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
IntFunction<double[]> fc, IntFunction<boolean[]> fm) {
double[] a = fa.apply(SPECIES.length());
double[] b = fb.apply(SPECIES.length());
}
assertAltBroadcastArraysEquals(r, a, b, c, mask, DoubleMaxVectorTests::FMA);
}
-
-
-
@Test(dataProvider = "doubleTernaryOpProvider")
static void FMADoubleMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
int count = INVOC_COUNT;
switch ("FMA") {
case "fma": case "lanewise_FMA":
av.lanewise(VectorOperators.FMA, b[i], c[i]).intoArray(r, i);
}
assertDoubleBroadcastArraysEquals(r, a, b, c, DoubleMaxVectorTests::FMA);
}
+
@Test(dataProvider = "doubleTernaryOpProvider")
static void fmaDoubleMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
int count = INVOC_COUNT;
switch ("fma") {
case "fma": case "lanewise_FMA":
}
assertDoubleBroadcastArraysEquals(r, a, b, c, DoubleMaxVectorTests::fma);
}
-
@Test(dataProvider = "doubleTernaryOpMaskProvider")
static void FMADoubleMaxVectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
IntFunction<double[]> fc, IntFunction<boolean[]> fm) {
int count = INVOC_COUNT;
switch ("FMA") {
}
assertDoubleBroadcastArraysEquals(r, a, b, c, mask, DoubleMaxVectorTests::FMA);
}
-
-
-
static double NEG(double a) {
return (double)(-((double)a));
}
static double neg(double a) {
}
assertArraysEquals(r, a, mask, DoubleMaxVectorTests::ABS);
}
-
-
-
-
-
-
-
static double SQRT(double a) {
return (double)(Math.sqrt((double)a));
}
static double sqrt(double a) {
return (double)(Math.sqrt((double)a));
}
-
-
@Test(dataProvider = "doubleUnaryOpProvider")
static void SQRTDoubleMaxVectorTests(IntFunction<double[]> fa) {
double[] a = fa.apply(SPECIES.length());
double[] r = fr.apply(SPECIES.length());
}
assertArraysEquals(r, a, DoubleMaxVectorTests::sqrt);
}
-
-
@Test(dataProvider = "doubleUnaryOpMaskProvider")
static void SQRTMaskedDoubleMaxVectorTests(IntFunction<double[]> fa,
IntFunction<boolean[]> fm) {
double[] a = fa.apply(SPECIES.length());
double[] r = fr.apply(SPECIES.length());
}
assertArraysEquals(r, a, mask, DoubleMaxVectorTests::SQRT);
}
-
@Test(dataProvider = "doubleCompareOpProvider")
static void ltDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
double[] a = fa.apply(SPECIES.length());
double[] b = fb.apply(SPECIES.length());
}
assertMaskReductionArraysEquals(r, a, DoubleMaxVectorTests::maskFirstTrue);
}
+ @Test(dataProvider = "maskProvider")
+ static void maskCompressDoubleMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
+ int trueCount = 0;
+ boolean[] a = fa.apply(SPECIES.length());
+
+ for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ var vmask = SPECIES.loadMask(a, i);
+ trueCount = vmask.trueCount();
+ var rmask = vmask.compress();
+ for (int j = 0; j < SPECIES.length(); j++) {
+ Assert.assertEquals(rmask.laneIsSet(j), j < trueCount);
+ }
+ }
+ }
+ }
+
@DataProvider
public static Object[][] offsetProvider() {
return new Object[][]{
{0},
Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
}
}
}
+ @Test(dataProvider = "offsetProvider")
+ static void indexInRangeLongDoubleMaxVectorTestsSmokeTest(int offset) {
+ long limit = SPECIES.length() * BUFFER_REPS;
+ for (long i = 0; i < limit; i += SPECIES.length()) {
+ var actualMask = SPECIES.indexInRange(i + offset, limit);
+ var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);
+ assert(actualMask.equals(expectedMask));
+ for (int j = 0; j < SPECIES.length(); j++) {
+ long index = i + j + offset;
+ Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
+ }
+ }
+ }
+
@DataProvider
public static Object[][] lengthProvider() {
return new Object[][]{
{0},
{1},
int actualLoopBound = SPECIES.loopBound(length);
int expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
Assert.assertEquals(actualLoopBound, expectedLoopBound);
}
+ @Test(dataProvider = "lengthProvider")
+ static void loopBoundLongDoubleMaxVectorTestsSmokeTest(int _length) {
+ long length = _length;
+ long actualLoopBound = SPECIES.loopBound(length);
+ long expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
+ Assert.assertEquals(actualLoopBound, expectedLoopBound);
+ }
+
@Test
static void ElementSizeDoubleMaxVectorTestsSmokeTest() {
DoubleVector av = DoubleVector.zero(SPECIES);
int elsize = av.elementSize();
Assert.assertEquals(elsize, Double.SIZE);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
Assert.assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length()));
}
}
}
-
< prev index next >