< prev index next >

test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java

Print this page
rev 55894 : 8222897: [vector] Renaming of shift, rotate operations. Few other api changes.
Summary: Renaming of shift, rotate operations. Few other api changes.
Reviewed-by: jrose, briangoetz

*** 662,809 **** } ! static byte aShiftR_unary(byte a, byte b) { ! return (byte)((a >> (b & 7))); } @Test(dataProvider = "byteBinaryOpProvider") ! static void aShiftRByteMaxVectorTestsShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.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.aShiftR((int)b[i]).intoArray(r, i); } } ! assertShiftArraysEquals(a, b, r, ByteMaxVectorTests::aShiftR_unary); } @Test(dataProvider = "byteBinaryOpMaskProvider") ! static void aShiftRByteMaxVectorTestsShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<boolean[]> fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask<Byte> vmask = VectorMask.fromValues(SPECIES, mask); 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.aShiftR((int)b[i], vmask).intoArray(r, i); } } ! assertShiftArraysEquals(a, b, r, mask, ByteMaxVectorTests::aShiftR_unary); } ! static byte shiftL_unary(byte a, byte b) { return (byte)((a << (b & 7))); } @Test(dataProvider = "byteBinaryOpProvider") ! static void shiftLByteMaxVectorTestsShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.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.shiftL((int)b[i]).intoArray(r, i); } } ! assertShiftArraysEquals(a, b, r, ByteMaxVectorTests::shiftL_unary); } @Test(dataProvider = "byteBinaryOpMaskProvider") ! static void shiftLByteMaxVectorTestsShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<boolean[]> fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask<Byte> vmask = VectorMask.fromValues(SPECIES, mask); 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.shiftL((int)b[i], vmask).intoArray(r, i); } } ! assertShiftArraysEquals(a, b, r, mask, ByteMaxVectorTests::shiftL_unary); } ! static byte shiftR_unary(byte a, byte b) { return (byte)(((a & 0xFF) >>> (b & 7))); } @Test(dataProvider = "byteBinaryOpProvider") ! static void shiftRByteMaxVectorTestsShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.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.shiftR((int)b[i]).intoArray(r, i); } } ! assertShiftArraysEquals(a, b, r, ByteMaxVectorTests::shiftR_unary); } @Test(dataProvider = "byteBinaryOpMaskProvider") ! static void shiftRByteMaxVectorTestsShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<boolean[]> fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask<Byte> vmask = VectorMask.fromValues(SPECIES, mask); 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.shiftR((int)b[i], vmask).intoArray(r, i); } } ! assertShiftArraysEquals(a, b, r, mask, ByteMaxVectorTests::shiftR_unary); } static byte max(byte a, byte b) { return (byte)(Math.max(a, b)); --- 662,947 ---- } + static byte shiftLeft(byte a, byte b) { + return (byte)((a << (b & 0x7))); + } + @Test(dataProvider = "byteBinaryOpProvider") + static void shiftLeftByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.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); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.shiftLeft(bv).intoArray(r, i); + } + } + assertArraysEquals(a, b, r, ByteMaxVectorTests::shiftLeft); + } + @Test(dataProvider = "byteBinaryOpMaskProvider") + static void shiftLeftByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb, + IntFunction<boolean[]> fm) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask<Byte> vmask = VectorMask.fromValues(SPECIES, mask); + + 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); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.shiftLeft(bv, vmask).intoArray(r, i); + } + } + assertArraysEquals(a, b, r, mask, ByteMaxVectorTests::shiftLeft); + } ! ! ! ! static byte shiftRight(byte a, byte b) { ! return (byte)((a >>> (b & 0x7))); ! } ! ! @Test(dataProvider = "byteBinaryOpProvider") ! static void shiftRightByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) { ! byte[] a = fa.apply(SPECIES.length()); ! byte[] b = fb.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); ! ByteVector bv = ByteVector.fromArray(SPECIES, b, i); ! av.shiftRight(bv).intoArray(r, i); ! } ! } ! ! assertArraysEquals(a, b, r, ByteMaxVectorTests::shiftRight); ! } ! ! ! ! @Test(dataProvider = "byteBinaryOpMaskProvider") ! static void shiftRightByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb, ! IntFunction<boolean[]> fm) { ! byte[] a = fa.apply(SPECIES.length()); ! byte[] b = fb.apply(SPECIES.length()); ! byte[] r = fr.apply(SPECIES.length()); ! boolean[] mask = fm.apply(SPECIES.length()); ! VectorMask<Byte> vmask = VectorMask.fromValues(SPECIES, mask); ! ! 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); ! ByteVector bv = ByteVector.fromArray(SPECIES, b, i); ! av.shiftRight(bv, vmask).intoArray(r, i); ! } ! } ! ! assertArraysEquals(a, b, r, mask, ByteMaxVectorTests::shiftRight); ! } ! ! ! ! ! ! ! static byte shiftArithmeticRight(byte a, byte b) { ! return (byte)((a >> (b & 0x7))); } @Test(dataProvider = "byteBinaryOpProvider") ! static void shiftArithmeticRightByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.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); ! ByteVector bv = ByteVector.fromArray(SPECIES, b, i); ! av.shiftArithmeticRight(bv).intoArray(r, i); } } ! assertArraysEquals(a, b, r, ByteMaxVectorTests::shiftArithmeticRight); } @Test(dataProvider = "byteBinaryOpMaskProvider") ! static void shiftArithmeticRightByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<boolean[]> fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask<Byte> vmask = VectorMask.fromValues(SPECIES, mask); 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); ! ByteVector bv = ByteVector.fromArray(SPECIES, b, i); ! av.shiftArithmeticRight(bv, vmask).intoArray(r, i); } } ! assertArraysEquals(a, b, r, mask, ByteMaxVectorTests::shiftArithmeticRight); } ! ! ! ! ! static byte shiftLeft_unary(byte a, byte b) { return (byte)((a << (b & 7))); } @Test(dataProvider = "byteBinaryOpProvider") ! static void shiftLeftByteMaxVectorTestsShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.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.shiftLeft((int)b[i]).intoArray(r, i); } } ! assertShiftArraysEquals(a, b, r, ByteMaxVectorTests::shiftLeft_unary); } @Test(dataProvider = "byteBinaryOpMaskProvider") ! static void shiftLeftByteMaxVectorTestsShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<boolean[]> fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask<Byte> vmask = VectorMask.fromValues(SPECIES, mask); 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.shiftLeft((int)b[i], vmask).intoArray(r, i); } } ! assertShiftArraysEquals(a, b, r, mask, ByteMaxVectorTests::shiftLeft_unary); } ! ! ! ! ! static byte shiftRight_unary(byte a, byte b) { return (byte)(((a & 0xFF) >>> (b & 7))); } @Test(dataProvider = "byteBinaryOpProvider") ! static void shiftRightByteMaxVectorTestsShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.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.shiftRight((int)b[i]).intoArray(r, i); } } ! assertShiftArraysEquals(a, b, r, ByteMaxVectorTests::shiftRight_unary); } @Test(dataProvider = "byteBinaryOpMaskProvider") ! static void shiftRightByteMaxVectorTestsShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<boolean[]> fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask<Byte> vmask = VectorMask.fromValues(SPECIES, mask); 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.shiftRight((int)b[i], vmask).intoArray(r, i); ! } ! } ! ! assertShiftArraysEquals(a, b, r, mask, ByteMaxVectorTests::shiftRight_unary); ! } ! ! ! ! ! ! ! static byte shiftArithmeticRight_unary(byte a, byte b) { ! return (byte)((a >> (b & 7))); ! } ! ! @Test(dataProvider = "byteBinaryOpProvider") ! static void shiftArithmeticRightByteMaxVectorTestsShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb) { ! byte[] a = fa.apply(SPECIES.length()); ! byte[] b = fb.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.shiftArithmeticRight((int)b[i]).intoArray(r, i); } } ! assertShiftArraysEquals(a, b, r, ByteMaxVectorTests::shiftArithmeticRight_unary); } + @Test(dataProvider = "byteBinaryOpMaskProvider") + static void shiftArithmeticRightByteMaxVectorTestsShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb, + IntFunction<boolean[]> fm) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask<Byte> vmask = VectorMask.fromValues(SPECIES, mask); + 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.shiftArithmeticRight((int)b[i], vmask).intoArray(r, i); + } + } + + assertShiftArraysEquals(a, b, r, mask, ByteMaxVectorTests::shiftArithmeticRight_unary); + } static byte max(byte a, byte b) { return (byte)(Math.max(a, b));
*** 844,863 **** } assertArraysEquals(a, b, r, ByteMaxVectorTests::min); } ! static byte andAll(byte[] a, int idx) { byte res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { res &= a[i]; } return res; } ! static byte andAll(byte[] a) { byte res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { byte tmp = -1; for (int j = 0; j < SPECIES.length(); j++) { tmp &= a[i + j]; --- 982,1001 ---- } assertArraysEquals(a, b, r, ByteMaxVectorTests::min); } ! static byte andLanes(byte[] a, int idx) { byte res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { res &= a[i]; } return res; } ! static byte andLanes(byte[] a) { byte res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { byte tmp = -1; for (int j = 0; j < SPECIES.length(); j++) { tmp &= a[i + j];
*** 868,911 **** return res; } @Test(dataProvider = "byteUnaryOpProvider") ! static void andAllByteMaxVectorTests(IntFunction<byte[]> fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = -1; for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ! r[i] = av.andAll(); } } for (int ic = 0; ic < INVOC_COUNT; ic++) { ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ! ra &= av.andAll(); } } ! assertReductionArraysEquals(a, r, ra, ByteMaxVectorTests::andAll, ByteMaxVectorTests::andAll); } ! static byte orAll(byte[] a, int idx) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { res |= a[i]; } return res; } ! static byte orAll(byte[] a) { byte res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { byte tmp = 0; for (int j = 0; j < SPECIES.length(); j++) { tmp |= a[i + j]; --- 1006,1049 ---- return res; } @Test(dataProvider = "byteUnaryOpProvider") ! static void andLanesByteMaxVectorTests(IntFunction<byte[]> fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = -1; for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ! r[i] = av.andLanes(); } } for (int ic = 0; ic < INVOC_COUNT; ic++) { ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ! ra &= av.andLanes(); } } ! assertReductionArraysEquals(a, r, ra, ByteMaxVectorTests::andLanes, ByteMaxVectorTests::andLanes); } ! static byte orLanes(byte[] a, int idx) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { res |= a[i]; } return res; } ! static byte orLanes(byte[] a) { byte res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { byte tmp = 0; for (int j = 0; j < SPECIES.length(); j++) { tmp |= a[i + j];
*** 916,959 **** return res; } @Test(dataProvider = "byteUnaryOpProvider") ! static void orAllByteMaxVectorTests(IntFunction<byte[]> fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ! r[i] = av.orAll(); } } for (int ic = 0; ic < INVOC_COUNT; ic++) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ! ra |= av.orAll(); } } ! assertReductionArraysEquals(a, r, ra, ByteMaxVectorTests::orAll, ByteMaxVectorTests::orAll); } ! static byte xorAll(byte[] a, int idx) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { res ^= a[i]; } return res; } ! static byte xorAll(byte[] a) { byte res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { byte tmp = 0; for (int j = 0; j < SPECIES.length(); j++) { tmp ^= a[i + j]; --- 1054,1097 ---- return res; } @Test(dataProvider = "byteUnaryOpProvider") ! static void orLanesByteMaxVectorTests(IntFunction<byte[]> fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ! r[i] = av.orLanes(); } } for (int ic = 0; ic < INVOC_COUNT; ic++) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ! ra |= av.orLanes(); } } ! assertReductionArraysEquals(a, r, ra, ByteMaxVectorTests::orLanes, ByteMaxVectorTests::orLanes); } ! static byte xorLanes(byte[] a, int idx) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { res ^= a[i]; } return res; } ! static byte xorLanes(byte[] a) { byte res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { byte tmp = 0; for (int j = 0; j < SPECIES.length(); j++) { tmp ^= a[i + j];
*** 964,1006 **** return res; } @Test(dataProvider = "byteUnaryOpProvider") ! static void xorAllByteMaxVectorTests(IntFunction<byte[]> fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ! r[i] = av.xorAll(); } } for (int ic = 0; ic < INVOC_COUNT; ic++) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ! ra ^= av.xorAll(); } } ! assertReductionArraysEquals(a, r, ra, ByteMaxVectorTests::xorAll, ByteMaxVectorTests::xorAll); } ! static byte addAll(byte[] a, int idx) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { res += a[i]; } return res; } ! static byte addAll(byte[] a) { byte res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { byte tmp = 0; for (int j = 0; j < SPECIES.length(); j++) { tmp += a[i + j]; --- 1102,1144 ---- return res; } @Test(dataProvider = "byteUnaryOpProvider") ! static void xorLanesByteMaxVectorTests(IntFunction<byte[]> fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ! r[i] = av.xorLanes(); } } for (int ic = 0; ic < INVOC_COUNT; ic++) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ! ra ^= av.xorLanes(); } } ! assertReductionArraysEquals(a, r, ra, ByteMaxVectorTests::xorLanes, ByteMaxVectorTests::xorLanes); } ! static byte addLanes(byte[] a, int idx) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { res += a[i]; } return res; } ! static byte addLanes(byte[] a) { byte res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { byte tmp = 0; for (int j = 0; j < SPECIES.length(); j++) { tmp += a[i + j];
*** 1009,1050 **** } return res; } @Test(dataProvider = "byteUnaryOpProvider") ! static void addAllByteMaxVectorTests(IntFunction<byte[]> fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ! r[i] = av.addAll(); } } for (int ic = 0; ic < INVOC_COUNT; ic++) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ! ra += av.addAll(); } } ! assertReductionArraysEquals(a, r, ra, ByteMaxVectorTests::addAll, ByteMaxVectorTests::addAll); } ! static byte mulAll(byte[] a, int idx) { byte res = 1; for (int i = idx; i < (idx + SPECIES.length()); i++) { res *= a[i]; } return res; } ! static byte mulAll(byte[] a) { byte res = 1; for (int i = 0; i < a.length; i += SPECIES.length()) { byte tmp = 1; for (int j = 0; j < SPECIES.length(); j++) { tmp *= a[i + j]; --- 1147,1188 ---- } return res; } @Test(dataProvider = "byteUnaryOpProvider") ! static void addLanesByteMaxVectorTests(IntFunction<byte[]> fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 0; for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ! r[i] = av.addLanes(); } } for (int ic = 0; ic < INVOC_COUNT; ic++) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ! ra += av.addLanes(); } } ! assertReductionArraysEquals(a, r, ra, ByteMaxVectorTests::addLanes, ByteMaxVectorTests::addLanes); } ! static byte mulLanes(byte[] a, int idx) { byte res = 1; for (int i = idx; i < (idx + SPECIES.length()); i++) { res *= a[i]; } return res; } ! static byte mulLanes(byte[] a) { byte res = 1; for (int i = 0; i < a.length; i += SPECIES.length()) { byte tmp = 1; for (int j = 0; j < SPECIES.length(); j++) { tmp *= a[i + j];
*** 1053,1163 **** } return res; } @Test(dataProvider = "byteUnaryOpProvider") ! static void mulAllByteMaxVectorTests(IntFunction<byte[]> fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 1; for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ! r[i] = av.mulAll(); } } for (int ic = 0; ic < INVOC_COUNT; ic++) { ra = 1; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ! ra *= av.mulAll(); } } ! assertReductionArraysEquals(a, r, ra, ByteMaxVectorTests::mulAll, ByteMaxVectorTests::mulAll); } ! static byte minAll(byte[] a, int idx) { byte res = Byte.MAX_VALUE; for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (byte)Math.min(res, a[i]); } return res; } ! static byte minAll(byte[] a) { byte res = Byte.MAX_VALUE; for (int i = 0; i < a.length; i++) { res = (byte)Math.min(res, a[i]); } return res; } @Test(dataProvider = "byteUnaryOpProvider") ! static void minAllByteMaxVectorTests(IntFunction<byte[]> fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = Byte.MAX_VALUE; for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ! r[i] = av.minAll(); } } for (int ic = 0; ic < INVOC_COUNT; ic++) { ra = Byte.MAX_VALUE; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ! ra = (byte)Math.min(ra, av.minAll()); } } ! assertReductionArraysEquals(a, r, ra, ByteMaxVectorTests::minAll, ByteMaxVectorTests::minAll); } ! static byte maxAll(byte[] a, int idx) { byte res = Byte.MIN_VALUE; for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (byte)Math.max(res, a[i]); } return res; } ! static byte maxAll(byte[] a) { byte res = Byte.MIN_VALUE; for (int i = 0; i < a.length; i++) { res = (byte)Math.max(res, a[i]); } return res; } @Test(dataProvider = "byteUnaryOpProvider") ! static void maxAllByteMaxVectorTests(IntFunction<byte[]> fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = Byte.MIN_VALUE; for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ! r[i] = av.maxAll(); } } for (int ic = 0; ic < INVOC_COUNT; ic++) { ra = Byte.MIN_VALUE; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ! ra = (byte)Math.max(ra, av.maxAll()); } } ! assertReductionArraysEquals(a, r, ra, ByteMaxVectorTests::maxAll, ByteMaxVectorTests::maxAll); } static boolean anyTrue(boolean[] a, int idx) { boolean res = false; for (int i = idx; i < (idx + SPECIES.length()); i++) { --- 1191,1301 ---- } return res; } @Test(dataProvider = "byteUnaryOpProvider") ! static void mulLanesByteMaxVectorTests(IntFunction<byte[]> fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = 1; for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ! r[i] = av.mulLanes(); } } for (int ic = 0; ic < INVOC_COUNT; ic++) { ra = 1; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ! ra *= av.mulLanes(); } } ! assertReductionArraysEquals(a, r, ra, ByteMaxVectorTests::mulLanes, ByteMaxVectorTests::mulLanes); } ! static byte minLanes(byte[] a, int idx) { byte res = Byte.MAX_VALUE; for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (byte)Math.min(res, a[i]); } return res; } ! static byte minLanes(byte[] a) { byte res = Byte.MAX_VALUE; for (int i = 0; i < a.length; i++) { res = (byte)Math.min(res, a[i]); } return res; } @Test(dataProvider = "byteUnaryOpProvider") ! static void minLanesByteMaxVectorTests(IntFunction<byte[]> fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = Byte.MAX_VALUE; for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ! r[i] = av.minLanes(); } } for (int ic = 0; ic < INVOC_COUNT; ic++) { ra = Byte.MAX_VALUE; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ! ra = (byte)Math.min(ra, av.minLanes()); } } ! assertReductionArraysEquals(a, r, ra, ByteMaxVectorTests::minLanes, ByteMaxVectorTests::minLanes); } ! static byte maxLanes(byte[] a, int idx) { byte res = Byte.MIN_VALUE; for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (byte)Math.max(res, a[i]); } return res; } ! static byte maxLanes(byte[] a) { byte res = Byte.MIN_VALUE; for (int i = 0; i < a.length; i++) { res = (byte)Math.max(res, a[i]); } return res; } @Test(dataProvider = "byteUnaryOpProvider") ! static void maxLanesByteMaxVectorTests(IntFunction<byte[]> fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); byte ra = Byte.MIN_VALUE; for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ! r[i] = av.maxLanes(); } } for (int ic = 0; ic < INVOC_COUNT; ic++) { ra = Byte.MIN_VALUE; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ! ra = (byte)Math.max(ra, av.maxLanes()); } } ! assertReductionArraysEquals(a, r, ra, ByteMaxVectorTests::maxLanes, ByteMaxVectorTests::maxLanes); } static boolean anyTrue(boolean[] a, int idx) { boolean res = false; for (int i = idx; i < (idx + SPECIES.length()); i++) {
< prev index next >