/* * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
staticvoid assertArraysEquals(long[] r, long[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { Assert.assertEquals(r[i], f.apply(a[i]));
}
} catch (AssertionError e) { Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]);
}
}
interface FUnArrayOp { long[] apply(long a);
}
staticvoid assertArraysEquals(long[] r, long[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
f.apply(a[i]));
}
} catch (AssertionError e) { long[] ref = f.apply(a[i]); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
+ ", res: " + Arrays.toString(res)
+ "), at index #" + i);
}
}
staticvoid assertArraysEquals(long[] r, long[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]);
}
} catch (AssertionError e) { Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]);
}
}
interface FReductionOp { long apply(long[] a, int idx);
}
interface FReductionAllOp { long apply(long[] a);
}
staticvoid assertReductionArraysEquals(long[] r, long rc, long[] a,
FReductionOp f, FReductionAllOp fa) { int i = 0; try { Assert.assertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { Assert.assertEquals(r[i], f.apply(a, i));
}
} catch (AssertionError e) { Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);
}
}
interface FReductionMaskedOp { long apply(long[] a, int idx, boolean[] mask);
}
interface FReductionAllMaskedOp { long apply(long[] a, boolean[] mask);
}
staticvoid assertReductionArraysEqualsMasked(long[] r, long rc, long[] a, boolean[] mask,
FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { Assert.assertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { Assert.assertEquals(r[i], f.apply(a, i, mask));
}
} catch (AssertionError e) { Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i);
}
}
interface FBoolReductionOp { boolean apply(boolean[] a, int idx);
}
staticvoid assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { Assert.assertEquals(r[i], f.apply(a, i));
}
} catch (AssertionError e) { Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);
}
}
interface FMaskReductionOp { int apply(boolean[] a, int idx);
}
staticvoid assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReductionOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { Assert.assertEquals(r[i], f.apply(a, i));
}
} catch (AssertionError e) { Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);
}
}
staticvoid assertInsertArraysEquals(long[] r, long[] a, long element, int index, int start, int end) { int i = start; try { for (; i < end; i += 1) { if(i%SPECIES.length() == index) { Assert.assertEquals(r[i], element);
} else { Assert.assertEquals(r[i], a[i]);
}
}
} catch (AssertionError e) { if (i%SPECIES.length() == index) { Assert.assertEquals(r[i], element, "at index #" + i);
} else { Assert.assertEquals(r[i], a[i], "at index #" + i);
}
}
}
staticvoid assertRearrangeArraysEquals(long[] r, long[] a, int[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { Assert.assertEquals(r[i+j], a[i+order[i+j]]);
}
}
} catch (AssertionError e) { int idx = i + j; Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]);
}
}
staticvoid assertcompressArraysEquals(long[] r, long[] 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], (long)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], (long)0, "at index #" + idx);
}
}
}
staticvoid assertexpandArraysEquals(long[] r, long[] 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], (long)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], (long)0, "at index #" + idx);
}
}
}
staticvoid assertSelectFromArraysEquals(long[] r, long[] a, long[] order, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]);
}
}
} catch (AssertionError e) { int idx = i + j; Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]);
}
}
staticvoid assertRearrangeArraysEquals(long[] r, long[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) Assert.assertEquals(r[i+j], a[i+order[i+j]]); else Assert.assertEquals(r[i+j], (long)0);
}
}
} catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else Assert.assertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);
}
}
staticvoid assertSelectFromArraysEquals(long[] r, long[] a, long[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); else Assert.assertEquals(r[i+j], (long)0);
}
}
} catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else Assert.assertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);
}
}
staticvoid assertBroadcastArraysEquals(long[] r, long[] a) { int i = 0; for (; i < a.length; i += SPECIES.length()) { int idx = i; for (int j = idx; j < (idx + SPECIES.length()); j++)
a[j]=a[idx];
}
try { for (i = 0; i < a.length; i++) { Assert.assertEquals(r[i], a[i]);
}
} catch (AssertionError e) { Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]);
}
}
interface FBinOp { long apply(long a, long b);
}
interface FBinMaskOp { long apply(long a, long b, boolean m);
static FBinMaskOp lift(FBinOp f) { return (a, b, m) -> m ? f.apply(a, b) : a;
}
}
staticvoid assertArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { Assert.assertEquals(r[i], f.apply(a[i], b[i]));
}
} catch (AssertionError e) { Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i);
}
}
staticvoid assertBroadcastArraysEquals(long[] r, long[] a, long[] b, 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);
}
}
staticvoid assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()])));
}
} catch (AssertionError e) { Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i);
}
}
staticvoid assertArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) {
assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
}
// Create combinations of pairs // @@@ Might be sensitive to order e.g. div by 0 staticfinal List<List<IntFunction<long[]>>> LONG_GENERATOR_PAIRS =
Stream.of(LONG_GENERATORS.get(0)).
flatMap(fa -> LONG_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))).
collect(Collectors.toList());
@DataProvider public Object[][] boolUnaryOpProvider() { return BOOL_ARRAY_GENERATORS.stream().
map(f -> new Object[]{f}).
toArray(Object[][]::new);
}
@Test // Test all shuffle related operations. staticvoid shuffleTest() { // To test backend instructions, make sure that C2 is used. for (int loop = 0; loop < INVOC_COUNT * INVOC_COUNT; loop++) {
iotaShuffle();
}
}
@Test // Test div by 0. staticvoid bitwiseDivByZeroSmokeTest() { try {
LongVector a = (LongVector) SPECIES.broadcast(0).addIndex(1);
LongVector b = (LongVector) SPECIES.broadcast(0);
a.div(b); Assert.fail();
} catch (ArithmeticException e) {
}
try {
LongVector a = (LongVector) SPECIES.broadcast(0).addIndex(1);
LongVector b = (LongVector) SPECIES.broadcast(0);
VectorMask<Long> m = a.lt((long) 1);
a.div(b, m); Assert.fail();
} catch (ArithmeticException e) {
}
}
staticlong ADD(long a, long b) { return (long)(a + b);
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid ADDLong64VectorTests(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.lanewise(VectorOperators.ADD, bv).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, Long64VectorTests::ADD);
}
staticlong add(long a, long b) { return (long)(a + b);
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid addLong64VectorTests(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);
LongVector bv = LongVector.fromArray(SPECIES, b, i);
av.add(bv).intoArray(r, i);
}
assertArraysEquals(r, a, b, Long64VectorTests::add);
}
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.lanewise(VectorOperators.ADD, bv, vmask).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, mask, Long64VectorTests::ADD);
}
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.add(bv, vmask).intoArray(r, i);
}
assertArraysEquals(r, a, b, mask, Long64VectorTests::add);
}
staticlong SUB(long a, long b) { return (long)(a - b);
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid SUBLong64VectorTests(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.lanewise(VectorOperators.SUB, bv).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, Long64VectorTests::SUB);
}
staticlong sub(long a, long b) { return (long)(a - b);
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid subLong64VectorTests(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);
LongVector bv = LongVector.fromArray(SPECIES, b, i);
av.sub(bv).intoArray(r, i);
}
assertArraysEquals(r, a, b, Long64VectorTests::sub);
}
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.lanewise(VectorOperators.SUB, bv, vmask).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, mask, Long64VectorTests::SUB);
}
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.sub(bv, vmask).intoArray(r, i);
}
assertArraysEquals(r, a, b, mask, Long64VectorTests::sub);
}
staticlong MUL(long a, long b) { return (long)(a * b);
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid MULLong64VectorTests(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.lanewise(VectorOperators.MUL, bv).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, Long64VectorTests::MUL);
}
staticlong mul(long a, long b) { return (long)(a * b);
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid mulLong64VectorTests(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);
LongVector bv = LongVector.fromArray(SPECIES, b, i);
av.mul(bv).intoArray(r, i);
}
assertArraysEquals(r, a, b, Long64VectorTests::mul);
}
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.lanewise(VectorOperators.MUL, bv, vmask).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, mask, Long64VectorTests::MUL);
}
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.mul(bv, vmask).intoArray(r, i);
}
assertArraysEquals(r, a, b, mask, Long64VectorTests::mul);
}
staticlong DIV(long a, long b) { return (long)(a / b);
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid DIVLong64VectorTests(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 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.lanewise(VectorOperators.DIV, bv).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, Long64VectorTests::DIV);
}
staticlong div(long a, long b) { return (long)(a / b);
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid divLong64VectorTests(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 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.div(bv).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, Long64VectorTests::div);
}
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.lanewise(VectorOperators.DIV, bv, vmask).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, mask, Long64VectorTests::DIV);
}
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.div(bv, vmask).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, mask, Long64VectorTests::div);
}
staticlong FIRST_NONZERO(long a, long b) { return (long)((a)!=0?a:b);
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid FIRST_NONZEROLong64VectorTests(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.lanewise(VectorOperators.FIRST_NONZERO, bv).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, Long64VectorTests::FIRST_NONZERO);
}
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.lanewise(VectorOperators.FIRST_NONZERO, bv, vmask).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, mask, Long64VectorTests::FIRST_NONZERO);
}
staticlong AND(long a, long b) { return (long)(a & b);
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid ANDLong64VectorTests(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.lanewise(VectorOperators.AND, bv).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, Long64VectorTests::AND);
}
staticlong and(long a, long b) { return (long)(a & b);
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid andLong64VectorTests(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);
LongVector bv = LongVector.fromArray(SPECIES, b, i);
av.and(bv).intoArray(r, i);
}
assertArraysEquals(r, a, b, Long64VectorTests::and);
}
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.lanewise(VectorOperators.AND, bv, vmask).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, mask, Long64VectorTests::AND);
}
staticlong AND_NOT(long a, long b) { return (long)(a & ~b);
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid AND_NOTLong64VectorTests(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.lanewise(VectorOperators.AND_NOT, bv).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, Long64VectorTests::AND_NOT);
}
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.lanewise(VectorOperators.AND_NOT, bv, vmask).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, mask, Long64VectorTests::AND_NOT);
}
staticlong OR(long a, long b) { return (long)(a | b);
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid 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.lanewise(VectorOperators.OR, bv).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, Long64VectorTests::OR);
}
staticlong or(long a, long b) { return (long)(a | b);
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid 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 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(r, a, b, Long64VectorTests::or);
}
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.lanewise(VectorOperators.OR, bv, vmask).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, mask, Long64VectorTests::OR);
}
staticlong XOR(long a, long b) { return (long)(a ^ b);
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid XORLong64VectorTests(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.lanewise(VectorOperators.XOR, bv).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, Long64VectorTests::XOR);
}
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.lanewise(VectorOperators.XOR, bv, vmask).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, mask, Long64VectorTests::XOR);
}
staticlong COMPRESS_BITS(long a, long b) { return (long)(Long.compress(a, b));
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid COMPRESS_BITSLong64VectorTests(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.lanewise(VectorOperators.COMPRESS_BITS, bv).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, Long64VectorTests::COMPRESS_BITS);
}
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.lanewise(VectorOperators.COMPRESS_BITS, bv, vmask).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, mask, Long64VectorTests::COMPRESS_BITS);
}
staticlong EXPAND_BITS(long a, long b) { return (long)(Long.expand(a, b));
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid EXPAND_BITSLong64VectorTests(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.lanewise(VectorOperators.EXPAND_BITS, bv).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, Long64VectorTests::EXPAND_BITS);
}
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.lanewise(VectorOperators.EXPAND_BITS, bv, vmask).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, mask, Long64VectorTests::EXPAND_BITS);
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid 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(r, a, b, Long64VectorTests::add);
}
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(r, a, b, mask, Long64VectorTests::div);
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid 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(r, a, b, Long64VectorTests::OR);
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid 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(r, a, b, Long64VectorTests::or);
}
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(r, a, b, mask, Long64VectorTests::OR);
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid ANDLong64VectorTestsBroadcastSmokeTest(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.AND, b[i]).intoArray(r, i);
}
assertBroadcastArraysEquals(r, a, b, Long64VectorTests::AND);
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid andLong64VectorTestsBroadcastSmokeTest(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.and(b[i]).intoArray(r, i);
}
assertBroadcastArraysEquals(r, a, b, Long64VectorTests::and);
}
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i);
}
assertBroadcastArraysEquals(r, a, b, mask, Long64VectorTests::AND);
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid ORLong64VectorTestsBroadcastLongSmokeTest(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, (long)b[i]).intoArray(r, i);
}
assertBroadcastLongArraysEquals(r, a, b, Long64VectorTests::OR);
}
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i);
}
assertBroadcastLongArraysEquals(r, a, b, mask, Long64VectorTests::OR);
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid ADDLong64VectorTestsBroadcastLongSmokeTest(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.ADD, (long)b[i]).intoArray(r, i);
}
assertBroadcastLongArraysEquals(r, a, b, Long64VectorTests::ADD);
}
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i);
}
assertBroadcastLongArraysEquals(r, a, b, mask, Long64VectorTests::ADD);
}
staticlong LSHL(long a, long b) { return (long)((a << b));
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid LSHLLong64VectorTests(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.lanewise(VectorOperators.LSHL, bv).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, Long64VectorTests::LSHL);
}
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.lanewise(VectorOperators.LSHL, bv, vmask).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, mask, Long64VectorTests::LSHL);
}
staticlong ASHR(long a, long b) { return (long)((a >> b));
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid ASHRLong64VectorTests(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.lanewise(VectorOperators.ASHR, bv).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, Long64VectorTests::ASHR);
}
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.lanewise(VectorOperators.ASHR, bv, vmask).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, mask, Long64VectorTests::ASHR);
}
staticlong LSHR(long a, long b) { return (long)((a >>> b));
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid LSHRLong64VectorTests(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.lanewise(VectorOperators.LSHR, bv).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, Long64VectorTests::LSHR);
}
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.lanewise(VectorOperators.LSHR, bv, vmask).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, mask, Long64VectorTests::LSHR);
}
staticlong LSHL_unary(long a, long b) { return (long)((a << b));
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid LSHLLong64VectorTestsScalarShift(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);
av.lanewise(VectorOperators.LSHL, (int)b[i]).intoArray(r, i);
}
}
assertShiftArraysEquals(r, a, b, Long64VectorTests::LSHL_unary);
}
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.lanewise(VectorOperators.LSHL, (int)b[i], vmask).intoArray(r, i);
}
}
assertShiftArraysEquals(r, a, b, mask, Long64VectorTests::LSHL_unary);
}
staticlong LSHR_unary(long a, long b) { return (long)((a >>> b));
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid LSHRLong64VectorTestsScalarShift(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);
av.lanewise(VectorOperators.LSHR, (int)b[i]).intoArray(r, i);
}
}
assertShiftArraysEquals(r, a, b, Long64VectorTests::LSHR_unary);
}
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.lanewise(VectorOperators.LSHR, (int)b[i], vmask).intoArray(r, i);
}
}
assertShiftArraysEquals(r, a, b, mask, Long64VectorTests::LSHR_unary);
}
staticlong ASHR_unary(long a, long b) { return (long)((a >> b));
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid ASHRLong64VectorTestsScalarShift(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);
av.lanewise(VectorOperators.ASHR, (int)b[i]).intoArray(r, i);
}
}
assertShiftArraysEquals(r, a, b, Long64VectorTests::ASHR_unary);
}
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.lanewise(VectorOperators.ASHR, (int)b[i], vmask).intoArray(r, i);
}
}
assertShiftArraysEquals(r, a, b, mask, Long64VectorTests::ASHR_unary);
}
staticlong ROR(long a, long b) { return (long)(ROR_scalar(a,b));
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid RORLong64VectorTests(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.lanewise(VectorOperators.ROR, bv).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, Long64VectorTests::ROR);
}
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.lanewise(VectorOperators.ROR, bv, vmask).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, mask, Long64VectorTests::ROR);
}
staticlong ROL(long a, long b) { return (long)(ROL_scalar(a,b));
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid ROLLong64VectorTests(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.lanewise(VectorOperators.ROL, bv).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, Long64VectorTests::ROL);
}
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.lanewise(VectorOperators.ROL, bv, vmask).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, mask, Long64VectorTests::ROL);
}
staticlong ROR_unary(long a, long b) { return (long)(ROR_scalar(a, b));
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid RORLong64VectorTestsScalarShift(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);
av.lanewise(VectorOperators.ROR, (int)b[i]).intoArray(r, i);
}
}
assertShiftArraysEquals(r, a, b, Long64VectorTests::ROR_unary);
}
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.lanewise(VectorOperators.ROR, (int)b[i], vmask).intoArray(r, i);
}
}
assertShiftArraysEquals(r, a, b, mask, Long64VectorTests::ROR_unary);
}
staticlong ROL_unary(long a, long b) { return (long)(ROL_scalar(a, b));
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid ROLLong64VectorTestsScalarShift(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);
av.lanewise(VectorOperators.ROL, (int)b[i]).intoArray(r, i);
}
}
assertShiftArraysEquals(r, a, b, Long64VectorTests::ROL_unary);
}
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.lanewise(VectorOperators.ROL, (int)b[i], vmask).intoArray(r, i);
}
}
assertShiftArraysEquals(r, a, b, mask, Long64VectorTests::ROL_unary);
} staticlong LSHR_binary_const(long a) { return (long)((a >>> CONST_SHIFT));
}
@Test(dataProvider = "longUnaryOpProvider") staticvoid LSHRLong64VectorTestsScalarShiftConst(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.lanewise(VectorOperators.LSHR, CONST_SHIFT).intoArray(r, i);
}
}
assertShiftConstEquals(r, a, Long64VectorTests::LSHR_binary_const);
}
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.lanewise(VectorOperators.LSHR, CONST_SHIFT, vmask).intoArray(r, i);
}
}
assertShiftConstEquals(r, a, mask, Long64VectorTests::LSHR_binary_const);
}
staticlong LSHL_binary_const(long a) { return (long)((a << CONST_SHIFT));
}
@Test(dataProvider = "longUnaryOpProvider") staticvoid LSHLLong64VectorTestsScalarShiftConst(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.lanewise(VectorOperators.LSHL, CONST_SHIFT).intoArray(r, i);
}
}
assertShiftConstEquals(r, a, Long64VectorTests::LSHL_binary_const);
}
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.lanewise(VectorOperators.LSHL, CONST_SHIFT, vmask).intoArray(r, i);
}
}
assertShiftConstEquals(r, a, mask, Long64VectorTests::LSHL_binary_const);
}
staticlong ASHR_binary_const(long a) { return (long)((a >> CONST_SHIFT));
}
@Test(dataProvider = "longUnaryOpProvider") staticvoid ASHRLong64VectorTestsScalarShiftConst(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.lanewise(VectorOperators.ASHR, CONST_SHIFT).intoArray(r, i);
}
}
assertShiftConstEquals(r, a, Long64VectorTests::ASHR_binary_const);
}
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.lanewise(VectorOperators.ASHR, CONST_SHIFT, vmask).intoArray(r, i);
}
}
assertShiftConstEquals(r, a, mask, Long64VectorTests::ASHR_binary_const);
}
staticlong ROR_binary_const(long a) { return (long)(ROR_scalar(a, CONST_SHIFT));
}
@Test(dataProvider = "longUnaryOpProvider") staticvoid RORLong64VectorTestsScalarShiftConst(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.lanewise(VectorOperators.ROR, CONST_SHIFT).intoArray(r, i);
}
}
assertShiftConstEquals(r, a, Long64VectorTests::ROR_binary_const);
}
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.lanewise(VectorOperators.ROR, CONST_SHIFT, vmask).intoArray(r, i);
}
}
assertShiftConstEquals(r, a, mask, Long64VectorTests::ROR_binary_const);
}
staticlong ROL_binary_const(long a) { return (long)(ROL_scalar(a, CONST_SHIFT));
}
@Test(dataProvider = "longUnaryOpProvider") staticvoid ROLLong64VectorTestsScalarShiftConst(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.lanewise(VectorOperators.ROL, CONST_SHIFT).intoArray(r, i);
}
}
assertShiftConstEquals(r, a, Long64VectorTests::ROL_binary_const);
}
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.lanewise(VectorOperators.ROL, CONST_SHIFT, vmask).intoArray(r, i);
}
}
assertShiftConstEquals(r, a, mask, Long64VectorTests::ROL_binary_const);
}
staticlong MIN(long a, long b) { return (long)(Math.min(a, b));
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid MINLong64VectorTests(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.lanewise(VectorOperators.MIN, bv).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, Long64VectorTests::MIN);
}
staticlong min(long a, long b) { return (long)(Math.min(a, b));
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid minLong64VectorTests(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);
LongVector bv = LongVector.fromArray(SPECIES, b, i);
av.min(bv).intoArray(r, i);
}
assertArraysEquals(r, a, b, Long64VectorTests::min);
}
staticlong MAX(long a, long b) { return (long)(Math.max(a, b));
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid MAXLong64VectorTests(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.lanewise(VectorOperators.MAX, bv).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, Long64VectorTests::MAX);
}
staticlong max(long a, long b) { return (long)(Math.max(a, b));
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid maxLong64VectorTests(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);
LongVector bv = LongVector.fromArray(SPECIES, b, i);
av.max(bv).intoArray(r, i);
}
assertArraysEquals(r, a, b, Long64VectorTests::max);
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid 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(r, a, b, Long64VectorTests::MIN);
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid 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(r, a, b, Long64VectorTests::min);
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid 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(r, a, b, Long64VectorTests::MAX);
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid 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(r, a, b, Long64VectorTests::max);
}
staticlong ANDReduce(long[] a, int idx) { long res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) {
res &= a[i];
}
return res;
}
staticlong ANDReduceAll(long[] a) { long res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) {
res &= ANDReduce(a, i);
}
return res;
}
@Test(dataProvider = "longUnaryOpProvider") staticvoid ANDReduceLong64VectorTests(IntFunction<long[]> fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = -1;
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);
r[i] = av.reduceLanes(VectorOperators.AND);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra &= av.reduceLanes(VectorOperators.AND);
}
}
assertReductionArraysEquals(r, ra, a,
Long64VectorTests::ANDReduce, Long64VectorTests::ANDReduceAll);
}
staticlong ANDReduceMasked(long[] a, int idx, boolean[] mask) { long res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()])
res &= a[i];
}
return res;
}
staticlong ANDReduceAllMasked(long[] a, boolean[] mask) { long res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) {
res &= ANDReduceMasked(a, i, mask);
}
return res;
}
@Test(dataProvider = "longUnaryOpMaskProvider") staticvoid ANDReduceLong64VectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); long ra = -1;
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);
r[i] = av.reduceLanes(VectorOperators.AND, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra &= av.reduceLanes(VectorOperators.AND, vmask);
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Long64VectorTests::ANDReduceMasked, Long64VectorTests::ANDReduceAllMasked);
}
staticlong ORReduce(long[] a, int idx) { long res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) {
res |= a[i];
}
return res;
}
staticlong ORReduceAll(long[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) {
res |= ORReduce(a, i);
}
return res;
}
@Test(dataProvider = "longUnaryOpProvider") staticvoid ORReduceLong64VectorTests(IntFunction<long[]> fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0;
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);
r[i] = av.reduceLanes(VectorOperators.OR);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra |= av.reduceLanes(VectorOperators.OR);
}
}
assertReductionArraysEquals(r, ra, a,
Long64VectorTests::ORReduce, Long64VectorTests::ORReduceAll);
}
staticlong ORReduceMasked(long[] a, int idx, boolean[] mask) { long res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()])
res |= a[i];
}
return res;
}
staticlong ORReduceAllMasked(long[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) {
res |= ORReduceMasked(a, i, mask);
}
return res;
}
@Test(dataProvider = "longUnaryOpMaskProvider") staticvoid ORReduceLong64VectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); long ra = 0;
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);
r[i] = av.reduceLanes(VectorOperators.OR, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra |= av.reduceLanes(VectorOperators.OR, vmask);
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Long64VectorTests::ORReduceMasked, Long64VectorTests::ORReduceAllMasked);
}
staticlong XORReduce(long[] a, int idx) { long res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) {
res ^= a[i];
}
return res;
}
staticlong XORReduceAll(long[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) {
res ^= XORReduce(a, i);
}
return res;
}
@Test(dataProvider = "longUnaryOpProvider") staticvoid XORReduceLong64VectorTests(IntFunction<long[]> fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0;
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);
r[i] = av.reduceLanes(VectorOperators.XOR);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra ^= av.reduceLanes(VectorOperators.XOR);
}
}
assertReductionArraysEquals(r, ra, a,
Long64VectorTests::XORReduce, Long64VectorTests::XORReduceAll);
}
staticlong XORReduceMasked(long[] a, int idx, boolean[] mask) { long res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()])
res ^= a[i];
}
return res;
}
staticlong XORReduceAllMasked(long[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) {
res ^= XORReduceMasked(a, i, mask);
}
return res;
}
@Test(dataProvider = "longUnaryOpMaskProvider") staticvoid XORReduceLong64VectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); long ra = 0;
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);
r[i] = av.reduceLanes(VectorOperators.XOR, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra ^= av.reduceLanes(VectorOperators.XOR, vmask);
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Long64VectorTests::XORReduceMasked, Long64VectorTests::XORReduceAllMasked);
}
staticlong ADDReduce(long[] a, int idx) { long res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) {
res += a[i];
}
return res;
}
staticlong ADDReduceAll(long[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) {
res += ADDReduce(a, i);
}
return res;
}
@Test(dataProvider = "longUnaryOpProvider") staticvoid ADDReduceLong64VectorTests(IntFunction<long[]> fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0;
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);
r[i] = av.reduceLanes(VectorOperators.ADD);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra += av.reduceLanes(VectorOperators.ADD);
}
}
assertReductionArraysEquals(r, ra, a,
Long64VectorTests::ADDReduce, Long64VectorTests::ADDReduceAll);
}
staticlong ADDReduceMasked(long[] a, int idx, boolean[] mask) { long res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()])
res += a[i];
}
return res;
}
staticlong ADDReduceAllMasked(long[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) {
res += ADDReduceMasked(a, i, mask);
}
return res;
}
@Test(dataProvider = "longUnaryOpMaskProvider") staticvoid ADDReduceLong64VectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); long ra = 0;
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);
r[i] = av.reduceLanes(VectorOperators.ADD, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra += av.reduceLanes(VectorOperators.ADD, vmask);
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Long64VectorTests::ADDReduceMasked, Long64VectorTests::ADDReduceAllMasked);
}
staticlong MULReduce(long[] a, int idx) { long res = 1; for (int i = idx; i < (idx + SPECIES.length()); i++) {
res *= a[i];
}
return res;
}
staticlong MULReduceAll(long[] a) { long res = 1; for (int i = 0; i < a.length; i += SPECIES.length()) {
res *= MULReduce(a, i);
}
return res;
}
@Test(dataProvider = "longUnaryOpProvider") staticvoid MULReduceLong64VectorTests(IntFunction<long[]> fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 1;
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);
r[i] = av.reduceLanes(VectorOperators.MUL);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = 1; for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra *= av.reduceLanes(VectorOperators.MUL);
}
}
assertReductionArraysEquals(r, ra, a,
Long64VectorTests::MULReduce, Long64VectorTests::MULReduceAll);
}
staticlong MULReduceMasked(long[] a, int idx, boolean[] mask) { long res = 1; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()])
res *= a[i];
}
return res;
}
staticlong MULReduceAllMasked(long[] a, boolean[] mask) { long res = 1; for (int i = 0; i < a.length; i += SPECIES.length()) {
res *= MULReduceMasked(a, i, mask);
}
return res;
}
@Test(dataProvider = "longUnaryOpMaskProvider") staticvoid MULReduceLong64VectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); long ra = 1;
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);
r[i] = av.reduceLanes(VectorOperators.MUL, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = 1; for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra *= av.reduceLanes(VectorOperators.MUL, vmask);
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Long64VectorTests::MULReduceMasked, Long64VectorTests::MULReduceAllMasked);
}
staticlong MINReduce(long[] a, int idx) { long res = Long.MAX_VALUE; for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (long) Math.min(res, a[i]);
}
return res;
}
staticlong MINReduceAll(long[] a) { long res = Long.MAX_VALUE; for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (long) Math.min(res, MINReduce(a, i));
}
return res;
}
@Test(dataProvider = "longUnaryOpProvider") staticvoid MINReduceLong64VectorTests(IntFunction<long[]> fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = Long.MAX_VALUE;
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);
r[i] = av.reduceLanes(VectorOperators.MIN);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Long.MAX_VALUE; for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra = (long) Math.min(ra, av.reduceLanes(VectorOperators.MIN));
}
}
assertReductionArraysEquals(r, ra, a,
Long64VectorTests::MINReduce, Long64VectorTests::MINReduceAll);
}
staticlong MINReduceMasked(long[] a, int idx, boolean[] mask) { long res = Long.MAX_VALUE; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()])
res = (long) Math.min(res, a[i]);
}
return res;
}
staticlong MINReduceAllMasked(long[] a, boolean[] mask) { long res = Long.MAX_VALUE; for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (long) Math.min(res, MINReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "longUnaryOpMaskProvider") staticvoid MINReduceLong64VectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); long ra = Long.MAX_VALUE;
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);
r[i] = av.reduceLanes(VectorOperators.MIN, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Long.MAX_VALUE; for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra = (long) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Long64VectorTests::MINReduceMasked, Long64VectorTests::MINReduceAllMasked);
}
staticlong MAXReduce(long[] a, int idx) { long res = Long.MIN_VALUE; for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (long) Math.max(res, a[i]);
}
return res;
}
staticlong MAXReduceAll(long[] a) { long res = Long.MIN_VALUE; for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (long) Math.max(res, MAXReduce(a, i));
}
return res;
}
@Test(dataProvider = "longUnaryOpProvider") staticvoid MAXReduceLong64VectorTests(IntFunction<long[]> fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = Long.MIN_VALUE;
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);
r[i] = av.reduceLanes(VectorOperators.MAX);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Long.MIN_VALUE; for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra = (long) Math.max(ra, av.reduceLanes(VectorOperators.MAX));
}
}
assertReductionArraysEquals(r, ra, a,
Long64VectorTests::MAXReduce, Long64VectorTests::MAXReduceAll);
}
staticlong MAXReduceMasked(long[] a, int idx, boolean[] mask) { long res = Long.MIN_VALUE; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()])
res = (long) Math.max(res, a[i]);
}
return res;
}
staticlong MAXReduceAllMasked(long[] a, boolean[] mask) { long res = Long.MIN_VALUE; for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (long) Math.max(res, MAXReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "longUnaryOpMaskProvider") staticvoid MAXReduceLong64VectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); long ra = Long.MIN_VALUE;
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);
r[i] = av.reduceLanes(VectorOperators.MAX, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Long.MIN_VALUE; for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra = (long) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Long64VectorTests::MAXReduceMasked, Long64VectorTests::MAXReduceAllMasked);
}
staticlong FIRST_NONZEROReduce(long[] a, int idx) { long res = (long) 0; for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = firstNonZero(res, a[i]);
}
return res;
}
staticlong FIRST_NONZEROReduceAll(long[] a) { long res = (long) 0; for (int i = 0; i < a.length; i += SPECIES.length()) {
res = firstNonZero(res, FIRST_NONZEROReduce(a, i));
}
return res;
}
@Test(dataProvider = "longUnaryOpProvider") staticvoid FIRST_NONZEROReduceLong64VectorTests(IntFunction<long[]> fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = (long) 0;
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);
r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = (long) 0; for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO));
}
}
assertReductionArraysEquals(r, ra, a,
Long64VectorTests::FIRST_NONZEROReduce, Long64VectorTests::FIRST_NONZEROReduceAll);
}
staticlong FIRST_NONZEROReduceMasked(long[] a, int idx, boolean[] mask) { long res = (long) 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()])
res = firstNonZero(res, a[i]);
}
return res;
}
staticlong FIRST_NONZEROReduceAllMasked(long[] a, boolean[] mask) { long res = (long) 0; for (int i = 0; i < a.length; i += SPECIES.length()) {
res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "longUnaryOpMaskProvider") staticvoid FIRST_NONZEROReduceLong64VectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); long ra = (long) 0;
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);
r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = (long) 0; for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Long64VectorTests::FIRST_NONZEROReduceMasked, Long64VectorTests::FIRST_NONZEROReduceAllMasked);
}
staticboolean anyTrue(boolean[] a, int idx) { boolean res = false; for (int i = idx; i < (idx + SPECIES.length()); i++) {
res |= a[i];
}
for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < mask.length; i += SPECIES.length()) {
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, i);
r[i] = vmask.anyTrue();
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < mask.length; i += SPECIES.length()) {
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, i);
r[i] = vmask.allTrue();
}
}
@Test(dataProvider = "longUnaryOpProvider") staticvoid withLong64VectorTests(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, j = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
av.withLane((j++ & (SPECIES.length()-1)), (long)(65535+i)).intoArray(r, i);
}
}
for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
assertInsertArraysEquals(r, a, (long)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length());
}
}
staticboolean testIS_DEFAULT(long a) { return bits(a)==0;
}
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);
VectorMask<Long> mv = av.test(VectorOperators.IS_DEFAULT);
// Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j]));
}
}
}
}
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);
VectorMask<Long> mv = av.test(VectorOperators.IS_DEFAULT, vmask);
// Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j]));
}
}
}
}
staticboolean testIS_NEGATIVE(long a) { return bits(a)<0;
}
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);
VectorMask<Long> mv = av.test(VectorOperators.IS_NEGATIVE);
// Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j]));
}
}
}
}
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);
VectorMask<Long> mv = av.test(VectorOperators.IS_NEGATIVE, vmask);
// Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j]));
}
}
}
}
@Test(dataProvider = "longCompareOpProvider") staticvoid LTLong64VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.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);
VectorMask<Long> mv = av.compare(VectorOperators.LT, bv);
// Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "longCompareOpProvider") staticvoid ltLong64VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.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);
VectorMask<Long> mv = av.lt(bv);
// Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
}
}
}
}
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);
VectorMask<Long> mv = av.compare(VectorOperators.LT, bv, vmask);
// Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "longCompareOpProvider") staticvoid GTLong64VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.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);
VectorMask<Long> mv = av.compare(VectorOperators.GT, bv);
// Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
}
}
}
}
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);
VectorMask<Long> mv = av.compare(VectorOperators.GT, bv, vmask);
// Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "longCompareOpProvider") staticvoid EQLong64VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.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);
VectorMask<Long> mv = av.compare(VectorOperators.EQ, bv);
// Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "longCompareOpProvider") staticvoid eqLong64VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.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);
VectorMask<Long> mv = av.eq(bv);
// Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
}
}
}
}
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);
VectorMask<Long> mv = av.compare(VectorOperators.EQ, bv, vmask);
// Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "longCompareOpProvider") staticvoid NELong64VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.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);
VectorMask<Long> mv = av.compare(VectorOperators.NE, bv);
// Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
}
}
}
}
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);
VectorMask<Long> mv = av.compare(VectorOperators.NE, bv, vmask);
// Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "longCompareOpProvider") staticvoid LELong64VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.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);
VectorMask<Long> mv = av.compare(VectorOperators.LE, bv);
// Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
}
}
}
}
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);
VectorMask<Long> mv = av.compare(VectorOperators.LE, bv, vmask);
// Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "longCompareOpProvider") staticvoid GELong64VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.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);
VectorMask<Long> mv = av.compare(VectorOperators.GE, bv);
// Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
}
}
}
}
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);
VectorMask<Long> mv = av.compare(VectorOperators.GE, bv, vmask);
// Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "longCompareOpProvider") staticvoid UNSIGNED_LTLong64VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.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);
VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_LT, bv);
// Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j]));
}
}
}
}
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);
VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask);
// Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { Assert.assertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "longCompareOpProvider") staticvoid UNSIGNED_GTLong64VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.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);
VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_GT, bv);
// Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j]));
}
}
}
}
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);
VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask);
// Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { Assert.assertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "longCompareOpProvider") staticvoid UNSIGNED_LELong64VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.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);
VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_LE, bv);
// Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j]));
}
}
}
}
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);
VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask);
// Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { Assert.assertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "longCompareOpProvider") staticvoid UNSIGNED_GELong64VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.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);
VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_GE, bv);
// Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j]));
}
}
}
}
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);
VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask);
// Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { Assert.assertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "longCompareOpProvider") staticvoid LTLong64VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length());
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
VectorMask<Long> mv = av.compare(VectorOperators.LT, b[i]);
// Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
}
}
}
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
VectorMask<Long> mv = av.compare(VectorOperators.LT, b[i], vmask);
// Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i]));
}
}
}
@Test(dataProvider = "longCompareOpProvider") staticvoid EQLong64VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length());
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
VectorMask<Long> mv = av.compare(VectorOperators.EQ, b[i]);
// Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);
}
}
}
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
VectorMask<Long> mv = av.compare(VectorOperators.EQ, b[i], vmask);
// Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i]));
}
}
}
staticlong blend(long a, long b, boolean mask) { return mask ? b : a;
}
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.blend(bv, vmask).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, mask, Long64VectorTests::blend);
}
@Test(dataProvider = "longUnaryOpShuffleProvider") staticvoid RearrangeLong64VectorTests(IntFunction<long[]> fa,
BiFunction<Integer,Integer,int[]> fs) { long[] a = fa.apply(SPECIES.length()); int[] order = fs.apply(a.length, 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.rearrange(VectorShuffle.fromArray(SPECIES, order, i)).intoArray(r, i);
}
}
assertRearrangeArraysEquals(r, a, order, SPECIES.length());
}
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i);
}
assertRearrangeArraysEquals(r, a, order, mask, 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.compress(vmask).intoArray(r, i);
}
}
assertcompressArraysEquals(r, a, mask, 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.expand(vmask).intoArray(r, i);
}
}
assertexpandArraysEquals(r, a, mask, SPECIES.length());
}
@Test(dataProvider = "longUnaryOpProvider") staticvoid getLong64VectorTests(IntFunction<long[]> fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length());
assertArraysEquals(r, a, Long64VectorTests::get);
}
@Test(dataProvider = "longUnaryOpProvider") staticvoid BroadcastLong64VectorTests(IntFunction<long[]> fa) { long[] a = fa.apply(SPECIES.length()); long[] r = newlong[a.length];
for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector.broadcast(SPECIES, a[i]).intoArray(r, i);
}
}
assertBroadcastArraysEquals(r, a);
}
@Test(dataProvider = "longUnaryOpProvider") staticvoid ZeroLong64VectorTests(IntFunction<long[]> fa) { long[] a = fa.apply(SPECIES.length()); long[] r = newlong[a.length];
for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector.zero(SPECIES).intoArray(a, i);
}
}
Assert.assertEquals(a, r);
}
staticlong[] sliceUnary(long[] a, int origin, int idx) { long[] res = newlong[SPECIES.length()]; for (int i = 0; i < SPECIES.length(); i++){ if(i+origin < SPECIES.length())
res[i] = a[idx+i+origin]; else
res[i] = (long)0;
} return res;
}
@Test(dataProvider = "longUnaryOpProvider") staticvoid sliceUnaryLong64VectorTests(IntFunction<long[]> fa) { long[] a = fa.apply(SPECIES.length()); long[] r = newlong[a.length]; int origin = (new java.util.Random()).nextInt(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.slice(origin).intoArray(r, i);
}
}
assertArraysEquals(r, a, origin, Long64VectorTests::sliceUnary);
}
staticlong[] sliceBinary(long[] a, long[] b, int origin, int idx) { long[] res = newlong[SPECIES.length()]; for (int i = 0, j = 0; i < SPECIES.length(); i++){ if(i+origin < SPECIES.length())
res[i] = a[idx+i+origin]; else {
res[i] = b[idx+j];
j++;
}
} return res;
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid sliceBinaryLong64VectorTestsBinary(IntFunction<long[]> fa, IntFunction<long[]> fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = newlong[a.length]; int origin = (new java.util.Random()).nextInt(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.slice(origin, bv).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, origin, Long64VectorTests::sliceBinary);
}
staticlong[] slice(long[] a, long[] b, int origin, boolean[] mask, int idx) { long[] res = newlong[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] : (long)0; else {
res[i] = mask[i] ? b[idx+j] : (long)0;
j++;
}
} return res;
}
long[] r = newlong[a.length]; int origin = (new java.util.Random()).nextInt(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.slice(origin, bv, vmask).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, origin, mask, Long64VectorTests::slice);
}
staticlong[] unsliceUnary(long[] a, int origin, int idx) { long[] res = newlong[SPECIES.length()]; for (int i = 0, j = 0; i < SPECIES.length(); i++){ if(i < origin)
res[i] = (long)0; else {
res[i] = a[idx+j];
j++;
}
} return res;
}
@Test(dataProvider = "longUnaryOpProvider") staticvoid unsliceUnaryLong64VectorTests(IntFunction<long[]> fa) { long[] a = fa.apply(SPECIES.length()); long[] r = newlong[a.length]; int origin = (new java.util.Random()).nextInt(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.unslice(origin).intoArray(r, i);
}
}
assertArraysEquals(r, a, origin, Long64VectorTests::unsliceUnary);
}
staticlong[] unsliceBinary(long[] a, long[] b, int origin, int part, int idx) { long[] res = newlong[SPECIES.length()]; for (int i = 0, j = 0; i < SPECIES.length(); i++){ if (part == 0) { if (i < origin)
res[i] = b[idx+i]; else {
res[i] = a[idx+j];
j++;
}
} elseif (part == 1) { if (i < origin)
res[i] = a[idx+SPECIES.length()-origin+i]; else {
res[i] = b[idx+origin+j];
j++;
}
}
} return res;
}
@Test(dataProvider = "longBinaryOpProvider") staticvoid unsliceBinaryLong64VectorTestsBinary(IntFunction<long[]> fa, IntFunction<long[]> fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] r = newlong[a.length]; int origin = (new java.util.Random()).nextInt(SPECIES.length()); int part = (new java.util.Random()).nextInt(2); 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.unslice(origin, bv, part).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, origin, part, Long64VectorTests::unsliceBinary);
}
staticlong[] unslice(long[] a, long[] b, int origin, int part, boolean[] mask, int idx) { long[] res = newlong[SPECIES.length()]; for (int i = 0, j = 0; i < SPECIES.length(); i++){ if(i+origin < SPECIES.length())
res[i] = b[idx+i+origin]; else {
res[i] = b[idx+j];
j++;
}
} for (int i = 0; i < SPECIES.length(); i++){
res[i] = mask[i] ? a[idx+i] : res[i];
} long[] res1 = newlong[SPECIES.length()]; if (part == 0) { for (int i = 0, j = 0; i < SPECIES.length(); i++){ if (i < origin)
res1[i] = b[idx+i]; else {
res1[i] = res[j];
j++;
}
}
} elseif (part == 1) { for (int i = 0, j = 0; i < SPECIES.length(); i++){ if (i < origin)
res1[i] = res[SPECIES.length()-origin+i]; else {
res1[i] = b[idx+origin+j];
j++;
}
}
} return res1;
}
@Test(dataProvider = "longBinaryOpMaskProvider") staticvoid unsliceLong64VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
IntFunction<boolean[]> fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); long[] r = newlong[a.length]; int origin = (new java.util.Random()).nextInt(SPECIES.length()); int part = (new java.util.Random()).nextInt(2); 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.unslice(origin, bv, part, vmask).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, origin, part, mask, Long64VectorTests::unslice);
}
staticlong BITWISE_BLEND(long a, long b, long c) { return (long)((a&~(c))|(b&c));
}
staticlong bitwiseBlend(long a, long b, long c) { return (long)((a&~(c))|(b&c));
}
@Test(dataProvider = "longTernaryOpProvider") staticvoid BITWISE_BLENDLong64VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.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);
LongVector cv = LongVector.fromArray(SPECIES, c, i);
av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, c, Long64VectorTests::BITWISE_BLEND);
}
@Test(dataProvider = "longTernaryOpProvider") staticvoid bitwiseBlendLong64VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.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);
LongVector bv = LongVector.fromArray(SPECIES, b, i);
LongVector cv = LongVector.fromArray(SPECIES, c, i);
av.bitwiseBlend(bv, cv).intoArray(r, i);
}
assertArraysEquals(r, a, b, c, Long64VectorTests::bitwiseBlend);
}
@Test(dataProvider = "longTernaryOpMaskProvider") staticvoid BITWISE_BLENDLong64VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
IntFunction<long[]> fc, IntFunction<boolean[]> fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.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 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);
LongVector cv = LongVector.fromArray(SPECIES, c, i);
av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv, vmask).intoArray(r, i);
}
}
assertArraysEquals(r, a, b, c, mask, Long64VectorTests::BITWISE_BLEND);
}
@Test(dataProvider = "longTernaryOpProvider") staticvoid BITWISE_BLENDLong64VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.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);
LongVector bv = LongVector.fromArray(SPECIES, b, i);
av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i);
}
assertBroadcastArraysEquals(r, a, b, c, Long64VectorTests::BITWISE_BLEND);
}
@Test(dataProvider = "longTernaryOpProvider") staticvoid BITWISE_BLENDLong64VectorTestsAltBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.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);
LongVector cv = LongVector.fromArray(SPECIES, c, i);
av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i);
}
assertAltBroadcastArraysEquals(r, a, b, c, Long64VectorTests::BITWISE_BLEND);
}
@Test(dataProvider = "longTernaryOpProvider") staticvoid bitwiseBlendLong64VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.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);
LongVector bv = LongVector.fromArray(SPECIES, b, i);
av.bitwiseBlend(bv, c[i]).intoArray(r, i);
}
assertBroadcastArraysEquals(r, a, b, c, Long64VectorTests::bitwiseBlend);
}
@Test(dataProvider = "longTernaryOpProvider") staticvoid bitwiseBlendLong64VectorTestsAltBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.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);
LongVector cv = LongVector.fromArray(SPECIES, c, i);
av.bitwiseBlend(b[i], cv).intoArray(r, i);
}
assertAltBroadcastArraysEquals(r, a, b, c, Long64VectorTests::bitwiseBlend);
}
@Test(dataProvider = "longTernaryOpMaskProvider") staticvoid BITWISE_BLENDLong64VectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,
IntFunction<long[]> fc, IntFunction<boolean[]> fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.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);
LongVector bv = LongVector.fromArray(SPECIES, b, i);
av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i);
}
assertBroadcastArraysEquals(r, a, b, c, mask, Long64VectorTests::BITWISE_BLEND);
}
@Test(dataProvider = "longTernaryOpMaskProvider") staticvoid BITWISE_BLENDLong64VectorTestsAltBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,
IntFunction<long[]> fc, IntFunction<boolean[]> fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.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);
LongVector cv = LongVector.fromArray(SPECIES, c, i);
av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i);
}
assertAltBroadcastArraysEquals(r, a, b, c, mask, Long64VectorTests::BITWISE_BLEND);
}
@Test(dataProvider = "longTernaryOpProvider") staticvoid BITWISE_BLENDLong64VectorTestsDoubleBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.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.BITWISE_BLEND, b[i], c[i]).intoArray(r, i);
}
assertDoubleBroadcastArraysEquals(r, a, b, c, Long64VectorTests::BITWISE_BLEND);
}
@Test(dataProvider = "longTernaryOpProvider") staticvoid bitwiseBlendLong64VectorTestsDoubleBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.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.bitwiseBlend(b[i], c[i]).intoArray(r, i);
}
assertDoubleBroadcastArraysEquals(r, a, b, c, Long64VectorTests::bitwiseBlend);
}
@Test(dataProvider = "longTernaryOpMaskProvider") staticvoid BITWISE_BLENDLong64VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,
IntFunction<long[]> fc, IntFunction<boolean[]> fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); long[] c = fc.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.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i);
}
assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Long64VectorTests::BITWISE_BLEND);
}
staticlong NEG(long a) { return (long)(-((long)a));
}
staticlong neg(long a) { return (long)(-((long)a));
}
@Test(dataProvider = "longUnaryOpProvider") staticvoid 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.lanewise(VectorOperators.NEG).intoArray(r, i);
}
}
assertArraysEquals(r, a, Long64VectorTests::NEG);
}
@Test(dataProvider = "longUnaryOpProvider") staticvoid 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(r, a, Long64VectorTests::neg);
}
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.lanewise(VectorOperators.NEG, vmask).intoArray(r, i);
}
}
assertArraysEquals(r, a, mask, Long64VectorTests::NEG);
}
staticlong ABS(long a) { return (long)(Math.abs((long)a));
}
staticlong abs(long a) { return (long)(Math.abs((long)a));
}
@Test(dataProvider = "longUnaryOpProvider") staticvoid ABSLong64VectorTests(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.lanewise(VectorOperators.ABS).intoArray(r, i);
}
}
assertArraysEquals(r, a, Long64VectorTests::ABS);
}
@Test(dataProvider = "longUnaryOpProvider") staticvoid absLong64VectorTests(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.abs().intoArray(r, i);
}
}
assertArraysEquals(r, a, Long64VectorTests::abs);
}
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.lanewise(VectorOperators.ABS, vmask).intoArray(r, i);
}
}
assertArraysEquals(r, a, mask, Long64VectorTests::ABS);
}
staticlong NOT(long a) { return (long)(~((long)a));
}
staticlong not(long a) { return (long)(~((long)a));
}
@Test(dataProvider = "longUnaryOpProvider") staticvoid 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.lanewise(VectorOperators.NOT).intoArray(r, i);
}
}
assertArraysEquals(r, a, Long64VectorTests::NOT);
}
@Test(dataProvider = "longUnaryOpProvider") staticvoid 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(r, a, Long64VectorTests::not);
}
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.lanewise(VectorOperators.NOT, vmask).intoArray(r, i);
}
}
assertArraysEquals(r, a, mask, Long64VectorTests::NOT);
}
staticlong ZOMO(long a) { return (long)((a==0?0:-1));
}
@Test(dataProvider = "longUnaryOpProvider") staticvoid ZOMOLong64VectorTests(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.lanewise(VectorOperators.ZOMO).intoArray(r, i);
}
}
assertArraysEquals(r, a, Long64VectorTests::ZOMO);
}
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.lanewise(VectorOperators.ZOMO, vmask).intoArray(r, i);
}
}
assertArraysEquals(r, a, mask, Long64VectorTests::ZOMO);
}
staticlong BIT_COUNT(long a) { return (long)(Long.bitCount(a));
}
@Test(dataProvider = "longUnaryOpProvider") staticvoid BIT_COUNTLong64VectorTests(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.lanewise(VectorOperators.BIT_COUNT).intoArray(r, i);
}
}
assertArraysEquals(r, a, Long64VectorTests::BIT_COUNT);
}
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.lanewise(VectorOperators.BIT_COUNT, vmask).intoArray(r, i);
}
}
assertArraysEquals(r, a, mask, Long64VectorTests::BIT_COUNT);
}
staticlong TRAILING_ZEROS_COUNT(long a) { return (long)(TRAILING_ZEROS_COUNT_scalar(a));
}
@Test(dataProvider = "longUnaryOpProvider") staticvoid TRAILING_ZEROS_COUNTLong64VectorTests(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.lanewise(VectorOperators.TRAILING_ZEROS_COUNT).intoArray(r, i);
}
}
assertArraysEquals(r, a, Long64VectorTests::TRAILING_ZEROS_COUNT);
}
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.lanewise(VectorOperators.TRAILING_ZEROS_COUNT, vmask).intoArray(r, i);
}
}
assertArraysEquals(r, a, mask, Long64VectorTests::TRAILING_ZEROS_COUNT);
}
staticlong LEADING_ZEROS_COUNT(long a) { return (long)(LEADING_ZEROS_COUNT_scalar(a));
}
@Test(dataProvider = "longUnaryOpProvider") staticvoid LEADING_ZEROS_COUNTLong64VectorTests(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.lanewise(VectorOperators.LEADING_ZEROS_COUNT).intoArray(r, i);
}
}
assertArraysEquals(r, a, Long64VectorTests::LEADING_ZEROS_COUNT);
}
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.lanewise(VectorOperators.LEADING_ZEROS_COUNT, vmask).intoArray(r, i);
}
}
assertArraysEquals(r, a, mask, Long64VectorTests::LEADING_ZEROS_COUNT);
}
staticlong REVERSE(long a) { return (long)(REVERSE_scalar(a));
}
@Test(dataProvider = "longUnaryOpProvider") staticvoid REVERSELong64VectorTests(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.lanewise(VectorOperators.REVERSE).intoArray(r, i);
}
}
assertArraysEquals(r, a, Long64VectorTests::REVERSE);
}
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.lanewise(VectorOperators.REVERSE, vmask).intoArray(r, i);
}
}
assertArraysEquals(r, a, mask, Long64VectorTests::REVERSE);
}
staticlong REVERSE_BYTES(long a) { return (long)(Long.reverseBytes(a));
}
@Test(dataProvider = "longUnaryOpProvider") staticvoid REVERSE_BYTESLong64VectorTests(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.lanewise(VectorOperators.REVERSE_BYTES).intoArray(r, i);
}
}
assertArraysEquals(r, a, Long64VectorTests::REVERSE_BYTES);
}
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.lanewise(VectorOperators.REVERSE_BYTES, vmask).intoArray(r, i);
}
}
assertArraysEquals(r, a, mask, Long64VectorTests::REVERSE_BYTES);
}
@Test(dataProvider = "longCompareOpProvider") staticvoid ltLong64VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length());
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
VectorMask<Long> mv = av.lt(b[i]);
// Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
}
}
}
@Test(dataProvider = "longCompareOpProvider") staticvoid eqLong64VectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length());
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
VectorMask<Long> mv = av.eq(b[i]);
// Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);
}
}
}
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i); int[] r = av.toIntArray();
assertArraysEquals(r, a, i);
}
}
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i); long[] r = av.toLongArray();
assertArraysEquals(r, a, i);
}
}
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i); double[] r = av.toDoubleArray();
assertArraysEquals(r, a, i);
}
}
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
String str = av.toString();
long subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); Assert.assertTrue(str.equals(Arrays.toString(subarr)), "at index " + i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str);
}
}
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i); int hash = av.hashCode();
long subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr)); Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);
}
}
@Test(dataProvider = "longUnaryOpProvider") staticvoid ADDReduceLongLong64VectorTests(IntFunction<long[]> fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); long ra = 0;
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanesToLong(VectorOperators.ADD);
}
ra = 0; for (int i = 0; i < a.length; i ++) {
ra += r[i];
}
assertReductionArraysEquals(r, ra, a,
Long64VectorTests::ADDReduce, Long64VectorTests::ADDReduceAll);
}
@Test(dataProvider = "longUnaryOpMaskProvider") staticvoid ADDReduceLongLong64VectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); long ra = 0;
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanesToLong(VectorOperators.ADD, vmask);
}
ra = 0; for (int i = 0; i < a.length; i ++) {
ra += r[i];
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Long64VectorTests::ADDReduceMasked, Long64VectorTests::ADDReduceAllMasked);
}
@Test(dataProvider = "longUnaryOpSelectFromProvider") staticvoid SelectFromLong64VectorTests(IntFunction<long[]> fa,
BiFunction<Integer,Integer,long[]> fs) { long[] a = fa.apply(SPECIES.length()); long[] order = fs.apply(a.length, 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);
LongVector bv = LongVector.fromArray(SPECIES, order, i);
bv.selectFrom(av).intoArray(r, i);
}
assertSelectFromArraysEquals(r, a, order, SPECIES.length());
}
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
LongVector bv = LongVector.fromArray(SPECIES, order, i);
bv.selectFrom(av, vmask).intoArray(r, i);
}
assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length());
}
for (int i = 0; i < a.length; i += SPECIES.length()) { var shuffle = VectorShuffle.fromArray(SPECIES, a, i); int hash = shuffle.hashCode(); int length = shuffle.length();
int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr)); Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash); Assert.assertEquals(length, SPECIES.length());
}
}
for (int i = 0; i < a.length; i += SPECIES.length()) { var shuffle = VectorShuffle.fromArray(SPECIES, a, i);
String str = shuffle.toString();
int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); Assert.assertTrue(str.equals("Shuffle" + Arrays.toString(subarr)), "at index " +
i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str);
}
}
for (int i = 0; i < a.length; i += SPECIES.length()) { var av = VectorShuffle.fromArray(SPECIES, a, i); var bv = VectorShuffle.fromArray(SPECIES, b, i); boolean eq = av.equals(bv); int to = i + SPECIES.length(); Assert.assertEquals(eq, Arrays.equals(a, i, to, b, i, to));
}
}
@Test(dataProvider = "maskCompareOpProvider") staticvoid maskEqualsLong64VectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length());
for (int i = 0; i < a.length; i += SPECIES.length()) { var av = SPECIES.loadMask(a, i); var bv = SPECIES.loadMask(b, i); boolean equals = av.equals(bv); int to = i + SPECIES.length(); Assert.assertEquals(equals, Arrays.equals(a, i, to, b, i, to));
}
}
staticboolean beq(boolean a, boolean b) { return (a == b);
}
@Test(dataProvider = "maskCompareOpProvider") staticvoid maskEqLong64VectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) { boolean[] a = fa.apply(SPECIES.length()); boolean[] b = fb.apply(SPECIES.length()); boolean[] r = newboolean[a.length];
for (int i = 0; i < a.length; i += SPECIES.length()) { var av = SPECIES.loadMask(a, i); var bv = SPECIES.loadMask(b, i); var cv = av.eq(bv);
cv.intoArray(r, i);
}
assertArraysEquals(r, a, b, Long64VectorTests::beq);
}
for (int i = 0; i < a.length; i += SPECIES.length()) { var vmask = SPECIES.loadMask(a, i); int hash = vmask.hashCode();
boolean subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr)); Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);
}
}
staticint maskTrueCount(boolean[] a, int idx) { int trueCount = 0; for (int i = idx; i < idx + SPECIES.length(); i++) {
trueCount += a[i] ? 1 : 0;
} return trueCount;
}
@Test(dataProvider = "maskProvider") staticvoid maskTrueCountLong64VectorTestsSmokeTest(IntFunction<boolean[]> fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = newint[a.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);
r[i] = vmask.trueCount();
}
}
assertMaskReductionArraysEquals(r, a, Long64VectorTests::maskTrueCount);
}
staticint maskLastTrue(boolean[] a, int idx) { int i = idx + SPECIES.length() - 1; for (; i >= idx; i--) { if (a[i]) { break;
}
} return i - idx;
}
@Test(dataProvider = "maskProvider") staticvoid maskLastTrueLong64VectorTestsSmokeTest(IntFunction<boolean[]> fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = newint[a.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);
r[i] = vmask.lastTrue();
}
}
assertMaskReductionArraysEquals(r, a, Long64VectorTests::maskLastTrue);
}
staticint maskFirstTrue(boolean[] a, int idx) { int i = idx; for (; i < idx + SPECIES.length(); i++) { if (a[i]) { break;
}
} return i - idx;
}
@Test(dataProvider = "maskProvider") staticvoid maskFirstTrueLong64VectorTestsSmokeTest(IntFunction<boolean[]> fa) { boolean[] a = fa.apply(SPECIES.length()); int[] r = newint[a.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);
r[i] = vmask.firstTrue();
}
}
assertMaskReductionArraysEquals(r, a, Long64VectorTests::maskFirstTrue);
}
@Test(dataProvider = "maskProvider") staticvoid maskCompressLong64VectorTestsSmokeTest(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);
}
}
}
}
@Test staticvoid WithLanesLong64VectorTestsSmokeTest() {
LongVector av = LongVector.zero(SPECIES);
VectorSpecies species = av.species().withLanes(long.class); assert(species.equals(SPECIES));
}
@Test staticvoid WithShapeLong64VectorTestsSmokeTest() {
LongVector av = LongVector.zero(SPECIES);
VectorShape vsh = av.shape();
VectorSpecies species = av.species().withShape(vsh); assert(species.equals(SPECIES));
}
@Test staticvoid MaskAllTrueLong64VectorTestsSmokeTest() { for (int ic = 0; ic < INVOC_COUNT; ic++) { Assert.assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length()));
}
}
}
Messung V0.5 in Prozent
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.158Bemerkung:
(vorverarbeitet am 2026-04-27)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.