< prev index next > test/jdk/jdk/incubator/vector/Float64VectorTests.java
Print this page
FloatVector.SPECIES_64;
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
- private static final float CONST_SHIFT = Float.SIZE / 2;
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 64);
interface FUnOp {
float apply(float 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(float[] r, float[] 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], (float)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], (float)0, "at index #" + idx);
+ }
+ }
+ }
+
+ static void assertexpandArraysEquals(float[] r, float[] 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], (float)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], (float)0, "at index #" + idx);
+ }
+ }
+ }
+
static void assertSelectFromArraysEquals(float[] r, float[] a, float[] 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], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
}
}
-
static int bits(float e) {
return Float.floatToIntBits(e);
}
static final List<IntFunction<float[]>> FLOAT_GENERATORS = List.of(
return new Object[] {fa, fs, fm};
}))).
toArray(Object[][]::new);
}
-
static final List<IntFunction<float[]>> FLOAT_COMPARE_GENERATORS = List.of(
withToString("float[i]", (int s) -> {
return fill(s * BUFFER_REPS,
i -> (float)i);
}),
static final IntFunction<long[]> lfr = (vl) -> {
int length = BUFFER_REPS * vl;
return new long[length];
};
-
static boolean eq(float a, float b) {
return a == b;
}
static boolean neq(float a, float b) {
static boolean ge(float a, float b) {
return a >= b;
}
-
static float firstNonZero(float a, float b) {
return Float.compare(a, (float) 0) != 0 ? a : b;
}
@Test
}
}
assertArraysEquals(r, a, b, Float64VectorTests::ADD);
}
+
static float add(float a, float b) {
return (float)(a + b);
}
@Test(dataProvider = "floatBinaryOpProvider")
av.add(bv, vmask).intoArray(r, i);
}
assertArraysEquals(r, a, b, mask, Float64VectorTests::add);
}
+
static float SUB(float a, float b) {
return (float)(a - b);
}
@Test(dataProvider = "floatBinaryOpProvider")
}
}
assertArraysEquals(r, a, b, Float64VectorTests::SUB);
}
+
static float sub(float a, float b) {
return (float)(a - b);
}
@Test(dataProvider = "floatBinaryOpProvider")
av.sub(bv, vmask).intoArray(r, i);
}
assertArraysEquals(r, a, b, mask, Float64VectorTests::sub);
}
+
static float MUL(float a, float b) {
return (float)(a * b);
}
@Test(dataProvider = "floatBinaryOpProvider")
}
}
assertArraysEquals(r, a, b, Float64VectorTests::MUL);
}
+
static float mul(float a, float b) {
return (float)(a * b);
}
@Test(dataProvider = "floatBinaryOpProvider")
}
}
assertArraysEquals(r, a, b, Float64VectorTests::DIV);
}
+
static float div(float a, float b) {
return (float)(a / b);
}
@Test(dataProvider = "floatBinaryOpProvider")
}
assertArraysEquals(r, a, b, Float64VectorTests::div);
}
-
-
@Test(dataProvider = "floatBinaryOpMaskProvider")
static void DIVFloat64VectorTestsMasked(IntFunction<float[]> fa, IntFunction<float[]> fb,
IntFunction<boolean[]> fm) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
}
assertArraysEquals(r, a, b, mask, Float64VectorTests::div);
}
-
-
static float FIRST_NONZERO(float a, float b) {
return (float)(Double.doubleToLongBits(a)!=0?a:b);
}
@Test(dataProvider = "floatBinaryOpProvider")
}
assertArraysEquals(r, a, b, mask, Float64VectorTests::FIRST_NONZERO);
}
-
-
-
-
-
-
-
-
@Test(dataProvider = "floatBinaryOpProvider")
static void addFloat64VectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
}
assertBroadcastArraysEquals(r, a, b, mask, Float64VectorTests::mul);
}
-
@Test(dataProvider = "floatBinaryOpProvider")
static void divFloat64VectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
}
assertBroadcastArraysEquals(r, a, b, Float64VectorTests::div);
}
-
-
@Test(dataProvider = "floatBinaryOpMaskProvider")
static void divFloat64VectorTestsBroadcastMaskedSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb,
IntFunction<boolean[]> fm) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
}
assertBroadcastArraysEquals(r, a, b, mask, Float64VectorTests::div);
}
-
-
-
-
-
-
-
-
-
@Test(dataProvider = "floatBinaryOpProvider")
static void ADDFloat64VectorTestsBroadcastLongSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
}
assertBroadcastLongArraysEquals(r, a, b, mask, Float64VectorTests::ADD);
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
static float MIN(float a, float b) {
return (float)(Math.min(a, b));
}
@Test(dataProvider = "floatBinaryOpProvider")
}
}
assertArraysEquals(r, a, b, Float64VectorTests::MIN);
}
+
static float min(float a, float b) {
return (float)(Math.min(a, b));
}
@Test(dataProvider = "floatBinaryOpProvider")
av.min(bv).intoArray(r, i);
}
assertArraysEquals(r, a, b, Float64VectorTests::min);
}
+
static float MAX(float a, float b) {
return (float)(Math.max(a, b));
}
@Test(dataProvider = "floatBinaryOpProvider")
}
}
assertArraysEquals(r, a, b, Float64VectorTests::MAX);
}
+
static float max(float a, float b) {
return (float)(Math.max(a, b));
}
@Test(dataProvider = "floatBinaryOpProvider")
}
assertBroadcastArraysEquals(r, a, b, Float64VectorTests::max);
}
-
-
-
-
-
-
-
-
-
-
-
static float ADDReduce(float[] a, int idx) {
float res = 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res += a[i];
}
res += ADDReduce(a, i);
}
return res;
}
+
@Test(dataProvider = "floatUnaryOpProvider")
static void ADDReduceFloat64VectorTests(IntFunction<float[]> fa) {
float[] a = fa.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
float ra = 0;
}
assertReductionArraysEquals(r, ra, a,
Float64VectorTests::ADDReduce, Float64VectorTests::ADDReduceAll);
}
+
static float ADDReduceMasked(float[] a, int idx, boolean[] mask) {
float 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 = "floatUnaryOpMaskProvider")
static void ADDReduceFloat64VectorTestsMasked(IntFunction<float[]> fa, IntFunction<boolean[]> fm) {
float[] a = fa.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Float64VectorTests::ADDReduceMasked, Float64VectorTests::ADDReduceAllMasked);
}
+
static float MULReduce(float[] a, int idx) {
float res = 1;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res *= a[i];
}
res *= MULReduce(a, i);
}
return res;
}
+
@Test(dataProvider = "floatUnaryOpProvider")
static void MULReduceFloat64VectorTests(IntFunction<float[]> fa) {
float[] a = fa.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
float ra = 1;
}
assertReductionArraysEquals(r, ra, a,
Float64VectorTests::MULReduce, Float64VectorTests::MULReduceAll);
}
+
static float MULReduceMasked(float[] a, int idx, boolean[] mask) {
float 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 = "floatUnaryOpMaskProvider")
static void MULReduceFloat64VectorTestsMasked(IntFunction<float[]> fa, IntFunction<boolean[]> fm) {
float[] a = fa.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Float64VectorTests::MULReduceMasked, Float64VectorTests::MULReduceAllMasked);
}
+
static float MINReduce(float[] a, int idx) {
float res = Float.POSITIVE_INFINITY;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (float) Math.min(res, a[i]);
}
res = (float) Math.min(res, MINReduce(a, i));
}
return res;
}
+
@Test(dataProvider = "floatUnaryOpProvider")
static void MINReduceFloat64VectorTests(IntFunction<float[]> fa) {
float[] a = fa.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
float ra = Float.POSITIVE_INFINITY;
}
assertReductionArraysEquals(r, ra, a,
Float64VectorTests::MINReduce, Float64VectorTests::MINReduceAll);
}
+
static float MINReduceMasked(float[] a, int idx, boolean[] mask) {
float res = Float.POSITIVE_INFINITY;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (float) Math.min(res, a[i]);
res = (float) Math.min(res, MINReduceMasked(a, i, mask));
}
return res;
}
+
@Test(dataProvider = "floatUnaryOpMaskProvider")
static void MINReduceFloat64VectorTestsMasked(IntFunction<float[]> fa, IntFunction<boolean[]> fm) {
float[] a = fa.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Float64VectorTests::MINReduceMasked, Float64VectorTests::MINReduceAllMasked);
}
+
static float MAXReduce(float[] a, int idx) {
float res = Float.NEGATIVE_INFINITY;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (float) Math.max(res, a[i]);
}
res = (float) Math.max(res, MAXReduce(a, i));
}
return res;
}
+
@Test(dataProvider = "floatUnaryOpProvider")
static void MAXReduceFloat64VectorTests(IntFunction<float[]> fa) {
float[] a = fa.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
float ra = Float.NEGATIVE_INFINITY;
}
assertReductionArraysEquals(r, ra, a,
Float64VectorTests::MAXReduce, Float64VectorTests::MAXReduceAll);
}
+
static float MAXReduceMasked(float[] a, int idx, boolean[] mask) {
float res = Float.NEGATIVE_INFINITY;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (float) Math.max(res, a[i]);
res = (float) Math.max(res, MAXReduceMasked(a, i, mask));
}
return res;
}
+
@Test(dataProvider = "floatUnaryOpMaskProvider")
static void MAXReduceFloat64VectorTestsMasked(IntFunction<float[]> fa, IntFunction<boolean[]> fm) {
float[] a = fa.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Float64VectorTests::MAXReduceMasked, Float64VectorTests::MAXReduceAllMasked);
}
+
static float FIRST_NONZEROReduce(float[] a, int idx) {
float res = (float) 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 = "floatUnaryOpProvider")
static void FIRST_NONZEROReduceFloat64VectorTests(IntFunction<float[]> fa) {
float[] a = fa.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
float ra = (float) 0;
}
assertReductionArraysEquals(r, ra, a,
Float64VectorTests::FIRST_NONZEROReduce, Float64VectorTests::FIRST_NONZEROReduceAll);
}
+
static float FIRST_NONZEROReduceMasked(float[] a, int idx, boolean[] mask) {
float res = (float) 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 = "floatUnaryOpMaskProvider")
static void FIRST_NONZEROReduceFloat64VectorTestsMasked(IntFunction<float[]> fa, IntFunction<boolean[]> fm) {
float[] a = fa.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
assertReductionArraysEqualsMasked(r, ra, a, mask,
Float64VectorTests::FIRST_NONZEROReduceMasked, Float64VectorTests::FIRST_NONZEROReduceAllMasked);
}
-
-
-
-
@Test(dataProvider = "floatUnaryOpProvider")
static void withFloat64VectorTests(IntFunction<float []> fa) {
float[] a = fa.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
assertInsertArraysEquals(r, a, (float)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length());
}
}
+
static boolean testIS_DEFAULT(float a) {
return bits(a)==0;
}
@Test(dataProvider = "floatTestOpProvider")
Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j]));
}
}
}
}
+
static boolean testIS_NEGATIVE(float a) {
return bits(a)<0;
}
@Test(dataProvider = "floatTestOpProvider")
}
}
}
}
-
static boolean testIS_NAN(float a) {
return Float.isNaN(a);
}
@Test(dataProvider = "floatTestOpProvider")
}
}
}
}
-
static boolean testIS_INFINITE(float a) {
return Float.isInfinite(a);
}
@Test(dataProvider = "floatTestOpProvider")
}
}
}
}
-
@Test(dataProvider = "floatCompareOpProvider")
static void LTFloat64VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
}
}
}
}
-
@Test(dataProvider = "floatCompareOpProvider")
static void ltFloat64VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
}
}
}
}
-
@Test(dataProvider = "floatCompareOpProvider")
static void GTFloat64VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
}
}
}
}
-
@Test(dataProvider = "floatCompareOpProvider")
static void EQFloat64VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
}
}
}
}
-
@Test(dataProvider = "floatCompareOpProvider")
static void eqFloat64VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
}
}
}
}
-
@Test(dataProvider = "floatCompareOpProvider")
static void NEFloat64VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
}
}
}
}
-
@Test(dataProvider = "floatCompareOpProvider")
static void LEFloat64VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
}
}
}
}
-
@Test(dataProvider = "floatCompareOpProvider")
static void GEFloat64VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
}
}
}
}
-
-
-
-
-
-
-
-
-
@Test(dataProvider = "floatCompareOpProvider")
static void LTFloat64VectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
}
}
}
-
@Test(dataProvider = "floatCompareOpMaskProvider")
static void LTFloat64VectorTestsBroadcastMaskedSmokeTest(IntFunction<float[]> fa,
IntFunction<float[]> fb, IntFunction<boolean[]> fm) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (float)((long)b[i]));
}
}
}
-
@Test(dataProvider = "floatCompareOpMaskProvider")
static void LTFloat64VectorTestsBroadcastLongMaskedSmokeTest(IntFunction<float[]> fa,
IntFunction<float[]> fb, IntFunction<boolean[]> fm) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);
}
}
}
-
@Test(dataProvider = "floatCompareOpMaskProvider")
static void EQFloat64VectorTestsBroadcastMaskedSmokeTest(IntFunction<float[]> fa,
IntFunction<float[]> fb, IntFunction<boolean[]> fm) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (float)((long)b[i]));
}
}
}
-
@Test(dataProvider = "floatCompareOpMaskProvider")
static void EQFloat64VectorTestsBroadcastLongMaskedSmokeTest(IntFunction<float[]> fa,
IntFunction<float[]> fb, IntFunction<boolean[]> fm) {
float[] a = fa.apply(SPECIES.length());
float[] 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 = "floatUnaryOpMaskProvider")
+ static void compressFloat64VectorTests(IntFunction<float[]> fa,
+ IntFunction<boolean[]> fm) {
+ float[] a = fa.apply(SPECIES.length());
+ float[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ FloatVector av = FloatVector.fromArray(SPECIES, a, i);
+ av.compress(vmask).intoArray(r, i);
+ }
+ }
+
+ assertcompressArraysEquals(r, a, mask, SPECIES.length());
+ }
+
+ @Test(dataProvider = "floatUnaryOpMaskProvider")
+ static void expandFloat64VectorTests(IntFunction<float[]> fa,
+ IntFunction<boolean[]> fm) {
+ float[] a = fa.apply(SPECIES.length());
+ float[] r = fr.apply(SPECIES.length());
+ boolean[] mask = fm.apply(SPECIES.length());
+ VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);
+
+ for (int ic = 0; ic < INVOC_COUNT; ic++) {
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ FloatVector av = FloatVector.fromArray(SPECIES, a, i);
+ av.expand(vmask).intoArray(r, i);
+ }
+ }
+
+ assertexpandArraysEquals(r, a, mask, SPECIES.length());
+ }
+
@Test(dataProvider = "floatUnaryOpProvider")
static void getFloat64VectorTests(IntFunction<float[]> fa) {
float[] a = fa.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
}
assertBroadcastArraysEquals(r, a);
}
-
-
-
-
@Test(dataProvider = "floatUnaryOpProvider")
static void ZeroFloat64VectorTests(IntFunction<float[]> fa) {
float[] a = fa.apply(SPECIES.length());
float[] r = new float[a.length];
}
Assert.assertEquals(a, r);
}
-
-
-
static float[] sliceUnary(float[] a, int origin, int idx) {
float[] res = new float[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, Float64VectorTests::sliceUnary);
}
+
static float[] sliceBinary(float[] a, float[] b, int origin, int idx) {
float[] res = new float[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, Float64VectorTests::sliceBinary);
}
+
static float[] slice(float[] a, float[] b, int origin, boolean[] mask, int idx) {
float[] res = new float[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] : (float)0;
}
}
assertArraysEquals(r, a, b, origin, mask, Float64VectorTests::slice);
}
+
static float[] unsliceUnary(float[] a, int origin, int idx) {
float[] res = new float[SPECIES.length()];
for (int i = 0, j = 0; i < SPECIES.length(); i++){
if(i < origin)
res[i] = (float)0;
}
}
assertArraysEquals(r, a, origin, Float64VectorTests::unsliceUnary);
}
+
static float[] unsliceBinary(float[] a, float[] b, int origin, int part, int idx) {
float[] res = new float[SPECIES.length()];
for (int i = 0, j = 0; i < SPECIES.length(); i++){
if (part == 0) {
if (i < origin)
}
}
assertArraysEquals(r, a, b, origin, part, Float64VectorTests::unsliceBinary);
}
+
static float[] unslice(float[] a, float[] b, int origin, int part, boolean[] mask, int idx) {
float[] res = new float[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, Float64VectorTests::SIN, Float64VectorTests::strictSIN);
}
-
static float EXP(float a) {
return (float)(Math.exp((double)a));
}
static float strictEXP(float a) {
}
assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::EXP, Float64VectorTests::strictEXP);
}
-
static float LOG1P(float a) {
return (float)(Math.log1p((double)a));
}
static float strictLOG1P(float a) {
}
assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::LOG1P, Float64VectorTests::strictLOG1P);
}
-
static float LOG(float a) {
return (float)(Math.log((double)a));
}
static float strictLOG(float a) {
}
assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::LOG, Float64VectorTests::strictLOG);
}
-
static float LOG10(float a) {
return (float)(Math.log10((double)a));
}
static float strictLOG10(float a) {
}
assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::LOG10, Float64VectorTests::strictLOG10);
}
-
static float EXPM1(float a) {
return (float)(Math.expm1((double)a));
}
static float strictEXPM1(float a) {
}
assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::EXPM1, Float64VectorTests::strictEXPM1);
}
-
static float COS(float a) {
return (float)(Math.cos((double)a));
}
static float strictCOS(float a) {
}
assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::COS, Float64VectorTests::strictCOS);
}
-
static float TAN(float a) {
return (float)(Math.tan((double)a));
}
static float strictTAN(float a) {
}
assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::TAN, Float64VectorTests::strictTAN);
}
-
static float SINH(float a) {
return (float)(Math.sinh((double)a));
}
static float strictSINH(float a) {
}
assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::SINH, Float64VectorTests::strictSINH);
}
-
static float COSH(float a) {
return (float)(Math.cosh((double)a));
}
static float strictCOSH(float a) {
}
assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::COSH, Float64VectorTests::strictCOSH);
}
-
static float TANH(float a) {
return (float)(Math.tanh((double)a));
}
static float strictTANH(float a) {
}
assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::TANH, Float64VectorTests::strictTANH);
}
-
static float ASIN(float a) {
return (float)(Math.asin((double)a));
}
static float strictASIN(float a) {
}
assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::ASIN, Float64VectorTests::strictASIN);
}
-
static float ACOS(float a) {
return (float)(Math.acos((double)a));
}
static float strictACOS(float a) {
}
assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::ACOS, Float64VectorTests::strictACOS);
}
-
static float ATAN(float a) {
return (float)(Math.atan((double)a));
}
static float strictATAN(float a) {
}
assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::ATAN, Float64VectorTests::strictATAN);
}
-
static float CBRT(float a) {
return (float)(Math.cbrt((double)a));
}
static float strictCBRT(float a) {
}
assertArraysEqualsWithinOneUlp(r, a, Float64VectorTests::CBRT, Float64VectorTests::strictCBRT);
}
-
static float HYPOT(float a, float b) {
return (float)(Math.hypot((double)a, (double)b));
}
static float strictHYPOT(float a, float b) {
assertArraysEqualsWithinOneUlp(r, a, b, Float64VectorTests::HYPOT, Float64VectorTests::strictHYPOT);
}
-
static float POW(float a, float b) {
return (float)(Math.pow((double)a, (double)b));
}
static float strictPOW(float a, float b) {
}
assertArraysEqualsWithinOneUlp(r, a, b, Float64VectorTests::POW, Float64VectorTests::strictPOW);
}
+
static float pow(float a, float b) {
return (float)(Math.pow((double)a, (double)b));
}
static float strictpow(float a, float b) {
assertArraysEqualsWithinOneUlp(r, a, b, Float64VectorTests::pow, Float64VectorTests::strictpow);
}
-
static float ATAN2(float a, float b) {
return (float)(Math.atan2((double)a, (double)b));
}
static float strictATAN2(float a, float b) {
assertArraysEqualsWithinOneUlp(r, a, b, Float64VectorTests::ATAN2, Float64VectorTests::strictATAN2);
}
-
@Test(dataProvider = "floatBinaryOpProvider")
static void POWFloat64VectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
}
assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Float64VectorTests::POW, Float64VectorTests::strictPOW);
}
+
@Test(dataProvider = "floatBinaryOpProvider")
static void powFloat64VectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Float64VectorTests::pow, Float64VectorTests::strictpow);
}
-
static float FMA(float a, float b, float c) {
return (float)(Math.fma(a, b, c));
}
static float fma(float a, float b, float c) {
return (float)(Math.fma(a, b, c));
}
-
@Test(dataProvider = "floatTernaryOpProvider")
static void FMAFloat64VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb, IntFunction<float[]> fc) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
float[] c = fc.apply(SPECIES.length());
assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Float64VectorTests::pow, Float64VectorTests::strictpow);
}
static float FMA(float a, float b, float c) {
return (float)(Math.fma(a, b, c));
}
+
static float fma(float a, float b, float c) {
return (float)(Math.fma(a, b, c));
}
@Test(dataProvider = "floatTernaryOpProvider")
static void FMAFloat64VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb, IntFunction<float[]> fc) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
float[] c = fc.apply(SPECIES.length());
}
}
assertArraysEquals(r, a, b, c, Float64VectorTests::FMA);
}
+
@Test(dataProvider = "floatTernaryOpProvider")
static void fmaFloat64VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb, IntFunction<float[]> fc) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
float[] c = fc.apply(SPECIES.length());
}
assertArraysEquals(r, a, b, c, Float64VectorTests::fma);
}
-
@Test(dataProvider = "floatTernaryOpMaskProvider")
static void FMAFloat64VectorTestsMasked(IntFunction<float[]> fa, IntFunction<float[]> fb,
IntFunction<float[]> fc, IntFunction<boolean[]> fm) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
}
assertArraysEquals(r, a, b, c, mask, Float64VectorTests::FMA);
}
-
-
-
-
@Test(dataProvider = "floatTernaryOpProvider")
static void FMAFloat64VectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb, IntFunction<float[]> fc) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
float[] c = fc.apply(SPECIES.length());
av.lanewise(VectorOperators.FMA, b[i], cv).intoArray(r, i);
}
assertAltBroadcastArraysEquals(r, a, b, c, Float64VectorTests::FMA);
}
-
@Test(dataProvider = "floatTernaryOpMaskProvider")
static void FMAFloat64VectorTestsBroadcastMaskedSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb,
IntFunction<float[]> fc, IntFunction<boolean[]> fm) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
}
assertAltBroadcastArraysEquals(r, a, b, c, mask, Float64VectorTests::FMA);
}
-
-
-
@Test(dataProvider = "floatTernaryOpProvider")
static void FMAFloat64VectorTestsDoubleBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb, IntFunction<float[]> fc) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
float[] c = fc.apply(SPECIES.length());
av.lanewise(VectorOperators.FMA, b[i], c[i]).intoArray(r, i);
}
assertDoubleBroadcastArraysEquals(r, a, b, c, Float64VectorTests::FMA);
}
+
@Test(dataProvider = "floatTernaryOpProvider")
static void fmaFloat64VectorTestsDoubleBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb, IntFunction<float[]> fc) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
float[] c = fc.apply(SPECIES.length());
}
assertDoubleBroadcastArraysEquals(r, a, b, c, Float64VectorTests::fma);
}
-
@Test(dataProvider = "floatTernaryOpMaskProvider")
static void FMAFloat64VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb,
IntFunction<float[]> fc, IntFunction<boolean[]> fm) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
}
assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Float64VectorTests::FMA);
}
-
-
-
static float NEG(float a) {
return (float)(-((float)a));
}
static float neg(float a) {
}
assertArraysEquals(r, a, mask, Float64VectorTests::ABS);
}
-
-
-
-
-
-
-
static float SQRT(float a) {
return (float)(Math.sqrt((double)a));
}
static float sqrt(float a) {
return (float)(Math.sqrt((double)a));
}
-
-
@Test(dataProvider = "floatUnaryOpProvider")
static void SQRTFloat64VectorTests(IntFunction<float[]> fa) {
float[] a = fa.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
}
assertArraysEquals(r, a, Float64VectorTests::sqrt);
}
-
-
@Test(dataProvider = "floatUnaryOpMaskProvider")
static void SQRTMaskedFloat64VectorTests(IntFunction<float[]> fa,
IntFunction<boolean[]> fm) {
float[] a = fa.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
}
assertArraysEquals(r, a, mask, Float64VectorTests::SQRT);
}
-
@Test(dataProvider = "floatCompareOpProvider")
static void ltFloat64VectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
}
assertMaskReductionArraysEquals(r, a, Float64VectorTests::maskFirstTrue);
}
+ @Test(dataProvider = "maskProvider")
+ static void maskCompressFloat64VectorTestsSmokeTest(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[][] longMaskProvider() {
return new Object[][]{
{0xFFFFFFFFFFFFFFFFL},
{0x0000000000000000L},
Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
}
}
}
+ @Test(dataProvider = "offsetProvider")
+ static void indexInRangeLongFloat64VectorTestsSmokeTest(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 loopBoundLongFloat64VectorTestsSmokeTest(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 ElementSizeFloat64VectorTestsSmokeTest() {
FloatVector av = FloatVector.zero(SPECIES);
int elsize = av.elementSize();
Assert.assertEquals(elsize, Float.SIZE);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
Assert.assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length()));
}
}
}
-
< prev index next >