8284564: Extend VectorAPI validation tests for SHIFTs and ROTATE operations with constant shift values.
Reviewed-by: psandoz, jbhateja
This commit is contained in:
parent
bf1c3ef02b
commit
bf85b0095f
@ -60,6 +60,8 @@ public class Byte128VectorTests extends AbstractVectorTest {
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
private static final byte CONST_SHIFT = Byte.SIZE / 2;
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 128);
|
||||
|
||||
interface FUnOp {
|
||||
@ -460,6 +462,50 @@ public class Byte128VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
interface FBinConstOp {
|
||||
byte apply(byte a);
|
||||
}
|
||||
|
||||
interface FBinConstMaskOp {
|
||||
byte apply(byte a, boolean m);
|
||||
|
||||
static FBinConstMaskOp lift(FBinConstOp f) {
|
||||
return (a, m) -> m ? f.apply(a) : a;
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(byte[] r, byte[] a, FBinConstOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(byte[] r, byte[] a, boolean[] mask, FBinConstOp f) {
|
||||
assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f));
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(byte[] r, byte[] a, boolean[] mask, FBinConstMaskOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError err) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]);
|
||||
}
|
||||
}
|
||||
|
||||
interface FTernOp {
|
||||
byte apply(byte a, byte b, byte c);
|
||||
}
|
||||
@ -2554,7 +2600,7 @@ public class Byte128VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static byte ROR_unary(byte a, byte b) {
|
||||
return (byte)(ROR_scalar(a,b));
|
||||
return (byte)(ROR_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteBinaryOpProvider")
|
||||
@ -2596,7 +2642,7 @@ public class Byte128VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static byte ROL_unary(byte a, byte b) {
|
||||
return (byte)(ROL_scalar(a,b));
|
||||
return (byte)(ROL_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteBinaryOpProvider")
|
||||
@ -2636,6 +2682,215 @@ public class Byte128VectorTests extends AbstractVectorTest {
|
||||
assertShiftArraysEquals(r, a, b, mask, Byte128VectorTests::ROL_unary);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static byte LSHR_binary_const(byte a) {
|
||||
return (byte)(((a & 0xFF) >>> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpProvider")
|
||||
static void LSHRByte128VectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
byte[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Byte128VectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpMaskProvider")
|
||||
static void LSHRByte128VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Byte128VectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static byte LSHL_binary_const(byte a) {
|
||||
return (byte)((a << CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpProvider")
|
||||
static void LSHLByte128VectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
byte[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Byte128VectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpMaskProvider")
|
||||
static void LSHLByte128VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Byte128VectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static byte ASHR_binary_const(byte a) {
|
||||
return (byte)((a >> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpProvider")
|
||||
static void ASHRByte128VectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
byte[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Byte128VectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpMaskProvider")
|
||||
static void ASHRByte128VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Byte128VectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static byte ROR_binary_const(byte a) {
|
||||
return (byte)(ROR_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpProvider")
|
||||
static void RORByte128VectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
byte[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Byte128VectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpMaskProvider")
|
||||
static void RORByte128VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Byte128VectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static byte ROL_binary_const(byte a) {
|
||||
return (byte)(ROL_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpProvider")
|
||||
static void ROLByte128VectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
byte[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Byte128VectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpMaskProvider")
|
||||
static void ROLByte128VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Byte128VectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
static byte MIN(byte a, byte b) {
|
||||
return (byte)(Math.min(a, b));
|
||||
}
|
||||
|
@ -60,6 +60,8 @@ public class Byte256VectorTests extends AbstractVectorTest {
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
private static final byte CONST_SHIFT = Byte.SIZE / 2;
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 256);
|
||||
|
||||
interface FUnOp {
|
||||
@ -460,6 +462,50 @@ public class Byte256VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
interface FBinConstOp {
|
||||
byte apply(byte a);
|
||||
}
|
||||
|
||||
interface FBinConstMaskOp {
|
||||
byte apply(byte a, boolean m);
|
||||
|
||||
static FBinConstMaskOp lift(FBinConstOp f) {
|
||||
return (a, m) -> m ? f.apply(a) : a;
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(byte[] r, byte[] a, FBinConstOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(byte[] r, byte[] a, boolean[] mask, FBinConstOp f) {
|
||||
assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f));
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(byte[] r, byte[] a, boolean[] mask, FBinConstMaskOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError err) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]);
|
||||
}
|
||||
}
|
||||
|
||||
interface FTernOp {
|
||||
byte apply(byte a, byte b, byte c);
|
||||
}
|
||||
@ -2554,7 +2600,7 @@ public class Byte256VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static byte ROR_unary(byte a, byte b) {
|
||||
return (byte)(ROR_scalar(a,b));
|
||||
return (byte)(ROR_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteBinaryOpProvider")
|
||||
@ -2596,7 +2642,7 @@ public class Byte256VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static byte ROL_unary(byte a, byte b) {
|
||||
return (byte)(ROL_scalar(a,b));
|
||||
return (byte)(ROL_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteBinaryOpProvider")
|
||||
@ -2636,6 +2682,215 @@ public class Byte256VectorTests extends AbstractVectorTest {
|
||||
assertShiftArraysEquals(r, a, b, mask, Byte256VectorTests::ROL_unary);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static byte LSHR_binary_const(byte a) {
|
||||
return (byte)(((a & 0xFF) >>> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpProvider")
|
||||
static void LSHRByte256VectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
byte[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Byte256VectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpMaskProvider")
|
||||
static void LSHRByte256VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Byte256VectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static byte LSHL_binary_const(byte a) {
|
||||
return (byte)((a << CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpProvider")
|
||||
static void LSHLByte256VectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
byte[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Byte256VectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpMaskProvider")
|
||||
static void LSHLByte256VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Byte256VectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static byte ASHR_binary_const(byte a) {
|
||||
return (byte)((a >> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpProvider")
|
||||
static void ASHRByte256VectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
byte[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Byte256VectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpMaskProvider")
|
||||
static void ASHRByte256VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Byte256VectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static byte ROR_binary_const(byte a) {
|
||||
return (byte)(ROR_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpProvider")
|
||||
static void RORByte256VectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
byte[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Byte256VectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpMaskProvider")
|
||||
static void RORByte256VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Byte256VectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static byte ROL_binary_const(byte a) {
|
||||
return (byte)(ROL_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpProvider")
|
||||
static void ROLByte256VectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
byte[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Byte256VectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpMaskProvider")
|
||||
static void ROLByte256VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Byte256VectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
static byte MIN(byte a, byte b) {
|
||||
return (byte)(Math.min(a, b));
|
||||
}
|
||||
|
@ -60,6 +60,8 @@ public class Byte512VectorTests extends AbstractVectorTest {
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
private static final byte CONST_SHIFT = Byte.SIZE / 2;
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 512);
|
||||
|
||||
interface FUnOp {
|
||||
@ -460,6 +462,50 @@ public class Byte512VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
interface FBinConstOp {
|
||||
byte apply(byte a);
|
||||
}
|
||||
|
||||
interface FBinConstMaskOp {
|
||||
byte apply(byte a, boolean m);
|
||||
|
||||
static FBinConstMaskOp lift(FBinConstOp f) {
|
||||
return (a, m) -> m ? f.apply(a) : a;
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(byte[] r, byte[] a, FBinConstOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(byte[] r, byte[] a, boolean[] mask, FBinConstOp f) {
|
||||
assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f));
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(byte[] r, byte[] a, boolean[] mask, FBinConstMaskOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError err) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]);
|
||||
}
|
||||
}
|
||||
|
||||
interface FTernOp {
|
||||
byte apply(byte a, byte b, byte c);
|
||||
}
|
||||
@ -2554,7 +2600,7 @@ public class Byte512VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static byte ROR_unary(byte a, byte b) {
|
||||
return (byte)(ROR_scalar(a,b));
|
||||
return (byte)(ROR_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteBinaryOpProvider")
|
||||
@ -2596,7 +2642,7 @@ public class Byte512VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static byte ROL_unary(byte a, byte b) {
|
||||
return (byte)(ROL_scalar(a,b));
|
||||
return (byte)(ROL_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteBinaryOpProvider")
|
||||
@ -2636,6 +2682,215 @@ public class Byte512VectorTests extends AbstractVectorTest {
|
||||
assertShiftArraysEquals(r, a, b, mask, Byte512VectorTests::ROL_unary);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static byte LSHR_binary_const(byte a) {
|
||||
return (byte)(((a & 0xFF) >>> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpProvider")
|
||||
static void LSHRByte512VectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
byte[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Byte512VectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpMaskProvider")
|
||||
static void LSHRByte512VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Byte512VectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static byte LSHL_binary_const(byte a) {
|
||||
return (byte)((a << CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpProvider")
|
||||
static void LSHLByte512VectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
byte[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Byte512VectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpMaskProvider")
|
||||
static void LSHLByte512VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Byte512VectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static byte ASHR_binary_const(byte a) {
|
||||
return (byte)((a >> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpProvider")
|
||||
static void ASHRByte512VectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
byte[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Byte512VectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpMaskProvider")
|
||||
static void ASHRByte512VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Byte512VectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static byte ROR_binary_const(byte a) {
|
||||
return (byte)(ROR_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpProvider")
|
||||
static void RORByte512VectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
byte[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Byte512VectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpMaskProvider")
|
||||
static void RORByte512VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Byte512VectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static byte ROL_binary_const(byte a) {
|
||||
return (byte)(ROL_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpProvider")
|
||||
static void ROLByte512VectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
byte[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Byte512VectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpMaskProvider")
|
||||
static void ROLByte512VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Byte512VectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
static byte MIN(byte a, byte b) {
|
||||
return (byte)(Math.min(a, b));
|
||||
}
|
||||
|
@ -60,6 +60,8 @@ public class Byte64VectorTests extends AbstractVectorTest {
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
private static final byte CONST_SHIFT = Byte.SIZE / 2;
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 64);
|
||||
|
||||
interface FUnOp {
|
||||
@ -460,6 +462,50 @@ public class Byte64VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
interface FBinConstOp {
|
||||
byte apply(byte a);
|
||||
}
|
||||
|
||||
interface FBinConstMaskOp {
|
||||
byte apply(byte a, boolean m);
|
||||
|
||||
static FBinConstMaskOp lift(FBinConstOp f) {
|
||||
return (a, m) -> m ? f.apply(a) : a;
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(byte[] r, byte[] a, FBinConstOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(byte[] r, byte[] a, boolean[] mask, FBinConstOp f) {
|
||||
assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f));
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(byte[] r, byte[] a, boolean[] mask, FBinConstMaskOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError err) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]);
|
||||
}
|
||||
}
|
||||
|
||||
interface FTernOp {
|
||||
byte apply(byte a, byte b, byte c);
|
||||
}
|
||||
@ -2554,7 +2600,7 @@ public class Byte64VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static byte ROR_unary(byte a, byte b) {
|
||||
return (byte)(ROR_scalar(a,b));
|
||||
return (byte)(ROR_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteBinaryOpProvider")
|
||||
@ -2596,7 +2642,7 @@ public class Byte64VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static byte ROL_unary(byte a, byte b) {
|
||||
return (byte)(ROL_scalar(a,b));
|
||||
return (byte)(ROL_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteBinaryOpProvider")
|
||||
@ -2636,6 +2682,215 @@ public class Byte64VectorTests extends AbstractVectorTest {
|
||||
assertShiftArraysEquals(r, a, b, mask, Byte64VectorTests::ROL_unary);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static byte LSHR_binary_const(byte a) {
|
||||
return (byte)(((a & 0xFF) >>> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpProvider")
|
||||
static void LSHRByte64VectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
byte[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Byte64VectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpMaskProvider")
|
||||
static void LSHRByte64VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Byte64VectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static byte LSHL_binary_const(byte a) {
|
||||
return (byte)((a << CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpProvider")
|
||||
static void LSHLByte64VectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
byte[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Byte64VectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpMaskProvider")
|
||||
static void LSHLByte64VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Byte64VectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static byte ASHR_binary_const(byte a) {
|
||||
return (byte)((a >> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpProvider")
|
||||
static void ASHRByte64VectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
byte[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Byte64VectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpMaskProvider")
|
||||
static void ASHRByte64VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Byte64VectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static byte ROR_binary_const(byte a) {
|
||||
return (byte)(ROR_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpProvider")
|
||||
static void RORByte64VectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
byte[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Byte64VectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpMaskProvider")
|
||||
static void RORByte64VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Byte64VectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static byte ROL_binary_const(byte a) {
|
||||
return (byte)(ROL_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpProvider")
|
||||
static void ROLByte64VectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
byte[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Byte64VectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpMaskProvider")
|
||||
static void ROLByte64VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Byte64VectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
static byte MIN(byte a, byte b) {
|
||||
return (byte)(Math.min(a, b));
|
||||
}
|
||||
|
@ -65,6 +65,8 @@ public class ByteMaxVectorTests extends AbstractVectorTest {
|
||||
|
||||
private static final int Max = 256; // juts so we can do N/Max
|
||||
|
||||
private static final byte CONST_SHIFT = Byte.SIZE / 2;
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max);
|
||||
|
||||
interface FUnOp {
|
||||
@ -465,6 +467,50 @@ public class ByteMaxVectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
interface FBinConstOp {
|
||||
byte apply(byte a);
|
||||
}
|
||||
|
||||
interface FBinConstMaskOp {
|
||||
byte apply(byte a, boolean m);
|
||||
|
||||
static FBinConstMaskOp lift(FBinConstOp f) {
|
||||
return (a, m) -> m ? f.apply(a) : a;
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(byte[] r, byte[] a, FBinConstOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(byte[] r, byte[] a, boolean[] mask, FBinConstOp f) {
|
||||
assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f));
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(byte[] r, byte[] a, boolean[] mask, FBinConstMaskOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError err) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]);
|
||||
}
|
||||
}
|
||||
|
||||
interface FTernOp {
|
||||
byte apply(byte a, byte b, byte c);
|
||||
}
|
||||
@ -2559,7 +2605,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static byte ROR_unary(byte a, byte b) {
|
||||
return (byte)(ROR_scalar(a,b));
|
||||
return (byte)(ROR_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteBinaryOpProvider")
|
||||
@ -2601,7 +2647,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static byte ROL_unary(byte a, byte b) {
|
||||
return (byte)(ROL_scalar(a,b));
|
||||
return (byte)(ROL_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteBinaryOpProvider")
|
||||
@ -2641,6 +2687,215 @@ public class ByteMaxVectorTests extends AbstractVectorTest {
|
||||
assertShiftArraysEquals(r, a, b, mask, ByteMaxVectorTests::ROL_unary);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static byte LSHR_binary_const(byte a) {
|
||||
return (byte)(((a & 0xFF) >>> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpProvider")
|
||||
static void LSHRByteMaxVectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
byte[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, ByteMaxVectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpMaskProvider")
|
||||
static void LSHRByteMaxVectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, ByteMaxVectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static byte LSHL_binary_const(byte a) {
|
||||
return (byte)((a << CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpProvider")
|
||||
static void LSHLByteMaxVectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
byte[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, ByteMaxVectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpMaskProvider")
|
||||
static void LSHLByteMaxVectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, ByteMaxVectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static byte ASHR_binary_const(byte a) {
|
||||
return (byte)((a >> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpProvider")
|
||||
static void ASHRByteMaxVectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
byte[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, ByteMaxVectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpMaskProvider")
|
||||
static void ASHRByteMaxVectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, ByteMaxVectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static byte ROR_binary_const(byte a) {
|
||||
return (byte)(ROR_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpProvider")
|
||||
static void RORByteMaxVectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
byte[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, ByteMaxVectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpMaskProvider")
|
||||
static void RORByteMaxVectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, ByteMaxVectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static byte ROL_binary_const(byte a) {
|
||||
return (byte)(ROL_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpProvider")
|
||||
static void ROLByteMaxVectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
byte[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, ByteMaxVectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpMaskProvider")
|
||||
static void ROLByteMaxVectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, ByteMaxVectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
static byte MIN(byte a, byte b) {
|
||||
return (byte)(Math.min(a, b));
|
||||
}
|
||||
|
@ -60,6 +60,8 @@ public class Double128VectorTests extends AbstractVectorTest {
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
private static final double CONST_SHIFT = Double.SIZE / 2;
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 128);
|
||||
|
||||
interface FUnOp {
|
||||
@ -460,6 +462,50 @@ public class Double128VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
interface FBinConstOp {
|
||||
double apply(double a);
|
||||
}
|
||||
|
||||
interface FBinConstMaskOp {
|
||||
double apply(double a, boolean m);
|
||||
|
||||
static FBinConstMaskOp lift(FBinConstOp f) {
|
||||
return (a, m) -> m ? f.apply(a) : a;
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(double[] r, double[] a, FBinConstOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(double[] r, double[] a, boolean[] mask, FBinConstOp f) {
|
||||
assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f));
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(double[] r, double[] a, boolean[] mask, FBinConstMaskOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError err) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]);
|
||||
}
|
||||
}
|
||||
|
||||
interface FTernOp {
|
||||
double apply(double a, double b, double c);
|
||||
}
|
||||
@ -1949,6 +1995,20 @@ public class Double128VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -60,6 +60,8 @@ public class Double256VectorTests extends AbstractVectorTest {
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
private static final double CONST_SHIFT = Double.SIZE / 2;
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 256);
|
||||
|
||||
interface FUnOp {
|
||||
@ -460,6 +462,50 @@ public class Double256VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
interface FBinConstOp {
|
||||
double apply(double a);
|
||||
}
|
||||
|
||||
interface FBinConstMaskOp {
|
||||
double apply(double a, boolean m);
|
||||
|
||||
static FBinConstMaskOp lift(FBinConstOp f) {
|
||||
return (a, m) -> m ? f.apply(a) : a;
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(double[] r, double[] a, FBinConstOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(double[] r, double[] a, boolean[] mask, FBinConstOp f) {
|
||||
assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f));
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(double[] r, double[] a, boolean[] mask, FBinConstMaskOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError err) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]);
|
||||
}
|
||||
}
|
||||
|
||||
interface FTernOp {
|
||||
double apply(double a, double b, double c);
|
||||
}
|
||||
@ -1949,6 +1995,20 @@ public class Double256VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -60,6 +60,8 @@ public class Double512VectorTests extends AbstractVectorTest {
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
private static final double CONST_SHIFT = Double.SIZE / 2;
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 512);
|
||||
|
||||
interface FUnOp {
|
||||
@ -460,6 +462,50 @@ public class Double512VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
interface FBinConstOp {
|
||||
double apply(double a);
|
||||
}
|
||||
|
||||
interface FBinConstMaskOp {
|
||||
double apply(double a, boolean m);
|
||||
|
||||
static FBinConstMaskOp lift(FBinConstOp f) {
|
||||
return (a, m) -> m ? f.apply(a) : a;
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(double[] r, double[] a, FBinConstOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(double[] r, double[] a, boolean[] mask, FBinConstOp f) {
|
||||
assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f));
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(double[] r, double[] a, boolean[] mask, FBinConstMaskOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError err) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]);
|
||||
}
|
||||
}
|
||||
|
||||
interface FTernOp {
|
||||
double apply(double a, double b, double c);
|
||||
}
|
||||
@ -1949,6 +1995,20 @@ public class Double512VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -60,6 +60,8 @@ public class Double64VectorTests extends AbstractVectorTest {
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
private static final double CONST_SHIFT = Double.SIZE / 2;
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 64);
|
||||
|
||||
interface FUnOp {
|
||||
@ -460,6 +462,50 @@ public class Double64VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
interface FBinConstOp {
|
||||
double apply(double a);
|
||||
}
|
||||
|
||||
interface FBinConstMaskOp {
|
||||
double apply(double a, boolean m);
|
||||
|
||||
static FBinConstMaskOp lift(FBinConstOp f) {
|
||||
return (a, m) -> m ? f.apply(a) : a;
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(double[] r, double[] a, FBinConstOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(double[] r, double[] a, boolean[] mask, FBinConstOp f) {
|
||||
assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f));
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(double[] r, double[] a, boolean[] mask, FBinConstMaskOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError err) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]);
|
||||
}
|
||||
}
|
||||
|
||||
interface FTernOp {
|
||||
double apply(double a, double b, double c);
|
||||
}
|
||||
@ -1949,6 +1995,20 @@ public class Double64VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -65,6 +65,8 @@ public class DoubleMaxVectorTests extends AbstractVectorTest {
|
||||
|
||||
private static final int Max = 256; // juts so we can do N/Max
|
||||
|
||||
private static final double CONST_SHIFT = Double.SIZE / 2;
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max);
|
||||
|
||||
interface FUnOp {
|
||||
@ -465,6 +467,50 @@ public class DoubleMaxVectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
interface FBinConstOp {
|
||||
double apply(double a);
|
||||
}
|
||||
|
||||
interface FBinConstMaskOp {
|
||||
double apply(double a, boolean m);
|
||||
|
||||
static FBinConstMaskOp lift(FBinConstOp f) {
|
||||
return (a, m) -> m ? f.apply(a) : a;
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(double[] r, double[] a, FBinConstOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(double[] r, double[] a, boolean[] mask, FBinConstOp f) {
|
||||
assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f));
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(double[] r, double[] a, boolean[] mask, FBinConstMaskOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError err) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]);
|
||||
}
|
||||
}
|
||||
|
||||
interface FTernOp {
|
||||
double apply(double a, double b, double c);
|
||||
}
|
||||
@ -1954,6 +2000,20 @@ public class DoubleMaxVectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -60,6 +60,8 @@ public class Float128VectorTests extends AbstractVectorTest {
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
private static final float CONST_SHIFT = Float.SIZE / 2;
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 128);
|
||||
|
||||
interface FUnOp {
|
||||
@ -460,6 +462,50 @@ public class Float128VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
interface FBinConstOp {
|
||||
float apply(float a);
|
||||
}
|
||||
|
||||
interface FBinConstMaskOp {
|
||||
float apply(float a, boolean m);
|
||||
|
||||
static FBinConstMaskOp lift(FBinConstOp f) {
|
||||
return (a, m) -> m ? f.apply(a) : a;
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(float[] r, float[] a, FBinConstOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(float[] r, float[] a, boolean[] mask, FBinConstOp f) {
|
||||
assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f));
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(float[] r, float[] a, boolean[] mask, FBinConstMaskOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError err) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]);
|
||||
}
|
||||
}
|
||||
|
||||
interface FTernOp {
|
||||
float apply(float a, float b, float c);
|
||||
}
|
||||
@ -1959,6 +2005,20 @@ public class Float128VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -60,6 +60,8 @@ public class Float256VectorTests extends AbstractVectorTest {
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
private static final float CONST_SHIFT = Float.SIZE / 2;
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 256);
|
||||
|
||||
interface FUnOp {
|
||||
@ -460,6 +462,50 @@ public class Float256VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
interface FBinConstOp {
|
||||
float apply(float a);
|
||||
}
|
||||
|
||||
interface FBinConstMaskOp {
|
||||
float apply(float a, boolean m);
|
||||
|
||||
static FBinConstMaskOp lift(FBinConstOp f) {
|
||||
return (a, m) -> m ? f.apply(a) : a;
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(float[] r, float[] a, FBinConstOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(float[] r, float[] a, boolean[] mask, FBinConstOp f) {
|
||||
assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f));
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(float[] r, float[] a, boolean[] mask, FBinConstMaskOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError err) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]);
|
||||
}
|
||||
}
|
||||
|
||||
interface FTernOp {
|
||||
float apply(float a, float b, float c);
|
||||
}
|
||||
@ -1959,6 +2005,20 @@ public class Float256VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -60,6 +60,8 @@ public class Float512VectorTests extends AbstractVectorTest {
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
private static final float CONST_SHIFT = Float.SIZE / 2;
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 512);
|
||||
|
||||
interface FUnOp {
|
||||
@ -460,6 +462,50 @@ public class Float512VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
interface FBinConstOp {
|
||||
float apply(float a);
|
||||
}
|
||||
|
||||
interface FBinConstMaskOp {
|
||||
float apply(float a, boolean m);
|
||||
|
||||
static FBinConstMaskOp lift(FBinConstOp f) {
|
||||
return (a, m) -> m ? f.apply(a) : a;
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(float[] r, float[] a, FBinConstOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(float[] r, float[] a, boolean[] mask, FBinConstOp f) {
|
||||
assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f));
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(float[] r, float[] a, boolean[] mask, FBinConstMaskOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError err) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]);
|
||||
}
|
||||
}
|
||||
|
||||
interface FTernOp {
|
||||
float apply(float a, float b, float c);
|
||||
}
|
||||
@ -1959,6 +2005,20 @@ public class Float512VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -60,6 +60,8 @@ public class Float64VectorTests extends AbstractVectorTest {
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
private static final float CONST_SHIFT = Float.SIZE / 2;
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 64);
|
||||
|
||||
interface FUnOp {
|
||||
@ -460,6 +462,50 @@ public class Float64VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
interface FBinConstOp {
|
||||
float apply(float a);
|
||||
}
|
||||
|
||||
interface FBinConstMaskOp {
|
||||
float apply(float a, boolean m);
|
||||
|
||||
static FBinConstMaskOp lift(FBinConstOp f) {
|
||||
return (a, m) -> m ? f.apply(a) : a;
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(float[] r, float[] a, FBinConstOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(float[] r, float[] a, boolean[] mask, FBinConstOp f) {
|
||||
assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f));
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(float[] r, float[] a, boolean[] mask, FBinConstMaskOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError err) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]);
|
||||
}
|
||||
}
|
||||
|
||||
interface FTernOp {
|
||||
float apply(float a, float b, float c);
|
||||
}
|
||||
@ -1959,6 +2005,20 @@ public class Float64VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -65,6 +65,8 @@ public class FloatMaxVectorTests extends AbstractVectorTest {
|
||||
|
||||
private static final int Max = 256; // juts so we can do N/Max
|
||||
|
||||
private static final float CONST_SHIFT = Float.SIZE / 2;
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max);
|
||||
|
||||
interface FUnOp {
|
||||
@ -465,6 +467,50 @@ public class FloatMaxVectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
interface FBinConstOp {
|
||||
float apply(float a);
|
||||
}
|
||||
|
||||
interface FBinConstMaskOp {
|
||||
float apply(float a, boolean m);
|
||||
|
||||
static FBinConstMaskOp lift(FBinConstOp f) {
|
||||
return (a, m) -> m ? f.apply(a) : a;
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(float[] r, float[] a, FBinConstOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(float[] r, float[] a, boolean[] mask, FBinConstOp f) {
|
||||
assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f));
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(float[] r, float[] a, boolean[] mask, FBinConstMaskOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError err) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]);
|
||||
}
|
||||
}
|
||||
|
||||
interface FTernOp {
|
||||
float apply(float a, float b, float c);
|
||||
}
|
||||
@ -1964,6 +2010,20 @@ public class FloatMaxVectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -60,6 +60,8 @@ public class Int128VectorTests extends AbstractVectorTest {
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
private static final int CONST_SHIFT = Integer.SIZE / 2;
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 128);
|
||||
|
||||
interface FUnOp {
|
||||
@ -460,6 +462,50 @@ public class Int128VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
interface FBinConstOp {
|
||||
int apply(int a);
|
||||
}
|
||||
|
||||
interface FBinConstMaskOp {
|
||||
int apply(int a, boolean m);
|
||||
|
||||
static FBinConstMaskOp lift(FBinConstOp f) {
|
||||
return (a, m) -> m ? f.apply(a) : a;
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(int[] r, int[] a, FBinConstOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(int[] r, int[] a, boolean[] mask, FBinConstOp f) {
|
||||
assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f));
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(int[] r, int[] a, boolean[] mask, FBinConstMaskOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError err) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]);
|
||||
}
|
||||
}
|
||||
|
||||
interface FTernOp {
|
||||
int apply(int a, int b, int c);
|
||||
}
|
||||
@ -2519,7 +2565,7 @@ public class Int128VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static int ROR_unary(int a, int b) {
|
||||
return (int)(ROR_scalar(a,b));
|
||||
return (int)(ROR_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intBinaryOpProvider")
|
||||
@ -2561,7 +2607,7 @@ public class Int128VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static int ROL_unary(int a, int b) {
|
||||
return (int)(ROL_scalar(a,b));
|
||||
return (int)(ROL_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intBinaryOpProvider")
|
||||
@ -2601,6 +2647,215 @@ public class Int128VectorTests extends AbstractVectorTest {
|
||||
assertShiftArraysEquals(r, a, b, mask, Int128VectorTests::ROL_unary);
|
||||
}
|
||||
|
||||
|
||||
static int LSHR_binary_const(int a) {
|
||||
return (int)((a >>> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryOpProvider")
|
||||
static void LSHRInt128VectorTestsScalarShiftConst(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Int128VectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "intUnaryOpMaskProvider")
|
||||
static void LSHRInt128VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Int128VectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static int LSHL_binary_const(int a) {
|
||||
return (int)((a << CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryOpProvider")
|
||||
static void LSHLInt128VectorTestsScalarShiftConst(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Int128VectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "intUnaryOpMaskProvider")
|
||||
static void LSHLInt128VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Int128VectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int ASHR_binary_const(int a) {
|
||||
return (int)((a >> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryOpProvider")
|
||||
static void ASHRInt128VectorTestsScalarShiftConst(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Int128VectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "intUnaryOpMaskProvider")
|
||||
static void ASHRInt128VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Int128VectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int ROR_binary_const(int a) {
|
||||
return (int)(ROR_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryOpProvider")
|
||||
static void RORInt128VectorTestsScalarShiftConst(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Int128VectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "intUnaryOpMaskProvider")
|
||||
static void RORInt128VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Int128VectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int ROL_binary_const(int a) {
|
||||
return (int)(ROL_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryOpProvider")
|
||||
static void ROLInt128VectorTestsScalarShiftConst(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Int128VectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "intUnaryOpMaskProvider")
|
||||
static void ROLInt128VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Int128VectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
static int MIN(int a, int b) {
|
||||
return (int)(Math.min(a, b));
|
||||
}
|
||||
|
@ -60,6 +60,8 @@ public class Int256VectorTests extends AbstractVectorTest {
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
private static final int CONST_SHIFT = Integer.SIZE / 2;
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 256);
|
||||
|
||||
interface FUnOp {
|
||||
@ -460,6 +462,50 @@ public class Int256VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
interface FBinConstOp {
|
||||
int apply(int a);
|
||||
}
|
||||
|
||||
interface FBinConstMaskOp {
|
||||
int apply(int a, boolean m);
|
||||
|
||||
static FBinConstMaskOp lift(FBinConstOp f) {
|
||||
return (a, m) -> m ? f.apply(a) : a;
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(int[] r, int[] a, FBinConstOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(int[] r, int[] a, boolean[] mask, FBinConstOp f) {
|
||||
assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f));
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(int[] r, int[] a, boolean[] mask, FBinConstMaskOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError err) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]);
|
||||
}
|
||||
}
|
||||
|
||||
interface FTernOp {
|
||||
int apply(int a, int b, int c);
|
||||
}
|
||||
@ -2519,7 +2565,7 @@ public class Int256VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static int ROR_unary(int a, int b) {
|
||||
return (int)(ROR_scalar(a,b));
|
||||
return (int)(ROR_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intBinaryOpProvider")
|
||||
@ -2561,7 +2607,7 @@ public class Int256VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static int ROL_unary(int a, int b) {
|
||||
return (int)(ROL_scalar(a,b));
|
||||
return (int)(ROL_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intBinaryOpProvider")
|
||||
@ -2601,6 +2647,215 @@ public class Int256VectorTests extends AbstractVectorTest {
|
||||
assertShiftArraysEquals(r, a, b, mask, Int256VectorTests::ROL_unary);
|
||||
}
|
||||
|
||||
|
||||
static int LSHR_binary_const(int a) {
|
||||
return (int)((a >>> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryOpProvider")
|
||||
static void LSHRInt256VectorTestsScalarShiftConst(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Int256VectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "intUnaryOpMaskProvider")
|
||||
static void LSHRInt256VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Int256VectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static int LSHL_binary_const(int a) {
|
||||
return (int)((a << CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryOpProvider")
|
||||
static void LSHLInt256VectorTestsScalarShiftConst(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Int256VectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "intUnaryOpMaskProvider")
|
||||
static void LSHLInt256VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Int256VectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int ASHR_binary_const(int a) {
|
||||
return (int)((a >> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryOpProvider")
|
||||
static void ASHRInt256VectorTestsScalarShiftConst(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Int256VectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "intUnaryOpMaskProvider")
|
||||
static void ASHRInt256VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Int256VectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int ROR_binary_const(int a) {
|
||||
return (int)(ROR_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryOpProvider")
|
||||
static void RORInt256VectorTestsScalarShiftConst(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Int256VectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "intUnaryOpMaskProvider")
|
||||
static void RORInt256VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Int256VectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int ROL_binary_const(int a) {
|
||||
return (int)(ROL_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryOpProvider")
|
||||
static void ROLInt256VectorTestsScalarShiftConst(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Int256VectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "intUnaryOpMaskProvider")
|
||||
static void ROLInt256VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Int256VectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
static int MIN(int a, int b) {
|
||||
return (int)(Math.min(a, b));
|
||||
}
|
||||
|
@ -60,6 +60,8 @@ public class Int512VectorTests extends AbstractVectorTest {
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
private static final int CONST_SHIFT = Integer.SIZE / 2;
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 512);
|
||||
|
||||
interface FUnOp {
|
||||
@ -460,6 +462,50 @@ public class Int512VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
interface FBinConstOp {
|
||||
int apply(int a);
|
||||
}
|
||||
|
||||
interface FBinConstMaskOp {
|
||||
int apply(int a, boolean m);
|
||||
|
||||
static FBinConstMaskOp lift(FBinConstOp f) {
|
||||
return (a, m) -> m ? f.apply(a) : a;
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(int[] r, int[] a, FBinConstOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(int[] r, int[] a, boolean[] mask, FBinConstOp f) {
|
||||
assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f));
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(int[] r, int[] a, boolean[] mask, FBinConstMaskOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError err) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]);
|
||||
}
|
||||
}
|
||||
|
||||
interface FTernOp {
|
||||
int apply(int a, int b, int c);
|
||||
}
|
||||
@ -2519,7 +2565,7 @@ public class Int512VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static int ROR_unary(int a, int b) {
|
||||
return (int)(ROR_scalar(a,b));
|
||||
return (int)(ROR_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intBinaryOpProvider")
|
||||
@ -2561,7 +2607,7 @@ public class Int512VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static int ROL_unary(int a, int b) {
|
||||
return (int)(ROL_scalar(a,b));
|
||||
return (int)(ROL_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intBinaryOpProvider")
|
||||
@ -2601,6 +2647,215 @@ public class Int512VectorTests extends AbstractVectorTest {
|
||||
assertShiftArraysEquals(r, a, b, mask, Int512VectorTests::ROL_unary);
|
||||
}
|
||||
|
||||
|
||||
static int LSHR_binary_const(int a) {
|
||||
return (int)((a >>> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryOpProvider")
|
||||
static void LSHRInt512VectorTestsScalarShiftConst(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Int512VectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "intUnaryOpMaskProvider")
|
||||
static void LSHRInt512VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Int512VectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static int LSHL_binary_const(int a) {
|
||||
return (int)((a << CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryOpProvider")
|
||||
static void LSHLInt512VectorTestsScalarShiftConst(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Int512VectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "intUnaryOpMaskProvider")
|
||||
static void LSHLInt512VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Int512VectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int ASHR_binary_const(int a) {
|
||||
return (int)((a >> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryOpProvider")
|
||||
static void ASHRInt512VectorTestsScalarShiftConst(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Int512VectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "intUnaryOpMaskProvider")
|
||||
static void ASHRInt512VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Int512VectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int ROR_binary_const(int a) {
|
||||
return (int)(ROR_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryOpProvider")
|
||||
static void RORInt512VectorTestsScalarShiftConst(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Int512VectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "intUnaryOpMaskProvider")
|
||||
static void RORInt512VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Int512VectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int ROL_binary_const(int a) {
|
||||
return (int)(ROL_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryOpProvider")
|
||||
static void ROLInt512VectorTestsScalarShiftConst(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Int512VectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "intUnaryOpMaskProvider")
|
||||
static void ROLInt512VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Int512VectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
static int MIN(int a, int b) {
|
||||
return (int)(Math.min(a, b));
|
||||
}
|
||||
|
@ -60,6 +60,8 @@ public class Int64VectorTests extends AbstractVectorTest {
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
private static final int CONST_SHIFT = Integer.SIZE / 2;
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 64);
|
||||
|
||||
interface FUnOp {
|
||||
@ -460,6 +462,50 @@ public class Int64VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
interface FBinConstOp {
|
||||
int apply(int a);
|
||||
}
|
||||
|
||||
interface FBinConstMaskOp {
|
||||
int apply(int a, boolean m);
|
||||
|
||||
static FBinConstMaskOp lift(FBinConstOp f) {
|
||||
return (a, m) -> m ? f.apply(a) : a;
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(int[] r, int[] a, FBinConstOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(int[] r, int[] a, boolean[] mask, FBinConstOp f) {
|
||||
assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f));
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(int[] r, int[] a, boolean[] mask, FBinConstMaskOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError err) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]);
|
||||
}
|
||||
}
|
||||
|
||||
interface FTernOp {
|
||||
int apply(int a, int b, int c);
|
||||
}
|
||||
@ -2519,7 +2565,7 @@ public class Int64VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static int ROR_unary(int a, int b) {
|
||||
return (int)(ROR_scalar(a,b));
|
||||
return (int)(ROR_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intBinaryOpProvider")
|
||||
@ -2561,7 +2607,7 @@ public class Int64VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static int ROL_unary(int a, int b) {
|
||||
return (int)(ROL_scalar(a,b));
|
||||
return (int)(ROL_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intBinaryOpProvider")
|
||||
@ -2601,6 +2647,215 @@ public class Int64VectorTests extends AbstractVectorTest {
|
||||
assertShiftArraysEquals(r, a, b, mask, Int64VectorTests::ROL_unary);
|
||||
}
|
||||
|
||||
|
||||
static int LSHR_binary_const(int a) {
|
||||
return (int)((a >>> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryOpProvider")
|
||||
static void LSHRInt64VectorTestsScalarShiftConst(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Int64VectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "intUnaryOpMaskProvider")
|
||||
static void LSHRInt64VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Int64VectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static int LSHL_binary_const(int a) {
|
||||
return (int)((a << CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryOpProvider")
|
||||
static void LSHLInt64VectorTestsScalarShiftConst(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Int64VectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "intUnaryOpMaskProvider")
|
||||
static void LSHLInt64VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Int64VectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int ASHR_binary_const(int a) {
|
||||
return (int)((a >> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryOpProvider")
|
||||
static void ASHRInt64VectorTestsScalarShiftConst(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Int64VectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "intUnaryOpMaskProvider")
|
||||
static void ASHRInt64VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Int64VectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int ROR_binary_const(int a) {
|
||||
return (int)(ROR_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryOpProvider")
|
||||
static void RORInt64VectorTestsScalarShiftConst(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Int64VectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "intUnaryOpMaskProvider")
|
||||
static void RORInt64VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Int64VectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int ROL_binary_const(int a) {
|
||||
return (int)(ROL_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryOpProvider")
|
||||
static void ROLInt64VectorTestsScalarShiftConst(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Int64VectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "intUnaryOpMaskProvider")
|
||||
static void ROLInt64VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Int64VectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
static int MIN(int a, int b) {
|
||||
return (int)(Math.min(a, b));
|
||||
}
|
||||
|
@ -65,6 +65,8 @@ public class IntMaxVectorTests extends AbstractVectorTest {
|
||||
|
||||
private static final int Max = 256; // juts so we can do N/Max
|
||||
|
||||
private static final int CONST_SHIFT = Integer.SIZE / 2;
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max);
|
||||
|
||||
interface FUnOp {
|
||||
@ -465,6 +467,50 @@ public class IntMaxVectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
interface FBinConstOp {
|
||||
int apply(int a);
|
||||
}
|
||||
|
||||
interface FBinConstMaskOp {
|
||||
int apply(int a, boolean m);
|
||||
|
||||
static FBinConstMaskOp lift(FBinConstOp f) {
|
||||
return (a, m) -> m ? f.apply(a) : a;
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(int[] r, int[] a, FBinConstOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(int[] r, int[] a, boolean[] mask, FBinConstOp f) {
|
||||
assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f));
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(int[] r, int[] a, boolean[] mask, FBinConstMaskOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError err) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]);
|
||||
}
|
||||
}
|
||||
|
||||
interface FTernOp {
|
||||
int apply(int a, int b, int c);
|
||||
}
|
||||
@ -2524,7 +2570,7 @@ public class IntMaxVectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static int ROR_unary(int a, int b) {
|
||||
return (int)(ROR_scalar(a,b));
|
||||
return (int)(ROR_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intBinaryOpProvider")
|
||||
@ -2566,7 +2612,7 @@ public class IntMaxVectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static int ROL_unary(int a, int b) {
|
||||
return (int)(ROL_scalar(a,b));
|
||||
return (int)(ROL_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intBinaryOpProvider")
|
||||
@ -2606,6 +2652,215 @@ public class IntMaxVectorTests extends AbstractVectorTest {
|
||||
assertShiftArraysEquals(r, a, b, mask, IntMaxVectorTests::ROL_unary);
|
||||
}
|
||||
|
||||
|
||||
static int LSHR_binary_const(int a) {
|
||||
return (int)((a >>> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryOpProvider")
|
||||
static void LSHRIntMaxVectorTestsScalarShiftConst(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, IntMaxVectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "intUnaryOpMaskProvider")
|
||||
static void LSHRIntMaxVectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, IntMaxVectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static int LSHL_binary_const(int a) {
|
||||
return (int)((a << CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryOpProvider")
|
||||
static void LSHLIntMaxVectorTestsScalarShiftConst(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, IntMaxVectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "intUnaryOpMaskProvider")
|
||||
static void LSHLIntMaxVectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, IntMaxVectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int ASHR_binary_const(int a) {
|
||||
return (int)((a >> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryOpProvider")
|
||||
static void ASHRIntMaxVectorTestsScalarShiftConst(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, IntMaxVectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "intUnaryOpMaskProvider")
|
||||
static void ASHRIntMaxVectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, IntMaxVectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int ROR_binary_const(int a) {
|
||||
return (int)(ROR_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryOpProvider")
|
||||
static void RORIntMaxVectorTestsScalarShiftConst(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, IntMaxVectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "intUnaryOpMaskProvider")
|
||||
static void RORIntMaxVectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, IntMaxVectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int ROL_binary_const(int a) {
|
||||
return (int)(ROL_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryOpProvider")
|
||||
static void ROLIntMaxVectorTestsScalarShiftConst(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, IntMaxVectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "intUnaryOpMaskProvider")
|
||||
static void ROLIntMaxVectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, IntMaxVectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
static int MIN(int a, int b) {
|
||||
return (int)(Math.min(a, b));
|
||||
}
|
||||
|
@ -60,6 +60,8 @@ public class Long128VectorTests extends AbstractVectorTest {
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
private static final long CONST_SHIFT = Long.SIZE / 2;
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 128);
|
||||
|
||||
interface FUnOp {
|
||||
@ -417,6 +419,50 @@ public class Long128VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
interface FBinConstOp {
|
||||
long apply(long a);
|
||||
}
|
||||
|
||||
interface FBinConstMaskOp {
|
||||
long apply(long a, boolean m);
|
||||
|
||||
static FBinConstMaskOp lift(FBinConstOp f) {
|
||||
return (a, m) -> m ? f.apply(a) : a;
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(long[] r, long[] a, FBinConstOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(long[] r, long[] a, boolean[] mask, FBinConstOp f) {
|
||||
assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f));
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(long[] r, long[] a, boolean[] mask, FBinConstMaskOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError err) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]);
|
||||
}
|
||||
}
|
||||
|
||||
interface FTernOp {
|
||||
long apply(long a, long b, long c);
|
||||
}
|
||||
@ -2541,7 +2587,7 @@ public class Long128VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static long ROR_unary(long a, long b) {
|
||||
return (long)(ROR_scalar(a,b));
|
||||
return (long)(ROR_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longBinaryOpProvider")
|
||||
@ -2583,7 +2629,7 @@ public class Long128VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static long ROL_unary(long a, long b) {
|
||||
return (long)(ROL_scalar(a,b));
|
||||
return (long)(ROL_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longBinaryOpProvider")
|
||||
@ -2623,6 +2669,215 @@ public class Long128VectorTests extends AbstractVectorTest {
|
||||
assertShiftArraysEquals(r, a, b, mask, Long128VectorTests::ROL_unary);
|
||||
}
|
||||
|
||||
|
||||
static long LSHR_binary_const(long a) {
|
||||
return (long)((a >>> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryOpProvider")
|
||||
static void LSHRLong128VectorTestsScalarShiftConst(IntFunction<long[]> fa) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
long[] r = fr.apply(SPECIES.length());
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Long128VectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "longUnaryOpMaskProvider")
|
||||
static void LSHRLong128VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Long128VectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static long LSHL_binary_const(long a) {
|
||||
return (long)((a << CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryOpProvider")
|
||||
static void LSHLLong128VectorTestsScalarShiftConst(IntFunction<long[]> fa) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
long[] r = fr.apply(SPECIES.length());
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Long128VectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "longUnaryOpMaskProvider")
|
||||
static void LSHLLong128VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Long128VectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static long ASHR_binary_const(long a) {
|
||||
return (long)((a >> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryOpProvider")
|
||||
static void ASHRLong128VectorTestsScalarShiftConst(IntFunction<long[]> fa) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
long[] r = fr.apply(SPECIES.length());
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Long128VectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "longUnaryOpMaskProvider")
|
||||
static void ASHRLong128VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Long128VectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static long ROR_binary_const(long a) {
|
||||
return (long)(ROR_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryOpProvider")
|
||||
static void RORLong128VectorTestsScalarShiftConst(IntFunction<long[]> fa) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
long[] r = fr.apply(SPECIES.length());
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Long128VectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "longUnaryOpMaskProvider")
|
||||
static void RORLong128VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Long128VectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static long ROL_binary_const(long a) {
|
||||
return (long)(ROL_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryOpProvider")
|
||||
static void ROLLong128VectorTestsScalarShiftConst(IntFunction<long[]> fa) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
long[] r = fr.apply(SPECIES.length());
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Long128VectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "longUnaryOpMaskProvider")
|
||||
static void ROLLong128VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Long128VectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
static long MIN(long a, long b) {
|
||||
return (long)(Math.min(a, b));
|
||||
}
|
||||
|
@ -60,6 +60,8 @@ public class Long256VectorTests extends AbstractVectorTest {
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
private static final long CONST_SHIFT = Long.SIZE / 2;
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 256);
|
||||
|
||||
interface FUnOp {
|
||||
@ -417,6 +419,50 @@ public class Long256VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
interface FBinConstOp {
|
||||
long apply(long a);
|
||||
}
|
||||
|
||||
interface FBinConstMaskOp {
|
||||
long apply(long a, boolean m);
|
||||
|
||||
static FBinConstMaskOp lift(FBinConstOp f) {
|
||||
return (a, m) -> m ? f.apply(a) : a;
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(long[] r, long[] a, FBinConstOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(long[] r, long[] a, boolean[] mask, FBinConstOp f) {
|
||||
assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f));
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(long[] r, long[] a, boolean[] mask, FBinConstMaskOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError err) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]);
|
||||
}
|
||||
}
|
||||
|
||||
interface FTernOp {
|
||||
long apply(long a, long b, long c);
|
||||
}
|
||||
@ -2541,7 +2587,7 @@ public class Long256VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static long ROR_unary(long a, long b) {
|
||||
return (long)(ROR_scalar(a,b));
|
||||
return (long)(ROR_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longBinaryOpProvider")
|
||||
@ -2583,7 +2629,7 @@ public class Long256VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static long ROL_unary(long a, long b) {
|
||||
return (long)(ROL_scalar(a,b));
|
||||
return (long)(ROL_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longBinaryOpProvider")
|
||||
@ -2623,6 +2669,215 @@ public class Long256VectorTests extends AbstractVectorTest {
|
||||
assertShiftArraysEquals(r, a, b, mask, Long256VectorTests::ROL_unary);
|
||||
}
|
||||
|
||||
|
||||
static long LSHR_binary_const(long a) {
|
||||
return (long)((a >>> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryOpProvider")
|
||||
static void LSHRLong256VectorTestsScalarShiftConst(IntFunction<long[]> fa) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
long[] r = fr.apply(SPECIES.length());
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Long256VectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "longUnaryOpMaskProvider")
|
||||
static void LSHRLong256VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Long256VectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static long LSHL_binary_const(long a) {
|
||||
return (long)((a << CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryOpProvider")
|
||||
static void LSHLLong256VectorTestsScalarShiftConst(IntFunction<long[]> fa) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
long[] r = fr.apply(SPECIES.length());
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Long256VectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "longUnaryOpMaskProvider")
|
||||
static void LSHLLong256VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Long256VectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static long ASHR_binary_const(long a) {
|
||||
return (long)((a >> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryOpProvider")
|
||||
static void ASHRLong256VectorTestsScalarShiftConst(IntFunction<long[]> fa) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
long[] r = fr.apply(SPECIES.length());
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Long256VectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "longUnaryOpMaskProvider")
|
||||
static void ASHRLong256VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Long256VectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static long ROR_binary_const(long a) {
|
||||
return (long)(ROR_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryOpProvider")
|
||||
static void RORLong256VectorTestsScalarShiftConst(IntFunction<long[]> fa) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
long[] r = fr.apply(SPECIES.length());
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Long256VectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "longUnaryOpMaskProvider")
|
||||
static void RORLong256VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Long256VectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static long ROL_binary_const(long a) {
|
||||
return (long)(ROL_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryOpProvider")
|
||||
static void ROLLong256VectorTestsScalarShiftConst(IntFunction<long[]> fa) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
long[] r = fr.apply(SPECIES.length());
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Long256VectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "longUnaryOpMaskProvider")
|
||||
static void ROLLong256VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Long256VectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
static long MIN(long a, long b) {
|
||||
return (long)(Math.min(a, b));
|
||||
}
|
||||
|
@ -60,6 +60,8 @@ public class Long512VectorTests extends AbstractVectorTest {
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
private static final long CONST_SHIFT = Long.SIZE / 2;
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 512);
|
||||
|
||||
interface FUnOp {
|
||||
@ -417,6 +419,50 @@ public class Long512VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
interface FBinConstOp {
|
||||
long apply(long a);
|
||||
}
|
||||
|
||||
interface FBinConstMaskOp {
|
||||
long apply(long a, boolean m);
|
||||
|
||||
static FBinConstMaskOp lift(FBinConstOp f) {
|
||||
return (a, m) -> m ? f.apply(a) : a;
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(long[] r, long[] a, FBinConstOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(long[] r, long[] a, boolean[] mask, FBinConstOp f) {
|
||||
assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f));
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(long[] r, long[] a, boolean[] mask, FBinConstMaskOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError err) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]);
|
||||
}
|
||||
}
|
||||
|
||||
interface FTernOp {
|
||||
long apply(long a, long b, long c);
|
||||
}
|
||||
@ -2541,7 +2587,7 @@ public class Long512VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static long ROR_unary(long a, long b) {
|
||||
return (long)(ROR_scalar(a,b));
|
||||
return (long)(ROR_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longBinaryOpProvider")
|
||||
@ -2583,7 +2629,7 @@ public class Long512VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static long ROL_unary(long a, long b) {
|
||||
return (long)(ROL_scalar(a,b));
|
||||
return (long)(ROL_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longBinaryOpProvider")
|
||||
@ -2623,6 +2669,215 @@ public class Long512VectorTests extends AbstractVectorTest {
|
||||
assertShiftArraysEquals(r, a, b, mask, Long512VectorTests::ROL_unary);
|
||||
}
|
||||
|
||||
|
||||
static long LSHR_binary_const(long a) {
|
||||
return (long)((a >>> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryOpProvider")
|
||||
static void LSHRLong512VectorTestsScalarShiftConst(IntFunction<long[]> fa) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
long[] r = fr.apply(SPECIES.length());
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Long512VectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "longUnaryOpMaskProvider")
|
||||
static void LSHRLong512VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Long512VectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static long LSHL_binary_const(long a) {
|
||||
return (long)((a << CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryOpProvider")
|
||||
static void LSHLLong512VectorTestsScalarShiftConst(IntFunction<long[]> fa) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
long[] r = fr.apply(SPECIES.length());
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Long512VectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "longUnaryOpMaskProvider")
|
||||
static void LSHLLong512VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Long512VectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static long ASHR_binary_const(long a) {
|
||||
return (long)((a >> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryOpProvider")
|
||||
static void ASHRLong512VectorTestsScalarShiftConst(IntFunction<long[]> fa) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
long[] r = fr.apply(SPECIES.length());
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Long512VectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "longUnaryOpMaskProvider")
|
||||
static void ASHRLong512VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Long512VectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static long ROR_binary_const(long a) {
|
||||
return (long)(ROR_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryOpProvider")
|
||||
static void RORLong512VectorTestsScalarShiftConst(IntFunction<long[]> fa) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
long[] r = fr.apply(SPECIES.length());
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Long512VectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "longUnaryOpMaskProvider")
|
||||
static void RORLong512VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Long512VectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static long ROL_binary_const(long a) {
|
||||
return (long)(ROL_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryOpProvider")
|
||||
static void ROLLong512VectorTestsScalarShiftConst(IntFunction<long[]> fa) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
long[] r = fr.apply(SPECIES.length());
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Long512VectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "longUnaryOpMaskProvider")
|
||||
static void ROLLong512VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Long512VectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
static long MIN(long a, long b) {
|
||||
return (long)(Math.min(a, b));
|
||||
}
|
||||
|
@ -60,6 +60,8 @@ public class Long64VectorTests extends AbstractVectorTest {
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
private static final long CONST_SHIFT = Long.SIZE / 2;
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 64);
|
||||
|
||||
interface FUnOp {
|
||||
@ -417,6 +419,50 @@ public class Long64VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
interface FBinConstOp {
|
||||
long apply(long a);
|
||||
}
|
||||
|
||||
interface FBinConstMaskOp {
|
||||
long apply(long a, boolean m);
|
||||
|
||||
static FBinConstMaskOp lift(FBinConstOp f) {
|
||||
return (a, m) -> m ? f.apply(a) : a;
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(long[] r, long[] a, FBinConstOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(long[] r, long[] a, boolean[] mask, FBinConstOp f) {
|
||||
assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f));
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(long[] r, long[] a, boolean[] mask, FBinConstMaskOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError err) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]);
|
||||
}
|
||||
}
|
||||
|
||||
interface FTernOp {
|
||||
long apply(long a, long b, long c);
|
||||
}
|
||||
@ -2541,7 +2587,7 @@ public class Long64VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static long ROR_unary(long a, long b) {
|
||||
return (long)(ROR_scalar(a,b));
|
||||
return (long)(ROR_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longBinaryOpProvider")
|
||||
@ -2583,7 +2629,7 @@ public class Long64VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static long ROL_unary(long a, long b) {
|
||||
return (long)(ROL_scalar(a,b));
|
||||
return (long)(ROL_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longBinaryOpProvider")
|
||||
@ -2623,6 +2669,215 @@ public class Long64VectorTests extends AbstractVectorTest {
|
||||
assertShiftArraysEquals(r, a, b, mask, Long64VectorTests::ROL_unary);
|
||||
}
|
||||
|
||||
|
||||
static long LSHR_binary_const(long a) {
|
||||
return (long)((a >>> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryOpProvider")
|
||||
static void LSHRLong64VectorTestsScalarShiftConst(IntFunction<long[]> fa) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
long[] r = fr.apply(SPECIES.length());
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Long64VectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "longUnaryOpMaskProvider")
|
||||
static void LSHRLong64VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Long64VectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static long LSHL_binary_const(long a) {
|
||||
return (long)((a << CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryOpProvider")
|
||||
static void LSHLLong64VectorTestsScalarShiftConst(IntFunction<long[]> fa) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
long[] r = fr.apply(SPECIES.length());
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Long64VectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "longUnaryOpMaskProvider")
|
||||
static void LSHLLong64VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Long64VectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static long ASHR_binary_const(long a) {
|
||||
return (long)((a >> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryOpProvider")
|
||||
static void ASHRLong64VectorTestsScalarShiftConst(IntFunction<long[]> fa) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
long[] r = fr.apply(SPECIES.length());
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Long64VectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "longUnaryOpMaskProvider")
|
||||
static void ASHRLong64VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Long64VectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static long ROR_binary_const(long a) {
|
||||
return (long)(ROR_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryOpProvider")
|
||||
static void RORLong64VectorTestsScalarShiftConst(IntFunction<long[]> fa) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
long[] r = fr.apply(SPECIES.length());
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Long64VectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "longUnaryOpMaskProvider")
|
||||
static void RORLong64VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Long64VectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static long ROL_binary_const(long a) {
|
||||
return (long)(ROL_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryOpProvider")
|
||||
static void ROLLong64VectorTestsScalarShiftConst(IntFunction<long[]> fa) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
long[] r = fr.apply(SPECIES.length());
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Long64VectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "longUnaryOpMaskProvider")
|
||||
static void ROLLong64VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Long64VectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
static long MIN(long a, long b) {
|
||||
return (long)(Math.min(a, b));
|
||||
}
|
||||
|
@ -65,6 +65,8 @@ public class LongMaxVectorTests extends AbstractVectorTest {
|
||||
|
||||
private static final int Max = 256; // juts so we can do N/Max
|
||||
|
||||
private static final long CONST_SHIFT = Long.SIZE / 2;
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max);
|
||||
|
||||
interface FUnOp {
|
||||
@ -422,6 +424,50 @@ public class LongMaxVectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
interface FBinConstOp {
|
||||
long apply(long a);
|
||||
}
|
||||
|
||||
interface FBinConstMaskOp {
|
||||
long apply(long a, boolean m);
|
||||
|
||||
static FBinConstMaskOp lift(FBinConstOp f) {
|
||||
return (a, m) -> m ? f.apply(a) : a;
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(long[] r, long[] a, FBinConstOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(long[] r, long[] a, boolean[] mask, FBinConstOp f) {
|
||||
assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f));
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(long[] r, long[] a, boolean[] mask, FBinConstMaskOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError err) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]);
|
||||
}
|
||||
}
|
||||
|
||||
interface FTernOp {
|
||||
long apply(long a, long b, long c);
|
||||
}
|
||||
@ -2546,7 +2592,7 @@ public class LongMaxVectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static long ROR_unary(long a, long b) {
|
||||
return (long)(ROR_scalar(a,b));
|
||||
return (long)(ROR_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longBinaryOpProvider")
|
||||
@ -2588,7 +2634,7 @@ public class LongMaxVectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static long ROL_unary(long a, long b) {
|
||||
return (long)(ROL_scalar(a,b));
|
||||
return (long)(ROL_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longBinaryOpProvider")
|
||||
@ -2628,6 +2674,215 @@ public class LongMaxVectorTests extends AbstractVectorTest {
|
||||
assertShiftArraysEquals(r, a, b, mask, LongMaxVectorTests::ROL_unary);
|
||||
}
|
||||
|
||||
|
||||
static long LSHR_binary_const(long a) {
|
||||
return (long)((a >>> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryOpProvider")
|
||||
static void LSHRLongMaxVectorTestsScalarShiftConst(IntFunction<long[]> fa) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
long[] r = fr.apply(SPECIES.length());
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, LongMaxVectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "longUnaryOpMaskProvider")
|
||||
static void LSHRLongMaxVectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, LongMaxVectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static long LSHL_binary_const(long a) {
|
||||
return (long)((a << CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryOpProvider")
|
||||
static void LSHLLongMaxVectorTestsScalarShiftConst(IntFunction<long[]> fa) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
long[] r = fr.apply(SPECIES.length());
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, LongMaxVectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "longUnaryOpMaskProvider")
|
||||
static void LSHLLongMaxVectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, LongMaxVectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static long ASHR_binary_const(long a) {
|
||||
return (long)((a >> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryOpProvider")
|
||||
static void ASHRLongMaxVectorTestsScalarShiftConst(IntFunction<long[]> fa) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
long[] r = fr.apply(SPECIES.length());
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, LongMaxVectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "longUnaryOpMaskProvider")
|
||||
static void ASHRLongMaxVectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, LongMaxVectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static long ROR_binary_const(long a) {
|
||||
return (long)(ROR_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryOpProvider")
|
||||
static void RORLongMaxVectorTestsScalarShiftConst(IntFunction<long[]> fa) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
long[] r = fr.apply(SPECIES.length());
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, LongMaxVectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "longUnaryOpMaskProvider")
|
||||
static void RORLongMaxVectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, LongMaxVectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static long ROL_binary_const(long a) {
|
||||
return (long)(ROL_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryOpProvider")
|
||||
static void ROLLongMaxVectorTestsScalarShiftConst(IntFunction<long[]> fa) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
long[] r = fr.apply(SPECIES.length());
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, LongMaxVectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "longUnaryOpMaskProvider")
|
||||
static void ROLLongMaxVectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
LongVector av = LongVector.fromArray(SPECIES, a, i);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, LongMaxVectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
static long MIN(long a, long b) {
|
||||
return (long)(Math.min(a, b));
|
||||
}
|
||||
|
@ -60,6 +60,8 @@ public class Short128VectorTests extends AbstractVectorTest {
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
private static final short CONST_SHIFT = Short.SIZE / 2;
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 128);
|
||||
|
||||
interface FUnOp {
|
||||
@ -460,6 +462,50 @@ public class Short128VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
interface FBinConstOp {
|
||||
short apply(short a);
|
||||
}
|
||||
|
||||
interface FBinConstMaskOp {
|
||||
short apply(short a, boolean m);
|
||||
|
||||
static FBinConstMaskOp lift(FBinConstOp f) {
|
||||
return (a, m) -> m ? f.apply(a) : a;
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(short[] r, short[] a, FBinConstOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinConstOp f) {
|
||||
assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f));
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinConstMaskOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError err) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]);
|
||||
}
|
||||
}
|
||||
|
||||
interface FTernOp {
|
||||
short apply(short a, short b, short c);
|
||||
}
|
||||
@ -2544,7 +2590,7 @@ public class Short128VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static short ROR_unary(short a, short b) {
|
||||
return (short)(ROR_scalar(a,b));
|
||||
return (short)(ROR_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortBinaryOpProvider")
|
||||
@ -2586,7 +2632,7 @@ public class Short128VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static short ROL_unary(short a, short b) {
|
||||
return (short)(ROL_scalar(a,b));
|
||||
return (short)(ROL_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortBinaryOpProvider")
|
||||
@ -2626,6 +2672,215 @@ public class Short128VectorTests extends AbstractVectorTest {
|
||||
assertShiftArraysEquals(r, a, b, mask, Short128VectorTests::ROL_unary);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static short LSHR_binary_const(short a) {
|
||||
return (short)(((a & 0xFFFF) >>> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpProvider")
|
||||
static void LSHRShort128VectorTestsScalarShiftConst(IntFunction<short[]> fa) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
short[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Short128VectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpMaskProvider")
|
||||
static void LSHRShort128VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Short128VectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static short LSHL_binary_const(short a) {
|
||||
return (short)((a << CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpProvider")
|
||||
static void LSHLShort128VectorTestsScalarShiftConst(IntFunction<short[]> fa) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
short[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Short128VectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpMaskProvider")
|
||||
static void LSHLShort128VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Short128VectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static short ASHR_binary_const(short a) {
|
||||
return (short)((a >> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpProvider")
|
||||
static void ASHRShort128VectorTestsScalarShiftConst(IntFunction<short[]> fa) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
short[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Short128VectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpMaskProvider")
|
||||
static void ASHRShort128VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Short128VectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static short ROR_binary_const(short a) {
|
||||
return (short)(ROR_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpProvider")
|
||||
static void RORShort128VectorTestsScalarShiftConst(IntFunction<short[]> fa) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
short[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Short128VectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpMaskProvider")
|
||||
static void RORShort128VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Short128VectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static short ROL_binary_const(short a) {
|
||||
return (short)(ROL_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpProvider")
|
||||
static void ROLShort128VectorTestsScalarShiftConst(IntFunction<short[]> fa) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
short[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Short128VectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpMaskProvider")
|
||||
static void ROLShort128VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Short128VectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
static short MIN(short a, short b) {
|
||||
return (short)(Math.min(a, b));
|
||||
}
|
||||
|
@ -60,6 +60,8 @@ public class Short256VectorTests extends AbstractVectorTest {
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
private static final short CONST_SHIFT = Short.SIZE / 2;
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 256);
|
||||
|
||||
interface FUnOp {
|
||||
@ -460,6 +462,50 @@ public class Short256VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
interface FBinConstOp {
|
||||
short apply(short a);
|
||||
}
|
||||
|
||||
interface FBinConstMaskOp {
|
||||
short apply(short a, boolean m);
|
||||
|
||||
static FBinConstMaskOp lift(FBinConstOp f) {
|
||||
return (a, m) -> m ? f.apply(a) : a;
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(short[] r, short[] a, FBinConstOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinConstOp f) {
|
||||
assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f));
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinConstMaskOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError err) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]);
|
||||
}
|
||||
}
|
||||
|
||||
interface FTernOp {
|
||||
short apply(short a, short b, short c);
|
||||
}
|
||||
@ -2544,7 +2590,7 @@ public class Short256VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static short ROR_unary(short a, short b) {
|
||||
return (short)(ROR_scalar(a,b));
|
||||
return (short)(ROR_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortBinaryOpProvider")
|
||||
@ -2586,7 +2632,7 @@ public class Short256VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static short ROL_unary(short a, short b) {
|
||||
return (short)(ROL_scalar(a,b));
|
||||
return (short)(ROL_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortBinaryOpProvider")
|
||||
@ -2626,6 +2672,215 @@ public class Short256VectorTests extends AbstractVectorTest {
|
||||
assertShiftArraysEquals(r, a, b, mask, Short256VectorTests::ROL_unary);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static short LSHR_binary_const(short a) {
|
||||
return (short)(((a & 0xFFFF) >>> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpProvider")
|
||||
static void LSHRShort256VectorTestsScalarShiftConst(IntFunction<short[]> fa) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
short[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Short256VectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpMaskProvider")
|
||||
static void LSHRShort256VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Short256VectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static short LSHL_binary_const(short a) {
|
||||
return (short)((a << CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpProvider")
|
||||
static void LSHLShort256VectorTestsScalarShiftConst(IntFunction<short[]> fa) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
short[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Short256VectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpMaskProvider")
|
||||
static void LSHLShort256VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Short256VectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static short ASHR_binary_const(short a) {
|
||||
return (short)((a >> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpProvider")
|
||||
static void ASHRShort256VectorTestsScalarShiftConst(IntFunction<short[]> fa) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
short[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Short256VectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpMaskProvider")
|
||||
static void ASHRShort256VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Short256VectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static short ROR_binary_const(short a) {
|
||||
return (short)(ROR_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpProvider")
|
||||
static void RORShort256VectorTestsScalarShiftConst(IntFunction<short[]> fa) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
short[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Short256VectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpMaskProvider")
|
||||
static void RORShort256VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Short256VectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static short ROL_binary_const(short a) {
|
||||
return (short)(ROL_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpProvider")
|
||||
static void ROLShort256VectorTestsScalarShiftConst(IntFunction<short[]> fa) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
short[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Short256VectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpMaskProvider")
|
||||
static void ROLShort256VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Short256VectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
static short MIN(short a, short b) {
|
||||
return (short)(Math.min(a, b));
|
||||
}
|
||||
|
@ -60,6 +60,8 @@ public class Short512VectorTests extends AbstractVectorTest {
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
private static final short CONST_SHIFT = Short.SIZE / 2;
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 512);
|
||||
|
||||
interface FUnOp {
|
||||
@ -460,6 +462,50 @@ public class Short512VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
interface FBinConstOp {
|
||||
short apply(short a);
|
||||
}
|
||||
|
||||
interface FBinConstMaskOp {
|
||||
short apply(short a, boolean m);
|
||||
|
||||
static FBinConstMaskOp lift(FBinConstOp f) {
|
||||
return (a, m) -> m ? f.apply(a) : a;
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(short[] r, short[] a, FBinConstOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinConstOp f) {
|
||||
assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f));
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinConstMaskOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError err) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]);
|
||||
}
|
||||
}
|
||||
|
||||
interface FTernOp {
|
||||
short apply(short a, short b, short c);
|
||||
}
|
||||
@ -2544,7 +2590,7 @@ public class Short512VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static short ROR_unary(short a, short b) {
|
||||
return (short)(ROR_scalar(a,b));
|
||||
return (short)(ROR_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortBinaryOpProvider")
|
||||
@ -2586,7 +2632,7 @@ public class Short512VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static short ROL_unary(short a, short b) {
|
||||
return (short)(ROL_scalar(a,b));
|
||||
return (short)(ROL_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortBinaryOpProvider")
|
||||
@ -2626,6 +2672,215 @@ public class Short512VectorTests extends AbstractVectorTest {
|
||||
assertShiftArraysEquals(r, a, b, mask, Short512VectorTests::ROL_unary);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static short LSHR_binary_const(short a) {
|
||||
return (short)(((a & 0xFFFF) >>> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpProvider")
|
||||
static void LSHRShort512VectorTestsScalarShiftConst(IntFunction<short[]> fa) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
short[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Short512VectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpMaskProvider")
|
||||
static void LSHRShort512VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Short512VectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static short LSHL_binary_const(short a) {
|
||||
return (short)((a << CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpProvider")
|
||||
static void LSHLShort512VectorTestsScalarShiftConst(IntFunction<short[]> fa) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
short[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Short512VectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpMaskProvider")
|
||||
static void LSHLShort512VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Short512VectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static short ASHR_binary_const(short a) {
|
||||
return (short)((a >> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpProvider")
|
||||
static void ASHRShort512VectorTestsScalarShiftConst(IntFunction<short[]> fa) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
short[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Short512VectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpMaskProvider")
|
||||
static void ASHRShort512VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Short512VectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static short ROR_binary_const(short a) {
|
||||
return (short)(ROR_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpProvider")
|
||||
static void RORShort512VectorTestsScalarShiftConst(IntFunction<short[]> fa) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
short[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Short512VectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpMaskProvider")
|
||||
static void RORShort512VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Short512VectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static short ROL_binary_const(short a) {
|
||||
return (short)(ROL_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpProvider")
|
||||
static void ROLShort512VectorTestsScalarShiftConst(IntFunction<short[]> fa) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
short[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Short512VectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpMaskProvider")
|
||||
static void ROLShort512VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Short512VectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
static short MIN(short a, short b) {
|
||||
return (short)(Math.min(a, b));
|
||||
}
|
||||
|
@ -60,6 +60,8 @@ public class Short64VectorTests extends AbstractVectorTest {
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
private static final short CONST_SHIFT = Short.SIZE / 2;
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 64);
|
||||
|
||||
interface FUnOp {
|
||||
@ -460,6 +462,50 @@ public class Short64VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
interface FBinConstOp {
|
||||
short apply(short a);
|
||||
}
|
||||
|
||||
interface FBinConstMaskOp {
|
||||
short apply(short a, boolean m);
|
||||
|
||||
static FBinConstMaskOp lift(FBinConstOp f) {
|
||||
return (a, m) -> m ? f.apply(a) : a;
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(short[] r, short[] a, FBinConstOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinConstOp f) {
|
||||
assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f));
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinConstMaskOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError err) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]);
|
||||
}
|
||||
}
|
||||
|
||||
interface FTernOp {
|
||||
short apply(short a, short b, short c);
|
||||
}
|
||||
@ -2544,7 +2590,7 @@ public class Short64VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static short ROR_unary(short a, short b) {
|
||||
return (short)(ROR_scalar(a,b));
|
||||
return (short)(ROR_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortBinaryOpProvider")
|
||||
@ -2586,7 +2632,7 @@ public class Short64VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static short ROL_unary(short a, short b) {
|
||||
return (short)(ROL_scalar(a,b));
|
||||
return (short)(ROL_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortBinaryOpProvider")
|
||||
@ -2626,6 +2672,215 @@ public class Short64VectorTests extends AbstractVectorTest {
|
||||
assertShiftArraysEquals(r, a, b, mask, Short64VectorTests::ROL_unary);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static short LSHR_binary_const(short a) {
|
||||
return (short)(((a & 0xFFFF) >>> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpProvider")
|
||||
static void LSHRShort64VectorTestsScalarShiftConst(IntFunction<short[]> fa) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
short[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Short64VectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpMaskProvider")
|
||||
static void LSHRShort64VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Short64VectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static short LSHL_binary_const(short a) {
|
||||
return (short)((a << CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpProvider")
|
||||
static void LSHLShort64VectorTestsScalarShiftConst(IntFunction<short[]> fa) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
short[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Short64VectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpMaskProvider")
|
||||
static void LSHLShort64VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Short64VectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static short ASHR_binary_const(short a) {
|
||||
return (short)((a >> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpProvider")
|
||||
static void ASHRShort64VectorTestsScalarShiftConst(IntFunction<short[]> fa) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
short[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Short64VectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpMaskProvider")
|
||||
static void ASHRShort64VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Short64VectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static short ROR_binary_const(short a) {
|
||||
return (short)(ROR_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpProvider")
|
||||
static void RORShort64VectorTestsScalarShiftConst(IntFunction<short[]> fa) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
short[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Short64VectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpMaskProvider")
|
||||
static void RORShort64VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Short64VectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static short ROL_binary_const(short a) {
|
||||
return (short)(ROL_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpProvider")
|
||||
static void ROLShort64VectorTestsScalarShiftConst(IntFunction<short[]> fa) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
short[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, Short64VectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpMaskProvider")
|
||||
static void ROLShort64VectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, Short64VectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
static short MIN(short a, short b) {
|
||||
return (short)(Math.min(a, b));
|
||||
}
|
||||
|
@ -65,6 +65,8 @@ public class ShortMaxVectorTests extends AbstractVectorTest {
|
||||
|
||||
private static final int Max = 256; // juts so we can do N/Max
|
||||
|
||||
private static final short CONST_SHIFT = Short.SIZE / 2;
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max);
|
||||
|
||||
interface FUnOp {
|
||||
@ -465,6 +467,50 @@ public class ShortMaxVectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
interface FBinConstOp {
|
||||
short apply(short a);
|
||||
}
|
||||
|
||||
interface FBinConstMaskOp {
|
||||
short apply(short a, boolean m);
|
||||
|
||||
static FBinConstMaskOp lift(FBinConstOp f) {
|
||||
return (a, m) -> m ? f.apply(a) : a;
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(short[] r, short[] a, FBinConstOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinConstOp f) {
|
||||
assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f));
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinConstMaskOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError err) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]);
|
||||
}
|
||||
}
|
||||
|
||||
interface FTernOp {
|
||||
short apply(short a, short b, short c);
|
||||
}
|
||||
@ -2549,7 +2595,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static short ROR_unary(short a, short b) {
|
||||
return (short)(ROR_scalar(a,b));
|
||||
return (short)(ROR_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortBinaryOpProvider")
|
||||
@ -2591,7 +2637,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
static short ROL_unary(short a, short b) {
|
||||
return (short)(ROL_scalar(a,b));
|
||||
return (short)(ROL_scalar(a, b));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortBinaryOpProvider")
|
||||
@ -2631,6 +2677,215 @@ public class ShortMaxVectorTests extends AbstractVectorTest {
|
||||
assertShiftArraysEquals(r, a, b, mask, ShortMaxVectorTests::ROL_unary);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static short LSHR_binary_const(short a) {
|
||||
return (short)(((a & 0xFFFF) >>> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpProvider")
|
||||
static void LSHRShortMaxVectorTestsScalarShiftConst(IntFunction<short[]> fa) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
short[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, ShortMaxVectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpMaskProvider")
|
||||
static void LSHRShortMaxVectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, ShortMaxVectorTests::LSHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static short LSHL_binary_const(short a) {
|
||||
return (short)((a << CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpProvider")
|
||||
static void LSHLShortMaxVectorTestsScalarShiftConst(IntFunction<short[]> fa) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
short[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, ShortMaxVectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpMaskProvider")
|
||||
static void LSHLShortMaxVectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.LSHL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, ShortMaxVectorTests::LSHL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static short ASHR_binary_const(short a) {
|
||||
return (short)((a >> CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpProvider")
|
||||
static void ASHRShortMaxVectorTestsScalarShiftConst(IntFunction<short[]> fa) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
short[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, ShortMaxVectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpMaskProvider")
|
||||
static void ASHRShortMaxVectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ASHR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, ShortMaxVectorTests::ASHR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static short ROR_binary_const(short a) {
|
||||
return (short)(ROR_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpProvider")
|
||||
static void RORShortMaxVectorTestsScalarShiftConst(IntFunction<short[]> fa) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
short[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, ShortMaxVectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpMaskProvider")
|
||||
static void RORShortMaxVectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROR, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, ShortMaxVectorTests::ROR_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static short ROL_binary_const(short a) {
|
||||
return (short)(ROL_scalar(a, CONST_SHIFT));
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpProvider")
|
||||
static void ROLShortMaxVectorTestsScalarShiftConst(IntFunction<short[]> fa) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
short[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, ShortMaxVectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpMaskProvider")
|
||||
static void ROLShortMaxVectorTestsScalarShiftMaskedConst(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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.ROL, CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertShiftConstEquals(r, a, mask, ShortMaxVectorTests::ROL_binary_const);
|
||||
}
|
||||
|
||||
|
||||
static short MIN(short a, short b) {
|
||||
return (short)(Math.min(a, b));
|
||||
}
|
||||
|
@ -70,6 +70,8 @@ bool_reduction_template="BoolReduction-op"
|
||||
with_op_template="With-Op"
|
||||
shift_template="Shift-op"
|
||||
shift_masked_template="Shift-Masked-op"
|
||||
shift_const_template="Shift-Const-op"
|
||||
shift_masked_const_template="Shift-Masked-Const-op"
|
||||
get_template="Get-op"
|
||||
rearrange_template="Rearrange"
|
||||
broadcast_template="Broadcast"
|
||||
@ -264,12 +266,18 @@ function gen_binary_alu_bcst_long_op {
|
||||
gen_op_tmpl $binary_broadcast_masked_long "$@"
|
||||
}
|
||||
|
||||
function gen_shift_cst_op {
|
||||
function gen_shift_op {
|
||||
echo "Generating Shift constant op $1 ($2)..."
|
||||
gen_op_tmpl $shift_template "$@"
|
||||
gen_op_tmpl $shift_masked_template "$@"
|
||||
}
|
||||
|
||||
function gen_shift_cst_op {
|
||||
echo "Generating Shift constant op $1 ($2)..."
|
||||
gen_op_tmpl $shift_const_template "$@"
|
||||
gen_op_tmpl $shift_masked_const_template "$@"
|
||||
}
|
||||
|
||||
function gen_unary_alu_op {
|
||||
echo "Generating unary op $1 ($2)..."
|
||||
gen_op_tmpl $unary_scalar "$@"
|
||||
@ -424,19 +432,28 @@ gen_binary_alu_op "ASHR" "(a >> (b \& 0xF))" "short"
|
||||
gen_binary_alu_op "LSHR" "(a >>> b)" "intOrLong"
|
||||
gen_binary_alu_op "LSHR" "((a \& 0xFF) >>> (b \& 0x7))" "byte"
|
||||
gen_binary_alu_op "LSHR" "((a \& 0xFFFF) >>> (b \& 0xF))" "short"
|
||||
gen_shift_cst_op "LSHL" "(a << b)" "intOrLong"
|
||||
gen_shift_cst_op "LSHL" "(a << (b \& 7))" "byte"
|
||||
gen_shift_cst_op "LSHL" "(a << (b \& 15))" "short"
|
||||
gen_shift_cst_op "LSHR" "(a >>> b)" "intOrLong"
|
||||
gen_shift_cst_op "LSHR" "((a \& 0xFF) >>> (b \& 7))" "byte"
|
||||
gen_shift_cst_op "LSHR" "((a \& 0xFFFF) >>> (b \& 15))" "short"
|
||||
gen_shift_cst_op "ASHR" "(a >> b)" "intOrLong"
|
||||
gen_shift_cst_op "ASHR" "(a >> (b \& 7))" "byte"
|
||||
gen_shift_cst_op "ASHR" "(a >> (b \& 15))" "short"
|
||||
gen_shift_op "LSHL" "(a << b)" "intOrLong"
|
||||
gen_shift_op "LSHL" "(a << (b \& 7))" "byte"
|
||||
gen_shift_op "LSHL" "(a << (b \& 15))" "short"
|
||||
gen_shift_op "LSHR" "(a >>> b)" "intOrLong"
|
||||
gen_shift_op "LSHR" "((a \& 0xFF) >>> (b \& 7))" "byte"
|
||||
gen_shift_op "LSHR" "((a \& 0xFFFF) >>> (b \& 15))" "short"
|
||||
gen_shift_op "ASHR" "(a >> b)" "intOrLong"
|
||||
gen_shift_op "ASHR" "(a >> (b \& 7))" "byte"
|
||||
gen_shift_op "ASHR" "(a >> (b \& 15))" "short"
|
||||
gen_binary_alu_op "ROR" "ROR_scalar(a,b)" "BITWISE"
|
||||
gen_binary_alu_op "ROL" "ROL_scalar(a,b)" "BITWISE"
|
||||
gen_shift_cst_op "ROR" "ROR_scalar(a,b)" "BITWISE"
|
||||
gen_shift_cst_op "ROL" "ROL_scalar(a,b)" "BITWISE"
|
||||
gen_shift_op "ROR" "ROR_scalar(a, b)" "BITWISE"
|
||||
gen_shift_op "ROL" "ROL_scalar(a, b)" "BITWISE"
|
||||
|
||||
# Constant Shifts
|
||||
gen_shift_cst_op "LSHR" "(a >>> CONST_SHIFT)" "intOrLong"
|
||||
gen_shift_cst_op "LSHR" "((a \& 0xFF) >>> CONST_SHIFT)" "byte"
|
||||
gen_shift_cst_op "LSHR" "((a \& 0xFFFF) >>> CONST_SHIFT)" "short"
|
||||
gen_shift_cst_op "LSHL" "(a << CONST_SHIFT)" "BITWISE"
|
||||
gen_shift_cst_op "ASHR" "(a >> CONST_SHIFT)" "BITWISE"
|
||||
gen_shift_cst_op "ROR" "ROR_scalar(a, CONST_SHIFT)" "BITWISE"
|
||||
gen_shift_cst_op "ROL" "ROL_scalar(a, CONST_SHIFT)" "BITWISE"
|
||||
|
||||
# Masked reductions.
|
||||
gen_binary_op_no_masked "MIN+min" "Math.min(a, b)"
|
||||
|
@ -0,0 +1,10 @@
|
||||
$type$[] a = fa.apply(SPECIES.length());
|
||||
$type$[] r = fr.apply(SPECIES.length());
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.[[TEST]], CONST_SHIFT).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,12 @@
|
||||
$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);
|
||||
|
||||
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);
|
||||
av.lanewise(VectorOperators.[[TEST]], CONST_SHIFT, vmask).intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
static $type$ [[TEST]]_binary_const($type$ a) {
|
||||
return ($type$)([[TEST_OP]]);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "$type$UnaryOpProvider")
|
||||
static void [[TEST]]$vectorteststype$ScalarShiftConst(IntFunction<$type$[]> fa) {
|
||||
[[KERNEL]]
|
||||
assertShiftConstEquals(r, a, $vectorteststype$::[[TEST]]_binary_const);
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
@Test(dataProvider = "$type$UnaryOpMaskProvider")
|
||||
static void [[TEST]]$vectorteststype$ScalarShiftMaskedConst(IntFunction<$type$[]> fa,
|
||||
IntFunction<boolean[]> fm) {
|
||||
[[KERNEL]]
|
||||
assertShiftConstEquals(r, a, mask, $vectorteststype$::[[TEST]]_binary_const);
|
||||
}
|
||||
|
@ -89,6 +89,8 @@ public class $vectorteststype$ extends AbstractVectorTest {
|
||||
private static final int Max = 256; // juts so we can do N/$bits$
|
||||
#end[MaxBit]
|
||||
|
||||
private static final $type$ CONST_SHIFT = $Boxtype$.SIZE / 2;
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / $bits$);
|
||||
|
||||
interface FUnOp {
|
||||
@ -491,6 +493,50 @@ public class $vectorteststype$ extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
interface FBinConstOp {
|
||||
$type$ apply($type$ a);
|
||||
}
|
||||
|
||||
interface FBinConstMaskOp {
|
||||
$type$ apply($type$ a, boolean m);
|
||||
|
||||
static FBinConstMaskOp lift(FBinConstOp f) {
|
||||
return (a, m) -> m ? f.apply(a) : a;
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals($type$[] r, $type$[] a, FBinConstOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals($type$[] r, $type$[] a, boolean[] mask, FBinConstOp f) {
|
||||
assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f));
|
||||
}
|
||||
|
||||
static void assertShiftConstEquals($type$[] r, $type$[] a, boolean[] mask, FBinConstMaskOp f) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; j < a.length; j += SPECIES.length()) {
|
||||
for (i = 0; i < SPECIES.length(); i++) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]));
|
||||
}
|
||||
}
|
||||
} catch (AssertionError err) {
|
||||
Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]);
|
||||
}
|
||||
}
|
||||
|
||||
interface FTernOp {
|
||||
$type$ apply($type$ a, $type$ b, $type$ c);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user