mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-05 07:58:40 +00:00
8266518: Refactor and expand scatter/gather tests
Reviewed-by: sviswanathan
This commit is contained in:
parent
f9c8c1c386
commit
dab00ee59b
@ -108,20 +108,6 @@ public class AbstractVectorTest {
|
||||
i -> ((i % 5) == 0));
|
||||
})
|
||||
);
|
||||
static final List<IntFunction<int[]>> INDEX_GENERATORS = List.of(
|
||||
withToString("index[i -> i]", (int s) -> {
|
||||
return fillInts(s,
|
||||
i -> i);
|
||||
}),
|
||||
withToString("index[i -> size - i - 1]", (int s) -> {
|
||||
return fillInts(s,
|
||||
i -> s - i - 1);
|
||||
}),
|
||||
withToString("index[i -> (i % 2) == 0 ? i : s - i - 1]", (int s) -> {
|
||||
return fillInts(s,
|
||||
i -> (i % 2) == 0 ? i : s - i - 1);
|
||||
})
|
||||
);
|
||||
|
||||
interface IntOp {
|
||||
int apply(int i);
|
||||
@ -161,9 +147,8 @@ public class AbstractVectorTest {
|
||||
fb -> List.of(fa, fb))).collect(Collectors.toList());
|
||||
|
||||
static final List<BiFunction<Integer,Integer,int[]>> INT_SHUFFLE_GENERATORS = List.of(
|
||||
withToStringBi("shuffle[random]", (Integer l, Integer m) -> {
|
||||
return RAND.ints(l, 0, m).toArray();
|
||||
})
|
||||
withToStringBi("shuffle[random]",
|
||||
(Integer l, Integer m) -> RAND.ints(l, 0, m).toArray())
|
||||
);
|
||||
|
||||
interface RangeIntOp {
|
||||
@ -202,17 +187,10 @@ public class AbstractVectorTest {
|
||||
);
|
||||
|
||||
static final List<BiFunction<Integer,Integer,int[]>> INT_INDEX_GENERATORS = List.of(
|
||||
withToStringBi("index[random]", (Integer l, Integer m) -> {
|
||||
return RAND.ints(l, 0, m).toArray();
|
||||
})
|
||||
withToStringBi("index[random]",
|
||||
(Integer l, Integer m) -> RAND.ints(l, 0, m).toArray())
|
||||
);
|
||||
|
||||
static int countTrailingFalse(boolean[] m) {
|
||||
int i;
|
||||
for (i = m.length - 1; i >= 0 && !m[i]; i--);
|
||||
return m.length - 1 - i;
|
||||
}
|
||||
|
||||
static boolean isIndexOutOfBoundsForMask(boolean[] mask, int offset, int length) {
|
||||
return isIndexOutOfBoundsForMask(mask, offset, length, 1);
|
||||
}
|
||||
|
||||
@ -42,6 +42,7 @@ import org.testng.annotations.Test;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.*;
|
||||
|
||||
@ -50,13 +51,11 @@ public class Byte128VectorLoadStoreTests extends AbstractVectorTest {
|
||||
static final VectorSpecies<Byte> SPECIES =
|
||||
ByteVector.SPECIES_128;
|
||||
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 10);
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 128);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (128 / 8));
|
||||
|
||||
static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -178,25 +177,6 @@ public class Byte128VectorLoadStoreTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteIndexMapProvider() {
|
||||
return INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> BYTE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteIndexMapMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> BYTE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim, fm};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteByteBufferProvider() {
|
||||
return BYTE_GENERATORS.stream().
|
||||
@ -1038,4 +1018,281 @@ public class Byte128VectorLoadStoreTests extends AbstractVectorTest {
|
||||
}
|
||||
assertArraysEquals(r, a, mask);
|
||||
}
|
||||
|
||||
|
||||
// Gather/Scatter load/store tests
|
||||
|
||||
static void assertGatherArraysEquals(byte[] r, byte[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(byte[] r, byte[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (byte) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (byte) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(byte[] r, byte[] a, int[] indexMap, boolean[] mask) {
|
||||
byte[] expected = new byte[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(byte[] r, byte[] a, int[] indexMap) {
|
||||
byte[] expected = new byte[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> BYTE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
BYTE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void gather(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = new byte[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void gatherMask(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = new byte[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void scatter(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = new byte[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void scatterMask(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = new byte[a.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
|
||||
static void assertGatherArraysEquals(boolean[] r, boolean[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(boolean[] r, boolean[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: false);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: false, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(boolean[] r, boolean[] a, int[] indexMap, boolean[] mask) {
|
||||
boolean[] expected = new boolean[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(boolean[] r, boolean[] a, int[] indexMap) {
|
||||
boolean[] expected = new boolean[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void booleanGather(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
boolean[] a = convertToBooleanArray(fa.apply(SPECIES.length()));
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
boolean[] r = new boolean[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ByteVector av = ByteVector.fromBooleanArray(SPECIES, a, i, b, i);
|
||||
av.intoBooleanArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void booleanGatherMask(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
boolean[] a = convertToBooleanArray(fa.apply(SPECIES.length()));
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
boolean[] r = new boolean[a.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.fromBooleanArray(SPECIES, a, i, b, i, vmask);
|
||||
av.intoBooleanArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void booleanScatter(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
boolean[] a = convertToBooleanArray(fa.apply(SPECIES.length()));
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
boolean[] r = new boolean[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ByteVector av = ByteVector.fromBooleanArray(SPECIES, a, i);
|
||||
av.intoBooleanArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void booleanScatterMask(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
boolean[] a = convertToBooleanArray(fa.apply(SPECIES.length()));
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
boolean[] r = new boolean[a.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.fromBooleanArray(SPECIES, a, i);
|
||||
av.intoBooleanArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -62,8 +62,6 @@ public class Byte128VectorTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 128);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (128 / 8));
|
||||
|
||||
interface FUnOp {
|
||||
byte apply(byte a);
|
||||
}
|
||||
@ -1008,36 +1006,6 @@ public class Byte128VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteUnaryOpIndexProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> BYTE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteUnaryMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
BYTE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] scatterMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
BYTE_GENERATORS.stream().flatMap(fn ->
|
||||
BYTE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fn, fm, fs};
|
||||
})))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
static final List<IntFunction<byte[]>> BYTE_COMPARE_GENERATORS = List.of(
|
||||
withToString("byte[i]", (int s) -> {
|
||||
return fill(s * BUFFER_REPS,
|
||||
@ -4922,122 +4890,6 @@ public class Byte128VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
static byte[] gather(byte a[], int ix, int[] b, int iy) {
|
||||
byte[] res = new byte[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpIndexProvider")
|
||||
static void gatherByte128VectorTests(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = new byte[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Byte128VectorTests::gather);
|
||||
}
|
||||
static byte[] gatherMasked(byte a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
byte[] res = new byte[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
if (mask[i]) {
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryMaskedOpIndexProvider")
|
||||
static void gatherMaskedByte128VectorTests(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = new byte[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Byte128VectorTests::gatherMasked);
|
||||
}
|
||||
|
||||
static byte[] scatter(byte a[], int ix, int[] b, int iy) {
|
||||
byte[] res = new byte[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = a[i + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpIndexProvider")
|
||||
static void scatterByte128VectorTests(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = new byte[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Byte128VectorTests::scatter);
|
||||
}
|
||||
|
||||
static byte[] scatterMasked(byte r[], byte a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
// First, gather r.
|
||||
byte[] oldVal = gather(r, ix, b, iy);
|
||||
byte[] newVal = new byte[SPECIES.length()];
|
||||
|
||||
// Second, blending it with a.
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
newVal[i] = blend(oldVal[i], a[i+ix], mask[i]);
|
||||
}
|
||||
|
||||
// Third, scatter: copy old value of r, and scatter it manually.
|
||||
byte[] res = Arrays.copyOfRange(r, ix, ix+SPECIES.length());
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = newVal[i];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "scatterMaskedOpIndexProvider")
|
||||
static void scatterMaskedByte128VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = fb.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Byte128VectorTests::scatterMasked);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "byteCompareOpProvider")
|
||||
static void ltByte128VectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
|
||||
|
||||
@ -42,6 +42,7 @@ import org.testng.annotations.Test;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.*;
|
||||
|
||||
@ -50,13 +51,11 @@ public class Byte256VectorLoadStoreTests extends AbstractVectorTest {
|
||||
static final VectorSpecies<Byte> SPECIES =
|
||||
ByteVector.SPECIES_256;
|
||||
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 10);
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 256);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (256 / 8));
|
||||
|
||||
static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -178,25 +177,6 @@ public class Byte256VectorLoadStoreTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteIndexMapProvider() {
|
||||
return INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> BYTE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteIndexMapMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> BYTE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim, fm};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteByteBufferProvider() {
|
||||
return BYTE_GENERATORS.stream().
|
||||
@ -1038,4 +1018,281 @@ public class Byte256VectorLoadStoreTests extends AbstractVectorTest {
|
||||
}
|
||||
assertArraysEquals(r, a, mask);
|
||||
}
|
||||
|
||||
|
||||
// Gather/Scatter load/store tests
|
||||
|
||||
static void assertGatherArraysEquals(byte[] r, byte[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(byte[] r, byte[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (byte) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (byte) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(byte[] r, byte[] a, int[] indexMap, boolean[] mask) {
|
||||
byte[] expected = new byte[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(byte[] r, byte[] a, int[] indexMap) {
|
||||
byte[] expected = new byte[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> BYTE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
BYTE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void gather(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = new byte[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void gatherMask(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = new byte[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void scatter(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = new byte[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void scatterMask(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = new byte[a.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
|
||||
static void assertGatherArraysEquals(boolean[] r, boolean[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(boolean[] r, boolean[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: false);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: false, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(boolean[] r, boolean[] a, int[] indexMap, boolean[] mask) {
|
||||
boolean[] expected = new boolean[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(boolean[] r, boolean[] a, int[] indexMap) {
|
||||
boolean[] expected = new boolean[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void booleanGather(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
boolean[] a = convertToBooleanArray(fa.apply(SPECIES.length()));
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
boolean[] r = new boolean[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ByteVector av = ByteVector.fromBooleanArray(SPECIES, a, i, b, i);
|
||||
av.intoBooleanArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void booleanGatherMask(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
boolean[] a = convertToBooleanArray(fa.apply(SPECIES.length()));
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
boolean[] r = new boolean[a.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.fromBooleanArray(SPECIES, a, i, b, i, vmask);
|
||||
av.intoBooleanArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void booleanScatter(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
boolean[] a = convertToBooleanArray(fa.apply(SPECIES.length()));
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
boolean[] r = new boolean[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ByteVector av = ByteVector.fromBooleanArray(SPECIES, a, i);
|
||||
av.intoBooleanArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void booleanScatterMask(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
boolean[] a = convertToBooleanArray(fa.apply(SPECIES.length()));
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
boolean[] r = new boolean[a.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.fromBooleanArray(SPECIES, a, i);
|
||||
av.intoBooleanArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -62,8 +62,6 @@ public class Byte256VectorTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 256);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (256 / 8));
|
||||
|
||||
interface FUnOp {
|
||||
byte apply(byte a);
|
||||
}
|
||||
@ -1008,36 +1006,6 @@ public class Byte256VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteUnaryOpIndexProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> BYTE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteUnaryMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
BYTE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] scatterMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
BYTE_GENERATORS.stream().flatMap(fn ->
|
||||
BYTE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fn, fm, fs};
|
||||
})))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
static final List<IntFunction<byte[]>> BYTE_COMPARE_GENERATORS = List.of(
|
||||
withToString("byte[i]", (int s) -> {
|
||||
return fill(s * BUFFER_REPS,
|
||||
@ -4922,122 +4890,6 @@ public class Byte256VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
static byte[] gather(byte a[], int ix, int[] b, int iy) {
|
||||
byte[] res = new byte[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpIndexProvider")
|
||||
static void gatherByte256VectorTests(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = new byte[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Byte256VectorTests::gather);
|
||||
}
|
||||
static byte[] gatherMasked(byte a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
byte[] res = new byte[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
if (mask[i]) {
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryMaskedOpIndexProvider")
|
||||
static void gatherMaskedByte256VectorTests(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = new byte[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Byte256VectorTests::gatherMasked);
|
||||
}
|
||||
|
||||
static byte[] scatter(byte a[], int ix, int[] b, int iy) {
|
||||
byte[] res = new byte[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = a[i + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpIndexProvider")
|
||||
static void scatterByte256VectorTests(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = new byte[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Byte256VectorTests::scatter);
|
||||
}
|
||||
|
||||
static byte[] scatterMasked(byte r[], byte a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
// First, gather r.
|
||||
byte[] oldVal = gather(r, ix, b, iy);
|
||||
byte[] newVal = new byte[SPECIES.length()];
|
||||
|
||||
// Second, blending it with a.
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
newVal[i] = blend(oldVal[i], a[i+ix], mask[i]);
|
||||
}
|
||||
|
||||
// Third, scatter: copy old value of r, and scatter it manually.
|
||||
byte[] res = Arrays.copyOfRange(r, ix, ix+SPECIES.length());
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = newVal[i];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "scatterMaskedOpIndexProvider")
|
||||
static void scatterMaskedByte256VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = fb.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Byte256VectorTests::scatterMasked);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "byteCompareOpProvider")
|
||||
static void ltByte256VectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
|
||||
|
||||
@ -42,6 +42,7 @@ import org.testng.annotations.Test;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.*;
|
||||
|
||||
@ -50,13 +51,11 @@ public class Byte512VectorLoadStoreTests extends AbstractVectorTest {
|
||||
static final VectorSpecies<Byte> SPECIES =
|
||||
ByteVector.SPECIES_512;
|
||||
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 10);
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 512);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (512 / 8));
|
||||
|
||||
static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -178,25 +177,6 @@ public class Byte512VectorLoadStoreTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteIndexMapProvider() {
|
||||
return INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> BYTE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteIndexMapMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> BYTE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim, fm};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteByteBufferProvider() {
|
||||
return BYTE_GENERATORS.stream().
|
||||
@ -1038,4 +1018,281 @@ public class Byte512VectorLoadStoreTests extends AbstractVectorTest {
|
||||
}
|
||||
assertArraysEquals(r, a, mask);
|
||||
}
|
||||
|
||||
|
||||
// Gather/Scatter load/store tests
|
||||
|
||||
static void assertGatherArraysEquals(byte[] r, byte[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(byte[] r, byte[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (byte) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (byte) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(byte[] r, byte[] a, int[] indexMap, boolean[] mask) {
|
||||
byte[] expected = new byte[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(byte[] r, byte[] a, int[] indexMap) {
|
||||
byte[] expected = new byte[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> BYTE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
BYTE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void gather(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = new byte[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void gatherMask(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = new byte[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void scatter(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = new byte[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void scatterMask(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = new byte[a.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
|
||||
static void assertGatherArraysEquals(boolean[] r, boolean[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(boolean[] r, boolean[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: false);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: false, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(boolean[] r, boolean[] a, int[] indexMap, boolean[] mask) {
|
||||
boolean[] expected = new boolean[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(boolean[] r, boolean[] a, int[] indexMap) {
|
||||
boolean[] expected = new boolean[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void booleanGather(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
boolean[] a = convertToBooleanArray(fa.apply(SPECIES.length()));
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
boolean[] r = new boolean[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ByteVector av = ByteVector.fromBooleanArray(SPECIES, a, i, b, i);
|
||||
av.intoBooleanArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void booleanGatherMask(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
boolean[] a = convertToBooleanArray(fa.apply(SPECIES.length()));
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
boolean[] r = new boolean[a.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.fromBooleanArray(SPECIES, a, i, b, i, vmask);
|
||||
av.intoBooleanArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void booleanScatter(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
boolean[] a = convertToBooleanArray(fa.apply(SPECIES.length()));
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
boolean[] r = new boolean[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ByteVector av = ByteVector.fromBooleanArray(SPECIES, a, i);
|
||||
av.intoBooleanArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void booleanScatterMask(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
boolean[] a = convertToBooleanArray(fa.apply(SPECIES.length()));
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
boolean[] r = new boolean[a.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.fromBooleanArray(SPECIES, a, i);
|
||||
av.intoBooleanArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -62,8 +62,6 @@ public class Byte512VectorTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 512);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (512 / 8));
|
||||
|
||||
interface FUnOp {
|
||||
byte apply(byte a);
|
||||
}
|
||||
@ -1008,36 +1006,6 @@ public class Byte512VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteUnaryOpIndexProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> BYTE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteUnaryMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
BYTE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] scatterMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
BYTE_GENERATORS.stream().flatMap(fn ->
|
||||
BYTE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fn, fm, fs};
|
||||
})))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
static final List<IntFunction<byte[]>> BYTE_COMPARE_GENERATORS = List.of(
|
||||
withToString("byte[i]", (int s) -> {
|
||||
return fill(s * BUFFER_REPS,
|
||||
@ -4922,122 +4890,6 @@ public class Byte512VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
static byte[] gather(byte a[], int ix, int[] b, int iy) {
|
||||
byte[] res = new byte[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpIndexProvider")
|
||||
static void gatherByte512VectorTests(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = new byte[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Byte512VectorTests::gather);
|
||||
}
|
||||
static byte[] gatherMasked(byte a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
byte[] res = new byte[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
if (mask[i]) {
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryMaskedOpIndexProvider")
|
||||
static void gatherMaskedByte512VectorTests(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = new byte[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Byte512VectorTests::gatherMasked);
|
||||
}
|
||||
|
||||
static byte[] scatter(byte a[], int ix, int[] b, int iy) {
|
||||
byte[] res = new byte[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = a[i + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpIndexProvider")
|
||||
static void scatterByte512VectorTests(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = new byte[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Byte512VectorTests::scatter);
|
||||
}
|
||||
|
||||
static byte[] scatterMasked(byte r[], byte a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
// First, gather r.
|
||||
byte[] oldVal = gather(r, ix, b, iy);
|
||||
byte[] newVal = new byte[SPECIES.length()];
|
||||
|
||||
// Second, blending it with a.
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
newVal[i] = blend(oldVal[i], a[i+ix], mask[i]);
|
||||
}
|
||||
|
||||
// Third, scatter: copy old value of r, and scatter it manually.
|
||||
byte[] res = Arrays.copyOfRange(r, ix, ix+SPECIES.length());
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = newVal[i];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "scatterMaskedOpIndexProvider")
|
||||
static void scatterMaskedByte512VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = fb.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Byte512VectorTests::scatterMasked);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "byteCompareOpProvider")
|
||||
static void ltByte512VectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
|
||||
|
||||
@ -42,6 +42,7 @@ import org.testng.annotations.Test;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.*;
|
||||
|
||||
@ -50,13 +51,11 @@ public class Byte64VectorLoadStoreTests extends AbstractVectorTest {
|
||||
static final VectorSpecies<Byte> SPECIES =
|
||||
ByteVector.SPECIES_64;
|
||||
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 10);
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 64);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (64 / 8));
|
||||
|
||||
static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -178,25 +177,6 @@ public class Byte64VectorLoadStoreTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteIndexMapProvider() {
|
||||
return INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> BYTE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteIndexMapMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> BYTE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim, fm};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteByteBufferProvider() {
|
||||
return BYTE_GENERATORS.stream().
|
||||
@ -1038,4 +1018,281 @@ public class Byte64VectorLoadStoreTests extends AbstractVectorTest {
|
||||
}
|
||||
assertArraysEquals(r, a, mask);
|
||||
}
|
||||
|
||||
|
||||
// Gather/Scatter load/store tests
|
||||
|
||||
static void assertGatherArraysEquals(byte[] r, byte[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(byte[] r, byte[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (byte) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (byte) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(byte[] r, byte[] a, int[] indexMap, boolean[] mask) {
|
||||
byte[] expected = new byte[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(byte[] r, byte[] a, int[] indexMap) {
|
||||
byte[] expected = new byte[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> BYTE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
BYTE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void gather(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = new byte[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void gatherMask(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = new byte[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void scatter(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = new byte[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void scatterMask(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = new byte[a.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
|
||||
static void assertGatherArraysEquals(boolean[] r, boolean[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(boolean[] r, boolean[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: false);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: false, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(boolean[] r, boolean[] a, int[] indexMap, boolean[] mask) {
|
||||
boolean[] expected = new boolean[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(boolean[] r, boolean[] a, int[] indexMap) {
|
||||
boolean[] expected = new boolean[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void booleanGather(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
boolean[] a = convertToBooleanArray(fa.apply(SPECIES.length()));
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
boolean[] r = new boolean[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ByteVector av = ByteVector.fromBooleanArray(SPECIES, a, i, b, i);
|
||||
av.intoBooleanArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void booleanGatherMask(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
boolean[] a = convertToBooleanArray(fa.apply(SPECIES.length()));
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
boolean[] r = new boolean[a.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.fromBooleanArray(SPECIES, a, i, b, i, vmask);
|
||||
av.intoBooleanArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void booleanScatter(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
boolean[] a = convertToBooleanArray(fa.apply(SPECIES.length()));
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
boolean[] r = new boolean[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ByteVector av = ByteVector.fromBooleanArray(SPECIES, a, i);
|
||||
av.intoBooleanArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void booleanScatterMask(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
boolean[] a = convertToBooleanArray(fa.apply(SPECIES.length()));
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
boolean[] r = new boolean[a.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.fromBooleanArray(SPECIES, a, i);
|
||||
av.intoBooleanArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -62,8 +62,6 @@ public class Byte64VectorTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 64);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (64 / 8));
|
||||
|
||||
interface FUnOp {
|
||||
byte apply(byte a);
|
||||
}
|
||||
@ -1008,36 +1006,6 @@ public class Byte64VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteUnaryOpIndexProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> BYTE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteUnaryMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
BYTE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] scatterMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
BYTE_GENERATORS.stream().flatMap(fn ->
|
||||
BYTE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fn, fm, fs};
|
||||
})))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
static final List<IntFunction<byte[]>> BYTE_COMPARE_GENERATORS = List.of(
|
||||
withToString("byte[i]", (int s) -> {
|
||||
return fill(s * BUFFER_REPS,
|
||||
@ -4922,122 +4890,6 @@ public class Byte64VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
static byte[] gather(byte a[], int ix, int[] b, int iy) {
|
||||
byte[] res = new byte[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpIndexProvider")
|
||||
static void gatherByte64VectorTests(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = new byte[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Byte64VectorTests::gather);
|
||||
}
|
||||
static byte[] gatherMasked(byte a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
byte[] res = new byte[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
if (mask[i]) {
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryMaskedOpIndexProvider")
|
||||
static void gatherMaskedByte64VectorTests(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = new byte[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Byte64VectorTests::gatherMasked);
|
||||
}
|
||||
|
||||
static byte[] scatter(byte a[], int ix, int[] b, int iy) {
|
||||
byte[] res = new byte[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = a[i + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpIndexProvider")
|
||||
static void scatterByte64VectorTests(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = new byte[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Byte64VectorTests::scatter);
|
||||
}
|
||||
|
||||
static byte[] scatterMasked(byte r[], byte a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
// First, gather r.
|
||||
byte[] oldVal = gather(r, ix, b, iy);
|
||||
byte[] newVal = new byte[SPECIES.length()];
|
||||
|
||||
// Second, blending it with a.
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
newVal[i] = blend(oldVal[i], a[i+ix], mask[i]);
|
||||
}
|
||||
|
||||
// Third, scatter: copy old value of r, and scatter it manually.
|
||||
byte[] res = Arrays.copyOfRange(r, ix, ix+SPECIES.length());
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = newVal[i];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "scatterMaskedOpIndexProvider")
|
||||
static void scatterMaskedByte64VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = fb.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Byte64VectorTests::scatterMasked);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "byteCompareOpProvider")
|
||||
static void ltByte64VectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
|
||||
|
||||
@ -46,6 +46,7 @@ import java.lang.invoke.VarHandle;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.*;
|
||||
|
||||
@ -54,7 +55,7 @@ public class ByteMaxVectorLoadStoreTests extends AbstractVectorTest {
|
||||
static final VectorSpecies<Byte> SPECIES =
|
||||
ByteVector.SPECIES_MAX;
|
||||
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 10);
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
static VectorShape getMaxBit() {
|
||||
return VectorShape.S_Max_BIT;
|
||||
@ -64,8 +65,6 @@ public class ByteMaxVectorLoadStoreTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (Max / 8));
|
||||
|
||||
static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -187,25 +186,6 @@ public class ByteMaxVectorLoadStoreTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteIndexMapProvider() {
|
||||
return INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> BYTE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteIndexMapMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> BYTE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim, fm};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteByteBufferProvider() {
|
||||
return BYTE_GENERATORS.stream().
|
||||
@ -1047,4 +1027,281 @@ public class ByteMaxVectorLoadStoreTests extends AbstractVectorTest {
|
||||
}
|
||||
assertArraysEquals(r, a, mask);
|
||||
}
|
||||
|
||||
|
||||
// Gather/Scatter load/store tests
|
||||
|
||||
static void assertGatherArraysEquals(byte[] r, byte[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(byte[] r, byte[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (byte) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (byte) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(byte[] r, byte[] a, int[] indexMap, boolean[] mask) {
|
||||
byte[] expected = new byte[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(byte[] r, byte[] a, int[] indexMap) {
|
||||
byte[] expected = new byte[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> BYTE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
BYTE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void gather(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = new byte[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void gatherMask(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = new byte[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void scatter(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = new byte[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void scatterMask(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = new byte[a.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
|
||||
static void assertGatherArraysEquals(boolean[] r, boolean[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(boolean[] r, boolean[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: false);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: false, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(boolean[] r, boolean[] a, int[] indexMap, boolean[] mask) {
|
||||
boolean[] expected = new boolean[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(boolean[] r, boolean[] a, int[] indexMap) {
|
||||
boolean[] expected = new boolean[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void booleanGather(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
boolean[] a = convertToBooleanArray(fa.apply(SPECIES.length()));
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
boolean[] r = new boolean[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ByteVector av = ByteVector.fromBooleanArray(SPECIES, a, i, b, i);
|
||||
av.intoBooleanArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void booleanGatherMask(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
boolean[] a = convertToBooleanArray(fa.apply(SPECIES.length()));
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
boolean[] r = new boolean[a.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.fromBooleanArray(SPECIES, a, i, b, i, vmask);
|
||||
av.intoBooleanArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void booleanScatter(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
boolean[] a = convertToBooleanArray(fa.apply(SPECIES.length()));
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
boolean[] r = new boolean[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ByteVector av = ByteVector.fromBooleanArray(SPECIES, a, i);
|
||||
av.intoBooleanArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void booleanScatterMask(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
boolean[] a = convertToBooleanArray(fa.apply(SPECIES.length()));
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
boolean[] r = new boolean[a.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.fromBooleanArray(SPECIES, a, i);
|
||||
av.intoBooleanArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -67,8 +67,6 @@ public class ByteMaxVectorTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (Max / 8));
|
||||
|
||||
interface FUnOp {
|
||||
byte apply(byte a);
|
||||
}
|
||||
@ -1013,36 +1011,6 @@ public class ByteMaxVectorTests extends AbstractVectorTest {
|
||||
}
|
||||
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteUnaryOpIndexProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> BYTE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] byteUnaryMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
BYTE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] scatterMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
BYTE_GENERATORS.stream().flatMap(fn ->
|
||||
BYTE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fn, fm, fs};
|
||||
})))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
static final List<IntFunction<byte[]>> BYTE_COMPARE_GENERATORS = List.of(
|
||||
withToString("byte[i]", (int s) -> {
|
||||
return fill(s * BUFFER_REPS,
|
||||
@ -4927,122 +4895,6 @@ public class ByteMaxVectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
static byte[] gather(byte a[], int ix, int[] b, int iy) {
|
||||
byte[] res = new byte[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpIndexProvider")
|
||||
static void gatherByteMaxVectorTests(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = new byte[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, ByteMaxVectorTests::gather);
|
||||
}
|
||||
static byte[] gatherMasked(byte a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
byte[] res = new byte[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
if (mask[i]) {
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryMaskedOpIndexProvider")
|
||||
static void gatherMaskedByteMaxVectorTests(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = new byte[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::gatherMasked);
|
||||
}
|
||||
|
||||
static byte[] scatter(byte a[], int ix, int[] b, int iy) {
|
||||
byte[] res = new byte[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = a[i + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "byteUnaryOpIndexProvider")
|
||||
static void scatterByteMaxVectorTests(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = new byte[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, ByteMaxVectorTests::scatter);
|
||||
}
|
||||
|
||||
static byte[] scatterMasked(byte r[], byte a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
// First, gather r.
|
||||
byte[] oldVal = gather(r, ix, b, iy);
|
||||
byte[] newVal = new byte[SPECIES.length()];
|
||||
|
||||
// Second, blending it with a.
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
newVal[i] = blend(oldVal[i], a[i+ix], mask[i]);
|
||||
}
|
||||
|
||||
// Third, scatter: copy old value of r, and scatter it manually.
|
||||
byte[] res = Arrays.copyOfRange(r, ix, ix+SPECIES.length());
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = newVal[i];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "scatterMaskedOpIndexProvider")
|
||||
static void scatterMaskedByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
byte[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
byte[] r = fb.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::scatterMasked);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "byteCompareOpProvider")
|
||||
static void ltByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
|
||||
|
||||
@ -43,6 +43,7 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.DoubleBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.*;
|
||||
|
||||
@ -51,13 +52,11 @@ public class Double128VectorLoadStoreTests extends AbstractVectorTest {
|
||||
static final VectorSpecies<Double> SPECIES =
|
||||
DoubleVector.SPECIES_128;
|
||||
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 10);
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 128);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (128 / 8));
|
||||
|
||||
static void assertArraysEquals(double[] r, double[] a, boolean[] mask) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -189,25 +188,6 @@ public class Double128VectorLoadStoreTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] doubleIndexMapProvider() {
|
||||
return INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> DOUBLE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] doubleIndexMapMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> DOUBLE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim, fm};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] doubleByteBufferProvider() {
|
||||
return DOUBLE_GENERATORS.stream().
|
||||
@ -962,4 +942,156 @@ public class Double128VectorLoadStoreTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Gather/Scatter load/store tests
|
||||
|
||||
static void assertGatherArraysEquals(double[] r, double[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(double[] r, double[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (double) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (double) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(double[] r, double[] a, int[] indexMap, boolean[] mask) {
|
||||
double[] expected = new double[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(double[] r, double[] a, int[] indexMap) {
|
||||
double[] expected = new double[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> DOUBLE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
DOUBLE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void gather(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = new double[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void gatherMask(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = new double[a.length];
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void scatter(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = new double[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void scatterMask(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = new double[a.length];
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -62,8 +62,6 @@ public class Double128VectorTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 128);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (128 / 8));
|
||||
|
||||
interface FUnOp {
|
||||
double apply(double a);
|
||||
}
|
||||
@ -1140,36 +1138,6 @@ public class Double128VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
|
||||
|
||||
@DataProvider
|
||||
public Object[][] doubleUnaryOpIndexProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> DOUBLE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] doubleUnaryMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
DOUBLE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] scatterMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
DOUBLE_GENERATORS.stream().flatMap(fn ->
|
||||
DOUBLE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fn, fm, fs};
|
||||
})))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
static final List<IntFunction<double[]>> DOUBLE_COMPARE_GENERATORS = List.of(
|
||||
withToString("double[i]", (int s) -> {
|
||||
return fill(s * BUFFER_REPS,
|
||||
@ -4494,122 +4462,6 @@ public class Double128VectorTests extends AbstractVectorTest {
|
||||
assertArraysEquals(r, a, mask, Double128VectorTests::SQRT);
|
||||
}
|
||||
|
||||
static double[] gather(double a[], int ix, int[] b, int iy) {
|
||||
double[] res = new double[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "doubleUnaryOpIndexProvider")
|
||||
static void gatherDouble128VectorTests(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = new double[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Double128VectorTests::gather);
|
||||
}
|
||||
static double[] gatherMasked(double a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
double[] res = new double[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
if (mask[i]) {
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "doubleUnaryMaskedOpIndexProvider")
|
||||
static void gatherMaskedDouble128VectorTests(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = new double[a.length];
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Double128VectorTests::gatherMasked);
|
||||
}
|
||||
|
||||
static double[] scatter(double a[], int ix, int[] b, int iy) {
|
||||
double[] res = new double[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = a[i + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "doubleUnaryOpIndexProvider")
|
||||
static void scatterDouble128VectorTests(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = new double[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Double128VectorTests::scatter);
|
||||
}
|
||||
|
||||
static double[] scatterMasked(double r[], double a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
// First, gather r.
|
||||
double[] oldVal = gather(r, ix, b, iy);
|
||||
double[] newVal = new double[SPECIES.length()];
|
||||
|
||||
// Second, blending it with a.
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
newVal[i] = blend(oldVal[i], a[i+ix], mask[i]);
|
||||
}
|
||||
|
||||
// Third, scatter: copy old value of r, and scatter it manually.
|
||||
double[] res = Arrays.copyOfRange(r, ix, ix+SPECIES.length());
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = newVal[i];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "scatterMaskedOpIndexProvider")
|
||||
static void scatterMaskedDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = fb.apply(SPECIES.length());
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Double128VectorTests::scatterMasked);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "doubleCompareOpProvider")
|
||||
static void ltDouble128VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
|
||||
|
||||
@ -43,6 +43,7 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.DoubleBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.*;
|
||||
|
||||
@ -51,13 +52,11 @@ public class Double256VectorLoadStoreTests extends AbstractVectorTest {
|
||||
static final VectorSpecies<Double> SPECIES =
|
||||
DoubleVector.SPECIES_256;
|
||||
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 10);
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 256);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (256 / 8));
|
||||
|
||||
static void assertArraysEquals(double[] r, double[] a, boolean[] mask) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -189,25 +188,6 @@ public class Double256VectorLoadStoreTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] doubleIndexMapProvider() {
|
||||
return INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> DOUBLE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] doubleIndexMapMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> DOUBLE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim, fm};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] doubleByteBufferProvider() {
|
||||
return DOUBLE_GENERATORS.stream().
|
||||
@ -962,4 +942,156 @@ public class Double256VectorLoadStoreTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Gather/Scatter load/store tests
|
||||
|
||||
static void assertGatherArraysEquals(double[] r, double[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(double[] r, double[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (double) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (double) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(double[] r, double[] a, int[] indexMap, boolean[] mask) {
|
||||
double[] expected = new double[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(double[] r, double[] a, int[] indexMap) {
|
||||
double[] expected = new double[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> DOUBLE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
DOUBLE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void gather(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = new double[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void gatherMask(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = new double[a.length];
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void scatter(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = new double[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void scatterMask(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = new double[a.length];
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -62,8 +62,6 @@ public class Double256VectorTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 256);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (256 / 8));
|
||||
|
||||
interface FUnOp {
|
||||
double apply(double a);
|
||||
}
|
||||
@ -1140,36 +1138,6 @@ public class Double256VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
|
||||
|
||||
@DataProvider
|
||||
public Object[][] doubleUnaryOpIndexProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> DOUBLE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] doubleUnaryMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
DOUBLE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] scatterMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
DOUBLE_GENERATORS.stream().flatMap(fn ->
|
||||
DOUBLE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fn, fm, fs};
|
||||
})))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
static final List<IntFunction<double[]>> DOUBLE_COMPARE_GENERATORS = List.of(
|
||||
withToString("double[i]", (int s) -> {
|
||||
return fill(s * BUFFER_REPS,
|
||||
@ -4494,122 +4462,6 @@ public class Double256VectorTests extends AbstractVectorTest {
|
||||
assertArraysEquals(r, a, mask, Double256VectorTests::SQRT);
|
||||
}
|
||||
|
||||
static double[] gather(double a[], int ix, int[] b, int iy) {
|
||||
double[] res = new double[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "doubleUnaryOpIndexProvider")
|
||||
static void gatherDouble256VectorTests(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = new double[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Double256VectorTests::gather);
|
||||
}
|
||||
static double[] gatherMasked(double a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
double[] res = new double[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
if (mask[i]) {
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "doubleUnaryMaskedOpIndexProvider")
|
||||
static void gatherMaskedDouble256VectorTests(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = new double[a.length];
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Double256VectorTests::gatherMasked);
|
||||
}
|
||||
|
||||
static double[] scatter(double a[], int ix, int[] b, int iy) {
|
||||
double[] res = new double[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = a[i + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "doubleUnaryOpIndexProvider")
|
||||
static void scatterDouble256VectorTests(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = new double[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Double256VectorTests::scatter);
|
||||
}
|
||||
|
||||
static double[] scatterMasked(double r[], double a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
// First, gather r.
|
||||
double[] oldVal = gather(r, ix, b, iy);
|
||||
double[] newVal = new double[SPECIES.length()];
|
||||
|
||||
// Second, blending it with a.
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
newVal[i] = blend(oldVal[i], a[i+ix], mask[i]);
|
||||
}
|
||||
|
||||
// Third, scatter: copy old value of r, and scatter it manually.
|
||||
double[] res = Arrays.copyOfRange(r, ix, ix+SPECIES.length());
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = newVal[i];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "scatterMaskedOpIndexProvider")
|
||||
static void scatterMaskedDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = fb.apply(SPECIES.length());
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Double256VectorTests::scatterMasked);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "doubleCompareOpProvider")
|
||||
static void ltDouble256VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
|
||||
|
||||
@ -43,6 +43,7 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.DoubleBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.*;
|
||||
|
||||
@ -51,13 +52,11 @@ public class Double512VectorLoadStoreTests extends AbstractVectorTest {
|
||||
static final VectorSpecies<Double> SPECIES =
|
||||
DoubleVector.SPECIES_512;
|
||||
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 10);
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 512);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (512 / 8));
|
||||
|
||||
static void assertArraysEquals(double[] r, double[] a, boolean[] mask) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -189,25 +188,6 @@ public class Double512VectorLoadStoreTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] doubleIndexMapProvider() {
|
||||
return INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> DOUBLE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] doubleIndexMapMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> DOUBLE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim, fm};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] doubleByteBufferProvider() {
|
||||
return DOUBLE_GENERATORS.stream().
|
||||
@ -962,4 +942,156 @@ public class Double512VectorLoadStoreTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Gather/Scatter load/store tests
|
||||
|
||||
static void assertGatherArraysEquals(double[] r, double[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(double[] r, double[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (double) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (double) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(double[] r, double[] a, int[] indexMap, boolean[] mask) {
|
||||
double[] expected = new double[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(double[] r, double[] a, int[] indexMap) {
|
||||
double[] expected = new double[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> DOUBLE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
DOUBLE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void gather(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = new double[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void gatherMask(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = new double[a.length];
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void scatter(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = new double[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void scatterMask(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = new double[a.length];
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -62,8 +62,6 @@ public class Double512VectorTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 512);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (512 / 8));
|
||||
|
||||
interface FUnOp {
|
||||
double apply(double a);
|
||||
}
|
||||
@ -1140,36 +1138,6 @@ public class Double512VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
|
||||
|
||||
@DataProvider
|
||||
public Object[][] doubleUnaryOpIndexProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> DOUBLE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] doubleUnaryMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
DOUBLE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] scatterMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
DOUBLE_GENERATORS.stream().flatMap(fn ->
|
||||
DOUBLE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fn, fm, fs};
|
||||
})))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
static final List<IntFunction<double[]>> DOUBLE_COMPARE_GENERATORS = List.of(
|
||||
withToString("double[i]", (int s) -> {
|
||||
return fill(s * BUFFER_REPS,
|
||||
@ -4494,122 +4462,6 @@ public class Double512VectorTests extends AbstractVectorTest {
|
||||
assertArraysEquals(r, a, mask, Double512VectorTests::SQRT);
|
||||
}
|
||||
|
||||
static double[] gather(double a[], int ix, int[] b, int iy) {
|
||||
double[] res = new double[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "doubleUnaryOpIndexProvider")
|
||||
static void gatherDouble512VectorTests(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = new double[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Double512VectorTests::gather);
|
||||
}
|
||||
static double[] gatherMasked(double a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
double[] res = new double[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
if (mask[i]) {
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "doubleUnaryMaskedOpIndexProvider")
|
||||
static void gatherMaskedDouble512VectorTests(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = new double[a.length];
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Double512VectorTests::gatherMasked);
|
||||
}
|
||||
|
||||
static double[] scatter(double a[], int ix, int[] b, int iy) {
|
||||
double[] res = new double[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = a[i + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "doubleUnaryOpIndexProvider")
|
||||
static void scatterDouble512VectorTests(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = new double[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Double512VectorTests::scatter);
|
||||
}
|
||||
|
||||
static double[] scatterMasked(double r[], double a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
// First, gather r.
|
||||
double[] oldVal = gather(r, ix, b, iy);
|
||||
double[] newVal = new double[SPECIES.length()];
|
||||
|
||||
// Second, blending it with a.
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
newVal[i] = blend(oldVal[i], a[i+ix], mask[i]);
|
||||
}
|
||||
|
||||
// Third, scatter: copy old value of r, and scatter it manually.
|
||||
double[] res = Arrays.copyOfRange(r, ix, ix+SPECIES.length());
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = newVal[i];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "scatterMaskedOpIndexProvider")
|
||||
static void scatterMaskedDouble512VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = fb.apply(SPECIES.length());
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Double512VectorTests::scatterMasked);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "doubleCompareOpProvider")
|
||||
static void ltDouble512VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
|
||||
|
||||
@ -43,6 +43,7 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.DoubleBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.*;
|
||||
|
||||
@ -51,13 +52,11 @@ public class Double64VectorLoadStoreTests extends AbstractVectorTest {
|
||||
static final VectorSpecies<Double> SPECIES =
|
||||
DoubleVector.SPECIES_64;
|
||||
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 10);
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 64);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (64 / 8));
|
||||
|
||||
static void assertArraysEquals(double[] r, double[] a, boolean[] mask) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -189,25 +188,6 @@ public class Double64VectorLoadStoreTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] doubleIndexMapProvider() {
|
||||
return INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> DOUBLE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] doubleIndexMapMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> DOUBLE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim, fm};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] doubleByteBufferProvider() {
|
||||
return DOUBLE_GENERATORS.stream().
|
||||
@ -962,4 +942,156 @@ public class Double64VectorLoadStoreTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Gather/Scatter load/store tests
|
||||
|
||||
static void assertGatherArraysEquals(double[] r, double[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(double[] r, double[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (double) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (double) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(double[] r, double[] a, int[] indexMap, boolean[] mask) {
|
||||
double[] expected = new double[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(double[] r, double[] a, int[] indexMap) {
|
||||
double[] expected = new double[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> DOUBLE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
DOUBLE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void gather(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = new double[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void gatherMask(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = new double[a.length];
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void scatter(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = new double[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void scatterMask(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = new double[a.length];
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -62,8 +62,6 @@ public class Double64VectorTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 64);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (64 / 8));
|
||||
|
||||
interface FUnOp {
|
||||
double apply(double a);
|
||||
}
|
||||
@ -1140,36 +1138,6 @@ public class Double64VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
|
||||
|
||||
@DataProvider
|
||||
public Object[][] doubleUnaryOpIndexProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> DOUBLE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] doubleUnaryMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
DOUBLE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] scatterMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
DOUBLE_GENERATORS.stream().flatMap(fn ->
|
||||
DOUBLE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fn, fm, fs};
|
||||
})))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
static final List<IntFunction<double[]>> DOUBLE_COMPARE_GENERATORS = List.of(
|
||||
withToString("double[i]", (int s) -> {
|
||||
return fill(s * BUFFER_REPS,
|
||||
@ -4494,122 +4462,6 @@ public class Double64VectorTests extends AbstractVectorTest {
|
||||
assertArraysEquals(r, a, mask, Double64VectorTests::SQRT);
|
||||
}
|
||||
|
||||
static double[] gather(double a[], int ix, int[] b, int iy) {
|
||||
double[] res = new double[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "doubleUnaryOpIndexProvider")
|
||||
static void gatherDouble64VectorTests(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = new double[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Double64VectorTests::gather);
|
||||
}
|
||||
static double[] gatherMasked(double a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
double[] res = new double[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
if (mask[i]) {
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "doubleUnaryMaskedOpIndexProvider")
|
||||
static void gatherMaskedDouble64VectorTests(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = new double[a.length];
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Double64VectorTests::gatherMasked);
|
||||
}
|
||||
|
||||
static double[] scatter(double a[], int ix, int[] b, int iy) {
|
||||
double[] res = new double[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = a[i + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "doubleUnaryOpIndexProvider")
|
||||
static void scatterDouble64VectorTests(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = new double[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Double64VectorTests::scatter);
|
||||
}
|
||||
|
||||
static double[] scatterMasked(double r[], double a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
// First, gather r.
|
||||
double[] oldVal = gather(r, ix, b, iy);
|
||||
double[] newVal = new double[SPECIES.length()];
|
||||
|
||||
// Second, blending it with a.
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
newVal[i] = blend(oldVal[i], a[i+ix], mask[i]);
|
||||
}
|
||||
|
||||
// Third, scatter: copy old value of r, and scatter it manually.
|
||||
double[] res = Arrays.copyOfRange(r, ix, ix+SPECIES.length());
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = newVal[i];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "scatterMaskedOpIndexProvider")
|
||||
static void scatterMaskedDouble64VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = fb.apply(SPECIES.length());
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Double64VectorTests::scatterMasked);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "doubleCompareOpProvider")
|
||||
static void ltDouble64VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
|
||||
|
||||
@ -47,6 +47,7 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.DoubleBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.*;
|
||||
|
||||
@ -55,7 +56,7 @@ public class DoubleMaxVectorLoadStoreTests extends AbstractVectorTest {
|
||||
static final VectorSpecies<Double> SPECIES =
|
||||
DoubleVector.SPECIES_MAX;
|
||||
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 10);
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
static VectorShape getMaxBit() {
|
||||
return VectorShape.S_Max_BIT;
|
||||
@ -65,8 +66,6 @@ public class DoubleMaxVectorLoadStoreTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (Max / 8));
|
||||
|
||||
static void assertArraysEquals(double[] r, double[] a, boolean[] mask) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -198,25 +197,6 @@ public class DoubleMaxVectorLoadStoreTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] doubleIndexMapProvider() {
|
||||
return INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> DOUBLE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] doubleIndexMapMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> DOUBLE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim, fm};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] doubleByteBufferProvider() {
|
||||
return DOUBLE_GENERATORS.stream().
|
||||
@ -971,4 +951,156 @@ public class DoubleMaxVectorLoadStoreTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Gather/Scatter load/store tests
|
||||
|
||||
static void assertGatherArraysEquals(double[] r, double[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(double[] r, double[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (double) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (double) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(double[] r, double[] a, int[] indexMap, boolean[] mask) {
|
||||
double[] expected = new double[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(double[] r, double[] a, int[] indexMap) {
|
||||
double[] expected = new double[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> DOUBLE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
DOUBLE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void gather(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = new double[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void gatherMask(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = new double[a.length];
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void scatter(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = new double[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void scatterMask(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = new double[a.length];
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -67,8 +67,6 @@ public class DoubleMaxVectorTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (Max / 8));
|
||||
|
||||
interface FUnOp {
|
||||
double apply(double a);
|
||||
}
|
||||
@ -1145,36 +1143,6 @@ public class DoubleMaxVectorTests extends AbstractVectorTest {
|
||||
}
|
||||
|
||||
|
||||
@DataProvider
|
||||
public Object[][] doubleUnaryOpIndexProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> DOUBLE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] doubleUnaryMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
DOUBLE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] scatterMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
DOUBLE_GENERATORS.stream().flatMap(fn ->
|
||||
DOUBLE_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fn, fm, fs};
|
||||
})))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
static final List<IntFunction<double[]>> DOUBLE_COMPARE_GENERATORS = List.of(
|
||||
withToString("double[i]", (int s) -> {
|
||||
return fill(s * BUFFER_REPS,
|
||||
@ -4499,122 +4467,6 @@ public class DoubleMaxVectorTests extends AbstractVectorTest {
|
||||
assertArraysEquals(r, a, mask, DoubleMaxVectorTests::SQRT);
|
||||
}
|
||||
|
||||
static double[] gather(double a[], int ix, int[] b, int iy) {
|
||||
double[] res = new double[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "doubleUnaryOpIndexProvider")
|
||||
static void gatherDoubleMaxVectorTests(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = new double[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, DoubleMaxVectorTests::gather);
|
||||
}
|
||||
static double[] gatherMasked(double a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
double[] res = new double[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
if (mask[i]) {
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "doubleUnaryMaskedOpIndexProvider")
|
||||
static void gatherMaskedDoubleMaxVectorTests(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = new double[a.length];
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::gatherMasked);
|
||||
}
|
||||
|
||||
static double[] scatter(double a[], int ix, int[] b, int iy) {
|
||||
double[] res = new double[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = a[i + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "doubleUnaryOpIndexProvider")
|
||||
static void scatterDoubleMaxVectorTests(IntFunction<double[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = new double[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, DoubleMaxVectorTests::scatter);
|
||||
}
|
||||
|
||||
static double[] scatterMasked(double r[], double a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
// First, gather r.
|
||||
double[] oldVal = gather(r, ix, b, iy);
|
||||
double[] newVal = new double[SPECIES.length()];
|
||||
|
||||
// Second, blending it with a.
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
newVal[i] = blend(oldVal[i], a[i+ix], mask[i]);
|
||||
}
|
||||
|
||||
// Third, scatter: copy old value of r, and scatter it manually.
|
||||
double[] res = Arrays.copyOfRange(r, ix, ix+SPECIES.length());
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = newVal[i];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "scatterMaskedOpIndexProvider")
|
||||
static void scatterMaskedDoubleMaxVectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
double[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
double[] r = fb.apply(SPECIES.length());
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, DoubleMaxVectorTests::scatterMasked);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "doubleCompareOpProvider")
|
||||
static void ltDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
|
||||
|
||||
@ -43,6 +43,7 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.*;
|
||||
|
||||
@ -51,13 +52,11 @@ public class Float128VectorLoadStoreTests extends AbstractVectorTest {
|
||||
static final VectorSpecies<Float> SPECIES =
|
||||
FloatVector.SPECIES_128;
|
||||
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 10);
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 128);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (128 / 8));
|
||||
|
||||
static void assertArraysEquals(float[] r, float[] a, boolean[] mask) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -189,25 +188,6 @@ public class Float128VectorLoadStoreTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] floatIndexMapProvider() {
|
||||
return INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> FLOAT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] floatIndexMapMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> FLOAT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim, fm};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] floatByteBufferProvider() {
|
||||
return FLOAT_GENERATORS.stream().
|
||||
@ -962,4 +942,156 @@ public class Float128VectorLoadStoreTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Gather/Scatter load/store tests
|
||||
|
||||
static void assertGatherArraysEquals(float[] r, float[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(float[] r, float[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (float) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (float) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(float[] r, float[] a, int[] indexMap, boolean[] mask) {
|
||||
float[] expected = new float[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(float[] r, float[] a, int[] indexMap) {
|
||||
float[] expected = new float[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> FLOAT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
FLOAT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void gather(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = new float[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void gatherMask(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = new float[a.length];
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void scatter(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = new float[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void scatterMask(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = new float[a.length];
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -62,8 +62,6 @@ public class Float128VectorTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 128);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (128 / 8));
|
||||
|
||||
interface FUnOp {
|
||||
float apply(float a);
|
||||
}
|
||||
@ -1150,36 +1148,6 @@ public class Float128VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
|
||||
|
||||
@DataProvider
|
||||
public Object[][] floatUnaryOpIndexProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> FLOAT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] floatUnaryMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
FLOAT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] scatterMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
FLOAT_GENERATORS.stream().flatMap(fn ->
|
||||
FLOAT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fn, fm, fs};
|
||||
})))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
static final List<IntFunction<float[]>> FLOAT_COMPARE_GENERATORS = List.of(
|
||||
withToString("float[i]", (int s) -> {
|
||||
return fill(s * BUFFER_REPS,
|
||||
@ -4462,122 +4430,6 @@ public class Float128VectorTests extends AbstractVectorTest {
|
||||
assertArraysEquals(r, a, mask, Float128VectorTests::SQRT);
|
||||
}
|
||||
|
||||
static float[] gather(float a[], int ix, int[] b, int iy) {
|
||||
float[] res = new float[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "floatUnaryOpIndexProvider")
|
||||
static void gatherFloat128VectorTests(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = new float[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Float128VectorTests::gather);
|
||||
}
|
||||
static float[] gatherMasked(float a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
float[] res = new float[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
if (mask[i]) {
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "floatUnaryMaskedOpIndexProvider")
|
||||
static void gatherMaskedFloat128VectorTests(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = new float[a.length];
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Float128VectorTests::gatherMasked);
|
||||
}
|
||||
|
||||
static float[] scatter(float a[], int ix, int[] b, int iy) {
|
||||
float[] res = new float[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = a[i + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "floatUnaryOpIndexProvider")
|
||||
static void scatterFloat128VectorTests(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = new float[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Float128VectorTests::scatter);
|
||||
}
|
||||
|
||||
static float[] scatterMasked(float r[], float a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
// First, gather r.
|
||||
float[] oldVal = gather(r, ix, b, iy);
|
||||
float[] newVal = new float[SPECIES.length()];
|
||||
|
||||
// Second, blending it with a.
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
newVal[i] = blend(oldVal[i], a[i+ix], mask[i]);
|
||||
}
|
||||
|
||||
// Third, scatter: copy old value of r, and scatter it manually.
|
||||
float[] res = Arrays.copyOfRange(r, ix, ix+SPECIES.length());
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = newVal[i];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "scatterMaskedOpIndexProvider")
|
||||
static void scatterMaskedFloat128VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = fb.apply(SPECIES.length());
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Float128VectorTests::scatterMasked);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "floatCompareOpProvider")
|
||||
static void ltFloat128VectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) {
|
||||
|
||||
@ -43,6 +43,7 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.*;
|
||||
|
||||
@ -51,13 +52,11 @@ public class Float256VectorLoadStoreTests extends AbstractVectorTest {
|
||||
static final VectorSpecies<Float> SPECIES =
|
||||
FloatVector.SPECIES_256;
|
||||
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 10);
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 256);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (256 / 8));
|
||||
|
||||
static void assertArraysEquals(float[] r, float[] a, boolean[] mask) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -189,25 +188,6 @@ public class Float256VectorLoadStoreTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] floatIndexMapProvider() {
|
||||
return INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> FLOAT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] floatIndexMapMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> FLOAT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim, fm};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] floatByteBufferProvider() {
|
||||
return FLOAT_GENERATORS.stream().
|
||||
@ -962,4 +942,156 @@ public class Float256VectorLoadStoreTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Gather/Scatter load/store tests
|
||||
|
||||
static void assertGatherArraysEquals(float[] r, float[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(float[] r, float[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (float) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (float) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(float[] r, float[] a, int[] indexMap, boolean[] mask) {
|
||||
float[] expected = new float[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(float[] r, float[] a, int[] indexMap) {
|
||||
float[] expected = new float[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> FLOAT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
FLOAT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void gather(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = new float[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void gatherMask(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = new float[a.length];
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void scatter(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = new float[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void scatterMask(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = new float[a.length];
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -62,8 +62,6 @@ public class Float256VectorTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 256);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (256 / 8));
|
||||
|
||||
interface FUnOp {
|
||||
float apply(float a);
|
||||
}
|
||||
@ -1150,36 +1148,6 @@ public class Float256VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
|
||||
|
||||
@DataProvider
|
||||
public Object[][] floatUnaryOpIndexProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> FLOAT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] floatUnaryMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
FLOAT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] scatterMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
FLOAT_GENERATORS.stream().flatMap(fn ->
|
||||
FLOAT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fn, fm, fs};
|
||||
})))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
static final List<IntFunction<float[]>> FLOAT_COMPARE_GENERATORS = List.of(
|
||||
withToString("float[i]", (int s) -> {
|
||||
return fill(s * BUFFER_REPS,
|
||||
@ -4462,122 +4430,6 @@ public class Float256VectorTests extends AbstractVectorTest {
|
||||
assertArraysEquals(r, a, mask, Float256VectorTests::SQRT);
|
||||
}
|
||||
|
||||
static float[] gather(float a[], int ix, int[] b, int iy) {
|
||||
float[] res = new float[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "floatUnaryOpIndexProvider")
|
||||
static void gatherFloat256VectorTests(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = new float[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Float256VectorTests::gather);
|
||||
}
|
||||
static float[] gatherMasked(float a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
float[] res = new float[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
if (mask[i]) {
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "floatUnaryMaskedOpIndexProvider")
|
||||
static void gatherMaskedFloat256VectorTests(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = new float[a.length];
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Float256VectorTests::gatherMasked);
|
||||
}
|
||||
|
||||
static float[] scatter(float a[], int ix, int[] b, int iy) {
|
||||
float[] res = new float[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = a[i + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "floatUnaryOpIndexProvider")
|
||||
static void scatterFloat256VectorTests(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = new float[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Float256VectorTests::scatter);
|
||||
}
|
||||
|
||||
static float[] scatterMasked(float r[], float a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
// First, gather r.
|
||||
float[] oldVal = gather(r, ix, b, iy);
|
||||
float[] newVal = new float[SPECIES.length()];
|
||||
|
||||
// Second, blending it with a.
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
newVal[i] = blend(oldVal[i], a[i+ix], mask[i]);
|
||||
}
|
||||
|
||||
// Third, scatter: copy old value of r, and scatter it manually.
|
||||
float[] res = Arrays.copyOfRange(r, ix, ix+SPECIES.length());
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = newVal[i];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "scatterMaskedOpIndexProvider")
|
||||
static void scatterMaskedFloat256VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = fb.apply(SPECIES.length());
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Float256VectorTests::scatterMasked);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "floatCompareOpProvider")
|
||||
static void ltFloat256VectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) {
|
||||
|
||||
@ -43,6 +43,7 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.*;
|
||||
|
||||
@ -51,13 +52,11 @@ public class Float512VectorLoadStoreTests extends AbstractVectorTest {
|
||||
static final VectorSpecies<Float> SPECIES =
|
||||
FloatVector.SPECIES_512;
|
||||
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 10);
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 512);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (512 / 8));
|
||||
|
||||
static void assertArraysEquals(float[] r, float[] a, boolean[] mask) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -189,25 +188,6 @@ public class Float512VectorLoadStoreTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] floatIndexMapProvider() {
|
||||
return INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> FLOAT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] floatIndexMapMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> FLOAT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim, fm};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] floatByteBufferProvider() {
|
||||
return FLOAT_GENERATORS.stream().
|
||||
@ -962,4 +942,156 @@ public class Float512VectorLoadStoreTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Gather/Scatter load/store tests
|
||||
|
||||
static void assertGatherArraysEquals(float[] r, float[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(float[] r, float[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (float) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (float) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(float[] r, float[] a, int[] indexMap, boolean[] mask) {
|
||||
float[] expected = new float[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(float[] r, float[] a, int[] indexMap) {
|
||||
float[] expected = new float[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> FLOAT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
FLOAT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void gather(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = new float[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void gatherMask(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = new float[a.length];
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void scatter(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = new float[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void scatterMask(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = new float[a.length];
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -62,8 +62,6 @@ public class Float512VectorTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 512);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (512 / 8));
|
||||
|
||||
interface FUnOp {
|
||||
float apply(float a);
|
||||
}
|
||||
@ -1150,36 +1148,6 @@ public class Float512VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
|
||||
|
||||
@DataProvider
|
||||
public Object[][] floatUnaryOpIndexProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> FLOAT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] floatUnaryMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
FLOAT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] scatterMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
FLOAT_GENERATORS.stream().flatMap(fn ->
|
||||
FLOAT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fn, fm, fs};
|
||||
})))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
static final List<IntFunction<float[]>> FLOAT_COMPARE_GENERATORS = List.of(
|
||||
withToString("float[i]", (int s) -> {
|
||||
return fill(s * BUFFER_REPS,
|
||||
@ -4462,122 +4430,6 @@ public class Float512VectorTests extends AbstractVectorTest {
|
||||
assertArraysEquals(r, a, mask, Float512VectorTests::SQRT);
|
||||
}
|
||||
|
||||
static float[] gather(float a[], int ix, int[] b, int iy) {
|
||||
float[] res = new float[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "floatUnaryOpIndexProvider")
|
||||
static void gatherFloat512VectorTests(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = new float[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Float512VectorTests::gather);
|
||||
}
|
||||
static float[] gatherMasked(float a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
float[] res = new float[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
if (mask[i]) {
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "floatUnaryMaskedOpIndexProvider")
|
||||
static void gatherMaskedFloat512VectorTests(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = new float[a.length];
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Float512VectorTests::gatherMasked);
|
||||
}
|
||||
|
||||
static float[] scatter(float a[], int ix, int[] b, int iy) {
|
||||
float[] res = new float[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = a[i + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "floatUnaryOpIndexProvider")
|
||||
static void scatterFloat512VectorTests(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = new float[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Float512VectorTests::scatter);
|
||||
}
|
||||
|
||||
static float[] scatterMasked(float r[], float a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
// First, gather r.
|
||||
float[] oldVal = gather(r, ix, b, iy);
|
||||
float[] newVal = new float[SPECIES.length()];
|
||||
|
||||
// Second, blending it with a.
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
newVal[i] = blend(oldVal[i], a[i+ix], mask[i]);
|
||||
}
|
||||
|
||||
// Third, scatter: copy old value of r, and scatter it manually.
|
||||
float[] res = Arrays.copyOfRange(r, ix, ix+SPECIES.length());
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = newVal[i];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "scatterMaskedOpIndexProvider")
|
||||
static void scatterMaskedFloat512VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = fb.apply(SPECIES.length());
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Float512VectorTests::scatterMasked);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "floatCompareOpProvider")
|
||||
static void ltFloat512VectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) {
|
||||
|
||||
@ -43,6 +43,7 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.*;
|
||||
|
||||
@ -51,13 +52,11 @@ public class Float64VectorLoadStoreTests extends AbstractVectorTest {
|
||||
static final VectorSpecies<Float> SPECIES =
|
||||
FloatVector.SPECIES_64;
|
||||
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 10);
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 64);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (64 / 8));
|
||||
|
||||
static void assertArraysEquals(float[] r, float[] a, boolean[] mask) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -189,25 +188,6 @@ public class Float64VectorLoadStoreTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] floatIndexMapProvider() {
|
||||
return INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> FLOAT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] floatIndexMapMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> FLOAT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim, fm};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] floatByteBufferProvider() {
|
||||
return FLOAT_GENERATORS.stream().
|
||||
@ -962,4 +942,156 @@ public class Float64VectorLoadStoreTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Gather/Scatter load/store tests
|
||||
|
||||
static void assertGatherArraysEquals(float[] r, float[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(float[] r, float[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (float) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (float) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(float[] r, float[] a, int[] indexMap, boolean[] mask) {
|
||||
float[] expected = new float[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(float[] r, float[] a, int[] indexMap) {
|
||||
float[] expected = new float[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> FLOAT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
FLOAT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void gather(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = new float[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void gatherMask(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = new float[a.length];
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void scatter(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = new float[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void scatterMask(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = new float[a.length];
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -62,8 +62,6 @@ public class Float64VectorTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 64);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (64 / 8));
|
||||
|
||||
interface FUnOp {
|
||||
float apply(float a);
|
||||
}
|
||||
@ -1150,36 +1148,6 @@ public class Float64VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
|
||||
|
||||
@DataProvider
|
||||
public Object[][] floatUnaryOpIndexProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> FLOAT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] floatUnaryMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
FLOAT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] scatterMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
FLOAT_GENERATORS.stream().flatMap(fn ->
|
||||
FLOAT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fn, fm, fs};
|
||||
})))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
static final List<IntFunction<float[]>> FLOAT_COMPARE_GENERATORS = List.of(
|
||||
withToString("float[i]", (int s) -> {
|
||||
return fill(s * BUFFER_REPS,
|
||||
@ -4462,122 +4430,6 @@ public class Float64VectorTests extends AbstractVectorTest {
|
||||
assertArraysEquals(r, a, mask, Float64VectorTests::SQRT);
|
||||
}
|
||||
|
||||
static float[] gather(float a[], int ix, int[] b, int iy) {
|
||||
float[] res = new float[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "floatUnaryOpIndexProvider")
|
||||
static void gatherFloat64VectorTests(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = new float[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Float64VectorTests::gather);
|
||||
}
|
||||
static float[] gatherMasked(float a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
float[] res = new float[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
if (mask[i]) {
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "floatUnaryMaskedOpIndexProvider")
|
||||
static void gatherMaskedFloat64VectorTests(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = new float[a.length];
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Float64VectorTests::gatherMasked);
|
||||
}
|
||||
|
||||
static float[] scatter(float a[], int ix, int[] b, int iy) {
|
||||
float[] res = new float[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = a[i + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "floatUnaryOpIndexProvider")
|
||||
static void scatterFloat64VectorTests(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = new float[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Float64VectorTests::scatter);
|
||||
}
|
||||
|
||||
static float[] scatterMasked(float r[], float a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
// First, gather r.
|
||||
float[] oldVal = gather(r, ix, b, iy);
|
||||
float[] newVal = new float[SPECIES.length()];
|
||||
|
||||
// Second, blending it with a.
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
newVal[i] = blend(oldVal[i], a[i+ix], mask[i]);
|
||||
}
|
||||
|
||||
// Third, scatter: copy old value of r, and scatter it manually.
|
||||
float[] res = Arrays.copyOfRange(r, ix, ix+SPECIES.length());
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = newVal[i];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "scatterMaskedOpIndexProvider")
|
||||
static void scatterMaskedFloat64VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = fb.apply(SPECIES.length());
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Float64VectorTests::scatterMasked);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "floatCompareOpProvider")
|
||||
static void ltFloat64VectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) {
|
||||
|
||||
@ -47,6 +47,7 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.*;
|
||||
|
||||
@ -55,7 +56,7 @@ public class FloatMaxVectorLoadStoreTests extends AbstractVectorTest {
|
||||
static final VectorSpecies<Float> SPECIES =
|
||||
FloatVector.SPECIES_MAX;
|
||||
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 10);
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
static VectorShape getMaxBit() {
|
||||
return VectorShape.S_Max_BIT;
|
||||
@ -65,8 +66,6 @@ public class FloatMaxVectorLoadStoreTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (Max / 8));
|
||||
|
||||
static void assertArraysEquals(float[] r, float[] a, boolean[] mask) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -198,25 +197,6 @@ public class FloatMaxVectorLoadStoreTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] floatIndexMapProvider() {
|
||||
return INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> FLOAT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] floatIndexMapMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> FLOAT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim, fm};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] floatByteBufferProvider() {
|
||||
return FLOAT_GENERATORS.stream().
|
||||
@ -971,4 +951,156 @@ public class FloatMaxVectorLoadStoreTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Gather/Scatter load/store tests
|
||||
|
||||
static void assertGatherArraysEquals(float[] r, float[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(float[] r, float[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (float) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (float) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(float[] r, float[] a, int[] indexMap, boolean[] mask) {
|
||||
float[] expected = new float[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(float[] r, float[] a, int[] indexMap) {
|
||||
float[] expected = new float[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> FLOAT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
FLOAT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void gather(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = new float[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void gatherMask(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = new float[a.length];
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void scatter(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = new float[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void scatterMask(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = new float[a.length];
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -67,8 +67,6 @@ public class FloatMaxVectorTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (Max / 8));
|
||||
|
||||
interface FUnOp {
|
||||
float apply(float a);
|
||||
}
|
||||
@ -1155,36 +1153,6 @@ public class FloatMaxVectorTests extends AbstractVectorTest {
|
||||
}
|
||||
|
||||
|
||||
@DataProvider
|
||||
public Object[][] floatUnaryOpIndexProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> FLOAT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] floatUnaryMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
FLOAT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] scatterMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
FLOAT_GENERATORS.stream().flatMap(fn ->
|
||||
FLOAT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fn, fm, fs};
|
||||
})))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
static final List<IntFunction<float[]>> FLOAT_COMPARE_GENERATORS = List.of(
|
||||
withToString("float[i]", (int s) -> {
|
||||
return fill(s * BUFFER_REPS,
|
||||
@ -4467,122 +4435,6 @@ public class FloatMaxVectorTests extends AbstractVectorTest {
|
||||
assertArraysEquals(r, a, mask, FloatMaxVectorTests::SQRT);
|
||||
}
|
||||
|
||||
static float[] gather(float a[], int ix, int[] b, int iy) {
|
||||
float[] res = new float[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "floatUnaryOpIndexProvider")
|
||||
static void gatherFloatMaxVectorTests(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = new float[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, FloatMaxVectorTests::gather);
|
||||
}
|
||||
static float[] gatherMasked(float a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
float[] res = new float[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
if (mask[i]) {
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "floatUnaryMaskedOpIndexProvider")
|
||||
static void gatherMaskedFloatMaxVectorTests(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = new float[a.length];
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, FloatMaxVectorTests::gatherMasked);
|
||||
}
|
||||
|
||||
static float[] scatter(float a[], int ix, int[] b, int iy) {
|
||||
float[] res = new float[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = a[i + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "floatUnaryOpIndexProvider")
|
||||
static void scatterFloatMaxVectorTests(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = new float[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, FloatMaxVectorTests::scatter);
|
||||
}
|
||||
|
||||
static float[] scatterMasked(float r[], float a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
// First, gather r.
|
||||
float[] oldVal = gather(r, ix, b, iy);
|
||||
float[] newVal = new float[SPECIES.length()];
|
||||
|
||||
// Second, blending it with a.
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
newVal[i] = blend(oldVal[i], a[i+ix], mask[i]);
|
||||
}
|
||||
|
||||
// Third, scatter: copy old value of r, and scatter it manually.
|
||||
float[] res = Arrays.copyOfRange(r, ix, ix+SPECIES.length());
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = newVal[i];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "scatterMaskedOpIndexProvider")
|
||||
static void scatterMaskedFloatMaxVectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
float[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
float[] r = fb.apply(SPECIES.length());
|
||||
boolean[] mask = fm.apply(SPECIES.length());
|
||||
VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
|
||||
av.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, FloatMaxVectorTests::scatterMasked);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "floatCompareOpProvider")
|
||||
static void ltFloatMaxVectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) {
|
||||
|
||||
@ -43,6 +43,7 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.*;
|
||||
|
||||
@ -51,13 +52,11 @@ public class Int128VectorLoadStoreTests extends AbstractVectorTest {
|
||||
static final VectorSpecies<Integer> SPECIES =
|
||||
IntVector.SPECIES_128;
|
||||
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 10);
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 128);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (128 / 8));
|
||||
|
||||
static void assertArraysEquals(int[] r, int[] a, boolean[] mask) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -189,25 +188,6 @@ public class Int128VectorLoadStoreTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intIndexMapProvider() {
|
||||
return INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> INT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intIndexMapMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> INT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim, fm};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intByteBufferProvider() {
|
||||
return INT_GENERATORS.stream().
|
||||
@ -962,4 +942,156 @@ public class Int128VectorLoadStoreTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Gather/Scatter load/store tests
|
||||
|
||||
static void assertGatherArraysEquals(int[] r, int[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(int[] r, int[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (int) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (int) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(int[] r, int[] a, int[] indexMap, boolean[] mask) {
|
||||
int[] expected = new int[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(int[] r, int[] a, int[] indexMap) {
|
||||
int[] expected = new int[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> INT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
INT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void gather(IntFunction<int[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = new int[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void gatherMask(IntFunction<int[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = new int[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void scatter(IntFunction<int[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = new int[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void scatterMask(IntFunction<int[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = new int[a.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -62,8 +62,6 @@ public class Int128VectorTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 128);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (128 / 8));
|
||||
|
||||
interface FUnOp {
|
||||
int apply(int a);
|
||||
}
|
||||
@ -968,36 +966,6 @@ public class Int128VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intUnaryOpIndexProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> INT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intUnaryMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
INT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] scatterMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
INT_GENERATORS.stream().flatMap(fn ->
|
||||
INT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fn, fm, fs};
|
||||
})))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
static final List<IntFunction<int[]>> INT_COMPARE_GENERATORS = List.of(
|
||||
withToString("int[i]", (int s) -> {
|
||||
return fill(s * BUFFER_REPS,
|
||||
@ -4887,122 +4855,6 @@ public class Int128VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
static int[] gather(int a[], int ix, int[] b, int iy) {
|
||||
int[] res = new int[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryOpIndexProvider")
|
||||
static void gatherInt128VectorTests(IntFunction<int[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = new int[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Int128VectorTests::gather);
|
||||
}
|
||||
static int[] gatherMasked(int a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
int[] res = new int[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
if (mask[i]) {
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryMaskedOpIndexProvider")
|
||||
static void gatherMaskedInt128VectorTests(IntFunction<int[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = new int[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Int128VectorTests::gatherMasked);
|
||||
}
|
||||
|
||||
static int[] scatter(int a[], int ix, int[] b, int iy) {
|
||||
int[] res = new int[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = a[i + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryOpIndexProvider")
|
||||
static void scatterInt128VectorTests(IntFunction<int[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = new int[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Int128VectorTests::scatter);
|
||||
}
|
||||
|
||||
static int[] scatterMasked(int r[], int a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
// First, gather r.
|
||||
int[] oldVal = gather(r, ix, b, iy);
|
||||
int[] newVal = new int[SPECIES.length()];
|
||||
|
||||
// Second, blending it with a.
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
newVal[i] = blend(oldVal[i], a[i+ix], mask[i]);
|
||||
}
|
||||
|
||||
// Third, scatter: copy old value of r, and scatter it manually.
|
||||
int[] res = Arrays.copyOfRange(r, ix, ix+SPECIES.length());
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = newVal[i];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "scatterMaskedOpIndexProvider")
|
||||
static void scatterMaskedInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = fb.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Int128VectorTests::scatterMasked);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "intCompareOpProvider")
|
||||
static void ltInt128VectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
|
||||
|
||||
@ -43,6 +43,7 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.*;
|
||||
|
||||
@ -51,13 +52,11 @@ public class Int256VectorLoadStoreTests extends AbstractVectorTest {
|
||||
static final VectorSpecies<Integer> SPECIES =
|
||||
IntVector.SPECIES_256;
|
||||
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 10);
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 256);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (256 / 8));
|
||||
|
||||
static void assertArraysEquals(int[] r, int[] a, boolean[] mask) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -189,25 +188,6 @@ public class Int256VectorLoadStoreTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intIndexMapProvider() {
|
||||
return INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> INT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intIndexMapMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> INT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim, fm};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intByteBufferProvider() {
|
||||
return INT_GENERATORS.stream().
|
||||
@ -962,4 +942,156 @@ public class Int256VectorLoadStoreTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Gather/Scatter load/store tests
|
||||
|
||||
static void assertGatherArraysEquals(int[] r, int[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(int[] r, int[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (int) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (int) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(int[] r, int[] a, int[] indexMap, boolean[] mask) {
|
||||
int[] expected = new int[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(int[] r, int[] a, int[] indexMap) {
|
||||
int[] expected = new int[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> INT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
INT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void gather(IntFunction<int[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = new int[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void gatherMask(IntFunction<int[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = new int[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void scatter(IntFunction<int[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = new int[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void scatterMask(IntFunction<int[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = new int[a.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -62,8 +62,6 @@ public class Int256VectorTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 256);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (256 / 8));
|
||||
|
||||
interface FUnOp {
|
||||
int apply(int a);
|
||||
}
|
||||
@ -968,36 +966,6 @@ public class Int256VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intUnaryOpIndexProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> INT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intUnaryMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
INT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] scatterMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
INT_GENERATORS.stream().flatMap(fn ->
|
||||
INT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fn, fm, fs};
|
||||
})))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
static final List<IntFunction<int[]>> INT_COMPARE_GENERATORS = List.of(
|
||||
withToString("int[i]", (int s) -> {
|
||||
return fill(s * BUFFER_REPS,
|
||||
@ -4887,122 +4855,6 @@ public class Int256VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
static int[] gather(int a[], int ix, int[] b, int iy) {
|
||||
int[] res = new int[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryOpIndexProvider")
|
||||
static void gatherInt256VectorTests(IntFunction<int[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = new int[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Int256VectorTests::gather);
|
||||
}
|
||||
static int[] gatherMasked(int a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
int[] res = new int[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
if (mask[i]) {
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryMaskedOpIndexProvider")
|
||||
static void gatherMaskedInt256VectorTests(IntFunction<int[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = new int[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Int256VectorTests::gatherMasked);
|
||||
}
|
||||
|
||||
static int[] scatter(int a[], int ix, int[] b, int iy) {
|
||||
int[] res = new int[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = a[i + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryOpIndexProvider")
|
||||
static void scatterInt256VectorTests(IntFunction<int[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = new int[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Int256VectorTests::scatter);
|
||||
}
|
||||
|
||||
static int[] scatterMasked(int r[], int a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
// First, gather r.
|
||||
int[] oldVal = gather(r, ix, b, iy);
|
||||
int[] newVal = new int[SPECIES.length()];
|
||||
|
||||
// Second, blending it with a.
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
newVal[i] = blend(oldVal[i], a[i+ix], mask[i]);
|
||||
}
|
||||
|
||||
// Third, scatter: copy old value of r, and scatter it manually.
|
||||
int[] res = Arrays.copyOfRange(r, ix, ix+SPECIES.length());
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = newVal[i];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "scatterMaskedOpIndexProvider")
|
||||
static void scatterMaskedInt256VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = fb.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Int256VectorTests::scatterMasked);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "intCompareOpProvider")
|
||||
static void ltInt256VectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
|
||||
|
||||
@ -43,6 +43,7 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.*;
|
||||
|
||||
@ -51,13 +52,11 @@ public class Int512VectorLoadStoreTests extends AbstractVectorTest {
|
||||
static final VectorSpecies<Integer> SPECIES =
|
||||
IntVector.SPECIES_512;
|
||||
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 10);
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 512);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (512 / 8));
|
||||
|
||||
static void assertArraysEquals(int[] r, int[] a, boolean[] mask) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -189,25 +188,6 @@ public class Int512VectorLoadStoreTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intIndexMapProvider() {
|
||||
return INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> INT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intIndexMapMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> INT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim, fm};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intByteBufferProvider() {
|
||||
return INT_GENERATORS.stream().
|
||||
@ -962,4 +942,156 @@ public class Int512VectorLoadStoreTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Gather/Scatter load/store tests
|
||||
|
||||
static void assertGatherArraysEquals(int[] r, int[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(int[] r, int[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (int) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (int) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(int[] r, int[] a, int[] indexMap, boolean[] mask) {
|
||||
int[] expected = new int[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(int[] r, int[] a, int[] indexMap) {
|
||||
int[] expected = new int[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> INT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
INT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void gather(IntFunction<int[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = new int[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void gatherMask(IntFunction<int[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = new int[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void scatter(IntFunction<int[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = new int[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void scatterMask(IntFunction<int[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = new int[a.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -62,8 +62,6 @@ public class Int512VectorTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 512);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (512 / 8));
|
||||
|
||||
interface FUnOp {
|
||||
int apply(int a);
|
||||
}
|
||||
@ -968,36 +966,6 @@ public class Int512VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intUnaryOpIndexProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> INT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intUnaryMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
INT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] scatterMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
INT_GENERATORS.stream().flatMap(fn ->
|
||||
INT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fn, fm, fs};
|
||||
})))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
static final List<IntFunction<int[]>> INT_COMPARE_GENERATORS = List.of(
|
||||
withToString("int[i]", (int s) -> {
|
||||
return fill(s * BUFFER_REPS,
|
||||
@ -4887,122 +4855,6 @@ public class Int512VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
static int[] gather(int a[], int ix, int[] b, int iy) {
|
||||
int[] res = new int[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryOpIndexProvider")
|
||||
static void gatherInt512VectorTests(IntFunction<int[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = new int[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Int512VectorTests::gather);
|
||||
}
|
||||
static int[] gatherMasked(int a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
int[] res = new int[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
if (mask[i]) {
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryMaskedOpIndexProvider")
|
||||
static void gatherMaskedInt512VectorTests(IntFunction<int[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = new int[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Int512VectorTests::gatherMasked);
|
||||
}
|
||||
|
||||
static int[] scatter(int a[], int ix, int[] b, int iy) {
|
||||
int[] res = new int[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = a[i + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryOpIndexProvider")
|
||||
static void scatterInt512VectorTests(IntFunction<int[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = new int[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Int512VectorTests::scatter);
|
||||
}
|
||||
|
||||
static int[] scatterMasked(int r[], int a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
// First, gather r.
|
||||
int[] oldVal = gather(r, ix, b, iy);
|
||||
int[] newVal = new int[SPECIES.length()];
|
||||
|
||||
// Second, blending it with a.
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
newVal[i] = blend(oldVal[i], a[i+ix], mask[i]);
|
||||
}
|
||||
|
||||
// Third, scatter: copy old value of r, and scatter it manually.
|
||||
int[] res = Arrays.copyOfRange(r, ix, ix+SPECIES.length());
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = newVal[i];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "scatterMaskedOpIndexProvider")
|
||||
static void scatterMaskedInt512VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = fb.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Int512VectorTests::scatterMasked);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "intCompareOpProvider")
|
||||
static void ltInt512VectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
|
||||
|
||||
@ -43,6 +43,7 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.*;
|
||||
|
||||
@ -51,13 +52,11 @@ public class Int64VectorLoadStoreTests extends AbstractVectorTest {
|
||||
static final VectorSpecies<Integer> SPECIES =
|
||||
IntVector.SPECIES_64;
|
||||
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 10);
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 64);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (64 / 8));
|
||||
|
||||
static void assertArraysEquals(int[] r, int[] a, boolean[] mask) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -189,25 +188,6 @@ public class Int64VectorLoadStoreTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intIndexMapProvider() {
|
||||
return INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> INT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intIndexMapMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> INT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim, fm};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intByteBufferProvider() {
|
||||
return INT_GENERATORS.stream().
|
||||
@ -962,4 +942,156 @@ public class Int64VectorLoadStoreTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Gather/Scatter load/store tests
|
||||
|
||||
static void assertGatherArraysEquals(int[] r, int[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(int[] r, int[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (int) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (int) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(int[] r, int[] a, int[] indexMap, boolean[] mask) {
|
||||
int[] expected = new int[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(int[] r, int[] a, int[] indexMap) {
|
||||
int[] expected = new int[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> INT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
INT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void gather(IntFunction<int[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = new int[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void gatherMask(IntFunction<int[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = new int[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void scatter(IntFunction<int[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = new int[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void scatterMask(IntFunction<int[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = new int[a.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -62,8 +62,6 @@ public class Int64VectorTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 64);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (64 / 8));
|
||||
|
||||
interface FUnOp {
|
||||
int apply(int a);
|
||||
}
|
||||
@ -968,36 +966,6 @@ public class Int64VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intUnaryOpIndexProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> INT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intUnaryMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
INT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] scatterMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
INT_GENERATORS.stream().flatMap(fn ->
|
||||
INT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fn, fm, fs};
|
||||
})))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
static final List<IntFunction<int[]>> INT_COMPARE_GENERATORS = List.of(
|
||||
withToString("int[i]", (int s) -> {
|
||||
return fill(s * BUFFER_REPS,
|
||||
@ -4887,122 +4855,6 @@ public class Int64VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
static int[] gather(int a[], int ix, int[] b, int iy) {
|
||||
int[] res = new int[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryOpIndexProvider")
|
||||
static void gatherInt64VectorTests(IntFunction<int[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = new int[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Int64VectorTests::gather);
|
||||
}
|
||||
static int[] gatherMasked(int a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
int[] res = new int[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
if (mask[i]) {
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryMaskedOpIndexProvider")
|
||||
static void gatherMaskedInt64VectorTests(IntFunction<int[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = new int[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Int64VectorTests::gatherMasked);
|
||||
}
|
||||
|
||||
static int[] scatter(int a[], int ix, int[] b, int iy) {
|
||||
int[] res = new int[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = a[i + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryOpIndexProvider")
|
||||
static void scatterInt64VectorTests(IntFunction<int[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = new int[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Int64VectorTests::scatter);
|
||||
}
|
||||
|
||||
static int[] scatterMasked(int r[], int a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
// First, gather r.
|
||||
int[] oldVal = gather(r, ix, b, iy);
|
||||
int[] newVal = new int[SPECIES.length()];
|
||||
|
||||
// Second, blending it with a.
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
newVal[i] = blend(oldVal[i], a[i+ix], mask[i]);
|
||||
}
|
||||
|
||||
// Third, scatter: copy old value of r, and scatter it manually.
|
||||
int[] res = Arrays.copyOfRange(r, ix, ix+SPECIES.length());
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = newVal[i];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "scatterMaskedOpIndexProvider")
|
||||
static void scatterMaskedInt64VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = fb.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Int64VectorTests::scatterMasked);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "intCompareOpProvider")
|
||||
static void ltInt64VectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
|
||||
|
||||
@ -47,6 +47,7 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.*;
|
||||
|
||||
@ -55,7 +56,7 @@ public class IntMaxVectorLoadStoreTests extends AbstractVectorTest {
|
||||
static final VectorSpecies<Integer> SPECIES =
|
||||
IntVector.SPECIES_MAX;
|
||||
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 10);
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
static VectorShape getMaxBit() {
|
||||
return VectorShape.S_Max_BIT;
|
||||
@ -65,8 +66,6 @@ public class IntMaxVectorLoadStoreTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (Max / 8));
|
||||
|
||||
static void assertArraysEquals(int[] r, int[] a, boolean[] mask) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -198,25 +197,6 @@ public class IntMaxVectorLoadStoreTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intIndexMapProvider() {
|
||||
return INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> INT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intIndexMapMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> INT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim, fm};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intByteBufferProvider() {
|
||||
return INT_GENERATORS.stream().
|
||||
@ -971,4 +951,156 @@ public class IntMaxVectorLoadStoreTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Gather/Scatter load/store tests
|
||||
|
||||
static void assertGatherArraysEquals(int[] r, int[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(int[] r, int[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (int) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (int) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(int[] r, int[] a, int[] indexMap, boolean[] mask) {
|
||||
int[] expected = new int[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(int[] r, int[] a, int[] indexMap) {
|
||||
int[] expected = new int[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> INT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
INT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void gather(IntFunction<int[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = new int[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void gatherMask(IntFunction<int[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = new int[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void scatter(IntFunction<int[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = new int[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void scatterMask(IntFunction<int[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = new int[a.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -67,8 +67,6 @@ public class IntMaxVectorTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (Max / 8));
|
||||
|
||||
interface FUnOp {
|
||||
int apply(int a);
|
||||
}
|
||||
@ -973,36 +971,6 @@ public class IntMaxVectorTests extends AbstractVectorTest {
|
||||
}
|
||||
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intUnaryOpIndexProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> INT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] intUnaryMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
INT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] scatterMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
INT_GENERATORS.stream().flatMap(fn ->
|
||||
INT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fn, fm, fs};
|
||||
})))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
static final List<IntFunction<int[]>> INT_COMPARE_GENERATORS = List.of(
|
||||
withToString("int[i]", (int s) -> {
|
||||
return fill(s * BUFFER_REPS,
|
||||
@ -4892,122 +4860,6 @@ public class IntMaxVectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
static int[] gather(int a[], int ix, int[] b, int iy) {
|
||||
int[] res = new int[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryOpIndexProvider")
|
||||
static void gatherIntMaxVectorTests(IntFunction<int[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = new int[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, IntMaxVectorTests::gather);
|
||||
}
|
||||
static int[] gatherMasked(int a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
int[] res = new int[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
if (mask[i]) {
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryMaskedOpIndexProvider")
|
||||
static void gatherMaskedIntMaxVectorTests(IntFunction<int[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = new int[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, IntMaxVectorTests::gatherMasked);
|
||||
}
|
||||
|
||||
static int[] scatter(int a[], int ix, int[] b, int iy) {
|
||||
int[] res = new int[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = a[i + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "intUnaryOpIndexProvider")
|
||||
static void scatterIntMaxVectorTests(IntFunction<int[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = new int[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, IntMaxVectorTests::scatter);
|
||||
}
|
||||
|
||||
static int[] scatterMasked(int r[], int a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
// First, gather r.
|
||||
int[] oldVal = gather(r, ix, b, iy);
|
||||
int[] newVal = new int[SPECIES.length()];
|
||||
|
||||
// Second, blending it with a.
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
newVal[i] = blend(oldVal[i], a[i+ix], mask[i]);
|
||||
}
|
||||
|
||||
// Third, scatter: copy old value of r, and scatter it manually.
|
||||
int[] res = Arrays.copyOfRange(r, ix, ix+SPECIES.length());
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = newVal[i];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "scatterMaskedOpIndexProvider")
|
||||
static void scatterMaskedIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
int[] r = fb.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, IntMaxVectorTests::scatterMasked);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "intCompareOpProvider")
|
||||
static void ltIntMaxVectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
|
||||
|
||||
@ -43,6 +43,7 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.LongBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.*;
|
||||
|
||||
@ -51,13 +52,11 @@ public class Long128VectorLoadStoreTests extends AbstractVectorTest {
|
||||
static final VectorSpecies<Long> SPECIES =
|
||||
LongVector.SPECIES_128;
|
||||
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 10);
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 128);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (128 / 8));
|
||||
|
||||
static void assertArraysEquals(long[] r, long[] a, boolean[] mask) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -189,25 +188,6 @@ public class Long128VectorLoadStoreTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longIndexMapProvider() {
|
||||
return INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> LONG_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longIndexMapMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> LONG_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim, fm};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longByteBufferProvider() {
|
||||
return LONG_GENERATORS.stream().
|
||||
@ -962,4 +942,156 @@ public class Long128VectorLoadStoreTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Gather/Scatter load/store tests
|
||||
|
||||
static void assertGatherArraysEquals(long[] r, long[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(long[] r, long[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (long) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (long) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(long[] r, long[] a, int[] indexMap, boolean[] mask) {
|
||||
long[] expected = new long[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(long[] r, long[] a, int[] indexMap) {
|
||||
long[] expected = new long[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> LONG_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
LONG_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void gather(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = new long[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void gatherMask(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = new long[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void scatter(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = new long[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void scatterMask(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = new long[a.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -62,8 +62,6 @@ public class Long128VectorTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 128);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (128 / 8));
|
||||
|
||||
interface FUnOp {
|
||||
long apply(long a);
|
||||
}
|
||||
@ -994,36 +992,6 @@ public class Long128VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longUnaryOpIndexProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> LONG_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longUnaryMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
LONG_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] scatterMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
LONG_GENERATORS.stream().flatMap(fn ->
|
||||
LONG_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fn, fm, fs};
|
||||
})))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
static final List<IntFunction<long[]>> LONG_COMPARE_GENERATORS = List.of(
|
||||
withToString("long[i]", (int s) -> {
|
||||
return fill(s * BUFFER_REPS,
|
||||
@ -4837,122 +4805,6 @@ public class Long128VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
static long[] gather(long a[], int ix, int[] b, int iy) {
|
||||
long[] res = new long[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryOpIndexProvider")
|
||||
static void gatherLong128VectorTests(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = new long[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Long128VectorTests::gather);
|
||||
}
|
||||
static long[] gatherMasked(long a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
long[] res = new long[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
if (mask[i]) {
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryMaskedOpIndexProvider")
|
||||
static void gatherMaskedLong128VectorTests(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = new long[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Long128VectorTests::gatherMasked);
|
||||
}
|
||||
|
||||
static long[] scatter(long a[], int ix, int[] b, int iy) {
|
||||
long[] res = new long[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = a[i + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryOpIndexProvider")
|
||||
static void scatterLong128VectorTests(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = new long[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Long128VectorTests::scatter);
|
||||
}
|
||||
|
||||
static long[] scatterMasked(long r[], long a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
// First, gather r.
|
||||
long[] oldVal = gather(r, ix, b, iy);
|
||||
long[] newVal = new long[SPECIES.length()];
|
||||
|
||||
// Second, blending it with a.
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
newVal[i] = blend(oldVal[i], a[i+ix], mask[i]);
|
||||
}
|
||||
|
||||
// Third, scatter: copy old value of r, and scatter it manually.
|
||||
long[] res = Arrays.copyOfRange(r, ix, ix+SPECIES.length());
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = newVal[i];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "scatterMaskedOpIndexProvider")
|
||||
static void scatterMaskedLong128VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = fb.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Long128VectorTests::scatterMasked);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "longCompareOpProvider")
|
||||
static void ltLong128VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
|
||||
|
||||
@ -43,6 +43,7 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.LongBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.*;
|
||||
|
||||
@ -51,13 +52,11 @@ public class Long256VectorLoadStoreTests extends AbstractVectorTest {
|
||||
static final VectorSpecies<Long> SPECIES =
|
||||
LongVector.SPECIES_256;
|
||||
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 10);
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 256);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (256 / 8));
|
||||
|
||||
static void assertArraysEquals(long[] r, long[] a, boolean[] mask) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -189,25 +188,6 @@ public class Long256VectorLoadStoreTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longIndexMapProvider() {
|
||||
return INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> LONG_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longIndexMapMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> LONG_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim, fm};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longByteBufferProvider() {
|
||||
return LONG_GENERATORS.stream().
|
||||
@ -962,4 +942,156 @@ public class Long256VectorLoadStoreTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Gather/Scatter load/store tests
|
||||
|
||||
static void assertGatherArraysEquals(long[] r, long[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(long[] r, long[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (long) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (long) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(long[] r, long[] a, int[] indexMap, boolean[] mask) {
|
||||
long[] expected = new long[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(long[] r, long[] a, int[] indexMap) {
|
||||
long[] expected = new long[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> LONG_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
LONG_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void gather(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = new long[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void gatherMask(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = new long[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void scatter(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = new long[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void scatterMask(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = new long[a.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -62,8 +62,6 @@ public class Long256VectorTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 256);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (256 / 8));
|
||||
|
||||
interface FUnOp {
|
||||
long apply(long a);
|
||||
}
|
||||
@ -994,36 +992,6 @@ public class Long256VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longUnaryOpIndexProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> LONG_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longUnaryMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
LONG_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] scatterMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
LONG_GENERATORS.stream().flatMap(fn ->
|
||||
LONG_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fn, fm, fs};
|
||||
})))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
static final List<IntFunction<long[]>> LONG_COMPARE_GENERATORS = List.of(
|
||||
withToString("long[i]", (int s) -> {
|
||||
return fill(s * BUFFER_REPS,
|
||||
@ -4837,122 +4805,6 @@ public class Long256VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
static long[] gather(long a[], int ix, int[] b, int iy) {
|
||||
long[] res = new long[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryOpIndexProvider")
|
||||
static void gatherLong256VectorTests(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = new long[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Long256VectorTests::gather);
|
||||
}
|
||||
static long[] gatherMasked(long a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
long[] res = new long[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
if (mask[i]) {
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryMaskedOpIndexProvider")
|
||||
static void gatherMaskedLong256VectorTests(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = new long[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Long256VectorTests::gatherMasked);
|
||||
}
|
||||
|
||||
static long[] scatter(long a[], int ix, int[] b, int iy) {
|
||||
long[] res = new long[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = a[i + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryOpIndexProvider")
|
||||
static void scatterLong256VectorTests(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = new long[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Long256VectorTests::scatter);
|
||||
}
|
||||
|
||||
static long[] scatterMasked(long r[], long a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
// First, gather r.
|
||||
long[] oldVal = gather(r, ix, b, iy);
|
||||
long[] newVal = new long[SPECIES.length()];
|
||||
|
||||
// Second, blending it with a.
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
newVal[i] = blend(oldVal[i], a[i+ix], mask[i]);
|
||||
}
|
||||
|
||||
// Third, scatter: copy old value of r, and scatter it manually.
|
||||
long[] res = Arrays.copyOfRange(r, ix, ix+SPECIES.length());
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = newVal[i];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "scatterMaskedOpIndexProvider")
|
||||
static void scatterMaskedLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = fb.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Long256VectorTests::scatterMasked);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "longCompareOpProvider")
|
||||
static void ltLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
|
||||
|
||||
@ -43,6 +43,7 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.LongBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.*;
|
||||
|
||||
@ -51,13 +52,11 @@ public class Long512VectorLoadStoreTests extends AbstractVectorTest {
|
||||
static final VectorSpecies<Long> SPECIES =
|
||||
LongVector.SPECIES_512;
|
||||
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 10);
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 512);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (512 / 8));
|
||||
|
||||
static void assertArraysEquals(long[] r, long[] a, boolean[] mask) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -189,25 +188,6 @@ public class Long512VectorLoadStoreTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longIndexMapProvider() {
|
||||
return INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> LONG_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longIndexMapMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> LONG_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim, fm};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longByteBufferProvider() {
|
||||
return LONG_GENERATORS.stream().
|
||||
@ -962,4 +942,156 @@ public class Long512VectorLoadStoreTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Gather/Scatter load/store tests
|
||||
|
||||
static void assertGatherArraysEquals(long[] r, long[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(long[] r, long[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (long) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (long) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(long[] r, long[] a, int[] indexMap, boolean[] mask) {
|
||||
long[] expected = new long[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(long[] r, long[] a, int[] indexMap) {
|
||||
long[] expected = new long[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> LONG_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
LONG_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void gather(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = new long[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void gatherMask(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = new long[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void scatter(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = new long[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void scatterMask(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = new long[a.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -62,8 +62,6 @@ public class Long512VectorTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 512);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (512 / 8));
|
||||
|
||||
interface FUnOp {
|
||||
long apply(long a);
|
||||
}
|
||||
@ -994,36 +992,6 @@ public class Long512VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longUnaryOpIndexProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> LONG_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longUnaryMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
LONG_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] scatterMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
LONG_GENERATORS.stream().flatMap(fn ->
|
||||
LONG_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fn, fm, fs};
|
||||
})))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
static final List<IntFunction<long[]>> LONG_COMPARE_GENERATORS = List.of(
|
||||
withToString("long[i]", (int s) -> {
|
||||
return fill(s * BUFFER_REPS,
|
||||
@ -4837,122 +4805,6 @@ public class Long512VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
static long[] gather(long a[], int ix, int[] b, int iy) {
|
||||
long[] res = new long[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryOpIndexProvider")
|
||||
static void gatherLong512VectorTests(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = new long[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Long512VectorTests::gather);
|
||||
}
|
||||
static long[] gatherMasked(long a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
long[] res = new long[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
if (mask[i]) {
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryMaskedOpIndexProvider")
|
||||
static void gatherMaskedLong512VectorTests(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = new long[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Long512VectorTests::gatherMasked);
|
||||
}
|
||||
|
||||
static long[] scatter(long a[], int ix, int[] b, int iy) {
|
||||
long[] res = new long[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = a[i + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryOpIndexProvider")
|
||||
static void scatterLong512VectorTests(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = new long[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Long512VectorTests::scatter);
|
||||
}
|
||||
|
||||
static long[] scatterMasked(long r[], long a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
// First, gather r.
|
||||
long[] oldVal = gather(r, ix, b, iy);
|
||||
long[] newVal = new long[SPECIES.length()];
|
||||
|
||||
// Second, blending it with a.
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
newVal[i] = blend(oldVal[i], a[i+ix], mask[i]);
|
||||
}
|
||||
|
||||
// Third, scatter: copy old value of r, and scatter it manually.
|
||||
long[] res = Arrays.copyOfRange(r, ix, ix+SPECIES.length());
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = newVal[i];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "scatterMaskedOpIndexProvider")
|
||||
static void scatterMaskedLong512VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = fb.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Long512VectorTests::scatterMasked);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "longCompareOpProvider")
|
||||
static void ltLong512VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
|
||||
|
||||
@ -43,6 +43,7 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.LongBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.*;
|
||||
|
||||
@ -51,13 +52,11 @@ public class Long64VectorLoadStoreTests extends AbstractVectorTest {
|
||||
static final VectorSpecies<Long> SPECIES =
|
||||
LongVector.SPECIES_64;
|
||||
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 10);
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 64);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (64 / 8));
|
||||
|
||||
static void assertArraysEquals(long[] r, long[] a, boolean[] mask) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -189,25 +188,6 @@ public class Long64VectorLoadStoreTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longIndexMapProvider() {
|
||||
return INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> LONG_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longIndexMapMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> LONG_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim, fm};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longByteBufferProvider() {
|
||||
return LONG_GENERATORS.stream().
|
||||
@ -962,4 +942,156 @@ public class Long64VectorLoadStoreTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Gather/Scatter load/store tests
|
||||
|
||||
static void assertGatherArraysEquals(long[] r, long[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(long[] r, long[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (long) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (long) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(long[] r, long[] a, int[] indexMap, boolean[] mask) {
|
||||
long[] expected = new long[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(long[] r, long[] a, int[] indexMap) {
|
||||
long[] expected = new long[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> LONG_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
LONG_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void gather(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = new long[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void gatherMask(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = new long[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void scatter(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = new long[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void scatterMask(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = new long[a.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -62,8 +62,6 @@ public class Long64VectorTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 64);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (64 / 8));
|
||||
|
||||
interface FUnOp {
|
||||
long apply(long a);
|
||||
}
|
||||
@ -994,36 +992,6 @@ public class Long64VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longUnaryOpIndexProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> LONG_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longUnaryMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
LONG_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] scatterMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
LONG_GENERATORS.stream().flatMap(fn ->
|
||||
LONG_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fn, fm, fs};
|
||||
})))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
static final List<IntFunction<long[]>> LONG_COMPARE_GENERATORS = List.of(
|
||||
withToString("long[i]", (int s) -> {
|
||||
return fill(s * BUFFER_REPS,
|
||||
@ -4837,122 +4805,6 @@ public class Long64VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
static long[] gather(long a[], int ix, int[] b, int iy) {
|
||||
long[] res = new long[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryOpIndexProvider")
|
||||
static void gatherLong64VectorTests(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = new long[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Long64VectorTests::gather);
|
||||
}
|
||||
static long[] gatherMasked(long a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
long[] res = new long[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
if (mask[i]) {
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryMaskedOpIndexProvider")
|
||||
static void gatherMaskedLong64VectorTests(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = new long[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Long64VectorTests::gatherMasked);
|
||||
}
|
||||
|
||||
static long[] scatter(long a[], int ix, int[] b, int iy) {
|
||||
long[] res = new long[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = a[i + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryOpIndexProvider")
|
||||
static void scatterLong64VectorTests(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = new long[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Long64VectorTests::scatter);
|
||||
}
|
||||
|
||||
static long[] scatterMasked(long r[], long a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
// First, gather r.
|
||||
long[] oldVal = gather(r, ix, b, iy);
|
||||
long[] newVal = new long[SPECIES.length()];
|
||||
|
||||
// Second, blending it with a.
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
newVal[i] = blend(oldVal[i], a[i+ix], mask[i]);
|
||||
}
|
||||
|
||||
// Third, scatter: copy old value of r, and scatter it manually.
|
||||
long[] res = Arrays.copyOfRange(r, ix, ix+SPECIES.length());
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = newVal[i];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "scatterMaskedOpIndexProvider")
|
||||
static void scatterMaskedLong64VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = fb.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Long64VectorTests::scatterMasked);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "longCompareOpProvider")
|
||||
static void ltLong64VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
|
||||
|
||||
@ -47,6 +47,7 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.LongBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.*;
|
||||
|
||||
@ -55,7 +56,7 @@ public class LongMaxVectorLoadStoreTests extends AbstractVectorTest {
|
||||
static final VectorSpecies<Long> SPECIES =
|
||||
LongVector.SPECIES_MAX;
|
||||
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 10);
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
static VectorShape getMaxBit() {
|
||||
return VectorShape.S_Max_BIT;
|
||||
@ -65,8 +66,6 @@ public class LongMaxVectorLoadStoreTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (Max / 8));
|
||||
|
||||
static void assertArraysEquals(long[] r, long[] a, boolean[] mask) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -198,25 +197,6 @@ public class LongMaxVectorLoadStoreTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longIndexMapProvider() {
|
||||
return INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> LONG_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longIndexMapMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> LONG_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim, fm};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longByteBufferProvider() {
|
||||
return LONG_GENERATORS.stream().
|
||||
@ -971,4 +951,156 @@ public class LongMaxVectorLoadStoreTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Gather/Scatter load/store tests
|
||||
|
||||
static void assertGatherArraysEquals(long[] r, long[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(long[] r, long[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (long) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (long) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(long[] r, long[] a, int[] indexMap, boolean[] mask) {
|
||||
long[] expected = new long[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(long[] r, long[] a, int[] indexMap) {
|
||||
long[] expected = new long[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> LONG_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
LONG_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void gather(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = new long[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void gatherMask(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = new long[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void scatter(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = new long[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void scatterMask(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = new long[a.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -67,8 +67,6 @@ public class LongMaxVectorTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (Max / 8));
|
||||
|
||||
interface FUnOp {
|
||||
long apply(long a);
|
||||
}
|
||||
@ -999,36 +997,6 @@ public class LongMaxVectorTests extends AbstractVectorTest {
|
||||
}
|
||||
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longUnaryOpIndexProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> LONG_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] longUnaryMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
LONG_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] scatterMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
LONG_GENERATORS.stream().flatMap(fn ->
|
||||
LONG_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fn, fm, fs};
|
||||
})))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
static final List<IntFunction<long[]>> LONG_COMPARE_GENERATORS = List.of(
|
||||
withToString("long[i]", (int s) -> {
|
||||
return fill(s * BUFFER_REPS,
|
||||
@ -4842,122 +4810,6 @@ public class LongMaxVectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
static long[] gather(long a[], int ix, int[] b, int iy) {
|
||||
long[] res = new long[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryOpIndexProvider")
|
||||
static void gatherLongMaxVectorTests(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = new long[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, LongMaxVectorTests::gather);
|
||||
}
|
||||
static long[] gatherMasked(long a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
long[] res = new long[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
if (mask[i]) {
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryMaskedOpIndexProvider")
|
||||
static void gatherMaskedLongMaxVectorTests(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = new long[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, LongMaxVectorTests::gatherMasked);
|
||||
}
|
||||
|
||||
static long[] scatter(long a[], int ix, int[] b, int iy) {
|
||||
long[] res = new long[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = a[i + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "longUnaryOpIndexProvider")
|
||||
static void scatterLongMaxVectorTests(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = new long[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, LongMaxVectorTests::scatter);
|
||||
}
|
||||
|
||||
static long[] scatterMasked(long r[], long a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
// First, gather r.
|
||||
long[] oldVal = gather(r, ix, b, iy);
|
||||
long[] newVal = new long[SPECIES.length()];
|
||||
|
||||
// Second, blending it with a.
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
newVal[i] = blend(oldVal[i], a[i+ix], mask[i]);
|
||||
}
|
||||
|
||||
// Third, scatter: copy old value of r, and scatter it manually.
|
||||
long[] res = Arrays.copyOfRange(r, ix, ix+SPECIES.length());
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = newVal[i];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "scatterMaskedOpIndexProvider")
|
||||
static void scatterMaskedLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
long[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
long[] r = fb.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, LongMaxVectorTests::scatterMasked);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "longCompareOpProvider")
|
||||
static void ltLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
|
||||
|
||||
@ -43,6 +43,7 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.ShortBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.*;
|
||||
|
||||
@ -51,13 +52,11 @@ public class Short128VectorLoadStoreTests extends AbstractVectorTest {
|
||||
static final VectorSpecies<Short> SPECIES =
|
||||
ShortVector.SPECIES_128;
|
||||
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 10);
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 128);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (128 / 8));
|
||||
|
||||
static void assertArraysEquals(short[] r, short[] a, boolean[] mask) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -189,25 +188,6 @@ public class Short128VectorLoadStoreTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortIndexMapProvider() {
|
||||
return INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> SHORT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortIndexMapMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> SHORT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim, fm};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortByteBufferProvider() {
|
||||
return SHORT_GENERATORS.stream().
|
||||
@ -1206,4 +1186,301 @@ public class Short128VectorLoadStoreTests extends AbstractVectorTest {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Gather/Scatter load/store tests
|
||||
|
||||
static void assertGatherArraysEquals(short[] r, short[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(short[] r, short[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (short) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (short) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(short[] r, short[] a, int[] indexMap, boolean[] mask) {
|
||||
short[] expected = new short[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(short[] r, short[] a, int[] indexMap) {
|
||||
short[] expected = new short[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> SHORT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
SHORT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void gather(IntFunction<short[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = new short[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void gatherMask(IntFunction<short[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = new short[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void scatter(IntFunction<short[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = new short[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void scatterMask(IntFunction<short[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = new short[a.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(char[] r, char[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(char[] r, char[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (char) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (char) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(char[] r, char[] a, int[] indexMap, boolean[] mask) {
|
||||
char[] expected = new char[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(char[] r, char[] a, int[] indexMap) {
|
||||
char[] expected = new char[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] charGatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> CHAR_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] charGatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
CHAR_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "charGatherScatterProvider")
|
||||
static void charGather(IntFunction<char[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
char[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
char[] r = new char[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ShortVector av = ShortVector.fromCharArray(SPECIES, a, i, b, i);
|
||||
av.intoCharArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "charGatherScatterMaskProvider")
|
||||
static void charGatherMask(IntFunction<char[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
char[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
char[] r = new char[a.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.fromCharArray(SPECIES, a, i, b, i, vmask);
|
||||
av.intoCharArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "charGatherScatterProvider")
|
||||
static void charScatter(IntFunction<char[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
char[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
char[] r = new char[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ShortVector av = ShortVector.fromCharArray(SPECIES, a, i);
|
||||
av.intoCharArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "charGatherScatterMaskProvider")
|
||||
static void charScatterMask(IntFunction<char[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
char[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
char[] r = new char[a.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.fromCharArray(SPECIES, a, i);
|
||||
av.intoCharArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -62,8 +62,6 @@ public class Short128VectorTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 128);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (128 / 8));
|
||||
|
||||
interface FUnOp {
|
||||
short apply(short a);
|
||||
}
|
||||
@ -998,36 +996,6 @@ public class Short128VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortUnaryOpIndexProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> SHORT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortUnaryMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
SHORT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] scatterMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
SHORT_GENERATORS.stream().flatMap(fn ->
|
||||
SHORT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fn, fm, fs};
|
||||
})))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
static final List<IntFunction<short[]>> SHORT_COMPARE_GENERATORS = List.of(
|
||||
withToString("short[i]", (int s) -> {
|
||||
return fill(s * BUFFER_REPS,
|
||||
@ -4912,122 +4880,6 @@ public class Short128VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
static short[] gather(short a[], int ix, int[] b, int iy) {
|
||||
short[] res = new short[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpIndexProvider")
|
||||
static void gatherShort128VectorTests(IntFunction<short[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = new short[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Short128VectorTests::gather);
|
||||
}
|
||||
static short[] gatherMasked(short a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
short[] res = new short[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
if (mask[i]) {
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryMaskedOpIndexProvider")
|
||||
static void gatherMaskedShort128VectorTests(IntFunction<short[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = new short[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Short128VectorTests::gatherMasked);
|
||||
}
|
||||
|
||||
static short[] scatter(short a[], int ix, int[] b, int iy) {
|
||||
short[] res = new short[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = a[i + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpIndexProvider")
|
||||
static void scatterShort128VectorTests(IntFunction<short[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = new short[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Short128VectorTests::scatter);
|
||||
}
|
||||
|
||||
static short[] scatterMasked(short r[], short a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
// First, gather r.
|
||||
short[] oldVal = gather(r, ix, b, iy);
|
||||
short[] newVal = new short[SPECIES.length()];
|
||||
|
||||
// Second, blending it with a.
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
newVal[i] = blend(oldVal[i], a[i+ix], mask[i]);
|
||||
}
|
||||
|
||||
// Third, scatter: copy old value of r, and scatter it manually.
|
||||
short[] res = Arrays.copyOfRange(r, ix, ix+SPECIES.length());
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = newVal[i];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "scatterMaskedOpIndexProvider")
|
||||
static void scatterMaskedShort128VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = fb.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Short128VectorTests::scatterMasked);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "shortCompareOpProvider")
|
||||
static void ltShort128VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
|
||||
|
||||
@ -43,6 +43,7 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.ShortBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.*;
|
||||
|
||||
@ -51,13 +52,11 @@ public class Short256VectorLoadStoreTests extends AbstractVectorTest {
|
||||
static final VectorSpecies<Short> SPECIES =
|
||||
ShortVector.SPECIES_256;
|
||||
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 10);
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 256);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (256 / 8));
|
||||
|
||||
static void assertArraysEquals(short[] r, short[] a, boolean[] mask) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -189,25 +188,6 @@ public class Short256VectorLoadStoreTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortIndexMapProvider() {
|
||||
return INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> SHORT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortIndexMapMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> SHORT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim, fm};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortByteBufferProvider() {
|
||||
return SHORT_GENERATORS.stream().
|
||||
@ -1206,4 +1186,301 @@ public class Short256VectorLoadStoreTests extends AbstractVectorTest {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Gather/Scatter load/store tests
|
||||
|
||||
static void assertGatherArraysEquals(short[] r, short[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(short[] r, short[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (short) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (short) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(short[] r, short[] a, int[] indexMap, boolean[] mask) {
|
||||
short[] expected = new short[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(short[] r, short[] a, int[] indexMap) {
|
||||
short[] expected = new short[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> SHORT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
SHORT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void gather(IntFunction<short[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = new short[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void gatherMask(IntFunction<short[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = new short[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void scatter(IntFunction<short[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = new short[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void scatterMask(IntFunction<short[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = new short[a.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(char[] r, char[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(char[] r, char[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (char) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (char) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(char[] r, char[] a, int[] indexMap, boolean[] mask) {
|
||||
char[] expected = new char[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(char[] r, char[] a, int[] indexMap) {
|
||||
char[] expected = new char[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] charGatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> CHAR_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] charGatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
CHAR_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "charGatherScatterProvider")
|
||||
static void charGather(IntFunction<char[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
char[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
char[] r = new char[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ShortVector av = ShortVector.fromCharArray(SPECIES, a, i, b, i);
|
||||
av.intoCharArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "charGatherScatterMaskProvider")
|
||||
static void charGatherMask(IntFunction<char[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
char[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
char[] r = new char[a.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.fromCharArray(SPECIES, a, i, b, i, vmask);
|
||||
av.intoCharArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "charGatherScatterProvider")
|
||||
static void charScatter(IntFunction<char[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
char[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
char[] r = new char[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ShortVector av = ShortVector.fromCharArray(SPECIES, a, i);
|
||||
av.intoCharArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "charGatherScatterMaskProvider")
|
||||
static void charScatterMask(IntFunction<char[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
char[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
char[] r = new char[a.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.fromCharArray(SPECIES, a, i);
|
||||
av.intoCharArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -62,8 +62,6 @@ public class Short256VectorTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 256);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (256 / 8));
|
||||
|
||||
interface FUnOp {
|
||||
short apply(short a);
|
||||
}
|
||||
@ -998,36 +996,6 @@ public class Short256VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortUnaryOpIndexProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> SHORT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortUnaryMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
SHORT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] scatterMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
SHORT_GENERATORS.stream().flatMap(fn ->
|
||||
SHORT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fn, fm, fs};
|
||||
})))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
static final List<IntFunction<short[]>> SHORT_COMPARE_GENERATORS = List.of(
|
||||
withToString("short[i]", (int s) -> {
|
||||
return fill(s * BUFFER_REPS,
|
||||
@ -4912,122 +4880,6 @@ public class Short256VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
static short[] gather(short a[], int ix, int[] b, int iy) {
|
||||
short[] res = new short[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpIndexProvider")
|
||||
static void gatherShort256VectorTests(IntFunction<short[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = new short[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Short256VectorTests::gather);
|
||||
}
|
||||
static short[] gatherMasked(short a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
short[] res = new short[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
if (mask[i]) {
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryMaskedOpIndexProvider")
|
||||
static void gatherMaskedShort256VectorTests(IntFunction<short[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = new short[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Short256VectorTests::gatherMasked);
|
||||
}
|
||||
|
||||
static short[] scatter(short a[], int ix, int[] b, int iy) {
|
||||
short[] res = new short[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = a[i + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpIndexProvider")
|
||||
static void scatterShort256VectorTests(IntFunction<short[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = new short[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Short256VectorTests::scatter);
|
||||
}
|
||||
|
||||
static short[] scatterMasked(short r[], short a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
// First, gather r.
|
||||
short[] oldVal = gather(r, ix, b, iy);
|
||||
short[] newVal = new short[SPECIES.length()];
|
||||
|
||||
// Second, blending it with a.
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
newVal[i] = blend(oldVal[i], a[i+ix], mask[i]);
|
||||
}
|
||||
|
||||
// Third, scatter: copy old value of r, and scatter it manually.
|
||||
short[] res = Arrays.copyOfRange(r, ix, ix+SPECIES.length());
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = newVal[i];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "scatterMaskedOpIndexProvider")
|
||||
static void scatterMaskedShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = fb.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Short256VectorTests::scatterMasked);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "shortCompareOpProvider")
|
||||
static void ltShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
|
||||
|
||||
@ -43,6 +43,7 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.ShortBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.*;
|
||||
|
||||
@ -51,13 +52,11 @@ public class Short512VectorLoadStoreTests extends AbstractVectorTest {
|
||||
static final VectorSpecies<Short> SPECIES =
|
||||
ShortVector.SPECIES_512;
|
||||
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 10);
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 512);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (512 / 8));
|
||||
|
||||
static void assertArraysEquals(short[] r, short[] a, boolean[] mask) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -189,25 +188,6 @@ public class Short512VectorLoadStoreTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortIndexMapProvider() {
|
||||
return INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> SHORT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortIndexMapMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> SHORT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim, fm};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortByteBufferProvider() {
|
||||
return SHORT_GENERATORS.stream().
|
||||
@ -1206,4 +1186,301 @@ public class Short512VectorLoadStoreTests extends AbstractVectorTest {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Gather/Scatter load/store tests
|
||||
|
||||
static void assertGatherArraysEquals(short[] r, short[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(short[] r, short[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (short) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (short) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(short[] r, short[] a, int[] indexMap, boolean[] mask) {
|
||||
short[] expected = new short[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(short[] r, short[] a, int[] indexMap) {
|
||||
short[] expected = new short[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> SHORT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
SHORT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void gather(IntFunction<short[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = new short[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void gatherMask(IntFunction<short[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = new short[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void scatter(IntFunction<short[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = new short[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void scatterMask(IntFunction<short[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = new short[a.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(char[] r, char[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(char[] r, char[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (char) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (char) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(char[] r, char[] a, int[] indexMap, boolean[] mask) {
|
||||
char[] expected = new char[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(char[] r, char[] a, int[] indexMap) {
|
||||
char[] expected = new char[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] charGatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> CHAR_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] charGatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
CHAR_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "charGatherScatterProvider")
|
||||
static void charGather(IntFunction<char[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
char[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
char[] r = new char[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ShortVector av = ShortVector.fromCharArray(SPECIES, a, i, b, i);
|
||||
av.intoCharArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "charGatherScatterMaskProvider")
|
||||
static void charGatherMask(IntFunction<char[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
char[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
char[] r = new char[a.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.fromCharArray(SPECIES, a, i, b, i, vmask);
|
||||
av.intoCharArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "charGatherScatterProvider")
|
||||
static void charScatter(IntFunction<char[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
char[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
char[] r = new char[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ShortVector av = ShortVector.fromCharArray(SPECIES, a, i);
|
||||
av.intoCharArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "charGatherScatterMaskProvider")
|
||||
static void charScatterMask(IntFunction<char[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
char[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
char[] r = new char[a.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.fromCharArray(SPECIES, a, i);
|
||||
av.intoCharArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -62,8 +62,6 @@ public class Short512VectorTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 512);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (512 / 8));
|
||||
|
||||
interface FUnOp {
|
||||
short apply(short a);
|
||||
}
|
||||
@ -998,36 +996,6 @@ public class Short512VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortUnaryOpIndexProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> SHORT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortUnaryMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
SHORT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] scatterMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
SHORT_GENERATORS.stream().flatMap(fn ->
|
||||
SHORT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fn, fm, fs};
|
||||
})))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
static final List<IntFunction<short[]>> SHORT_COMPARE_GENERATORS = List.of(
|
||||
withToString("short[i]", (int s) -> {
|
||||
return fill(s * BUFFER_REPS,
|
||||
@ -4912,122 +4880,6 @@ public class Short512VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
static short[] gather(short a[], int ix, int[] b, int iy) {
|
||||
short[] res = new short[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpIndexProvider")
|
||||
static void gatherShort512VectorTests(IntFunction<short[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = new short[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Short512VectorTests::gather);
|
||||
}
|
||||
static short[] gatherMasked(short a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
short[] res = new short[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
if (mask[i]) {
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryMaskedOpIndexProvider")
|
||||
static void gatherMaskedShort512VectorTests(IntFunction<short[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = new short[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Short512VectorTests::gatherMasked);
|
||||
}
|
||||
|
||||
static short[] scatter(short a[], int ix, int[] b, int iy) {
|
||||
short[] res = new short[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = a[i + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpIndexProvider")
|
||||
static void scatterShort512VectorTests(IntFunction<short[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = new short[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Short512VectorTests::scatter);
|
||||
}
|
||||
|
||||
static short[] scatterMasked(short r[], short a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
// First, gather r.
|
||||
short[] oldVal = gather(r, ix, b, iy);
|
||||
short[] newVal = new short[SPECIES.length()];
|
||||
|
||||
// Second, blending it with a.
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
newVal[i] = blend(oldVal[i], a[i+ix], mask[i]);
|
||||
}
|
||||
|
||||
// Third, scatter: copy old value of r, and scatter it manually.
|
||||
short[] res = Arrays.copyOfRange(r, ix, ix+SPECIES.length());
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = newVal[i];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "scatterMaskedOpIndexProvider")
|
||||
static void scatterMaskedShort512VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = fb.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Short512VectorTests::scatterMasked);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "shortCompareOpProvider")
|
||||
static void ltShort512VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
|
||||
|
||||
@ -43,6 +43,7 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.ShortBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.*;
|
||||
|
||||
@ -51,13 +52,11 @@ public class Short64VectorLoadStoreTests extends AbstractVectorTest {
|
||||
static final VectorSpecies<Short> SPECIES =
|
||||
ShortVector.SPECIES_64;
|
||||
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 10);
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 64);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (64 / 8));
|
||||
|
||||
static void assertArraysEquals(short[] r, short[] a, boolean[] mask) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -189,25 +188,6 @@ public class Short64VectorLoadStoreTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortIndexMapProvider() {
|
||||
return INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> SHORT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortIndexMapMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> SHORT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim, fm};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortByteBufferProvider() {
|
||||
return SHORT_GENERATORS.stream().
|
||||
@ -1206,4 +1186,301 @@ public class Short64VectorLoadStoreTests extends AbstractVectorTest {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Gather/Scatter load/store tests
|
||||
|
||||
static void assertGatherArraysEquals(short[] r, short[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(short[] r, short[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (short) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (short) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(short[] r, short[] a, int[] indexMap, boolean[] mask) {
|
||||
short[] expected = new short[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(short[] r, short[] a, int[] indexMap) {
|
||||
short[] expected = new short[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> SHORT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
SHORT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void gather(IntFunction<short[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = new short[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void gatherMask(IntFunction<short[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = new short[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void scatter(IntFunction<short[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = new short[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void scatterMask(IntFunction<short[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = new short[a.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(char[] r, char[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(char[] r, char[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (char) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (char) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(char[] r, char[] a, int[] indexMap, boolean[] mask) {
|
||||
char[] expected = new char[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(char[] r, char[] a, int[] indexMap) {
|
||||
char[] expected = new char[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] charGatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> CHAR_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] charGatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
CHAR_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "charGatherScatterProvider")
|
||||
static void charGather(IntFunction<char[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
char[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
char[] r = new char[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ShortVector av = ShortVector.fromCharArray(SPECIES, a, i, b, i);
|
||||
av.intoCharArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "charGatherScatterMaskProvider")
|
||||
static void charGatherMask(IntFunction<char[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
char[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
char[] r = new char[a.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.fromCharArray(SPECIES, a, i, b, i, vmask);
|
||||
av.intoCharArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "charGatherScatterProvider")
|
||||
static void charScatter(IntFunction<char[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
char[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
char[] r = new char[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ShortVector av = ShortVector.fromCharArray(SPECIES, a, i);
|
||||
av.intoCharArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "charGatherScatterMaskProvider")
|
||||
static void charScatterMask(IntFunction<char[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
char[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
char[] r = new char[a.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.fromCharArray(SPECIES, a, i);
|
||||
av.intoCharArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -62,8 +62,6 @@ public class Short64VectorTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 64);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (64 / 8));
|
||||
|
||||
interface FUnOp {
|
||||
short apply(short a);
|
||||
}
|
||||
@ -998,36 +996,6 @@ public class Short64VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortUnaryOpIndexProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> SHORT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortUnaryMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
SHORT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] scatterMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
SHORT_GENERATORS.stream().flatMap(fn ->
|
||||
SHORT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fn, fm, fs};
|
||||
})))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
static final List<IntFunction<short[]>> SHORT_COMPARE_GENERATORS = List.of(
|
||||
withToString("short[i]", (int s) -> {
|
||||
return fill(s * BUFFER_REPS,
|
||||
@ -4912,122 +4880,6 @@ public class Short64VectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
static short[] gather(short a[], int ix, int[] b, int iy) {
|
||||
short[] res = new short[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpIndexProvider")
|
||||
static void gatherShort64VectorTests(IntFunction<short[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = new short[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Short64VectorTests::gather);
|
||||
}
|
||||
static short[] gatherMasked(short a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
short[] res = new short[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
if (mask[i]) {
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryMaskedOpIndexProvider")
|
||||
static void gatherMaskedShort64VectorTests(IntFunction<short[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = new short[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Short64VectorTests::gatherMasked);
|
||||
}
|
||||
|
||||
static short[] scatter(short a[], int ix, int[] b, int iy) {
|
||||
short[] res = new short[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = a[i + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpIndexProvider")
|
||||
static void scatterShort64VectorTests(IntFunction<short[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = new short[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, Short64VectorTests::scatter);
|
||||
}
|
||||
|
||||
static short[] scatterMasked(short r[], short a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
// First, gather r.
|
||||
short[] oldVal = gather(r, ix, b, iy);
|
||||
short[] newVal = new short[SPECIES.length()];
|
||||
|
||||
// Second, blending it with a.
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
newVal[i] = blend(oldVal[i], a[i+ix], mask[i]);
|
||||
}
|
||||
|
||||
// Third, scatter: copy old value of r, and scatter it manually.
|
||||
short[] res = Arrays.copyOfRange(r, ix, ix+SPECIES.length());
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = newVal[i];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "scatterMaskedOpIndexProvider")
|
||||
static void scatterMaskedShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = fb.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, Short64VectorTests::scatterMasked);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "shortCompareOpProvider")
|
||||
static void ltShort64VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
|
||||
|
||||
@ -47,6 +47,7 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.ShortBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.*;
|
||||
|
||||
@ -55,7 +56,7 @@ public class ShortMaxVectorLoadStoreTests extends AbstractVectorTest {
|
||||
static final VectorSpecies<Short> SPECIES =
|
||||
ShortVector.SPECIES_MAX;
|
||||
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 10);
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
static VectorShape getMaxBit() {
|
||||
return VectorShape.S_Max_BIT;
|
||||
@ -65,8 +66,6 @@ public class ShortMaxVectorLoadStoreTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (Max / 8));
|
||||
|
||||
static void assertArraysEquals(short[] r, short[] a, boolean[] mask) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -198,25 +197,6 @@ public class ShortMaxVectorLoadStoreTests extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortIndexMapProvider() {
|
||||
return INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> SHORT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortIndexMapMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> SHORT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim, fm};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortByteBufferProvider() {
|
||||
return SHORT_GENERATORS.stream().
|
||||
@ -1215,4 +1195,301 @@ public class ShortMaxVectorLoadStoreTests extends AbstractVectorTest {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Gather/Scatter load/store tests
|
||||
|
||||
static void assertGatherArraysEquals(short[] r, short[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(short[] r, short[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (short) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (short) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(short[] r, short[] a, int[] indexMap, boolean[] mask) {
|
||||
short[] expected = new short[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(short[] r, short[] a, int[] indexMap) {
|
||||
short[] expected = new short[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> SHORT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
SHORT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void gather(IntFunction<short[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = new short[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void gatherMask(IntFunction<short[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = new short[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void scatter(IntFunction<short[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = new short[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void scatterMask(IntFunction<short[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = new short[a.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(char[] r, char[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(char[] r, char[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (char) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (char) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(char[] r, char[] a, int[] indexMap, boolean[] mask) {
|
||||
char[] expected = new char[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(char[] r, char[] a, int[] indexMap) {
|
||||
char[] expected = new char[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] charGatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> CHAR_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] charGatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
CHAR_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "charGatherScatterProvider")
|
||||
static void charGather(IntFunction<char[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
char[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
char[] r = new char[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ShortVector av = ShortVector.fromCharArray(SPECIES, a, i, b, i);
|
||||
av.intoCharArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "charGatherScatterMaskProvider")
|
||||
static void charGatherMask(IntFunction<char[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
char[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
char[] r = new char[a.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.fromCharArray(SPECIES, a, i, b, i, vmask);
|
||||
av.intoCharArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "charGatherScatterProvider")
|
||||
static void charScatter(IntFunction<char[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
char[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
char[] r = new char[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
ShortVector av = ShortVector.fromCharArray(SPECIES, a, i);
|
||||
av.intoCharArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "charGatherScatterMaskProvider")
|
||||
static void charScatterMask(IntFunction<char[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
char[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
char[] r = new char[a.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.fromCharArray(SPECIES, a, i);
|
||||
av.intoCharArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -67,8 +67,6 @@ public class ShortMaxVectorTests extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (Max / 8));
|
||||
|
||||
interface FUnOp {
|
||||
short apply(short a);
|
||||
}
|
||||
@ -1003,36 +1001,6 @@ public class ShortMaxVectorTests extends AbstractVectorTest {
|
||||
}
|
||||
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortUnaryOpIndexProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> SHORT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shortUnaryMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
SHORT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] scatterMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
SHORT_GENERATORS.stream().flatMap(fn ->
|
||||
SHORT_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fn, fm, fs};
|
||||
})))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
static final List<IntFunction<short[]>> SHORT_COMPARE_GENERATORS = List.of(
|
||||
withToString("short[i]", (int s) -> {
|
||||
return fill(s * BUFFER_REPS,
|
||||
@ -4917,122 +4885,6 @@ public class ShortMaxVectorTests extends AbstractVectorTest {
|
||||
|
||||
|
||||
|
||||
static short[] gather(short a[], int ix, int[] b, int iy) {
|
||||
short[] res = new short[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpIndexProvider")
|
||||
static void gatherShortMaxVectorTests(IntFunction<short[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = new short[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, ShortMaxVectorTests::gather);
|
||||
}
|
||||
static short[] gatherMasked(short a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
short[] res = new short[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
if (mask[i]) {
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryMaskedOpIndexProvider")
|
||||
static void gatherMaskedShortMaxVectorTests(IntFunction<short[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = new short[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::gatherMasked);
|
||||
}
|
||||
|
||||
static short[] scatter(short a[], int ix, int[] b, int iy) {
|
||||
short[] res = new short[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = a[i + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shortUnaryOpIndexProvider")
|
||||
static void scatterShortMaxVectorTests(IntFunction<short[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = new short[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, ShortMaxVectorTests::scatter);
|
||||
}
|
||||
|
||||
static short[] scatterMasked(short r[], short a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
// First, gather r.
|
||||
short[] oldVal = gather(r, ix, b, iy);
|
||||
short[] newVal = new short[SPECIES.length()];
|
||||
|
||||
// Second, blending it with a.
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
newVal[i] = blend(oldVal[i], a[i+ix], mask[i]);
|
||||
}
|
||||
|
||||
// Third, scatter: copy old value of r, and scatter it manually.
|
||||
short[] res = Arrays.copyOfRange(r, ix, ix+SPECIES.length());
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = newVal[i];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "scatterMaskedOpIndexProvider")
|
||||
static void scatterMaskedShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
short[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
short[] r = fb.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::scatterMasked);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "shortCompareOpProvider")
|
||||
static void ltShortMaxVectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
|
||||
|
||||
@ -74,10 +74,6 @@ bool_reduction_template="BoolReduction-op"
|
||||
with_op_template="With-Op"
|
||||
shift_template="Shift-op"
|
||||
shift_masked_template="Shift-Masked-op"
|
||||
gather_template="Gather-op"
|
||||
gather_masked_template="Gather-Masked-op"
|
||||
scatter_template="Scatter-op"
|
||||
scatter_masked_template="Scatter-Masked-op"
|
||||
get_template="Get-op"
|
||||
rearrange_template="Rearrange"
|
||||
broadcast_template="Broadcast"
|
||||
@ -558,12 +554,6 @@ gen_unary_alu_op "NOT+not" "~((\$type\$)a)" "BITWISE"
|
||||
gen_unary_alu_op "ZOMO" "(a==0?0:-1)" "BITWISE"
|
||||
gen_unary_alu_op "SQRT+sqrt" "Math.sqrt((double)a)" "FP"
|
||||
|
||||
# Gather Scatter operations.
|
||||
gen_op_tmpl $gather_template "gather" ""
|
||||
gen_op_tmpl $gather_masked_template "gather" ""
|
||||
gen_op_tmpl $scatter_template "scatter" ""
|
||||
gen_op_tmpl $scatter_masked_template "scatter" ""
|
||||
|
||||
# Miscellaneous Smoke Tests
|
||||
gen_op_tmpl $miscellaneous_template "MISC" "" ""
|
||||
|
||||
|
||||
@ -1,12 +0,0 @@
|
||||
$type$[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
$type$[] r = new $type$[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
$type$[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
$type$[] r = new $type$[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
$type$[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
$type$[] r = fb.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
$type$[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
$type$[] r = new $type$[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
static $type$[] [[TEST]][[TEST_TYPE]]($type$ a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
$type$[] res = new $type$[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
if (mask[i]) {
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "$type$UnaryMaskedOpIndexProvider")
|
||||
static void [[TEST]][[TEST_TYPE]]$vectorteststype$(IntFunction<$type$[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
[[KERNEL]]
|
||||
assertArraysEquals(r, a, b, mask, $vectorteststype$::[[TEST]][[TEST_TYPE]]);
|
||||
}
|
||||
|
||||
@ -1,14 +0,0 @@
|
||||
static $type$[] [[TEST]]($type$ a[], int ix, int[] b, int iy) {
|
||||
$type$[] res = new $type$[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[i] = a[b[bi] + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "$type$UnaryOpIndexProvider")
|
||||
static void [[TEST]]$vectorteststype$(IntFunction<$type$[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
[[KERNEL]]
|
||||
assertArraysEquals(r, a, b, $vectorteststype$::[[TEST]]);
|
||||
}
|
||||
@ -1,26 +0,0 @@
|
||||
static $type$[] [[TEST]][[TEST_TYPE]]($type$ r[], $type$ a[], int ix, boolean[] mask, int[] b, int iy) {
|
||||
// First, gather r.
|
||||
$type$[] oldVal = gather(r, ix, b, iy);
|
||||
$type$[] newVal = new $type$[SPECIES.length()];
|
||||
|
||||
// Second, blending it with a.
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
newVal[i] = blend(oldVal[i], a[i+ix], mask[i]);
|
||||
}
|
||||
|
||||
// Third, scatter: copy old value of r, and scatter it manually.
|
||||
$type$[] res = Arrays.copyOfRange(r, ix, ix+SPECIES.length());
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = newVal[i];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "scatterMaskedOpIndexProvider")
|
||||
static void [[TEST]][[TEST_TYPE]]$vectorteststype$(IntFunction<$type$[]> fa, IntFunction<$type$[]> fb, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
[[KERNEL]]
|
||||
assertArraysEquals(r, a, b, mask, $vectorteststype$::[[TEST]][[TEST_TYPE]]);
|
||||
}
|
||||
|
||||
@ -1,15 +0,0 @@
|
||||
static $type$[] [[TEST]]($type$ a[], int ix, int[] b, int iy) {
|
||||
$type$[] res = new $type$[SPECIES.length()];
|
||||
for (int i = 0; i < SPECIES.length(); i++) {
|
||||
int bi = iy + i;
|
||||
res[b[bi]] = a[i + ix];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test(dataProvider = "$type$UnaryOpIndexProvider")
|
||||
static void [[TEST]]$vectorteststype$(IntFunction<$type$[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
[[KERNEL]]
|
||||
assertArraysEquals(r, a, b, $vectorteststype$::[[TEST]]);
|
||||
}
|
||||
|
||||
@ -91,8 +91,6 @@ public class $vectorteststype$ extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / $bits$);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * ($bits$ / 8));
|
||||
|
||||
interface FUnOp {
|
||||
$type$ apply($type$ a);
|
||||
}
|
||||
@ -1217,36 +1215,6 @@ public class $vectorteststype$ extends AbstractVectorTest {
|
||||
|
||||
#end[!Int]
|
||||
|
||||
@DataProvider
|
||||
public Object[][] $type$UnaryOpIndexProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> $TYPE$_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] $type$UnaryMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
$TYPE$_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] scatterMaskedOpIndexProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
$TYPE$_GENERATORS.stream().flatMap(fn ->
|
||||
$TYPE$_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fn, fm, fs};
|
||||
})))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
static final List<IntFunction<$type$[]>> $TYPE$_COMPARE_GENERATORS = List.of(
|
||||
withToString("$type$[i]", (int s) -> {
|
||||
return fill(s * BUFFER_REPS,
|
||||
|
||||
@ -57,6 +57,7 @@ import java.nio.$Type$Buffer;
|
||||
#end[!byte]
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.*;
|
||||
|
||||
@ -70,7 +71,7 @@ public class $vectorteststype$ extends AbstractVectorTest {
|
||||
$Type$Vector.SPECIES_$bits$;
|
||||
#end[MaxBit]
|
||||
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 10);
|
||||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
|
||||
|
||||
#if[MaxBit]
|
||||
static VectorShape getMaxBit() {
|
||||
@ -82,8 +83,6 @@ public class $vectorteststype$ extends AbstractVectorTest {
|
||||
|
||||
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / $bits$);
|
||||
|
||||
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * ($bits$ / 8));
|
||||
|
||||
static void assertArraysEquals($type$[] r, $type$[] a, boolean[] mask) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -217,25 +216,6 @@ public class $vectorteststype$ extends AbstractVectorTest {
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] $type$IndexMapProvider() {
|
||||
return INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> $TYPE$_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] $type$IndexMapMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fm -> INDEX_GENERATORS.stream().
|
||||
flatMap(fim -> $TYPE$_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fim, fm};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] $type$ByteBufferProvider() {
|
||||
return $TYPE$_GENERATORS.stream().
|
||||
@ -1329,4 +1309,430 @@ public class $vectorteststype$ extends AbstractVectorTest {
|
||||
assertArraysEquals(r, a, mask);
|
||||
}
|
||||
#end[byte]
|
||||
|
||||
|
||||
// Gather/Scatter load/store tests
|
||||
|
||||
static void assertGatherArraysEquals($type$[] r, $type$[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals($type$[] r, $type$[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: ($type$) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: ($type$) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals($type$[] r, $type$[] a, int[] indexMap, boolean[] mask) {
|
||||
$type$[] expected = new $type$[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals($type$[] r, $type$[] a, int[] indexMap) {
|
||||
$type$[] expected = new $type$[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> $TYPE$_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] gatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
$TYPE$_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void gather(IntFunction<$type$[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
$type$[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
$type$[] r = new $type$[a.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, b, i);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void gatherMask(IntFunction<$type$[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
$type$[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
$type$[] r = new $type$[a.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, b, i, vmask);
|
||||
av.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void scatter(IntFunction<$type$[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
$type$[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
$type$[] r = new $type$[a.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.intoArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void scatterMask(IntFunction<$type$[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
$type$[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
$type$[] r = new $type$[a.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.intoArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
#if[short]
|
||||
static void assertGatherArraysEquals(char[] r, char[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(char[] r, char[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (char) 0);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (char) 0, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(char[] r, char[] a, int[] indexMap, boolean[] mask) {
|
||||
char[] expected = new char[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(char[] r, char[] a, int[] indexMap) {
|
||||
char[] expected = new char[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] charGatherScatterProvider() {
|
||||
return INT_INDEX_GENERATORS.stream().
|
||||
flatMap(fs -> CHAR_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fs};
|
||||
})).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] charGatherScatterMaskProvider() {
|
||||
return BOOLEAN_MASK_GENERATORS.stream().
|
||||
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
|
||||
CHAR_GENERATORS.stream().map(fa -> {
|
||||
return new Object[] {fa, fm, fs};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
|
||||
@Test(dataProvider = "charGatherScatterProvider")
|
||||
static void charGather(IntFunction<char[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
char[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
char[] r = new char[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
$abstractvectortype$ av = $abstractvectortype$.fromCharArray(SPECIES, a, i, b, i);
|
||||
av.intoCharArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "charGatherScatterMaskProvider")
|
||||
static void charGatherMask(IntFunction<char[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
char[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
char[] r = new char[a.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$.fromCharArray(SPECIES, a, i, b, i, vmask);
|
||||
av.intoCharArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "charGatherScatterProvider")
|
||||
static void charScatter(IntFunction<char[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
char[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
char[] r = new char[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
$abstractvectortype$ av = $abstractvectortype$.fromCharArray(SPECIES, a, i);
|
||||
av.intoCharArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "charGatherScatterMaskProvider")
|
||||
static void charScatterMask(IntFunction<char[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
char[] a = fa.apply(SPECIES.length());
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
char[] r = new char[a.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$.fromCharArray(SPECIES, a, i);
|
||||
av.intoCharArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
#end[short]
|
||||
|
||||
#if[byte]
|
||||
static void assertGatherArraysEquals(boolean[] r, boolean[] a, int[] indexMap) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]]);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertGatherArraysEquals(boolean[] r, boolean[] a, int[] indexMap, boolean[] mask) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try {
|
||||
for (; i < a.length; i += SPECIES.length()) {
|
||||
j = i;
|
||||
for (; j < i + SPECIES.length(); j++) {
|
||||
Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: false);
|
||||
}
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: false, "at index #" + j);
|
||||
}
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(boolean[] r, boolean[] a, int[] indexMap, boolean[] mask) {
|
||||
boolean[] expected = new boolean[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
if (mask[j % SPECIES.length()]) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
static void assertScatterArraysEquals(boolean[] r, boolean[] a, int[] indexMap) {
|
||||
boolean[] expected = new boolean[r.length];
|
||||
|
||||
// Store before checking, since the same location may be stored to more than once
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expected[i + indexMap[j]] = a[j];
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(r, expected);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void booleanGather(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
boolean[] a = convertToBooleanArray(fa.apply(SPECIES.length()));
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
boolean[] r = new boolean[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
$abstractvectortype$ av = $abstractvectortype$.fromBooleanArray(SPECIES, a, i, b, i);
|
||||
av.intoBooleanArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void booleanGatherMask(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
boolean[] a = convertToBooleanArray(fa.apply(SPECIES.length()));
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
boolean[] r = new boolean[a.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$.fromBooleanArray(SPECIES, a, i, b, i, vmask);
|
||||
av.intoBooleanArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertGatherArraysEquals(r, a, b, mask);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterProvider")
|
||||
static void booleanScatter(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs) {
|
||||
boolean[] a = convertToBooleanArray(fa.apply(SPECIES.length()));
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
boolean[] r = new boolean[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
$abstractvectortype$ av = $abstractvectortype$.fromBooleanArray(SPECIES, a, i);
|
||||
av.intoBooleanArray(r, i, b, i);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "gatherScatterMaskProvider")
|
||||
static void booleanScatterMask(IntFunction<byte[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
|
||||
boolean[] a = convertToBooleanArray(fa.apply(SPECIES.length()));
|
||||
int[] b = fs.apply(a.length, SPECIES.length());
|
||||
boolean[] r = new boolean[a.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$.fromBooleanArray(SPECIES, a, i);
|
||||
av.intoBooleanArray(r, i, b, i, vmask);
|
||||
}
|
||||
}
|
||||
|
||||
assertScatterArraysEquals(r, a, b, mask);
|
||||
}
|
||||
#end[byte]
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user