< prev index next >
src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorShuffle.java
Print this page
rev 54658 : refactored mask and shuffle creation methods, moved classes to top-level
rev 54659 : changed VectorSpecies to interface and moved stuff to AbstractSpecies
rev 54660 : Javadoc changes
*** 128,137 ****
--- 128,174 ----
public static <E> VectorShuffle<E> shuffleIota(VectorSpecies<E> species) {
return ((AbstractSpecies<E>) species).shuffleFromOpFactory.apply(AbstractShuffle.IDENTITY);
}
/**
+ * Returns a shuffle with lane elements set to sequential {@code int} values starting from {@code start}.
+ * <p>
+ * This method behaves as if a shuffle is created from an identity
+ * index mapping function as follows:
+ * <pre>{@code
+ * return VectorShuffle.shuffle(i -> i + start);
+ * }</pre>
+ *
+ * @param species shuffle species
+ * @param start starting value of sequence
+ * @return a shuffle of lane indexes
+ */
+ @ForceInline
+ public static <E> VectorShuffle<E> shuffleIota(VectorSpecies<E> species, int start) {
+ return ((AbstractSpecies<E>) species).shuffleFromOpFactory.apply(i -> i + start);
+ }
+
+ /**
+ * Returns a shuffle with lane elements set to sequential {@code int} values starting from {@code start}
+ * and looping around species length.
+ * <p>
+ * This method behaves as if a shuffle is created from an identity
+ * index mapping function as follows:
+ * <pre>{@code
+ * return VectorShuffle.shuffle(i -> (i + start) & (species.length() - 1));
+ * }</pre>
+ *
+ * @param species shuffle species
+ * @param start starting value of sequence
+ * @return a shuffle of lane indexes
+ */
+ @ForceInline
+ public static <E> VectorShuffle<E> shuffleOffset(VectorSpecies<E> species, int start) {
+ return ((AbstractSpecies<E>) species).shuffleFromOpFactory.apply(i -> (i + start) & (species.length() - 1));
+ }
+
+ /**
* 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
*** 158,175 ****
* {@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 <E> VectorShuffle<E> fromArray(VectorSpecies<E> species, int[] ixs, int i) {
! return ((AbstractSpecies<E>) species).shuffleFromArrayFactory.apply(ixs, i);
}
/**
* Returns an {@code int} array containing the lane elements of this
* shuffle.
--- 195,212 ----
* {@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 offset the offset into the array
* @return a shuffle loaded from the {@code int} array
! * @throws IndexOutOfBoundsException if {@code offset < 0}, or
! * {@code offset > a.length - species.length()}
*/
@ForceInline
! public static <E> VectorShuffle<E> fromArray(VectorSpecies<E> species, int[] ixs, int offset) {
! return ((AbstractSpecies<E>) species).shuffleFromArrayFactory.apply(ixs, offset);
}
/**
* Returns an {@code int} array containing the lane elements of this
* shuffle.
*** 193,207 ****
* For each shuffle lane, where {@code N} is the shuffle lane index,
* the lane element at index {@code N} is stored into the array at index
* {@code i + N}.
*
* @param a the array
! * @param i the offset into the array
* @throws IndexOutOfBoundsException if {@code i < 0}, or
! * {@code i > a.length - this.length()}
*/
! public abstract void intoArray(int[] a, int i);
/**
* Converts this shuffle into a vector, creating a vector from shuffle
* lane elements (int values) cast to the vector element type.
* <p>
--- 230,244 ----
* For each shuffle lane, where {@code N} is the shuffle lane index,
* the lane element at index {@code N} is stored into the array at index
* {@code i + N}.
*
* @param a the array
! * @param offset the offset into the array
* @throws IndexOutOfBoundsException if {@code i < 0}, or
! * {@code offset > a.length - this.length()}
*/
! public abstract void intoArray(int[] a, int offset);
/**
* Converts this shuffle into a vector, creating a vector from shuffle
* lane elements (int values) cast to the vector element type.
* <p>
*** 225,235 ****
* Gets the {@code int} lane element at lane index {@code i}
*
* @param i the lane index
* @return the {@code int} lane element at lane index {@code i}
*/
! public int getElement(int i) { return toArray()[i]; }
/**
* Rearranges the lane elements of this shuffle selecting lane indexes
* controlled by another shuffle.
* <p>
--- 262,272 ----
* Gets the {@code int} lane element at lane index {@code i}
*
* @param i the lane index
* @return the {@code int} lane element at lane index {@code i}
*/
! public int lane(int i) { return toArray()[i]; }
/**
* Rearranges the lane elements of this shuffle selecting lane indexes
* controlled by another shuffle.
* <p>
< prev index next >