< prev index next >

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java

Print this page
rev 54658 : refactored mask and shuffle creation methods, moved classes to top-level

*** 54,84 **** long apply(int i, long a); } abstract LongVector uOp(FUnOp f); ! abstract LongVector uOp(Mask<Long> m, FUnOp f); // Binary operator interface FBinOp { long apply(int i, long a, long b); } abstract LongVector bOp(Vector<Long> v, FBinOp f); ! abstract LongVector bOp(Vector<Long> v, Mask<Long> m, FBinOp f); // Trinary operator interface FTriOp { long apply(int i, long a, long b, long c); } abstract LongVector tOp(Vector<Long> v1, Vector<Long> v2, FTriOp f); ! abstract LongVector tOp(Vector<Long> v1, Vector<Long> v2, Mask<Long> m, FTriOp f); // Reduction operator abstract long rOp(long v, FBinOp f); --- 54,84 ---- long apply(int i, long a); } abstract LongVector uOp(FUnOp f); ! abstract LongVector uOp(VectorMask<Long> m, FUnOp f); // Binary operator interface FBinOp { long apply(int i, long a, long b); } abstract LongVector bOp(Vector<Long> v, FBinOp f); ! abstract LongVector bOp(Vector<Long> v, VectorMask<Long> m, FBinOp f); // Trinary operator interface FTriOp { long apply(int i, long a, long b, long c); } abstract LongVector tOp(Vector<Long> v1, Vector<Long> v2, FTriOp f); ! abstract LongVector tOp(Vector<Long> v1, Vector<Long> v2, VectorMask<Long> m, FTriOp f); // Reduction operator abstract long rOp(long v, FBinOp f);
*** 86,106 **** interface FBinTest { boolean apply(int i, long a, long b); } ! abstract Mask<Long> bTest(Vector<Long> v, FBinTest f); // Foreach interface FUnCon { void apply(int i, long a); } abstract void forEach(FUnCon f); ! abstract void forEach(Mask<Long> m, FUnCon f); // Static factories /** * Returns a vector where all lane elements are set to the default --- 86,106 ---- interface FBinTest { boolean apply(int i, long a, long b); } ! abstract VectorMask<Long> bTest(Vector<Long> v, FBinTest f); // Foreach interface FUnCon { void apply(int i, long a); } abstract void forEach(FUnCon f); ! abstract void forEach(VectorMask<Long> m, FUnCon f); // Static factories /** * Returns a vector where all lane elements are set to the default
*** 109,119 **** * @param species species of desired vector * @return a zero vector of given species */ @ForceInline @SuppressWarnings("unchecked") ! public static LongVector zero(Species<Long> species) { return VectorIntrinsics.broadcastCoerced((Class<LongVector>) species.boxType(), long.class, species.length(), 0, species, ((bits, s) -> ((LongSpecies)s).op(i -> (long)bits))); } --- 109,119 ---- * @param species species of desired vector * @return a zero vector of given species */ @ForceInline @SuppressWarnings("unchecked") ! public static LongVector zero(VectorSpecies<Long> species) { return VectorIntrinsics.broadcastCoerced((Class<LongVector>) species.boxType(), long.class, species.length(), 0, species, ((bits, s) -> ((LongSpecies)s).op(i -> (long)bits))); }
*** 123,133 **** * Bytes are composed into primitive lane elements according to the * native byte order of the underlying platform * <p> * This method behaves as if it returns the result of calling the * byte buffer, offset, and mask accepting ! * {@link #fromByteBuffer(Species<Long>, ByteBuffer, int, Mask) method} as follows: * <pre>{@code * return this.fromByteBuffer(ByteBuffer.wrap(a), i, this.maskAllTrue()); * }</pre> * * @param species species of desired vector --- 123,133 ---- * Bytes are composed into primitive lane elements according to the * native byte order of the underlying platform * <p> * This method behaves as if it returns the result of calling the * byte buffer, offset, and mask accepting ! * {@link #fromByteBuffer(VectorSpecies<Long>, ByteBuffer, int, VectorMask) method} as follows: * <pre>{@code * return this.fromByteBuffer(ByteBuffer.wrap(a), i, this.maskAllTrue()); * }</pre> * * @param species species of desired vector
*** 137,147 **** * @throws IndexOutOfBoundsException if {@code i < 0} or * {@code i > a.length - (this.length() * this.elementSize() / Byte.SIZE)} */ @ForceInline @SuppressWarnings("unchecked") ! public static LongVector fromByteArray(Species<Long> species, byte[] a, int ix) { Objects.requireNonNull(a); ix = VectorIntrinsics.checkIndex(ix, a.length, species.bitSize() / Byte.SIZE); return VectorIntrinsics.load((Class<LongVector>) species.boxType(), long.class, species.length(), a, ((long) ix) + Unsafe.ARRAY_BYTE_BASE_OFFSET, a, ix, species, --- 137,147 ---- * @throws IndexOutOfBoundsException if {@code i < 0} or * {@code i > a.length - (this.length() * this.elementSize() / Byte.SIZE)} */ @ForceInline @SuppressWarnings("unchecked") ! public static LongVector fromByteArray(VectorSpecies<Long> species, byte[] a, int ix) { Objects.requireNonNull(a); ix = VectorIntrinsics.checkIndex(ix, a.length, species.bitSize() / Byte.SIZE); return VectorIntrinsics.load((Class<LongVector>) species.boxType(), long.class, species.length(), a, ((long) ix) + Unsafe.ARRAY_BYTE_BASE_OFFSET, a, ix, species,
*** 159,169 **** * Bytes are composed into primitive lane elements according to the * native byte order of the underlying platform. * <p> * This method behaves as if it returns the result of calling the * byte buffer, offset, and mask accepting ! * {@link #fromByteBuffer(Species<Long>, ByteBuffer, int, Mask) method} as follows: * <pre>{@code * return this.fromByteBuffer(ByteBuffer.wrap(a), i, m); * }</pre> * * @param species species of desired vector --- 159,169 ---- * Bytes are composed into primitive lane elements according to the * native byte order of the underlying platform. * <p> * This method behaves as if it returns the result of calling the * byte buffer, offset, and mask accepting ! * {@link #fromByteBuffer(VectorSpecies<Long>, ByteBuffer, int, VectorMask) method} as follows: * <pre>{@code * return this.fromByteBuffer(ByteBuffer.wrap(a), i, m); * }</pre> * * @param species species of desired vector
*** 178,188 **** * for any vector lane index {@code N} where the mask at lane {@code N} * is set * {@code i >= a.length - (N * this.elementSize() / Byte.SIZE)} */ @ForceInline ! public static LongVector fromByteArray(Species<Long> species, byte[] a, int ix, Mask<Long> m) { return zero(species).blend(fromByteArray(species, a, ix), m); } /** * Loads a vector from an array starting at offset. --- 178,188 ---- * for any vector lane index {@code N} where the mask at lane {@code N} * is set * {@code i >= a.length - (N * this.elementSize() / Byte.SIZE)} */ @ForceInline ! public static LongVector fromByteArray(VectorSpecies<Long> species, byte[] a, int ix, VectorMask<Long> m) { return zero(species).blend(fromByteArray(species, a, ix), m); } /** * Loads a vector from an array starting at offset.
*** 198,208 **** * @throws IndexOutOfBoundsException if {@code i < 0}, or * {@code i > a.length - this.length()} */ @ForceInline @SuppressWarnings("unchecked") ! public static LongVector fromArray(Species<Long> species, long[] a, int i){ Objects.requireNonNull(a); i = VectorIntrinsics.checkIndex(i, a.length, species.length()); return VectorIntrinsics.load((Class<LongVector>) species.boxType(), long.class, species.length(), a, (((long) i) << ARRAY_SHIFT) + Unsafe.ARRAY_LONG_BASE_OFFSET, a, i, species, --- 198,208 ---- * @throws IndexOutOfBoundsException if {@code i < 0}, or * {@code i > a.length - this.length()} */ @ForceInline @SuppressWarnings("unchecked") ! public static LongVector fromArray(VectorSpecies<Long> species, long[] a, int i){ Objects.requireNonNull(a); i = VectorIntrinsics.checkIndex(i, a.length, species.length()); return VectorIntrinsics.load((Class<LongVector>) species.boxType(), long.class, species.length(), a, (((long) i) << ARRAY_SHIFT) + Unsafe.ARRAY_LONG_BASE_OFFSET, a, i, species,
*** 227,237 **** * @throws IndexOutOfBoundsException if {@code i < 0}, or * for any vector lane index {@code N} where the mask at lane {@code N} * is set {@code i > a.length - N} */ @ForceInline ! public static LongVector fromArray(Species<Long> species, long[] a, int i, Mask<Long> m) { return zero(species).blend(fromArray(species, a, i), m); } /** * Loads a vector from an array using indexes obtained from an index --- 227,237 ---- * @throws IndexOutOfBoundsException if {@code i < 0}, or * for any vector lane index {@code N} where the mask at lane {@code N} * is set {@code i > a.length - N} */ @ForceInline ! public static LongVector fromArray(VectorSpecies<Long> species, long[] a, int i, VectorMask<Long> m) { return zero(species).blend(fromArray(species, a, i), m); } /** * Loads a vector from an array using indexes obtained from an index
*** 254,264 **** * or for any vector lane index {@code N} the result of * {@code i + indexMap[j + N]} is {@code < 0} or {@code >= a.length} */ @ForceInline @SuppressWarnings("unchecked") ! public static LongVector fromArray(Species<Long> species, long[] a, int i, int[] indexMap, int j) { Objects.requireNonNull(a); Objects.requireNonNull(indexMap); if (species.length() == 1) { return LongVector.fromArray(species, a, i + indexMap[j]); --- 254,264 ---- * or for any vector lane index {@code N} the result of * {@code i + indexMap[j + N]} is {@code < 0} or {@code >= a.length} */ @ForceInline @SuppressWarnings("unchecked") ! public static LongVector fromArray(VectorSpecies<Long> species, long[] a, int i, int[] indexMap, int j) { Objects.requireNonNull(a); Objects.requireNonNull(indexMap); if (species.length() == 1) { return LongVector.fromArray(species, a, i + indexMap[j]);
*** 270,280 **** vix = VectorIntrinsics.checkIndex(vix, a.length); return VectorIntrinsics.loadWithMap((Class<LongVector>) species.boxType(), long.class, species.length(), IntVector.species(species.indexShape()).boxType(), a, Unsafe.ARRAY_LONG_BASE_OFFSET, vix, a, i, indexMap, j, species, ! (long[] c, int idx, int[] iMap, int idy, Species<Long> s) -> ((LongSpecies)s).op(n -> c[idx + iMap[idy+n]])); } /** * Loads a vector from an array using indexes obtained from an index --- 270,280 ---- vix = VectorIntrinsics.checkIndex(vix, a.length); return VectorIntrinsics.loadWithMap((Class<LongVector>) species.boxType(), long.class, species.length(), IntVector.species(species.indexShape()).boxType(), a, Unsafe.ARRAY_LONG_BASE_OFFSET, vix, a, i, indexMap, j, species, ! (long[] c, int idx, int[] iMap, int idy, VectorSpecies<Long> s) -> ((LongSpecies)s).op(n -> c[idx + iMap[idy+n]])); } /** * Loads a vector from an array using indexes obtained from an index
*** 300,310 **** * {@code N} is set the result of {@code i + indexMap[j + N]} is * {@code < 0} or {@code >= a.length} */ @ForceInline @SuppressWarnings("unchecked") ! public static LongVector fromArray(Species<Long> species, long[] a, int i, Mask<Long> m, int[] indexMap, int j) { // @@@ This can result in out of bounds errors for unset mask lanes return zero(species).blend(fromArray(species, a, i, indexMap, j), m); } --- 300,310 ---- * {@code N} is set the result of {@code i + indexMap[j + N]} is * {@code < 0} or {@code >= a.length} */ @ForceInline @SuppressWarnings("unchecked") ! public static LongVector fromArray(VectorSpecies<Long> species, long[] a, int i, VectorMask<Long> m, int[] indexMap, int j) { // @@@ This can result in out of bounds errors for unset mask lanes return zero(species).blend(fromArray(species, a, i, indexMap, j), m); }
*** 315,325 **** * Bytes are composed into primitive lane elements according to the * native byte order of the underlying platform. * <p> * This method behaves as if it returns the result of calling the * byte buffer, offset, and mask accepting ! * {@link #fromByteBuffer(Species<Long>, ByteBuffer, int, Mask)} method} as follows: * <pre>{@code * return this.fromByteBuffer(b, i, this.maskAllTrue()) * }</pre> * * @param species species of desired vector --- 315,325 ---- * Bytes are composed into primitive lane elements according to the * native byte order of the underlying platform. * <p> * This method behaves as if it returns the result of calling the * byte buffer, offset, and mask accepting ! * {@link #fromByteBuffer(VectorSpecies<Long>, ByteBuffer, int, VectorMask)} method} as follows: * <pre>{@code * return this.fromByteBuffer(b, i, this.maskAllTrue()) * }</pre> * * @param species species of desired vector
*** 332,342 **** * {@code this.length() * this.elementSize() / Byte.SIZE} bytes * remaining in the byte buffer from the given offset */ @ForceInline @SuppressWarnings("unchecked") ! public static LongVector fromByteBuffer(Species<Long> species, ByteBuffer bb, int ix) { if (bb.order() != ByteOrder.nativeOrder()) { throw new IllegalArgumentException(); } ix = VectorIntrinsics.checkIndex(ix, bb.limit(), species.bitSize() / Byte.SIZE); return VectorIntrinsics.load((Class<LongVector>) species.boxType(), long.class, species.length(), --- 332,342 ---- * {@code this.length() * this.elementSize() / Byte.SIZE} bytes * remaining in the byte buffer from the given offset */ @ForceInline @SuppressWarnings("unchecked") ! public static LongVector fromByteBuffer(VectorSpecies<Long> species, ByteBuffer bb, int ix) { if (bb.order() != ByteOrder.nativeOrder()) { throw new IllegalArgumentException(); } ix = VectorIntrinsics.checkIndex(ix, bb.limit(), species.bitSize() / Byte.SIZE); return VectorIntrinsics.load((Class<LongVector>) species.boxType(), long.class, species.length(),
*** 384,394 **** * for any vector lane index {@code N} where the mask at lane {@code N} * is set * {@code i >= b.limit() - (N * this.elementSize() / Byte.SIZE)} */ @ForceInline ! public static LongVector fromByteBuffer(Species<Long> species, ByteBuffer bb, int ix, Mask<Long> m) { return zero(species).blend(fromByteBuffer(species, bb, ix), m); } /** * Returns a vector where all lane elements are set to the primitive --- 384,394 ---- * for any vector lane index {@code N} where the mask at lane {@code N} * is set * {@code i >= b.limit() - (N * this.elementSize() / Byte.SIZE)} */ @ForceInline ! public static LongVector fromByteBuffer(VectorSpecies<Long> species, ByteBuffer bb, int ix, VectorMask<Long> m) { return zero(species).blend(fromByteBuffer(species, bb, ix), m); } /** * Returns a vector where all lane elements are set to the primitive
*** 399,409 **** * @return a vector of vector where all lane elements are set to * the primitive value {@code e} */ @ForceInline @SuppressWarnings("unchecked") ! public static LongVector broadcast(Species<Long> s, long e) { return VectorIntrinsics.broadcastCoerced( (Class<LongVector>) s.boxType(), long.class, s.length(), e, s, ((bits, sp) -> ((LongSpecies)sp).op(i -> (long)bits))); } --- 399,409 ---- * @return a vector of vector where all lane elements are set to * the primitive value {@code e} */ @ForceInline @SuppressWarnings("unchecked") ! public static LongVector broadcast(VectorSpecies<Long> s, long e) { return VectorIntrinsics.broadcastCoerced( (Class<LongVector>) s.boxType(), long.class, s.length(), e, s, ((bits, sp) -> ((LongSpecies)sp).op(i -> (long)bits))); }
*** 422,432 **** * value * @throws IndexOutOfBoundsException if {@code es.length < this.length()} */ @ForceInline @SuppressWarnings("unchecked") ! public static LongVector scalars(Species<Long> s, long... es) { Objects.requireNonNull(es); int ix = VectorIntrinsics.checkIndex(0, es.length, s.length()); return VectorIntrinsics.load((Class<LongVector>) s.boxType(), long.class, s.length(), es, Unsafe.ARRAY_LONG_BASE_OFFSET, es, ix, s, --- 422,432 ---- * value * @throws IndexOutOfBoundsException if {@code es.length < this.length()} */ @ForceInline @SuppressWarnings("unchecked") ! public static LongVector scalars(VectorSpecies<Long> s, long... es) { Objects.requireNonNull(es); int ix = VectorIntrinsics.checkIndex(0, es.length, s.length()); return VectorIntrinsics.load((Class<LongVector>) s.boxType(), long.class, s.length(), es, Unsafe.ARRAY_LONG_BASE_OFFSET, es, ix, s,
*** 442,452 **** * @param e the value * @return a vector where the first lane element is set to the primitive * value {@code e} */ @ForceInline ! public static final LongVector single(Species<Long> s, long e) { return zero(s).with(0, e); } /** * Returns a vector where each lane element is set to a randomly --- 442,452 ---- * @param e the value * @return a vector where the first lane element is set to the primitive * value {@code e} */ @ForceInline ! public static final LongVector single(VectorSpecies<Long> s, long e) { return zero(s).with(0, e); } /** * Returns a vector where each lane element is set to a randomly
*** 457,695 **** * * @param s species of the desired vector * @return a vector where each lane elements is set to a randomly * generated primitive value */ ! public static LongVector random(Species<Long> s) { ThreadLocalRandom r = ThreadLocalRandom.current(); return ((LongSpecies)s).op(i -> r.nextLong()); } - /** - * Returns a mask where each lane is set or unset according to given - * {@code boolean} values - * <p> - * For each mask lane, where {@code N} is the mask lane index, - * if the given {@code boolean} value at index {@code N} is {@code true} - * then the mask lane at index {@code N} is set, otherwise it is unset. - * - * @param species mask species - * @param bits the given {@code boolean} values - * @return a mask where each lane is set or unset according to the given {@code boolean} value - * @throws IndexOutOfBoundsException if {@code bits.length < species.length()} - */ - @ForceInline - public static Mask<Long> maskFromValues(Species<Long> species, boolean... bits) { - if (species.boxType() == LongMaxVector.class) - return new LongMaxVector.LongMaxMask(bits); - switch (species.bitSize()) { - case 64: return new Long64Vector.Long64Mask(bits); - case 128: return new Long128Vector.Long128Mask(bits); - case 256: return new Long256Vector.Long256Mask(bits); - case 512: return new Long512Vector.Long512Mask(bits); - default: throw new IllegalArgumentException(Integer.toString(species.bitSize())); - } - } - - // @@@ This is a bad implementation -- makes lambdas capturing -- fix this - static Mask<Long> trueMask(Species<Long> species) { - if (species.boxType() == LongMaxVector.class) - return LongMaxVector.LongMaxMask.TRUE_MASK; - switch (species.bitSize()) { - case 64: return Long64Vector.Long64Mask.TRUE_MASK; - case 128: return Long128Vector.Long128Mask.TRUE_MASK; - case 256: return Long256Vector.Long256Mask.TRUE_MASK; - case 512: return Long512Vector.Long512Mask.TRUE_MASK; - default: throw new IllegalArgumentException(Integer.toString(species.bitSize())); - } - } - - static Mask<Long> falseMask(Species<Long> species) { - if (species.boxType() == LongMaxVector.class) - return LongMaxVector.LongMaxMask.FALSE_MASK; - switch (species.bitSize()) { - case 64: return Long64Vector.Long64Mask.FALSE_MASK; - case 128: return Long128Vector.Long128Mask.FALSE_MASK; - case 256: return Long256Vector.Long256Mask.FALSE_MASK; - case 512: return Long512Vector.Long512Mask.FALSE_MASK; - default: throw new IllegalArgumentException(Integer.toString(species.bitSize())); - } - } - - /** - * Loads a mask from a {@code boolean} array starting at an offset. - * <p> - * For each mask lane, where {@code N} is the mask lane index, - * if the array element at index {@code ix + N} is {@code true} then the - * mask lane at index {@code N} is set, otherwise it is unset. - * - * @param species mask species - * @param bits the {@code boolean} array - * @param ix the offset into the array - * @return the mask loaded from a {@code boolean} array - * @throws IndexOutOfBoundsException if {@code ix < 0}, or - * {@code ix > bits.length - species.length()} - */ - @ForceInline - @SuppressWarnings("unchecked") - public static Mask<Long> maskFromArray(Species<Long> species, boolean[] bits, int ix) { - Objects.requireNonNull(bits); - ix = VectorIntrinsics.checkIndex(ix, bits.length, species.length()); - return VectorIntrinsics.load((Class<Mask<Long>>) species.maskType(), long.class, species.length(), - bits, (((long) ix) << ARRAY_SHIFT) + Unsafe.ARRAY_BOOLEAN_BASE_OFFSET, - bits, ix, species, - (c, idx, s) -> (Mask<Long>) ((LongSpecies)s).opm(n -> c[idx + n])); - } - - /** - * Returns a mask where all lanes are set. - * - * @param species mask species - * @return a mask where all lanes are set - */ - @ForceInline - @SuppressWarnings("unchecked") - public static Mask<Long> maskAllTrue(Species<Long> species) { - return VectorIntrinsics.broadcastCoerced((Class<Mask<Long>>) species.maskType(), long.class, species.length(), - (long)-1, species, - ((z, s) -> trueMask(s))); - } - - /** - * Returns a mask where all lanes are unset. - * - * @param species mask species - * @return a mask where all lanes are unset - */ - @ForceInline - @SuppressWarnings("unchecked") - public static Mask<Long> maskAllFalse(Species<Long> species) { - return VectorIntrinsics.broadcastCoerced((Class<Mask<Long>>) species.maskType(), long.class, species.length(), - 0, species, - ((z, s) -> falseMask(s))); - } - - /** - * Returns a shuffle of mapped indexes where each lane element is - * the result of applying a mapping function to the corresponding lane - * index. - * <p> - * Care should be taken to ensure Shuffle values produced from this - * method are consumed as constants to ensure optimal generation of - * code. For example, values held in static final fields or values - * held in loop constant local variables. - * <p> - * This method behaves as if a shuffle is created from an array of - * mapped indexes as follows: - * <pre>{@code - * int[] a = new int[species.length()]; - * for (int i = 0; i < a.length; i++) { - * a[i] = f.applyAsInt(i); - * } - * return this.shuffleFromValues(a); - * }</pre> - * - * @param species shuffle species - * @param f the lane index mapping function - * @return a shuffle of mapped indexes - */ - @ForceInline - public static Shuffle<Long> shuffle(Species<Long> species, IntUnaryOperator f) { - if (species.boxType() == LongMaxVector.class) - return new LongMaxVector.LongMaxShuffle(f); - switch (species.bitSize()) { - case 64: return new Long64Vector.Long64Shuffle(f); - case 128: return new Long128Vector.Long128Shuffle(f); - case 256: return new Long256Vector.Long256Shuffle(f); - case 512: return new Long512Vector.Long512Shuffle(f); - default: throw new IllegalArgumentException(Integer.toString(species.bitSize())); - } - } - - /** - * Returns a shuffle where each lane element is the value of its - * corresponding lane index. - * <p> - * This method behaves as if a shuffle is created from an identity - * index mapping function as follows: - * <pre>{@code - * return this.shuffle(i -> i); - * }</pre> - * - * @param species shuffle species - * @return a shuffle of lane indexes - */ - @ForceInline - public static Shuffle<Long> shuffleIota(Species<Long> species) { - if (species.boxType() == LongMaxVector.class) - return new LongMaxVector.LongMaxShuffle(AbstractShuffle.IDENTITY); - switch (species.bitSize()) { - case 64: return new Long64Vector.Long64Shuffle(AbstractShuffle.IDENTITY); - case 128: return new Long128Vector.Long128Shuffle(AbstractShuffle.IDENTITY); - case 256: return new Long256Vector.Long256Shuffle(AbstractShuffle.IDENTITY); - case 512: return new Long512Vector.Long512Shuffle(AbstractShuffle.IDENTITY); - default: throw new IllegalArgumentException(Integer.toString(species.bitSize())); - } - } - - /** - * Returns a shuffle where each lane element is set to a given - * {@code int} value logically AND'ed by the species length minus one. - * <p> - * For each shuffle lane, where {@code N} is the shuffle lane index, the - * the {@code int} value at index {@code N} logically AND'ed by - * {@code species.length() - 1} is placed into the resulting shuffle at - * lane index {@code N}. - * - * @param species shuffle species - * @param ixs the given {@code int} values - * @return a shuffle where each lane element is set to a given - * {@code int} value - * @throws IndexOutOfBoundsException if the number of int values is - * {@code < species.length()} - */ - @ForceInline - public static Shuffle<Long> shuffleFromValues(Species<Long> species, int... ixs) { - if (species.boxType() == LongMaxVector.class) - return new LongMaxVector.LongMaxShuffle(ixs); - switch (species.bitSize()) { - case 64: return new Long64Vector.Long64Shuffle(ixs); - case 128: return new Long128Vector.Long128Shuffle(ixs); - case 256: return new Long256Vector.Long256Shuffle(ixs); - case 512: return new Long512Vector.Long512Shuffle(ixs); - default: throw new IllegalArgumentException(Integer.toString(species.bitSize())); - } - } - - /** - * Loads a shuffle from an {@code int} array starting at an offset. - * <p> - * For each shuffle lane, where {@code N} is the shuffle lane index, the - * array element at index {@code i + N} logically AND'ed by - * {@code species.length() - 1} is placed into the resulting shuffle at lane - * index {@code N}. - * - * @param species shuffle species - * @param ixs the {@code int} array - * @param i the offset into the array - * @return a shuffle loaded from the {@code int} array - * @throws IndexOutOfBoundsException if {@code i < 0}, or - * {@code i > a.length - species.length()} - */ - @ForceInline - public static Shuffle<Long> shuffleFromArray(Species<Long> species, int[] ixs, int i) { - if (species.boxType() == LongMaxVector.class) - return new LongMaxVector.LongMaxShuffle(ixs, i); - switch (species.bitSize()) { - case 64: return new Long64Vector.Long64Shuffle(ixs, i); - case 128: return new Long128Vector.Long128Shuffle(ixs, i); - case 256: return new Long256Vector.Long256Shuffle(ixs, i); - case 512: return new Long512Vector.Long512Shuffle(ixs, i); - default: throw new IllegalArgumentException(Integer.toString(species.bitSize())); - } - } - // Ops @Override public abstract LongVector add(Vector<Long> v); --- 457,471 ---- * * @param s species of the desired vector * @return a vector where each lane elements is set to a randomly * generated primitive value */ ! public static LongVector random(VectorSpecies<Long> s) { ThreadLocalRandom r = ThreadLocalRandom.current(); return ((LongSpecies)s).op(i -> r.nextLong()); } // Ops @Override public abstract LongVector add(Vector<Long> v);
*** 704,714 **** * scalar */ public abstract LongVector add(long s); @Override ! public abstract LongVector add(Vector<Long> v, Mask<Long> m); /** * Adds this vector to broadcast of an input scalar, * selecting lane elements controlled by a mask. * <p> --- 480,490 ---- * scalar */ public abstract LongVector add(long s); @Override ! public abstract LongVector add(Vector<Long> v, VectorMask<Long> m); /** * Adds this vector to broadcast of an input scalar, * selecting lane elements controlled by a mask. * <p>
*** 718,728 **** * @param s the input scalar * @param m the mask controlling lane selection * @return the result of adding this vector to the broadcast of an input * scalar */ ! public abstract LongVector add(long s, Mask<Long> m); @Override public abstract LongVector sub(Vector<Long> v); /** --- 494,504 ---- * @param s the input scalar * @param m the mask controlling lane selection * @return the result of adding this vector to the broadcast of an input * scalar */ ! public abstract LongVector add(long s, VectorMask<Long> m); @Override public abstract LongVector sub(Vector<Long> v); /**
*** 736,746 **** * scalar from this vector */ public abstract LongVector sub(long s); @Override ! public abstract LongVector sub(Vector<Long> v, Mask<Long> m); /** * Subtracts the broadcast of an input scalar from this vector, selecting * lane elements controlled by a mask. * <p> --- 512,522 ---- * scalar from this vector */ public abstract LongVector sub(long s); @Override ! public abstract LongVector sub(Vector<Long> v, VectorMask<Long> m); /** * Subtracts the broadcast of an input scalar from this vector, selecting * lane elements controlled by a mask. * <p>
*** 750,760 **** * @param s the input scalar * @param m the mask controlling lane selection * @return the result of subtracting the broadcast of an input * scalar from this vector */ ! public abstract LongVector sub(long s, Mask<Long> m); @Override public abstract LongVector mul(Vector<Long> v); /** --- 526,536 ---- * @param s the input scalar * @param m the mask controlling lane selection * @return the result of subtracting the broadcast of an input * scalar from this vector */ ! public abstract LongVector sub(long s, VectorMask<Long> m); @Override public abstract LongVector mul(Vector<Long> v); /**
*** 768,778 **** * input scalar */ public abstract LongVector mul(long s); @Override ! public abstract LongVector mul(Vector<Long> v, Mask<Long> m); /** * Multiplies this vector with the broadcast of an input scalar, selecting * lane elements controlled by a mask. * <p> --- 544,554 ---- * input scalar */ public abstract LongVector mul(long s); @Override ! public abstract LongVector mul(Vector<Long> v, VectorMask<Long> m); /** * Multiplies this vector with the broadcast of an input scalar, selecting * lane elements controlled by a mask. * <p>
*** 782,810 **** * @param s the input scalar * @param m the mask controlling lane selection * @return the result of multiplying this vector with the broadcast of an * input scalar */ ! public abstract LongVector mul(long s, Mask<Long> m); @Override public abstract LongVector neg(); @Override ! public abstract LongVector neg(Mask<Long> m); @Override public abstract LongVector abs(); @Override ! public abstract LongVector abs(Mask<Long> m); @Override public abstract LongVector min(Vector<Long> v); @Override ! public abstract LongVector min(Vector<Long> v, Mask<Long> m); /** * Returns the minimum of this vector and the broadcast of an input scalar. * <p> * This is a vector binary operation where the operation --- 558,586 ---- * @param s the input scalar * @param m the mask controlling lane selection * @return the result of multiplying this vector with the broadcast of an * input scalar */ ! public abstract LongVector mul(long s, VectorMask<Long> m); @Override public abstract LongVector neg(); @Override ! public abstract LongVector neg(VectorMask<Long> m); @Override public abstract LongVector abs(); @Override ! public abstract LongVector abs(VectorMask<Long> m); @Override public abstract LongVector min(Vector<Long> v); @Override ! public abstract LongVector min(Vector<Long> v, VectorMask<Long> m); /** * Returns the minimum of this vector and the broadcast of an input scalar. * <p> * This is a vector binary operation where the operation
*** 817,827 **** @Override public abstract LongVector max(Vector<Long> v); @Override ! public abstract LongVector max(Vector<Long> v, Mask<Long> m); /** * Returns the maximum of this vector and the broadcast of an input scalar. * <p> * This is a vector binary operation where the operation --- 593,603 ---- @Override public abstract LongVector max(Vector<Long> v); @Override ! public abstract LongVector max(Vector<Long> v, VectorMask<Long> m); /** * Returns the maximum of this vector and the broadcast of an input scalar. * <p> * This is a vector binary operation where the operation
*** 831,841 **** * @return the maximum of this vector and the broadcast of an input scalar */ public abstract LongVector max(long s); @Override ! public abstract Mask<Long> equal(Vector<Long> v); /** * Tests if this vector is equal to the broadcast of an input scalar. * <p> * This is a vector binary test operation where the primitive equals --- 607,617 ---- * @return the maximum of this vector and the broadcast of an input scalar */ public abstract LongVector max(long s); @Override ! public abstract VectorMask<Long> equal(Vector<Long> v); /** * Tests if this vector is equal to the broadcast of an input scalar. * <p> * This is a vector binary test operation where the primitive equals
*** 843,856 **** * * @param s the input scalar * @return the result mask of testing if this vector is equal to the * broadcast of an input scalar */ ! public abstract Mask<Long> equal(long s); @Override ! public abstract Mask<Long> notEqual(Vector<Long> v); /** * Tests if this vector is not equal to the broadcast of an input scalar. * <p> * This is a vector binary test operation where the primitive not equals --- 619,632 ---- * * @param s the input scalar * @return the result mask of testing if this vector is equal to the * broadcast of an input scalar */ ! public abstract VectorMask<Long> equal(long s); @Override ! public abstract VectorMask<Long> notEqual(Vector<Long> v); /** * Tests if this vector is not equal to the broadcast of an input scalar. * <p> * This is a vector binary test operation where the primitive not equals
*** 858,871 **** * * @param s the input scalar * @return the result mask of testing if this vector is not equal to the * broadcast of an input scalar */ ! public abstract Mask<Long> notEqual(long s); @Override ! public abstract Mask<Long> lessThan(Vector<Long> v); /** * Tests if this vector is less than the broadcast of an input scalar. * <p> * This is a vector binary test operation where the primitive less than --- 634,647 ---- * * @param s the input scalar * @return the result mask of testing if this vector is not equal to the * broadcast of an input scalar */ ! public abstract VectorMask<Long> notEqual(long s); @Override ! public abstract VectorMask<Long> lessThan(Vector<Long> v); /** * Tests if this vector is less than the broadcast of an input scalar. * <p> * This is a vector binary test operation where the primitive less than
*** 873,886 **** * * @param s the input scalar * @return the mask result of testing if this vector is less than the * broadcast of an input scalar */ ! public abstract Mask<Long> lessThan(long s); @Override ! public abstract Mask<Long> lessThanEq(Vector<Long> v); /** * Tests if this vector is less or equal to the broadcast of an input scalar. * <p> * This is a vector binary test operation where the primitive less than --- 649,662 ---- * * @param s the input scalar * @return the mask result of testing if this vector is less than the * broadcast of an input scalar */ ! public abstract VectorMask<Long> lessThan(long s); @Override ! public abstract VectorMask<Long> lessThanEq(Vector<Long> v); /** * Tests if this vector is less or equal to the broadcast of an input scalar. * <p> * This is a vector binary test operation where the primitive less than
*** 888,901 **** * * @param s the input scalar * @return the mask result of testing if this vector is less than or equal * to the broadcast of an input scalar */ ! public abstract Mask<Long> lessThanEq(long s); @Override ! public abstract Mask<Long> greaterThan(Vector<Long> v); /** * Tests if this vector is greater than the broadcast of an input scalar. * <p> * This is a vector binary test operation where the primitive greater than --- 664,677 ---- * * @param s the input scalar * @return the mask result of testing if this vector is less than or equal * to the broadcast of an input scalar */ ! public abstract VectorMask<Long> lessThanEq(long s); @Override ! public abstract VectorMask<Long> greaterThan(Vector<Long> v); /** * Tests if this vector is greater than the broadcast of an input scalar. * <p> * This is a vector binary test operation where the primitive greater than
*** 903,916 **** * * @param s the input scalar * @return the mask result of testing if this vector is greater than the * broadcast of an input scalar */ ! public abstract Mask<Long> greaterThan(long s); @Override ! public abstract Mask<Long> greaterThanEq(Vector<Long> v); /** * Tests if this vector is greater than or equal to the broadcast of an * input scalar. * <p> --- 679,692 ---- * * @param s the input scalar * @return the mask result of testing if this vector is greater than the * broadcast of an input scalar */ ! public abstract VectorMask<Long> greaterThan(long s); @Override ! public abstract VectorMask<Long> greaterThanEq(Vector<Long> v); /** * Tests if this vector is greater than or equal to the broadcast of an * input scalar. * <p>
*** 919,932 **** * * @param s the input scalar * @return the mask result of testing if this vector is greater than or * equal to the broadcast of an input scalar */ ! public abstract Mask<Long> greaterThanEq(long s); @Override ! public abstract LongVector blend(Vector<Long> v, Mask<Long> m); /** * Blends the lane elements of this vector with those of the broadcast of an * input scalar, selecting lanes controlled by a mask. * <p> --- 695,708 ---- * * @param s the input scalar * @return the mask result of testing if this vector is greater than or * equal to the broadcast of an input scalar */ ! public abstract VectorMask<Long> greaterThanEq(long s); @Override ! public abstract LongVector blend(Vector<Long> v, VectorMask<Long> m); /** * Blends the lane elements of this vector with those of the broadcast of an * input scalar, selecting lanes controlled by a mask. * <p>
*** 939,959 **** * @param s the input scalar * @param m the mask controlling lane selection * @return the result of blending the lane elements of this vector with * those of the broadcast of an input scalar */ ! public abstract LongVector blend(long s, Mask<Long> m); @Override public abstract LongVector rearrange(Vector<Long> v, ! Shuffle<Long> s, Mask<Long> m); @Override ! public abstract LongVector rearrange(Shuffle<Long> m); @Override ! public abstract LongVector reshape(Species<Long> s); @Override public abstract LongVector rotateEL(int i); @Override --- 715,735 ---- * @param s the input scalar * @param m the mask controlling lane selection * @return the result of blending the lane elements of this vector with * those of the broadcast of an input scalar */ ! public abstract LongVector blend(long s, VectorMask<Long> m); @Override public abstract LongVector rearrange(Vector<Long> v, ! VectorShuffle<Long> s, VectorMask<Long> m); @Override ! public abstract LongVector rearrange(VectorShuffle<Long> m); @Override ! public abstract LongVector reshape(VectorSpecies<Long> s); @Override public abstract LongVector rotateEL(int i); @Override
*** 999,1009 **** * * @param v the input vector * @param m the mask controlling lane selection * @return the bitwise AND of this vector with the input vector */ ! public abstract LongVector and(Vector<Long> v, Mask<Long> m); /** * Bitwise ANDs this vector with the broadcast of an input scalar, selecting * lane elements controlled by a mask. * <p> --- 775,785 ---- * * @param v the input vector * @param m the mask controlling lane selection * @return the bitwise AND of this vector with the input vector */ ! public abstract LongVector and(Vector<Long> v, VectorMask<Long> m); /** * Bitwise ANDs this vector with the broadcast of an input scalar, selecting * lane elements controlled by a mask. * <p>
*** 1013,1023 **** * @param s the input scalar * @param m the mask controlling lane selection * @return the bitwise AND of this vector with the broadcast of an input * scalar */ ! public abstract LongVector and(long s, Mask<Long> m); /** * Bitwise ORs this vector with an input vector. * <p> * This is a vector binary operation where the primitive bitwise OR --- 789,799 ---- * @param s the input scalar * @param m the mask controlling lane selection * @return the bitwise AND of this vector with the broadcast of an input * scalar */ ! public abstract LongVector and(long s, VectorMask<Long> m); /** * Bitwise ORs this vector with an input vector. * <p> * This is a vector binary operation where the primitive bitwise OR
*** 1049,1059 **** * * @param v the input vector * @param m the mask controlling lane selection * @return the bitwise OR of this vector with the input vector */ ! public abstract LongVector or(Vector<Long> v, Mask<Long> m); /** * Bitwise ORs this vector with the broadcast of an input scalar, selecting * lane elements controlled by a mask. * <p> --- 825,835 ---- * * @param v the input vector * @param m the mask controlling lane selection * @return the bitwise OR of this vector with the input vector */ ! public abstract LongVector or(Vector<Long> v, VectorMask<Long> m); /** * Bitwise ORs this vector with the broadcast of an input scalar, selecting * lane elements controlled by a mask. * <p>
*** 1063,1073 **** * @param s the input scalar * @param m the mask controlling lane selection * @return the bitwise OR of this vector with the broadcast of an input * scalar */ ! public abstract LongVector or(long s, Mask<Long> m); /** * Bitwise XORs this vector with an input vector. * <p> * This is a vector binary operation where the primitive bitwise XOR --- 839,849 ---- * @param s the input scalar * @param m the mask controlling lane selection * @return the bitwise OR of this vector with the broadcast of an input * scalar */ ! public abstract LongVector or(long s, VectorMask<Long> m); /** * Bitwise XORs this vector with an input vector. * <p> * This is a vector binary operation where the primitive bitwise XOR
*** 1099,1109 **** * * @param v the input vector * @param m the mask controlling lane selection * @return the bitwise XOR of this vector with the input vector */ ! public abstract LongVector xor(Vector<Long> v, Mask<Long> m); /** * Bitwise XORs this vector with the broadcast of an input scalar, selecting * lane elements controlled by a mask. * <p> --- 875,885 ---- * * @param v the input vector * @param m the mask controlling lane selection * @return the bitwise XOR of this vector with the input vector */ ! public abstract LongVector xor(Vector<Long> v, VectorMask<Long> m); /** * Bitwise XORs this vector with the broadcast of an input scalar, selecting * lane elements controlled by a mask. * <p>
*** 1113,1123 **** * @param s the input scalar * @param m the mask controlling lane selection * @return the bitwise XOR of this vector with the broadcast of an input * scalar */ ! public abstract LongVector xor(long s, Mask<Long> m); /** * Bitwise NOTs this vector. * <p> * This is a vector unary operation where the primitive bitwise NOT --- 889,899 ---- * @param s the input scalar * @param m the mask controlling lane selection * @return the bitwise XOR of this vector with the broadcast of an input * scalar */ ! public abstract LongVector xor(long s, VectorMask<Long> m); /** * Bitwise NOTs this vector. * <p> * This is a vector unary operation where the primitive bitwise NOT
*** 1134,1144 **** * operation ({@code ~}) is applied to lane elements. * * @param m the mask controlling lane selection * @return the bitwise NOT of this vector */ ! public abstract LongVector not(Mask<Long> m); /** * Logically left shifts this vector by the broadcast of an input scalar. * <p> * This is a vector binary operation where the primitive logical left shift --- 910,920 ---- * operation ({@code ~}) is applied to lane elements. * * @param m the mask controlling lane selection * @return the bitwise NOT of this vector */ ! public abstract LongVector not(VectorMask<Long> m); /** * Logically left shifts this vector by the broadcast of an input scalar. * <p> * This is a vector binary operation where the primitive logical left shift
*** 1160,1170 **** * @param s the input scalar; the number of the bits to left shift * @param m the mask controlling lane selection * @return the result of logically left shifting this vector by the * broadcast of an input scalar */ ! public abstract LongVector shiftL(int s, Mask<Long> m); /** * Logically left shifts this vector by an input vector. * <p> * This is a vector binary operation where the primitive logical left shift --- 936,946 ---- * @param s the input scalar; the number of the bits to left shift * @param m the mask controlling lane selection * @return the result of logically left shifting this vector by the * broadcast of an input scalar */ ! public abstract LongVector shiftL(int s, VectorMask<Long> m); /** * Logically left shifts this vector by an input vector. * <p> * This is a vector binary operation where the primitive logical left shift
*** 1186,1196 **** * @param v the input vector * @param m the mask controlling lane selection * @return the result of logically left shifting this vector by the input * vector */ ! public LongVector shiftL(Vector<Long> v, Mask<Long> m) { return bOp(v, m, (i, a, b) -> (long) (a << b)); } // logical, or unsigned, shift right --- 962,972 ---- * @param v the input vector * @param m the mask controlling lane selection * @return the result of logically left shifting this vector by the input * vector */ ! public LongVector shiftL(Vector<Long> v, VectorMask<Long> m) { return bOp(v, m, (i, a, b) -> (long) (a << b)); } // logical, or unsigned, shift right
*** 1218,1228 **** * @param s the input scalar; the number of the bits to right shift * @param m the mask controlling lane selection * @return the result of logically right shifting this vector by the * broadcast of an input scalar */ ! public abstract LongVector shiftR(int s, Mask<Long> m); /** * Logically right shifts (or unsigned right shifts) this vector by an * input vector. * <p> --- 994,1004 ---- * @param s the input scalar; the number of the bits to right shift * @param m the mask controlling lane selection * @return the result of logically right shifting this vector by the * broadcast of an input scalar */ ! public abstract LongVector shiftR(int s, VectorMask<Long> m); /** * Logically right shifts (or unsigned right shifts) this vector by an * input vector. * <p>
*** 1245,1255 **** * @param v the input vector * @param m the mask controlling lane selection * @return the result of logically right shifting this vector by the * input vector */ ! public LongVector shiftR(Vector<Long> v, Mask<Long> m) { return bOp(v, m, (i, a, b) -> (long) (a >>> b)); } /** * Arithmetically right shifts (or signed right shifts) this vector by the --- 1021,1031 ---- * @param v the input vector * @param m the mask controlling lane selection * @return the result of logically right shifting this vector by the * input vector */ ! public LongVector shiftR(Vector<Long> v, VectorMask<Long> m) { return bOp(v, m, (i, a, b) -> (long) (a >>> b)); } /** * Arithmetically right shifts (or signed right shifts) this vector by the
*** 1275,1285 **** * @param s the input scalar; the number of the bits to right shift * @param m the mask controlling lane selection * @return the result of arithmetically right shifting this vector by the * broadcast of an input scalar */ ! public abstract LongVector aShiftR(int s, Mask<Long> m); /** * Arithmetically right shifts (or signed right shifts) this vector by an * input vector. * <p> --- 1051,1061 ---- * @param s the input scalar; the number of the bits to right shift * @param m the mask controlling lane selection * @return the result of arithmetically right shifting this vector by the * broadcast of an input scalar */ ! public abstract LongVector aShiftR(int s, VectorMask<Long> m); /** * Arithmetically right shifts (or signed right shifts) this vector by an * input vector. * <p>
*** 1302,1312 **** * @param v the input vector * @param m the mask controlling lane selection * @return the result of arithmetically right shifting this vector by the * input vector */ ! public LongVector aShiftR(Vector<Long> v, Mask<Long> m) { return bOp(v, m, (i, a, b) -> (long) (a >> b)); } /** * Rotates left this vector by the broadcast of an input scalar. --- 1078,1088 ---- * @param v the input vector * @param m the mask controlling lane selection * @return the result of arithmetically right shifting this vector by the * input vector */ ! public LongVector aShiftR(Vector<Long> v, VectorMask<Long> m) { return bOp(v, m, (i, a, b) -> (long) (a >> b)); } /** * Rotates left this vector by the broadcast of an input scalar.
*** 1340,1350 **** * @param m the mask controlling lane selection * @return the result of rotating left this vector by the broadcast of an * input scalar */ @ForceInline ! public final LongVector rotateL(int s, Mask<Long> m) { return shiftL(s, m).or(shiftR(-s, m), m); } /** * Rotates right this vector by the broadcast of an input scalar. --- 1116,1126 ---- * @param m the mask controlling lane selection * @return the result of rotating left this vector by the broadcast of an * input scalar */ @ForceInline ! public final LongVector rotateL(int s, VectorMask<Long> m) { return shiftL(s, m).or(shiftR(-s, m), m); } /** * Rotates right this vector by the broadcast of an input scalar.
*** 1378,1402 **** * @param m the mask controlling lane selection * @return the result of rotating right this vector by the broadcast of an * input scalar */ @ForceInline ! public final LongVector rotateR(int s, Mask<Long> m) { return shiftR(s, m).or(shiftL(-s, m), m); } @Override public abstract void intoByteArray(byte[] a, int ix); @Override ! public abstract void intoByteArray(byte[] a, int ix, Mask<Long> m); @Override public abstract void intoByteBuffer(ByteBuffer bb, int ix); @Override ! public abstract void intoByteBuffer(ByteBuffer bb, int ix, Mask<Long> m); // Type specific horizontal reductions /** * Adds all lane elements of this vector. --- 1154,1178 ---- * @param m the mask controlling lane selection * @return the result of rotating right this vector by the broadcast of an * input scalar */ @ForceInline ! public final LongVector rotateR(int s, VectorMask<Long> m) { return shiftR(s, m).or(shiftL(-s, m), m); } @Override public abstract void intoByteArray(byte[] a, int ix); @Override ! public abstract void intoByteArray(byte[] a, int ix, VectorMask<Long> m); @Override public abstract void intoByteBuffer(ByteBuffer bb, int ix); @Override ! public abstract void intoByteBuffer(ByteBuffer bb, int ix, VectorMask<Long> m); // Type specific horizontal reductions /** * Adds all lane elements of this vector.
*** 1418,1428 **** * and the identity value is {@code 0}. * * @param m the mask controlling lane selection * @return the addition of the selected lane elements of this vector */ ! public abstract long addAll(Mask<Long> m); /** * Multiplies all lane elements of this vector. * <p> * This is an associative vector reduction operation where the --- 1194,1204 ---- * and the identity value is {@code 0}. * * @param m the mask controlling lane selection * @return the addition of the selected lane elements of this vector */ ! public abstract long addAll(VectorMask<Long> m); /** * Multiplies all lane elements of this vector. * <p> * This is an associative vector reduction operation where the
*** 1442,1452 **** * and the identity value is {@code 1}. * * @param m the mask controlling lane selection * @return the multiplication of all the lane elements of this vector */ ! public abstract long mulAll(Mask<Long> m); /** * Returns the minimum lane element of this vector. * <p> * This is an associative vector reduction operation where the operation --- 1218,1228 ---- * and the identity value is {@code 1}. * * @param m the mask controlling lane selection * @return the multiplication of all the lane elements of this vector */ ! public abstract long mulAll(VectorMask<Long> m); /** * Returns the minimum lane element of this vector. * <p> * This is an associative vector reduction operation where the operation
*** 1468,1478 **** * {@link Long#MAX_VALUE}. * * @param m the mask controlling lane selection * @return the minimum lane element of this vector */ ! public abstract long minAll(Mask<Long> m); /** * Returns the maximum lane element of this vector. * <p> * This is an associative vector reduction operation where the operation --- 1244,1254 ---- * {@link Long#MAX_VALUE}. * * @param m the mask controlling lane selection * @return the minimum lane element of this vector */ ! public abstract long minAll(VectorMask<Long> m); /** * Returns the maximum lane element of this vector. * <p> * This is an associative vector reduction operation where the operation
*** 1494,1504 **** * {@link Long#MIN_VALUE}. * * @param m the mask controlling lane selection * @return the maximum lane element of this vector */ ! public abstract long maxAll(Mask<Long> m); /** * Logically ORs all lane elements of this vector. * <p> * This is an associative vector reduction operation where the logical OR --- 1270,1280 ---- * {@link Long#MIN_VALUE}. * * @param m the mask controlling lane selection * @return the maximum lane element of this vector */ ! public abstract long maxAll(VectorMask<Long> m); /** * Logically ORs all lane elements of this vector. * <p> * This is an associative vector reduction operation where the logical OR
*** 1518,1528 **** * and the identity value is {@code 0}. * * @param m the mask controlling lane selection * @return the logical OR all the lane elements of this vector */ ! public abstract long orAll(Mask<Long> m); /** * Logically ANDs all lane elements of this vector. * <p> * This is an associative vector reduction operation where the logical AND --- 1294,1304 ---- * and the identity value is {@code 0}. * * @param m the mask controlling lane selection * @return the logical OR all the lane elements of this vector */ ! public abstract long orAll(VectorMask<Long> m); /** * Logically ANDs all lane elements of this vector. * <p> * This is an associative vector reduction operation where the logical AND
*** 1542,1552 **** * and the identity value is {@code -1}. * * @param m the mask controlling lane selection * @return the logical AND all the lane elements of this vector */ ! public abstract long andAll(Mask<Long> m); /** * Logically XORs all lane elements of this vector. * <p> * This is an associative vector reduction operation where the logical XOR --- 1318,1328 ---- * and the identity value is {@code -1}. * * @param m the mask controlling lane selection * @return the logical AND all the lane elements of this vector */ ! public abstract long andAll(VectorMask<Long> m); /** * Logically XORs all lane elements of this vector. * <p> * This is an associative vector reduction operation where the logical XOR
*** 1566,1576 **** * and the identity value is {@code 0}. * * @param m the mask controlling lane selection * @return the logical XOR all the lane elements of this vector */ ! public abstract long xorAll(Mask<Long> m); // Type specific accessors /** * Gets the lane element at lane index {@code i} --- 1342,1352 ---- * and the identity value is {@code 0}. * * @param m the mask controlling lane selection * @return the logical XOR all the lane elements of this vector */ ! public abstract long xorAll(VectorMask<Long> m); // Type specific accessors /** * Gets the lane element at lane index {@code i}
*** 1648,1658 **** * @param m the mask * @throws IndexOutOfBoundsException if {@code i < 0}, or * for any vector lane index {@code N} where the mask at lane {@code N} * is set {@code i >= a.length - N} */ ! public abstract void intoArray(long[] a, int i, Mask<Long> m); /** * Stores this vector into an array using indexes obtained from an index * map. * <p> --- 1424,1434 ---- * @param m the mask * @throws IndexOutOfBoundsException if {@code i < 0}, or * for any vector lane index {@code N} where the mask at lane {@code N} * is set {@code i >= a.length - N} */ ! public abstract void intoArray(long[] a, int i, VectorMask<Long> m); /** * Stores this vector into an array using indexes obtained from an index * map. * <p>
*** 1693,1759 **** * {@code j > indexMap.length - this.length()}, * or for any vector lane index {@code N} where the mask at lane * {@code N} is set the result of {@code i + indexMap[j + N]} is * {@code < 0} or {@code >= a.length} */ ! public abstract void intoArray(long[] a, int i, Mask<Long> m, int[] indexMap, int j); // Species @Override ! public abstract Species<Long> species(); /** ! * Class representing {@link LongVector}'s of the same {@link Vector.Shape Shape}. */ ! static final class LongSpecies extends Vector.AbstractSpecies<Long> { final Function<long[], LongVector> vectorFactory; - final Function<boolean[], Vector.Mask<Long>> maskFactory; ! private LongSpecies(Vector.Shape shape, Class<?> boxType, Class<?> maskType, Function<long[], LongVector> vectorFactory, ! Function<boolean[], Vector.Mask<Long>> maskFactory) { ! super(shape, long.class, Long.SIZE, boxType, maskType); this.vectorFactory = vectorFactory; - this.maskFactory = maskFactory; } interface FOp { long apply(int i); } - interface FOpm { - boolean apply(int i); - } - LongVector op(FOp f) { long[] res = new long[length()]; for (int i = 0; i < length(); i++) { res[i] = f.apply(i); } return vectorFactory.apply(res); } ! LongVector op(Vector.Mask<Long> o, FOp f) { long[] res = new long[length()]; boolean[] mbits = ((AbstractMask<Long>)o).getBits(); for (int i = 0; i < length(); i++) { if (mbits[i]) { res[i] = f.apply(i); } } return vectorFactory.apply(res); } - - Vector.Mask<Long> opm(IntVector.IntSpecies.FOpm f) { - boolean[] res = new boolean[length()]; - for (int i = 0; i < length(); i++) { - res[i] = (boolean)f.apply(i); - } - return maskFactory.apply(res); - } } /** * Finds the preferred species for an element type of {@code long}. * <p> --- 1469,1524 ---- * {@code j > indexMap.length - this.length()}, * or for any vector lane index {@code N} where the mask at lane * {@code N} is set the result of {@code i + indexMap[j + N]} is * {@code < 0} or {@code >= a.length} */ ! public abstract void intoArray(long[] a, int i, VectorMask<Long> m, int[] indexMap, int j); // Species @Override ! public abstract VectorSpecies<Long> species(); /** ! * Class representing {@link LongVector}'s of the same {@link VectorShape VectorShape}. */ ! static final class LongSpecies extends AbstractSpecies<Long> { final Function<long[], LongVector> vectorFactory; ! private LongSpecies(VectorShape shape, Class<?> boxType, Class<?> maskType, Function<long[], LongVector> vectorFactory, ! Function<boolean[], VectorMask<Long>> maskFactory, ! Function<IntUnaryOperator, VectorShuffle<Long>> shuffleFromArrayFactory, ! fShuffleFromArray<Long> shuffleFromOpFactory) { ! super(shape, long.class, Long.SIZE, boxType, maskType, maskFactory, ! shuffleFromArrayFactory, shuffleFromOpFactory); this.vectorFactory = vectorFactory; } interface FOp { long apply(int i); } LongVector op(FOp f) { long[] res = new long[length()]; for (int i = 0; i < length(); i++) { res[i] = f.apply(i); } return vectorFactory.apply(res); } ! LongVector op(VectorMask<Long> o, FOp f) { long[] res = new long[length()]; boolean[] mbits = ((AbstractMask<Long>)o).getBits(); for (int i = 0; i < length(); i++) { if (mbits[i]) { res[i] = f.apply(i); } } return vectorFactory.apply(res); } } /** * Finds the preferred species for an element type of {@code long}. * <p>
*** 1763,1783 **** * shuffles created from such species will be shape compatible. * * @return the preferred species for an element type of {@code long} */ private static LongSpecies preferredSpecies() { ! return (LongSpecies) Species.ofPreferred(long.class); } /** * Finds a species for an element type of {@code long} and shape. * * @param s the shape * @return a species for an element type of {@code long} and shape * @throws IllegalArgumentException if no such species exists for the shape */ ! static LongSpecies species(Vector.Shape s) { Objects.requireNonNull(s); switch (s) { case S_64_BIT: return (LongSpecies) SPECIES_64; case S_128_BIT: return (LongSpecies) SPECIES_128; case S_256_BIT: return (LongSpecies) SPECIES_256; --- 1528,1548 ---- * shuffles created from such species will be shape compatible. * * @return the preferred species for an element type of {@code long} */ private static LongSpecies preferredSpecies() { ! return (LongSpecies) VectorSpecies.ofPreferred(long.class); } /** * Finds a species for an element type of {@code long} and shape. * * @param s the shape * @return a species for an element type of {@code long} and shape * @throws IllegalArgumentException if no such species exists for the shape */ ! static LongSpecies species(VectorShape s) { Objects.requireNonNull(s); switch (s) { case S_64_BIT: return (LongSpecies) SPECIES_64; case S_128_BIT: return (LongSpecies) SPECIES_128; case S_256_BIT: return (LongSpecies) SPECIES_256;
*** 1785,1815 **** case S_Max_BIT: return (LongSpecies) SPECIES_MAX; default: throw new IllegalArgumentException("Bad shape: " + s); } } ! /** Species representing {@link LongVector}s of {@link Vector.Shape#S_64_BIT Shape.S_64_BIT}. */ ! public static final Species<Long> SPECIES_64 = new LongSpecies(Shape.S_64_BIT, Long64Vector.class, Long64Vector.Long64Mask.class, ! Long64Vector::new, Long64Vector.Long64Mask::new); ! ! /** Species representing {@link LongVector}s of {@link Vector.Shape#S_128_BIT Shape.S_128_BIT}. */ ! public static final Species<Long> SPECIES_128 = new LongSpecies(Shape.S_128_BIT, Long128Vector.class, Long128Vector.Long128Mask.class, ! Long128Vector::new, Long128Vector.Long128Mask::new); ! ! /** Species representing {@link LongVector}s of {@link Vector.Shape#S_256_BIT Shape.S_256_BIT}. */ ! public static final Species<Long> SPECIES_256 = new LongSpecies(Shape.S_256_BIT, Long256Vector.class, Long256Vector.Long256Mask.class, ! Long256Vector::new, Long256Vector.Long256Mask::new); ! ! /** Species representing {@link LongVector}s of {@link Vector.Shape#S_512_BIT Shape.S_512_BIT}. */ ! public static final Species<Long> SPECIES_512 = new LongSpecies(Shape.S_512_BIT, Long512Vector.class, Long512Vector.Long512Mask.class, ! Long512Vector::new, Long512Vector.Long512Mask::new); ! ! /** Species representing {@link LongVector}s of {@link Vector.Shape#S_Max_BIT Shape.S_Max_BIT}. */ ! public static final Species<Long> SPECIES_MAX = new LongSpecies(Shape.S_Max_BIT, LongMaxVector.class, LongMaxVector.LongMaxMask.class, ! LongMaxVector::new, LongMaxVector.LongMaxMask::new); /** * Preferred species for {@link LongVector}s. * A preferred species is a species of maximal bit size for the platform. */ ! public static final Species<Long> SPECIES_PREFERRED = (Species<Long>) preferredSpecies(); } --- 1550,1585 ---- case S_Max_BIT: return (LongSpecies) SPECIES_MAX; default: throw new IllegalArgumentException("Bad shape: " + s); } } ! /** Species representing {@link LongVector}s of {@link VectorShape#S_64_BIT VectorShape.S_64_BIT}. */ ! public static final VectorSpecies<Long> SPECIES_64 = new LongSpecies(VectorShape.S_64_BIT, Long64Vector.class, Long64Vector.Long64Mask.class, ! Long64Vector::new, Long64Vector.Long64Mask::new, ! Long64Vector.Long64Shuffle::new, Long64Vector.Long64Shuffle::new); ! ! /** Species representing {@link LongVector}s of {@link VectorShape#S_128_BIT VectorShape.S_128_BIT}. */ ! public static final VectorSpecies<Long> SPECIES_128 = new LongSpecies(VectorShape.S_128_BIT, Long128Vector.class, Long128Vector.Long128Mask.class, ! Long128Vector::new, Long128Vector.Long128Mask::new, ! Long128Vector.Long128Shuffle::new, Long128Vector.Long128Shuffle::new); ! ! /** Species representing {@link LongVector}s of {@link VectorShape#S_256_BIT VectorShape.S_256_BIT}. */ ! public static final VectorSpecies<Long> SPECIES_256 = new LongSpecies(VectorShape.S_256_BIT, Long256Vector.class, Long256Vector.Long256Mask.class, ! Long256Vector::new, Long256Vector.Long256Mask::new, ! Long256Vector.Long256Shuffle::new, Long256Vector.Long256Shuffle::new); ! ! /** Species representing {@link LongVector}s of {@link VectorShape#S_512_BIT VectorShape.S_512_BIT}. */ ! public static final VectorSpecies<Long> SPECIES_512 = new LongSpecies(VectorShape.S_512_BIT, Long512Vector.class, Long512Vector.Long512Mask.class, ! Long512Vector::new, Long512Vector.Long512Mask::new, ! Long512Vector.Long512Shuffle::new, Long512Vector.Long512Shuffle::new); ! ! /** Species representing {@link LongVector}s of {@link VectorShape#S_Max_BIT VectorShape.S_Max_BIT}. */ ! public static final VectorSpecies<Long> SPECIES_MAX = new LongSpecies(VectorShape.S_Max_BIT, LongMaxVector.class, LongMaxVector.LongMaxMask.class, ! LongMaxVector::new, LongMaxVector.LongMaxMask::new, ! LongMaxVector.LongMaxShuffle::new, LongMaxVector.LongMaxShuffle::new); /** * Preferred species for {@link LongVector}s. * A preferred species is a species of maximal bit size for the platform. */ ! public static final VectorSpecies<Long> SPECIES_PREFERRED = (VectorSpecies<Long>) preferredSpecies(); }
< prev index next >