mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 03:58:21 +00:00
8362279: [vectorapi] VECTOR_OP_SUADD needs reduction support
Reviewed-by: jbhateja, qamai
This commit is contained in:
parent
a2e86ff3c5
commit
57d02d9ac5
@ -2876,6 +2876,8 @@ public abstract class ByteVector extends AbstractVector<Byte> {
|
||||
toBits(v.rOp(MAX_OR_INF, m, (i, a, b) -> (byte) VectorMath.minUnsigned(a, b)));
|
||||
case VECTOR_OP_UMAX: return (v, m) ->
|
||||
toBits(v.rOp(MIN_OR_INF, m, (i, a, b) -> (byte) VectorMath.maxUnsigned(a, b)));
|
||||
case VECTOR_OP_SUADD: return (v, m) ->
|
||||
toBits(v.rOp((byte)0, m, (i, a, b) -> (byte) VectorMath.addSaturatingUnsigned(a, b)));
|
||||
case VECTOR_OP_AND: return (v, m) ->
|
||||
toBits(v.rOp((byte)-1, m, (i, a, b) -> (byte)(a & b)));
|
||||
case VECTOR_OP_OR: return (v, m) ->
|
||||
|
||||
@ -2861,6 +2861,8 @@ public abstract class IntVector extends AbstractVector<Integer> {
|
||||
toBits(v.rOp(MAX_OR_INF, m, (i, a, b) -> (int) VectorMath.minUnsigned(a, b)));
|
||||
case VECTOR_OP_UMAX: return (v, m) ->
|
||||
toBits(v.rOp(MIN_OR_INF, m, (i, a, b) -> (int) VectorMath.maxUnsigned(a, b)));
|
||||
case VECTOR_OP_SUADD: return (v, m) ->
|
||||
toBits(v.rOp((int)0, m, (i, a, b) -> (int) VectorMath.addSaturatingUnsigned(a, b)));
|
||||
case VECTOR_OP_AND: return (v, m) ->
|
||||
toBits(v.rOp((int)-1, m, (i, a, b) -> (int)(a & b)));
|
||||
case VECTOR_OP_OR: return (v, m) ->
|
||||
|
||||
@ -2727,6 +2727,8 @@ public abstract class LongVector extends AbstractVector<Long> {
|
||||
toBits(v.rOp(MAX_OR_INF, m, (i, a, b) -> (long) VectorMath.minUnsigned(a, b)));
|
||||
case VECTOR_OP_UMAX: return (v, m) ->
|
||||
toBits(v.rOp(MIN_OR_INF, m, (i, a, b) -> (long) VectorMath.maxUnsigned(a, b)));
|
||||
case VECTOR_OP_SUADD: return (v, m) ->
|
||||
toBits(v.rOp((long)0, m, (i, a, b) -> (long) VectorMath.addSaturatingUnsigned(a, b)));
|
||||
case VECTOR_OP_AND: return (v, m) ->
|
||||
toBits(v.rOp((long)-1, m, (i, a, b) -> (long)(a & b)));
|
||||
case VECTOR_OP_OR: return (v, m) ->
|
||||
|
||||
@ -2877,6 +2877,8 @@ public abstract class ShortVector extends AbstractVector<Short> {
|
||||
toBits(v.rOp(MAX_OR_INF, m, (i, a, b) -> (short) VectorMath.minUnsigned(a, b)));
|
||||
case VECTOR_OP_UMAX: return (v, m) ->
|
||||
toBits(v.rOp(MIN_OR_INF, m, (i, a, b) -> (short) VectorMath.maxUnsigned(a, b)));
|
||||
case VECTOR_OP_SUADD: return (v, m) ->
|
||||
toBits(v.rOp((short)0, m, (i, a, b) -> (short) VectorMath.addSaturatingUnsigned(a, b)));
|
||||
case VECTOR_OP_AND: return (v, m) ->
|
||||
toBits(v.rOp((short)-1, m, (i, a, b) -> (short)(a & b)));
|
||||
case VECTOR_OP_OR: return (v, m) ->
|
||||
|
||||
@ -3451,6 +3451,8 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> {
|
||||
toBits(v.rOp(MAX_OR_INF, m, (i, a, b) -> ($type$) VectorMath.minUnsigned(a, b)));
|
||||
case VECTOR_OP_UMAX: return (v, m) ->
|
||||
toBits(v.rOp(MIN_OR_INF, m, (i, a, b) -> ($type$) VectorMath.maxUnsigned(a, b)));
|
||||
case VECTOR_OP_SUADD: return (v, m) ->
|
||||
toBits(v.rOp(($type$)0, m, (i, a, b) -> ($type$) VectorMath.addSaturatingUnsigned(a, b)));
|
||||
#end[!FP]
|
||||
#if[BITWISE]
|
||||
case VECTOR_OP_AND: return (v, m) ->
|
||||
|
||||
@ -1162,6 +1162,22 @@ public class Byte128VectorTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteSaturatingUnaryOpProvider() {
|
||||
return BYTE_SATURATING_GENERATORS.stream().
|
||||
map(f -> new Object[]{f}).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteSaturatingUnaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> BYTE_SATURATING_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteBinaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
@ -4487,6 +4503,94 @@ public class Byte128VectorTests extends AbstractVectorTest {
|
||||
assertReductionBoolArraysEquals(r, mask, Byte128VectorTests::allTrue);
|
||||
}
|
||||
|
||||
static byte SUADDReduce(byte[] a, int idx) {
|
||||
byte res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
res = (byte) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static byte SUADDReduceAll(byte[] a) {
|
||||
byte res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (byte) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteSaturatingUnaryOpProvider")
|
||||
static void SUADDReduceByte128VectorTests(IntFunction<byte[]> fa) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
byte[] r = fr.apply(SPECIES.length());
|
||||
byte ra = 0;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
|
||||
r[i] = av.reduceLanes(VectorOperators.SUADD);
|
||||
}
|
||||
}
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
ra = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
|
||||
ra = (byte) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEquals(r, ra, a,
|
||||
Byte128VectorTests::SUADDReduce, Byte128VectorTests::SUADDReduceAll);
|
||||
}
|
||||
|
||||
static byte SUADDReduceMasked(byte[] a, int idx, boolean[] mask) {
|
||||
byte res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
if (mask[i % SPECIES.length()])
|
||||
res = (byte) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static byte SUADDReduceAllMasked(byte[] a, boolean[] mask) {
|
||||
byte res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (byte) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
@Test(dataProvider = "byteSaturatingUnaryOpMaskProvider")
|
||||
static void SUADDReduceByte128VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
byte[] r = fr.apply(SPECIES.length());
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
byte ra = 0;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
|
||||
r[i] = av.reduceLanes(VectorOperators.SUADD, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
ra = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
|
||||
ra = (byte) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEqualsMasked(r, ra, a, mask,
|
||||
Byte128VectorTests::SUADDReduceMasked, Byte128VectorTests::SUADDReduceAllMasked);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteBinaryOpProvider")
|
||||
static void withByte128VectorTests(IntFunction<byte []> fa, IntFunction<byte []> fb) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
|
||||
@ -1162,6 +1162,22 @@ public class Byte256VectorTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteSaturatingUnaryOpProvider() {
|
||||
return BYTE_SATURATING_GENERATORS.stream().
|
||||
map(f -> new Object[]{f}).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteSaturatingUnaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> BYTE_SATURATING_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteBinaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
@ -4487,6 +4503,94 @@ public class Byte256VectorTests extends AbstractVectorTest {
|
||||
assertReductionBoolArraysEquals(r, mask, Byte256VectorTests::allTrue);
|
||||
}
|
||||
|
||||
static byte SUADDReduce(byte[] a, int idx) {
|
||||
byte res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
res = (byte) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static byte SUADDReduceAll(byte[] a) {
|
||||
byte res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (byte) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteSaturatingUnaryOpProvider")
|
||||
static void SUADDReduceByte256VectorTests(IntFunction<byte[]> fa) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
byte[] r = fr.apply(SPECIES.length());
|
||||
byte ra = 0;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
|
||||
r[i] = av.reduceLanes(VectorOperators.SUADD);
|
||||
}
|
||||
}
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
ra = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
|
||||
ra = (byte) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEquals(r, ra, a,
|
||||
Byte256VectorTests::SUADDReduce, Byte256VectorTests::SUADDReduceAll);
|
||||
}
|
||||
|
||||
static byte SUADDReduceMasked(byte[] a, int idx, boolean[] mask) {
|
||||
byte res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
if (mask[i % SPECIES.length()])
|
||||
res = (byte) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static byte SUADDReduceAllMasked(byte[] a, boolean[] mask) {
|
||||
byte res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (byte) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
@Test(dataProvider = "byteSaturatingUnaryOpMaskProvider")
|
||||
static void SUADDReduceByte256VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
byte[] r = fr.apply(SPECIES.length());
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
byte ra = 0;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
|
||||
r[i] = av.reduceLanes(VectorOperators.SUADD, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
ra = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
|
||||
ra = (byte) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEqualsMasked(r, ra, a, mask,
|
||||
Byte256VectorTests::SUADDReduceMasked, Byte256VectorTests::SUADDReduceAllMasked);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteBinaryOpProvider")
|
||||
static void withByte256VectorTests(IntFunction<byte []> fa, IntFunction<byte []> fb) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
|
||||
@ -1162,6 +1162,22 @@ public class Byte512VectorTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteSaturatingUnaryOpProvider() {
|
||||
return BYTE_SATURATING_GENERATORS.stream().
|
||||
map(f -> new Object[]{f}).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteSaturatingUnaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> BYTE_SATURATING_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteBinaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
@ -4487,6 +4503,94 @@ public class Byte512VectorTests extends AbstractVectorTest {
|
||||
assertReductionBoolArraysEquals(r, mask, Byte512VectorTests::allTrue);
|
||||
}
|
||||
|
||||
static byte SUADDReduce(byte[] a, int idx) {
|
||||
byte res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
res = (byte) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static byte SUADDReduceAll(byte[] a) {
|
||||
byte res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (byte) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteSaturatingUnaryOpProvider")
|
||||
static void SUADDReduceByte512VectorTests(IntFunction<byte[]> fa) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
byte[] r = fr.apply(SPECIES.length());
|
||||
byte ra = 0;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
|
||||
r[i] = av.reduceLanes(VectorOperators.SUADD);
|
||||
}
|
||||
}
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
ra = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
|
||||
ra = (byte) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEquals(r, ra, a,
|
||||
Byte512VectorTests::SUADDReduce, Byte512VectorTests::SUADDReduceAll);
|
||||
}
|
||||
|
||||
static byte SUADDReduceMasked(byte[] a, int idx, boolean[] mask) {
|
||||
byte res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
if (mask[i % SPECIES.length()])
|
||||
res = (byte) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static byte SUADDReduceAllMasked(byte[] a, boolean[] mask) {
|
||||
byte res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (byte) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
@Test(dataProvider = "byteSaturatingUnaryOpMaskProvider")
|
||||
static void SUADDReduceByte512VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
byte[] r = fr.apply(SPECIES.length());
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
byte ra = 0;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
|
||||
r[i] = av.reduceLanes(VectorOperators.SUADD, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
ra = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
|
||||
ra = (byte) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEqualsMasked(r, ra, a, mask,
|
||||
Byte512VectorTests::SUADDReduceMasked, Byte512VectorTests::SUADDReduceAllMasked);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteBinaryOpProvider")
|
||||
static void withByte512VectorTests(IntFunction<byte []> fa, IntFunction<byte []> fb) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
|
||||
@ -1162,6 +1162,22 @@ public class Byte64VectorTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteSaturatingUnaryOpProvider() {
|
||||
return BYTE_SATURATING_GENERATORS.stream().
|
||||
map(f -> new Object[]{f}).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteSaturatingUnaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> BYTE_SATURATING_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteBinaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
@ -4487,6 +4503,94 @@ public class Byte64VectorTests extends AbstractVectorTest {
|
||||
assertReductionBoolArraysEquals(r, mask, Byte64VectorTests::allTrue);
|
||||
}
|
||||
|
||||
static byte SUADDReduce(byte[] a, int idx) {
|
||||
byte res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
res = (byte) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static byte SUADDReduceAll(byte[] a) {
|
||||
byte res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (byte) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteSaturatingUnaryOpProvider")
|
||||
static void SUADDReduceByte64VectorTests(IntFunction<byte[]> fa) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
byte[] r = fr.apply(SPECIES.length());
|
||||
byte ra = 0;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
|
||||
r[i] = av.reduceLanes(VectorOperators.SUADD);
|
||||
}
|
||||
}
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
ra = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
|
||||
ra = (byte) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEquals(r, ra, a,
|
||||
Byte64VectorTests::SUADDReduce, Byte64VectorTests::SUADDReduceAll);
|
||||
}
|
||||
|
||||
static byte SUADDReduceMasked(byte[] a, int idx, boolean[] mask) {
|
||||
byte res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
if (mask[i % SPECIES.length()])
|
||||
res = (byte) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static byte SUADDReduceAllMasked(byte[] a, boolean[] mask) {
|
||||
byte res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (byte) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
@Test(dataProvider = "byteSaturatingUnaryOpMaskProvider")
|
||||
static void SUADDReduceByte64VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
byte[] r = fr.apply(SPECIES.length());
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
byte ra = 0;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
|
||||
r[i] = av.reduceLanes(VectorOperators.SUADD, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
ra = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
|
||||
ra = (byte) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEqualsMasked(r, ra, a, mask,
|
||||
Byte64VectorTests::SUADDReduceMasked, Byte64VectorTests::SUADDReduceAllMasked);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteBinaryOpProvider")
|
||||
static void withByte64VectorTests(IntFunction<byte []> fa, IntFunction<byte []> fb) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
|
||||
@ -1167,6 +1167,22 @@ public class ByteMaxVectorTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteSaturatingUnaryOpProvider() {
|
||||
return BYTE_SATURATING_GENERATORS.stream().
|
||||
map(f -> new Object[]{f}).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteSaturatingUnaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> BYTE_SATURATING_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteBinaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
@ -4492,6 +4508,94 @@ public class ByteMaxVectorTests extends AbstractVectorTest {
|
||||
assertReductionBoolArraysEquals(r, mask, ByteMaxVectorTests::allTrue);
|
||||
}
|
||||
|
||||
static byte SUADDReduce(byte[] a, int idx) {
|
||||
byte res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
res = (byte) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static byte SUADDReduceAll(byte[] a) {
|
||||
byte res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (byte) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteSaturatingUnaryOpProvider")
|
||||
static void SUADDReduceByteMaxVectorTests(IntFunction<byte[]> fa) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
byte[] r = fr.apply(SPECIES.length());
|
||||
byte ra = 0;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
|
||||
r[i] = av.reduceLanes(VectorOperators.SUADD);
|
||||
}
|
||||
}
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
ra = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
|
||||
ra = (byte) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEquals(r, ra, a,
|
||||
ByteMaxVectorTests::SUADDReduce, ByteMaxVectorTests::SUADDReduceAll);
|
||||
}
|
||||
|
||||
static byte SUADDReduceMasked(byte[] a, int idx, boolean[] mask) {
|
||||
byte res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
if (mask[i % SPECIES.length()])
|
||||
res = (byte) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static byte SUADDReduceAllMasked(byte[] a, boolean[] mask) {
|
||||
byte res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (byte) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
@Test(dataProvider = "byteSaturatingUnaryOpMaskProvider")
|
||||
static void SUADDReduceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
byte[] r = fr.apply(SPECIES.length());
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
byte ra = 0;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
|
||||
r[i] = av.reduceLanes(VectorOperators.SUADD, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
ra = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
|
||||
ra = (byte) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEqualsMasked(r, ra, a, mask,
|
||||
ByteMaxVectorTests::SUADDReduceMasked, ByteMaxVectorTests::SUADDReduceAllMasked);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteBinaryOpProvider")
|
||||
static void withByteMaxVectorTests(IntFunction<byte []> fa, IntFunction<byte []> fb) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
|
||||
@ -1152,6 +1152,22 @@ public class Int128VectorTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intSaturatingUnaryOpProvider() {
|
||||
return INT_SATURATING_GENERATORS.stream().
|
||||
map(f -> new Object[]{f}).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intSaturatingUnaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INT_SATURATING_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intBinaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
@ -4531,6 +4547,94 @@ public class Int128VectorTests extends AbstractVectorTest {
|
||||
assertReductionBoolArraysEquals(r, mask, Int128VectorTests::allTrue);
|
||||
}
|
||||
|
||||
static int SUADDReduce(int[] a, int idx) {
|
||||
int res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
res = (int) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static int SUADDReduceAll(int[] a) {
|
||||
int res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (int) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intSaturatingUnaryOpProvider")
|
||||
static void SUADDReduceInt128VectorTests(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = fr.apply(SPECIES.length());
|
||||
int ra = 0;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
IntVector av = IntVector.fromArray(SPECIES, a, i);
|
||||
r[i] = av.reduceLanes(VectorOperators.SUADD);
|
||||
}
|
||||
}
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
ra = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
IntVector av = IntVector.fromArray(SPECIES, a, i);
|
||||
ra = (int) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEquals(r, ra, a,
|
||||
Int128VectorTests::SUADDReduce, Int128VectorTests::SUADDReduceAll);
|
||||
}
|
||||
|
||||
static int SUADDReduceMasked(int[] a, int idx, boolean[] mask) {
|
||||
int res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
if (mask[i % SPECIES.length()])
|
||||
res = (int) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static int SUADDReduceAllMasked(int[] a, boolean[] mask) {
|
||||
int res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (int) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
@Test(dataProvider = "intSaturatingUnaryOpMaskProvider")
|
||||
static void SUADDReduceInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = fr.apply(SPECIES.length());
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
int ra = 0;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
IntVector av = IntVector.fromArray(SPECIES, a, i);
|
||||
r[i] = av.reduceLanes(VectorOperators.SUADD, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
ra = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
IntVector av = IntVector.fromArray(SPECIES, a, i);
|
||||
ra = (int) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEqualsMasked(r, ra, a, mask,
|
||||
Int128VectorTests::SUADDReduceMasked, Int128VectorTests::SUADDReduceAllMasked);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intBinaryOpProvider")
|
||||
static void withInt128VectorTests(IntFunction<int []> fa, IntFunction<int []> fb) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
|
||||
@ -1152,6 +1152,22 @@ public class Int256VectorTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intSaturatingUnaryOpProvider() {
|
||||
return INT_SATURATING_GENERATORS.stream().
|
||||
map(f -> new Object[]{f}).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intSaturatingUnaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INT_SATURATING_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intBinaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
@ -4531,6 +4547,94 @@ public class Int256VectorTests extends AbstractVectorTest {
|
||||
assertReductionBoolArraysEquals(r, mask, Int256VectorTests::allTrue);
|
||||
}
|
||||
|
||||
static int SUADDReduce(int[] a, int idx) {
|
||||
int res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
res = (int) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static int SUADDReduceAll(int[] a) {
|
||||
int res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (int) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intSaturatingUnaryOpProvider")
|
||||
static void SUADDReduceInt256VectorTests(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = fr.apply(SPECIES.length());
|
||||
int ra = 0;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
IntVector av = IntVector.fromArray(SPECIES, a, i);
|
||||
r[i] = av.reduceLanes(VectorOperators.SUADD);
|
||||
}
|
||||
}
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
ra = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
IntVector av = IntVector.fromArray(SPECIES, a, i);
|
||||
ra = (int) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEquals(r, ra, a,
|
||||
Int256VectorTests::SUADDReduce, Int256VectorTests::SUADDReduceAll);
|
||||
}
|
||||
|
||||
static int SUADDReduceMasked(int[] a, int idx, boolean[] mask) {
|
||||
int res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
if (mask[i % SPECIES.length()])
|
||||
res = (int) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static int SUADDReduceAllMasked(int[] a, boolean[] mask) {
|
||||
int res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (int) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
@Test(dataProvider = "intSaturatingUnaryOpMaskProvider")
|
||||
static void SUADDReduceInt256VectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = fr.apply(SPECIES.length());
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
int ra = 0;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
IntVector av = IntVector.fromArray(SPECIES, a, i);
|
||||
r[i] = av.reduceLanes(VectorOperators.SUADD, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
ra = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
IntVector av = IntVector.fromArray(SPECIES, a, i);
|
||||
ra = (int) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEqualsMasked(r, ra, a, mask,
|
||||
Int256VectorTests::SUADDReduceMasked, Int256VectorTests::SUADDReduceAllMasked);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intBinaryOpProvider")
|
||||
static void withInt256VectorTests(IntFunction<int []> fa, IntFunction<int []> fb) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
|
||||
@ -1152,6 +1152,22 @@ public class Int512VectorTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intSaturatingUnaryOpProvider() {
|
||||
return INT_SATURATING_GENERATORS.stream().
|
||||
map(f -> new Object[]{f}).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intSaturatingUnaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INT_SATURATING_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intBinaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
@ -4531,6 +4547,94 @@ public class Int512VectorTests extends AbstractVectorTest {
|
||||
assertReductionBoolArraysEquals(r, mask, Int512VectorTests::allTrue);
|
||||
}
|
||||
|
||||
static int SUADDReduce(int[] a, int idx) {
|
||||
int res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
res = (int) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static int SUADDReduceAll(int[] a) {
|
||||
int res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (int) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intSaturatingUnaryOpProvider")
|
||||
static void SUADDReduceInt512VectorTests(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = fr.apply(SPECIES.length());
|
||||
int ra = 0;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
IntVector av = IntVector.fromArray(SPECIES, a, i);
|
||||
r[i] = av.reduceLanes(VectorOperators.SUADD);
|
||||
}
|
||||
}
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
ra = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
IntVector av = IntVector.fromArray(SPECIES, a, i);
|
||||
ra = (int) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEquals(r, ra, a,
|
||||
Int512VectorTests::SUADDReduce, Int512VectorTests::SUADDReduceAll);
|
||||
}
|
||||
|
||||
static int SUADDReduceMasked(int[] a, int idx, boolean[] mask) {
|
||||
int res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
if (mask[i % SPECIES.length()])
|
||||
res = (int) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static int SUADDReduceAllMasked(int[] a, boolean[] mask) {
|
||||
int res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (int) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
@Test(dataProvider = "intSaturatingUnaryOpMaskProvider")
|
||||
static void SUADDReduceInt512VectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = fr.apply(SPECIES.length());
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
int ra = 0;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
IntVector av = IntVector.fromArray(SPECIES, a, i);
|
||||
r[i] = av.reduceLanes(VectorOperators.SUADD, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
ra = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
IntVector av = IntVector.fromArray(SPECIES, a, i);
|
||||
ra = (int) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEqualsMasked(r, ra, a, mask,
|
||||
Int512VectorTests::SUADDReduceMasked, Int512VectorTests::SUADDReduceAllMasked);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intBinaryOpProvider")
|
||||
static void withInt512VectorTests(IntFunction<int []> fa, IntFunction<int []> fb) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
|
||||
@ -1152,6 +1152,22 @@ public class Int64VectorTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intSaturatingUnaryOpProvider() {
|
||||
return INT_SATURATING_GENERATORS.stream().
|
||||
map(f -> new Object[]{f}).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intSaturatingUnaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INT_SATURATING_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intBinaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
@ -4531,6 +4547,94 @@ public class Int64VectorTests extends AbstractVectorTest {
|
||||
assertReductionBoolArraysEquals(r, mask, Int64VectorTests::allTrue);
|
||||
}
|
||||
|
||||
static int SUADDReduce(int[] a, int idx) {
|
||||
int res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
res = (int) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static int SUADDReduceAll(int[] a) {
|
||||
int res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (int) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intSaturatingUnaryOpProvider")
|
||||
static void SUADDReduceInt64VectorTests(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = fr.apply(SPECIES.length());
|
||||
int ra = 0;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
IntVector av = IntVector.fromArray(SPECIES, a, i);
|
||||
r[i] = av.reduceLanes(VectorOperators.SUADD);
|
||||
}
|
||||
}
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
ra = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
IntVector av = IntVector.fromArray(SPECIES, a, i);
|
||||
ra = (int) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEquals(r, ra, a,
|
||||
Int64VectorTests::SUADDReduce, Int64VectorTests::SUADDReduceAll);
|
||||
}
|
||||
|
||||
static int SUADDReduceMasked(int[] a, int idx, boolean[] mask) {
|
||||
int res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
if (mask[i % SPECIES.length()])
|
||||
res = (int) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static int SUADDReduceAllMasked(int[] a, boolean[] mask) {
|
||||
int res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (int) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
@Test(dataProvider = "intSaturatingUnaryOpMaskProvider")
|
||||
static void SUADDReduceInt64VectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = fr.apply(SPECIES.length());
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
int ra = 0;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
IntVector av = IntVector.fromArray(SPECIES, a, i);
|
||||
r[i] = av.reduceLanes(VectorOperators.SUADD, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
ra = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
IntVector av = IntVector.fromArray(SPECIES, a, i);
|
||||
ra = (int) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEqualsMasked(r, ra, a, mask,
|
||||
Int64VectorTests::SUADDReduceMasked, Int64VectorTests::SUADDReduceAllMasked);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intBinaryOpProvider")
|
||||
static void withInt64VectorTests(IntFunction<int []> fa, IntFunction<int []> fb) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
|
||||
@ -1157,6 +1157,22 @@ public class IntMaxVectorTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intSaturatingUnaryOpProvider() {
|
||||
return INT_SATURATING_GENERATORS.stream().
|
||||
map(f -> new Object[]{f}).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intSaturatingUnaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INT_SATURATING_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intBinaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
@ -4536,6 +4552,94 @@ public class IntMaxVectorTests extends AbstractVectorTest {
|
||||
assertReductionBoolArraysEquals(r, mask, IntMaxVectorTests::allTrue);
|
||||
}
|
||||
|
||||
static int SUADDReduce(int[] a, int idx) {
|
||||
int res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
res = (int) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static int SUADDReduceAll(int[] a) {
|
||||
int res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (int) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intSaturatingUnaryOpProvider")
|
||||
static void SUADDReduceIntMaxVectorTests(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = fr.apply(SPECIES.length());
|
||||
int ra = 0;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
IntVector av = IntVector.fromArray(SPECIES, a, i);
|
||||
r[i] = av.reduceLanes(VectorOperators.SUADD);
|
||||
}
|
||||
}
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
ra = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
IntVector av = IntVector.fromArray(SPECIES, a, i);
|
||||
ra = (int) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEquals(r, ra, a,
|
||||
IntMaxVectorTests::SUADDReduce, IntMaxVectorTests::SUADDReduceAll);
|
||||
}
|
||||
|
||||
static int SUADDReduceMasked(int[] a, int idx, boolean[] mask) {
|
||||
int res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
if (mask[i % SPECIES.length()])
|
||||
res = (int) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static int SUADDReduceAllMasked(int[] a, boolean[] mask) {
|
||||
int res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (int) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
@Test(dataProvider = "intSaturatingUnaryOpMaskProvider")
|
||||
static void SUADDReduceIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = fr.apply(SPECIES.length());
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
int ra = 0;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
IntVector av = IntVector.fromArray(SPECIES, a, i);
|
||||
r[i] = av.reduceLanes(VectorOperators.SUADD, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
ra = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
IntVector av = IntVector.fromArray(SPECIES, a, i);
|
||||
ra = (int) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEqualsMasked(r, ra, a, mask,
|
||||
IntMaxVectorTests::SUADDReduceMasked, IntMaxVectorTests::SUADDReduceAllMasked);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intBinaryOpProvider")
|
||||
static void withIntMaxVectorTests(IntFunction<int []> fa, IntFunction<int []> fb) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
|
||||
@ -1142,6 +1142,22 @@ public class Long128VectorTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longSaturatingUnaryOpProvider() {
|
||||
return LONG_SATURATING_GENERATORS.stream().
|
||||
map(f -> new Object[]{f}).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longSaturatingUnaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> LONG_SATURATING_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longBinaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
@ -4553,6 +4569,94 @@ public class Long128VectorTests extends AbstractVectorTest {
|
||||
assertReductionBoolArraysEquals(r, mask, Long128VectorTests::allTrue);
|
||||
}
|
||||
|
||||
static long SUADDReduce(long[] a, int idx) {
|
||||
long res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
res = (long) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static long SUADDReduceAll(long[] a) {
|
||||
long res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (long) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longSaturatingUnaryOpProvider")
|
||||
static void SUADDReduceLong128VectorTests(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.SUADD);
|
||||
}
|
||||
}
|
||||
|
||||
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 = (long) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEquals(r, ra, a,
|
||||
Long128VectorTests::SUADDReduce, Long128VectorTests::SUADDReduceAll);
|
||||
}
|
||||
|
||||
static long SUADDReduceMasked(long[] a, int idx, boolean[] mask) {
|
||||
long res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
if (mask[i % SPECIES.length()])
|
||||
res = (long) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static long SUADDReduceAllMasked(long[] a, boolean[] mask) {
|
||||
long res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (long) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
@Test(dataProvider = "longSaturatingUnaryOpMaskProvider")
|
||||
static void SUADDReduceLong128VectorTestsMasked(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.SUADD, 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 = (long) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEqualsMasked(r, ra, a, mask,
|
||||
Long128VectorTests::SUADDReduceMasked, Long128VectorTests::SUADDReduceAllMasked);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longBinaryOpProvider")
|
||||
static void withLong128VectorTests(IntFunction<long []> fa, IntFunction<long []> fb) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
|
||||
@ -1142,6 +1142,22 @@ public class Long256VectorTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longSaturatingUnaryOpProvider() {
|
||||
return LONG_SATURATING_GENERATORS.stream().
|
||||
map(f -> new Object[]{f}).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longSaturatingUnaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> LONG_SATURATING_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longBinaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
@ -4553,6 +4569,94 @@ public class Long256VectorTests extends AbstractVectorTest {
|
||||
assertReductionBoolArraysEquals(r, mask, Long256VectorTests::allTrue);
|
||||
}
|
||||
|
||||
static long SUADDReduce(long[] a, int idx) {
|
||||
long res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
res = (long) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static long SUADDReduceAll(long[] a) {
|
||||
long res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (long) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longSaturatingUnaryOpProvider")
|
||||
static void SUADDReduceLong256VectorTests(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.SUADD);
|
||||
}
|
||||
}
|
||||
|
||||
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 = (long) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEquals(r, ra, a,
|
||||
Long256VectorTests::SUADDReduce, Long256VectorTests::SUADDReduceAll);
|
||||
}
|
||||
|
||||
static long SUADDReduceMasked(long[] a, int idx, boolean[] mask) {
|
||||
long res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
if (mask[i % SPECIES.length()])
|
||||
res = (long) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static long SUADDReduceAllMasked(long[] a, boolean[] mask) {
|
||||
long res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (long) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
@Test(dataProvider = "longSaturatingUnaryOpMaskProvider")
|
||||
static void SUADDReduceLong256VectorTestsMasked(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.SUADD, 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 = (long) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEqualsMasked(r, ra, a, mask,
|
||||
Long256VectorTests::SUADDReduceMasked, Long256VectorTests::SUADDReduceAllMasked);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longBinaryOpProvider")
|
||||
static void withLong256VectorTests(IntFunction<long []> fa, IntFunction<long []> fb) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
|
||||
@ -1142,6 +1142,22 @@ public class Long512VectorTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longSaturatingUnaryOpProvider() {
|
||||
return LONG_SATURATING_GENERATORS.stream().
|
||||
map(f -> new Object[]{f}).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longSaturatingUnaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> LONG_SATURATING_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longBinaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
@ -4553,6 +4569,94 @@ public class Long512VectorTests extends AbstractVectorTest {
|
||||
assertReductionBoolArraysEquals(r, mask, Long512VectorTests::allTrue);
|
||||
}
|
||||
|
||||
static long SUADDReduce(long[] a, int idx) {
|
||||
long res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
res = (long) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static long SUADDReduceAll(long[] a) {
|
||||
long res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (long) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longSaturatingUnaryOpProvider")
|
||||
static void SUADDReduceLong512VectorTests(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.SUADD);
|
||||
}
|
||||
}
|
||||
|
||||
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 = (long) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEquals(r, ra, a,
|
||||
Long512VectorTests::SUADDReduce, Long512VectorTests::SUADDReduceAll);
|
||||
}
|
||||
|
||||
static long SUADDReduceMasked(long[] a, int idx, boolean[] mask) {
|
||||
long res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
if (mask[i % SPECIES.length()])
|
||||
res = (long) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static long SUADDReduceAllMasked(long[] a, boolean[] mask) {
|
||||
long res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (long) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
@Test(dataProvider = "longSaturatingUnaryOpMaskProvider")
|
||||
static void SUADDReduceLong512VectorTestsMasked(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.SUADD, 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 = (long) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEqualsMasked(r, ra, a, mask,
|
||||
Long512VectorTests::SUADDReduceMasked, Long512VectorTests::SUADDReduceAllMasked);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longBinaryOpProvider")
|
||||
static void withLong512VectorTests(IntFunction<long []> fa, IntFunction<long []> fb) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
|
||||
@ -1142,6 +1142,22 @@ public class Long64VectorTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longSaturatingUnaryOpProvider() {
|
||||
return LONG_SATURATING_GENERATORS.stream().
|
||||
map(f -> new Object[]{f}).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longSaturatingUnaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> LONG_SATURATING_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longBinaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
@ -4553,6 +4569,94 @@ public class Long64VectorTests extends AbstractVectorTest {
|
||||
assertReductionBoolArraysEquals(r, mask, Long64VectorTests::allTrue);
|
||||
}
|
||||
|
||||
static long SUADDReduce(long[] a, int idx) {
|
||||
long res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
res = (long) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static long SUADDReduceAll(long[] a) {
|
||||
long res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (long) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longSaturatingUnaryOpProvider")
|
||||
static void SUADDReduceLong64VectorTests(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.SUADD);
|
||||
}
|
||||
}
|
||||
|
||||
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 = (long) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEquals(r, ra, a,
|
||||
Long64VectorTests::SUADDReduce, Long64VectorTests::SUADDReduceAll);
|
||||
}
|
||||
|
||||
static long SUADDReduceMasked(long[] a, int idx, boolean[] mask) {
|
||||
long res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
if (mask[i % SPECIES.length()])
|
||||
res = (long) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static long SUADDReduceAllMasked(long[] a, boolean[] mask) {
|
||||
long res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (long) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
@Test(dataProvider = "longSaturatingUnaryOpMaskProvider")
|
||||
static void SUADDReduceLong64VectorTestsMasked(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.SUADD, 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 = (long) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEqualsMasked(r, ra, a, mask,
|
||||
Long64VectorTests::SUADDReduceMasked, Long64VectorTests::SUADDReduceAllMasked);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longBinaryOpProvider")
|
||||
static void withLong64VectorTests(IntFunction<long []> fa, IntFunction<long []> fb) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
|
||||
@ -1147,6 +1147,22 @@ public class LongMaxVectorTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longSaturatingUnaryOpProvider() {
|
||||
return LONG_SATURATING_GENERATORS.stream().
|
||||
map(f -> new Object[]{f}).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longSaturatingUnaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> LONG_SATURATING_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longBinaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
@ -4558,6 +4574,94 @@ public class LongMaxVectorTests extends AbstractVectorTest {
|
||||
assertReductionBoolArraysEquals(r, mask, LongMaxVectorTests::allTrue);
|
||||
}
|
||||
|
||||
static long SUADDReduce(long[] a, int idx) {
|
||||
long res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
res = (long) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static long SUADDReduceAll(long[] a) {
|
||||
long res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (long) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longSaturatingUnaryOpProvider")
|
||||
static void SUADDReduceLongMaxVectorTests(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.SUADD);
|
||||
}
|
||||
}
|
||||
|
||||
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 = (long) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEquals(r, ra, a,
|
||||
LongMaxVectorTests::SUADDReduce, LongMaxVectorTests::SUADDReduceAll);
|
||||
}
|
||||
|
||||
static long SUADDReduceMasked(long[] a, int idx, boolean[] mask) {
|
||||
long res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
if (mask[i % SPECIES.length()])
|
||||
res = (long) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static long SUADDReduceAllMasked(long[] a, boolean[] mask) {
|
||||
long res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (long) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
@Test(dataProvider = "longSaturatingUnaryOpMaskProvider")
|
||||
static void SUADDReduceLongMaxVectorTestsMasked(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.SUADD, 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 = (long) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEqualsMasked(r, ra, a, mask,
|
||||
LongMaxVectorTests::SUADDReduceMasked, LongMaxVectorTests::SUADDReduceAllMasked);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longBinaryOpProvider")
|
||||
static void withLongMaxVectorTests(IntFunction<long []> fa, IntFunction<long []> fb) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
|
||||
@ -1152,6 +1152,22 @@ public class Short128VectorTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortSaturatingUnaryOpProvider() {
|
||||
return SHORT_SATURATING_GENERATORS.stream().
|
||||
map(f -> new Object[]{f}).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortSaturatingUnaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> SHORT_SATURATING_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortBinaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
@ -4478,6 +4494,94 @@ public class Short128VectorTests extends AbstractVectorTest {
|
||||
assertReductionBoolArraysEquals(r, mask, Short128VectorTests::allTrue);
|
||||
}
|
||||
|
||||
static short SUADDReduce(short[] a, int idx) {
|
||||
short res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
res = (short) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static short SUADDReduceAll(short[] a) {
|
||||
short res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (short) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortSaturatingUnaryOpProvider")
|
||||
static void SUADDReduceShort128VectorTests(IntFunction<short[]> fa) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
short[] r = fr.apply(SPECIES.length());
|
||||
short ra = 0;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
|
||||
r[i] = av.reduceLanes(VectorOperators.SUADD);
|
||||
}
|
||||
}
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
ra = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
|
||||
ra = (short) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEquals(r, ra, a,
|
||||
Short128VectorTests::SUADDReduce, Short128VectorTests::SUADDReduceAll);
|
||||
}
|
||||
|
||||
static short SUADDReduceMasked(short[] a, int idx, boolean[] mask) {
|
||||
short res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
if (mask[i % SPECIES.length()])
|
||||
res = (short) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static short SUADDReduceAllMasked(short[] a, boolean[] mask) {
|
||||
short res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (short) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
@Test(dataProvider = "shortSaturatingUnaryOpMaskProvider")
|
||||
static void SUADDReduceShort128VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
short[] r = fr.apply(SPECIES.length());
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
short ra = 0;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
|
||||
r[i] = av.reduceLanes(VectorOperators.SUADD, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
ra = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
|
||||
ra = (short) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEqualsMasked(r, ra, a, mask,
|
||||
Short128VectorTests::SUADDReduceMasked, Short128VectorTests::SUADDReduceAllMasked);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortBinaryOpProvider")
|
||||
static void withShort128VectorTests(IntFunction<short []> fa, IntFunction<short []> fb) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
|
||||
@ -1152,6 +1152,22 @@ public class Short256VectorTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortSaturatingUnaryOpProvider() {
|
||||
return SHORT_SATURATING_GENERATORS.stream().
|
||||
map(f -> new Object[]{f}).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortSaturatingUnaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> SHORT_SATURATING_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortBinaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
@ -4478,6 +4494,94 @@ public class Short256VectorTests extends AbstractVectorTest {
|
||||
assertReductionBoolArraysEquals(r, mask, Short256VectorTests::allTrue);
|
||||
}
|
||||
|
||||
static short SUADDReduce(short[] a, int idx) {
|
||||
short res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
res = (short) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static short SUADDReduceAll(short[] a) {
|
||||
short res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (short) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortSaturatingUnaryOpProvider")
|
||||
static void SUADDReduceShort256VectorTests(IntFunction<short[]> fa) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
short[] r = fr.apply(SPECIES.length());
|
||||
short ra = 0;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
|
||||
r[i] = av.reduceLanes(VectorOperators.SUADD);
|
||||
}
|
||||
}
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
ra = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
|
||||
ra = (short) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEquals(r, ra, a,
|
||||
Short256VectorTests::SUADDReduce, Short256VectorTests::SUADDReduceAll);
|
||||
}
|
||||
|
||||
static short SUADDReduceMasked(short[] a, int idx, boolean[] mask) {
|
||||
short res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
if (mask[i % SPECIES.length()])
|
||||
res = (short) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static short SUADDReduceAllMasked(short[] a, boolean[] mask) {
|
||||
short res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (short) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
@Test(dataProvider = "shortSaturatingUnaryOpMaskProvider")
|
||||
static void SUADDReduceShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
short[] r = fr.apply(SPECIES.length());
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
short ra = 0;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
|
||||
r[i] = av.reduceLanes(VectorOperators.SUADD, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
ra = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
|
||||
ra = (short) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEqualsMasked(r, ra, a, mask,
|
||||
Short256VectorTests::SUADDReduceMasked, Short256VectorTests::SUADDReduceAllMasked);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortBinaryOpProvider")
|
||||
static void withShort256VectorTests(IntFunction<short []> fa, IntFunction<short []> fb) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
|
||||
@ -1152,6 +1152,22 @@ public class Short512VectorTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortSaturatingUnaryOpProvider() {
|
||||
return SHORT_SATURATING_GENERATORS.stream().
|
||||
map(f -> new Object[]{f}).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortSaturatingUnaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> SHORT_SATURATING_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortBinaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
@ -4478,6 +4494,94 @@ public class Short512VectorTests extends AbstractVectorTest {
|
||||
assertReductionBoolArraysEquals(r, mask, Short512VectorTests::allTrue);
|
||||
}
|
||||
|
||||
static short SUADDReduce(short[] a, int idx) {
|
||||
short res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
res = (short) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static short SUADDReduceAll(short[] a) {
|
||||
short res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (short) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortSaturatingUnaryOpProvider")
|
||||
static void SUADDReduceShort512VectorTests(IntFunction<short[]> fa) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
short[] r = fr.apply(SPECIES.length());
|
||||
short ra = 0;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
|
||||
r[i] = av.reduceLanes(VectorOperators.SUADD);
|
||||
}
|
||||
}
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
ra = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
|
||||
ra = (short) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEquals(r, ra, a,
|
||||
Short512VectorTests::SUADDReduce, Short512VectorTests::SUADDReduceAll);
|
||||
}
|
||||
|
||||
static short SUADDReduceMasked(short[] a, int idx, boolean[] mask) {
|
||||
short res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
if (mask[i % SPECIES.length()])
|
||||
res = (short) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static short SUADDReduceAllMasked(short[] a, boolean[] mask) {
|
||||
short res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (short) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
@Test(dataProvider = "shortSaturatingUnaryOpMaskProvider")
|
||||
static void SUADDReduceShort512VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
short[] r = fr.apply(SPECIES.length());
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
short ra = 0;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
|
||||
r[i] = av.reduceLanes(VectorOperators.SUADD, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
ra = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
|
||||
ra = (short) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEqualsMasked(r, ra, a, mask,
|
||||
Short512VectorTests::SUADDReduceMasked, Short512VectorTests::SUADDReduceAllMasked);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortBinaryOpProvider")
|
||||
static void withShort512VectorTests(IntFunction<short []> fa, IntFunction<short []> fb) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
|
||||
@ -1152,6 +1152,22 @@ public class Short64VectorTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortSaturatingUnaryOpProvider() {
|
||||
return SHORT_SATURATING_GENERATORS.stream().
|
||||
map(f -> new Object[]{f}).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortSaturatingUnaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> SHORT_SATURATING_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortBinaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
@ -4478,6 +4494,94 @@ public class Short64VectorTests extends AbstractVectorTest {
|
||||
assertReductionBoolArraysEquals(r, mask, Short64VectorTests::allTrue);
|
||||
}
|
||||
|
||||
static short SUADDReduce(short[] a, int idx) {
|
||||
short res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
res = (short) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static short SUADDReduceAll(short[] a) {
|
||||
short res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (short) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortSaturatingUnaryOpProvider")
|
||||
static void SUADDReduceShort64VectorTests(IntFunction<short[]> fa) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
short[] r = fr.apply(SPECIES.length());
|
||||
short ra = 0;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
|
||||
r[i] = av.reduceLanes(VectorOperators.SUADD);
|
||||
}
|
||||
}
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
ra = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
|
||||
ra = (short) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEquals(r, ra, a,
|
||||
Short64VectorTests::SUADDReduce, Short64VectorTests::SUADDReduceAll);
|
||||
}
|
||||
|
||||
static short SUADDReduceMasked(short[] a, int idx, boolean[] mask) {
|
||||
short res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
if (mask[i % SPECIES.length()])
|
||||
res = (short) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static short SUADDReduceAllMasked(short[] a, boolean[] mask) {
|
||||
short res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (short) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
@Test(dataProvider = "shortSaturatingUnaryOpMaskProvider")
|
||||
static void SUADDReduceShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
short[] r = fr.apply(SPECIES.length());
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
short ra = 0;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
|
||||
r[i] = av.reduceLanes(VectorOperators.SUADD, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
ra = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
|
||||
ra = (short) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEqualsMasked(r, ra, a, mask,
|
||||
Short64VectorTests::SUADDReduceMasked, Short64VectorTests::SUADDReduceAllMasked);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortBinaryOpProvider")
|
||||
static void withShort64VectorTests(IntFunction<short []> fa, IntFunction<short []> fb) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
|
||||
@ -1157,6 +1157,22 @@ public class ShortMaxVectorTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortSaturatingUnaryOpProvider() {
|
||||
return SHORT_SATURATING_GENERATORS.stream().
|
||||
map(f -> new Object[]{f}).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortSaturatingUnaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> SHORT_SATURATING_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortBinaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
@ -4483,6 +4499,94 @@ public class ShortMaxVectorTests extends AbstractVectorTest {
|
||||
assertReductionBoolArraysEquals(r, mask, ShortMaxVectorTests::allTrue);
|
||||
}
|
||||
|
||||
static short SUADDReduce(short[] a, int idx) {
|
||||
short res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
res = (short) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static short SUADDReduceAll(short[] a) {
|
||||
short res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (short) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortSaturatingUnaryOpProvider")
|
||||
static void SUADDReduceShortMaxVectorTests(IntFunction<short[]> fa) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
short[] r = fr.apply(SPECIES.length());
|
||||
short ra = 0;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
|
||||
r[i] = av.reduceLanes(VectorOperators.SUADD);
|
||||
}
|
||||
}
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
ra = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
|
||||
ra = (short) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEquals(r, ra, a,
|
||||
ShortMaxVectorTests::SUADDReduce, ShortMaxVectorTests::SUADDReduceAll);
|
||||
}
|
||||
|
||||
static short SUADDReduceMasked(short[] a, int idx, boolean[] mask) {
|
||||
short res = 0;
|
||||
for (int i = idx; i < (idx + SPECIES.length()); i++) {
|
||||
if (mask[i % SPECIES.length()])
|
||||
res = (short) VectorMath.addSaturatingUnsigned(res, a[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static short SUADDReduceAllMasked(short[] a, boolean[] mask) {
|
||||
short res = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
res = (short) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
@Test(dataProvider = "shortSaturatingUnaryOpMaskProvider")
|
||||
static void SUADDReduceShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
short[] r = fr.apply(SPECIES.length());
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
short ra = 0;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
|
||||
r[i] = av.reduceLanes(VectorOperators.SUADD, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
ra = 0;
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
|
||||
ra = (short) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask));
|
||||
}
|
||||
}
|
||||
|
||||
assertReductionArraysEqualsMasked(r, ra, a, mask,
|
||||
ShortMaxVectorTests::SUADDReduceMasked, ShortMaxVectorTests::SUADDReduceAllMasked);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortBinaryOpProvider")
|
||||
static void withShortMaxVectorTests(IntFunction<short []> fa, IntFunction<short []> fb) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
|
||||
@ -66,6 +66,8 @@ reduction_op="Reduction-op"
|
||||
reduction_op_func="Reduction-op-func"
|
||||
reduction_op_masked="Reduction-Masked-op"
|
||||
reduction_op_masked_func="Reduction-Masked-op-func"
|
||||
reduction_saturating_op="SaturatingReduction-op"
|
||||
reduction_saturating_op_masked="SaturatingReduction-Masked-op"
|
||||
unary_math_template="Unary-op-math"
|
||||
binary_math_template="Binary-op-math"
|
||||
binary_math_broadcast_template="Binary-Broadcast-op-math"
|
||||
@ -377,6 +379,13 @@ function gen_bool_reduction_op {
|
||||
gen_op_tmpl $bool_reduction_scalar "$@"
|
||||
gen_op_tmpl $bool_reduction_template "$@"
|
||||
}
|
||||
function gen_saturating_reduction_op {
|
||||
echo "Generating saturating reduction op $1 ($2)..."
|
||||
gen_op_tmpl $reduction_scalar_func "$@"
|
||||
gen_op_tmpl $reduction_saturating_op "$@"
|
||||
gen_op_tmpl $reduction_scalar_masked_func "$@"
|
||||
gen_op_tmpl $reduction_saturating_op_masked "$@"
|
||||
}
|
||||
|
||||
function gen_with_op {
|
||||
echo "Generating with op $1 ($2)..."
|
||||
@ -513,6 +522,9 @@ gen_reduction_op_func "FIRST_NONZERO" "firstNonZero" "" "(\$type\$) 0"
|
||||
gen_bool_reduction_op "anyTrue" "|" "BITWISE" "false"
|
||||
gen_bool_reduction_op "allTrue" "\&" "BITWISE" "true"
|
||||
|
||||
# Saturating reductions.
|
||||
gen_saturating_reduction_op "SUADD" "(\$type\$) VectorMath.addSaturatingUnsigned" "BITWISE" "0"
|
||||
|
||||
#Insert
|
||||
gen_with_op "withLane" "" "" ""
|
||||
|
||||
|
||||
@ -0,0 +1,21 @@
|
||||
$type$[] a = fa.apply(SPECIES.length());
|
||||
$type$[] r = fr.apply(SPECIES.length());
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<$Wideboxtype$> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
$type$ ra = [[TEST_INIT]];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
$abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i);
|
||||
r[i] = av.reduceLanes(VectorOperators.[[TEST]], vmask);
|
||||
}
|
||||
}
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
ra = [[TEST_INIT]];
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
$abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i);
|
||||
ra = [[TEST_OP]](ra, av.reduceLanes(VectorOperators.[[TEST]], vmask));
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,19 @@
|
||||
$type$[] a = fa.apply(SPECIES.length());
|
||||
$type$[] r = fr.apply(SPECIES.length());
|
||||
$type$ ra = [[TEST_INIT]];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
$abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i);
|
||||
r[i] = av.reduceLanes(VectorOperators.[[TEST]]);
|
||||
}
|
||||
}
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
ra = [[TEST_INIT]];
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
$abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i);
|
||||
ra = [[TEST_OP]](ra, av.reduceLanes(VectorOperators.[[TEST]]));
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,6 @@
|
||||
@Test(dataProvider = "$type$SaturatingUnaryOpMaskProvider")
|
||||
static void [[TEST]]Reduce$vectorteststype$Masked(IntFunction<$type$[]> fa, IntFunction<boolean[]> fm) {
|
||||
[[KERNEL]]
|
||||
assertReductionArraysEqualsMasked(r, ra, a, mask,
|
||||
$vectorteststype$::[[TEST]]ReduceMasked, $vectorteststype$::[[TEST]]ReduceAllMasked);
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
|
||||
@Test(dataProvider = "$type$SaturatingUnaryOpProvider")
|
||||
static void [[TEST]]Reduce$vectorteststype$(IntFunction<$type$[]> fa) {
|
||||
[[KERNEL]]
|
||||
assertReductionArraysEquals(r, ra, a,
|
||||
$vectorteststype$::[[TEST]]Reduce, $vectorteststype$::[[TEST]]ReduceAll);
|
||||
}
|
||||
@ -1430,6 +1430,22 @@ relativeError));
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] $type$SaturatingUnaryOpProvider() {
|
||||
return $TYPE$_SATURATING_GENERATORS.stream().
|
||||
map(f -> new Object[]{f}).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] $type$SaturatingUnaryOpMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> $TYPE$_SATURATING_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
#end[!FP]
|
||||
@DataProvider
|
||||
public Object[][] $type$BinaryOpMaskProvider() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user