ETYPE,
the element type of a vector
VectorShuffle represents an ordered immutable sequence of
int values called source indexes, where each source
index numerically selects a source lane from a compatible Vector.
A VectorShuffle and Vector of the same
element type
(ETYPE) and shape have the same number of lanes,
and are therefore compatible (specifically, their vector species are compatible).
A shuffle is applied to a (compatible) source vector with the
rearrange
method.
A shuffle has a lane structure derived from its vector
species, but it stores lane indexes, as ints,
rather than lane values.
This method gathers lane values by random access to the source vector, selecting lanes by consulting the source indexes. If a source index appears more than once in a shuffle, then the selected lane's value is copied more than once into the result. If a particular lane is never selected by a source index, that lane's value is ignored. The resulting vector contains all the source lane values selected by the source indexes of the shuffle. The resulting lane values are ordered according to the shuffle's source indexes, not according to the original vector's lane order.
Each shuffle has a vectorSpecies()
property which determines the compatibility of vectors the shuffle
operates on. This ensures that the length() of a
shuffle is always equal to the VLENGTH
of any vector it operates on.
The element type and shape of the shuffle's species are not
directly relevant to the behavior of the shuffle. Shuffles can
easily be converted to other lane
types, as long as the lane count stays constant.
In its internal state, a shuffle always holds integral values
in a narrow range from [-VLENGTH..VLENGTH-1].
The positive numbers are self-explanatory; they are lane
numbers applied to any source vector. The negative numbers,
when present, are a sign that the shuffle was created from
a raw integer value which was not a valid lane index.
An invalid source index, represented in a shuffle by a negative number, is called an exceptional index.
Exceptional indexes are processed in a variety of ways:
ArrayIndexOutOfBoundsException when a lane is processed by
an exceptional index.
[-VLENGTH..-1] as if by wrapIndex().
This treatment of exceptional indexes is called partial
wrapping, because it preserves the distinction between normal
and exceptional indexes, while wrapping them into adjacent ranges
of positive and non-positive numbers. A partially wrapped index
can later on be fully wrapped into the positive range by adding
a final offset of VLENGTH.
[-VLENGTH..-1], are
cycled up to the valid range [0..VLENGTH-1] and used on the
second source vector.
VLENGTH, all indexes are re-validated against the
new VLENGTH, and some may be converted to exceptional
indexes. In any case, shuffle casting never converts exceptional
indexes to normal ones.
VectorShuffle, along with Vector is a
value-based
class. Identity-sensitive operations such as ==
may yield unpredictable results, or reduced performance.
Also, vector shuffle objects can be stored in locals and parameters and as
static final constants, but storing them in other Java
fields or in array elements, while semantically valid, may incur
performance penalties.
Finally, vector shuffles should not be computed in loops, when
possible, but instead should be stored in loop-invariant locals or
as static final constants.
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public abstract < the boxed element type of the species F> VectorShuffle | Returns: a shuffle converted by shape and element typethe species of desired shuffle species)Converts this shuffle to a shuffle of the given species of
element type |
| public abstract < the boxed element type of the required species F> VectorShuffle | Returns: the same shufflethe required species species)Checks that this shuffle has the given species, and returns this shuffle unchanged. |
| public abstract int | Returns: indexthe lane index index)Validation function for lane indexes which may be out of the
valid range of |
| public abstract VectorShuffle | Returns: the current shuffle, unchangedApply the |
| public final boolean | Returns: whether this vector is identical to some other objectOverrides java. Indicates whether this shuffle is identical to some other object. |
| public static < the boxed element type E> VectorShuffle | Returns: a shuffle where each lane's source index is set to the givenint value, partially wrapped if exceptionalshuffle species species, int[] the source indexes which the shuffle will draw from sourceIndexes, int the offset into the array offset)Creates a shuffle for a given species from
an |
| public static final < the boxed element type E> VectorShuffle | Returns: a shuffle where each lane's source index is set to the givenint value, partially wrapped if exceptionalthe shuffle species species, MemorySegment the source indexes in memory which the shuffle will draw from ms, long the offset into the segment offset, ByteOrder the byte order bo)Loads a shuffle from a memory segment starting at an offset into the memory segment. |
| public static < the boxed element type E> VectorShuffle | Returns: a shuffle of mapped indexesshuffle species species, IntUnaryOperator the lane index mapping function fn)Creates a shuffle for a given species from
the successive values of an operator applied to
the range |
| public static < the boxed element type E> VectorShuffle | Returns: a shuffle where each lane's source index is set to the givenint value, partially wrapped if exceptionalshuffle species species, int... the source indexes which the shuffle will draw from sourceIndexes)Creates a shuffle for a given species from a series of source indexes. |
| public final int | Returns: a hash code value for this shuffleOverrides java. Returns a hash code value for the shuffle, based on the lane source indexes and the vector species. |
| public abstract void | intoArray(int[]
the array, of type a, int int[]the offset into the array offset)Stores this shuffle into an |
| public abstract void | intoMemorySegment(MemorySegment
the memory segment ms, long the offset into the segment offset, ByteOrder the byte order bo)Stores this shuffle into a memory segment starting at an offset using explicit byte order. |
| public static < the boxed element type E> VectorShuffle | Returns: a shuffle of sequential lane indexes, possibly wrappedshuffle species species, int the starting value of the source index sequence start, int the difference between adjacent source indexes step, boolean whether to wrap resulting indexes wrap)Creates a shuffle using source indexes set to sequential
values starting from |
| public abstract VectorMask | Returns: a mask of lanes containing valid source indexesFind all lanes containing valid indexes (non-negative values) and return a mask where exactly those lanes are set. |
| public abstract int | Returns: theint lane element at lane index ithe lane index i)Gets the |
| public final int | |
| public static < the boxed element type E> VectorShuffle | Returns: a shuffle which unzips2*VLENGTH lanes into two vectors, returning the selected partthe shuffle species species, int the part number of the result (either zero or one) part)Creates a shuffle which will unzip the concatenation of two vectors, alternatively storing input lanes into one or the other output vector. |
| public static < the boxed element type E> VectorShuffle | Returns: a shuffle which zips two vectors into2*VLENGTH lanes, returning the selected partthe shuffle species species, int the part number of the result (either zero or one) part)Creates a shuffle which will zip together two vectors, alternatively selecting lanes from one or the other. |
| public abstract VectorShuffle | Returns: the rearrangement of the lane elements of this shufflethe shuffle controlling lane index selection s)Rearranges the lane elements of this shuffle selecting lane indexes controlled by another shuffle. |
| public abstract int[] | Returns: an array containing the lane source indexes of this shuffleReturns an |
| public final String | Returns: a string of the form"Shuffle[0,1,2...]"Overrides java. Returns a string representation of this shuffle, of the form
|
| public abstract Vector | Returns: a vector representation of this shuffleConverts this shuffle into a vector, creating a vector of integral values corresponding to the lane source indexes of the shuffle. |
| private static int | |
| public abstract VectorSpecies | |
| public abstract int | Returns: index, adjusted to the range [0..VLENGTH-1}
by an appropriate multiple of VLENGTHthe lane index index)Validation function for lane indexes which may be out of the
valid range of |
| public abstract VectorShuffle | Returns: the current shuffle, with all exceptional indexes wrappedApply the |
| private static ArrayIndexOutOfBoundsException | |
| private static int |
| VectorShuffle | back to summary |
|---|---|
| pack-priv VectorShuffle(Object indices) | |
| cast | back to summary |
|---|---|
| public abstract <F> VectorShuffle Converts this shuffle to a shuffle of the given species of
element type
| |
| check | back to summary |
|---|---|
| public abstract <F> VectorShuffle Checks that this shuffle has the given species,
and returns this shuffle unchanged.
The effect is similar to this pseudocode:
| |
| checkIndex | back to summary |
|---|---|
| public abstract int checkIndex(int index) Validation function for lane indexes which may be out of the
valid range of
| |
| checkIndexes | back to summary |
|---|---|
| public abstract VectorShuffle Apply the
| |
| equals | back to summary |
|---|---|
| public final boolean equals(Object obj) Overrides java. Indicates whether this shuffle is identical to some other object. Two shuffles are identical only if they have the same species and same source indexes, in the same order.
| |
| fromArray | back to summary |
|---|---|
| public static <E> VectorShuffle Creates a shuffle for a given species from
an For each shuffle lane, where
| |
| fromMemorySegment | back to summary |
|---|---|
| public static final <E> VectorShuffle Loads a shuffle from a memory segment starting at an offset into the memory segment. Bytes are composed into shuffle lanes according to the specified byte order. The shuffle is arranged into lanes according to memory ordering. The following pseudocode illustrates the behavior:
Implementation Note This operation is likely to be more efficient if the specified byte order is the same as the platform native order, since this method will not need to reorder the bytes of lane values.
| |
| fromOp | back to summary |
|---|---|
| public static <E> VectorShuffle Creates a shuffle for a given species from
the successive values of an operator applied to
the range For each shuffle lane, where Care should be taken to ensure This method behaves as if a shuffle is created from an array of mapped indexes as follows:
| |
| fromValues | back to summary |
|---|---|
| public static <E> VectorShuffle Creates a shuffle for a given species from a series of source indexes. For each shuffle lane, where
| |
| hashCode | back to summary |
|---|---|
| public final int hashCode() Overrides java. Returns a hash code value for the shuffle, based on the lane source indexes and the vector species.
| |
| intoArray | back to summary |
|---|---|
| public abstract void intoArray(int[] a, int offset) Stores this shuffle into an
For each shuffle lane API Note Shuffle source indexes are always in the
range from
| |
| intoMemorySegment | back to summary |
|---|---|
| public abstract void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) Stores this shuffle into a memory segment starting at an offset using explicit byte order. Bytes are extracted from shuffle lanes according to the specified byte ordering. The shuffle lanes are stored according to their memory ordering. The following pseudocode illustrates the behavior:
Implementation Note This operation is likely to be more efficient if the specified byte order is the same as the platform native order, since this method will not need to reorder the bytes of lane values. API Note Shuffle source indexes are always in the
range from
| |
| iota | back to summary |
|---|---|
| public static <E> VectorShuffle Creates a shuffle using source indexes set to sequential
values starting from
This method returns the value of the expression
If API Note The
| |
| laneIsValid | back to summary |
|---|---|
| public abstract VectorMask Find all lanes containing valid indexes (non-negative values) and return a mask where exactly those lanes are set.
| |
| laneSource | back to summary |
|---|---|
| public abstract int laneSource(int i) Gets the
| |
| length | back to summary |
|---|---|
| public final int length() Returns the number of lanes processed by this shuffle.
This is the same as the
| |
| makeUnzip | back to summary |
|---|---|
| public static <E> VectorShuffle Creates a shuffle which will unzip the concatenation of two
vectors, alternatively storing input lanes into one or the
other output vector.
Since the logical result of an unzip is twice the size of
either input, the
expanded result
is broken into two physical parts, selected by
a part number.
For example, unzipping two vectors
This method returns the value of the expression
Note that the source indexes in upper half of the shuffle will
be invalid indexes (
| |
| makeZip | back to summary |
|---|---|
| public static <E> VectorShuffle Creates a shuffle which will zip together two vectors,
alternatively selecting lanes from one or the other.
The logical result of a zip is twice the size of either
input, and so the
expanded result
is broken into two physical parts, selected by
a part number.
For example, zipping two vectors
This method returns the value of the expression
s
Note that the source indexes in the odd lanes of the shuffle
will be invalid indexes (
| |
| rearrange | back to summary |
|---|---|
| public abstract VectorShuffle Rearranges the lane elements of this shuffle selecting lane indexes controlled by another shuffle.
For each lane of the specified shuffle, at lane index
| |
| toArray | back to summary |
|---|---|
| public abstract int[] toArray() Returns an
This method behaves as if it stores
this shuffle into an allocated array
(using
API Note Shuffle source indexes are always in the
range from
| |
| toString | back to summary |
|---|---|
| public final String toString() Overrides java. Returns a string representation of this shuffle, of the form
| |
| toVector | back to summary |
|---|---|
| public abstract Vector Converts this shuffle into a vector, creating a vector of integral values corresponding to the lane source indexes of the shuffle.
This method behaves as if it returns the result of creating a
vector given an
API Note Shuffle source indexes are always in the
range from
| |
| unzipIndex | back to summary |
|---|---|
| private static int unzipIndex(int i, int vlen, int part) | |
| vectorSpecies | back to summary |
|---|---|
| public abstract VectorSpecies Returns the species of this shuffle.
| |
| wrapIndex | back to summary |
|---|---|
| public abstract int wrapIndex(int index) Validation function for lane indexes which may be out of the
valid range of
| |
| wrapIndexes | back to summary |
|---|---|
| public abstract VectorShuffle Apply the
| |
| wrongPartForZip | back to summary |
|---|---|
| private static ArrayIndexOutOfBoundsException wrongPartForZip(int part, boolean unzip) | |
| zipIndex | back to summary |
|---|---|
| private static int zipIndex(int i, int vlen, int part) | |