< prev index next >

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

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


  88      * index.
  89      * <p>
  90      * Care should be taken to ensure VectorShuffle values produced from this
  91      * method are consumed as constants to ensure optimal generation of
  92      * code.  For example, values held in static final fields or values
  93      * held in loop constant local variables.
  94      * <p>
  95      * This method behaves as if a shuffle is created from an array of
  96      * mapped indexes as follows:
  97      * <pre>{@code
  98      *   int[] a = new int[species.length()];
  99      *   for (int i = 0; i < a.length; i++) {
 100      *       a[i] = f.applyAsInt(i);
 101      *   }
 102      *   return VectorShuffle.fromValues(a);
 103      * }</pre>
 104      *
 105      * @param species shuffle species
 106      * @param f the lane index mapping function
 107      * @return a shuffle of mapped indexes

 108      */
 109     @ForceInline
 110     public static <E> VectorShuffle<E> shuffle(VectorSpecies<E> species, IntUnaryOperator f) {
 111         return ((AbstractSpecies<E>) species).shuffleFromOpFactory.apply(f);
 112     }
 113 
 114     /**
 115      * Returns a shuffle where each lane element is the value of its
 116      * corresponding lane index.
 117      * <p>
 118      * This method behaves as if a shuffle is created from an identity
 119      * index mapping function as follows:
 120      * <pre>{@code
 121      *   return VectorShuffle.shuffle(i -> i);
 122      * }</pre>
 123      *
 124      * @param species shuffle species
 125      * @return a shuffle of lane indexes

 126      */
 127     @ForceInline
 128     public static <E> VectorShuffle<E> shuffleIota(VectorSpecies<E> species) {
 129         return ((AbstractSpecies<E>) species).shuffleFromOpFactory.apply(AbstractShuffle.IDENTITY);
 130     }
 131 
 132     /**
 133      * Returns a shuffle with lane elements set to sequential {@code int} values starting from {@code start}.
 134      * <p>
 135      * This method behaves as if a shuffle is created from an identity
 136      * index mapping function as follows:
 137      * <pre>{@code
 138      *   return VectorShuffle.shuffle(i -> i + start);
 139      * }</pre>
 140      *
 141      * @param species shuffle species
 142      * @param start starting value of sequence
 143      * @return a shuffle of lane indexes

 144      */
 145     @ForceInline
 146     public static <E> VectorShuffle<E> shuffleIota(VectorSpecies<E> species, int start) {
 147         return ((AbstractSpecies<E>) species).shuffleFromOpFactory.apply(i -> i + start);
 148     }
 149 
 150     /**
 151      * Returns a shuffle with lane elements set to sequential {@code int} values starting from {@code start}
 152      * and looping around species length.
 153      * <p>
 154      * This method behaves as if a shuffle is created from an identity
 155      * index mapping function as follows:
 156      * <pre>{@code
 157      *   return VectorShuffle.shuffle(i -> (i + start) & (species.length() - 1));
 158      * }</pre>
 159      *
 160      * @param species shuffle species
 161      * @param start starting value of sequence
 162      * @return a shuffle of lane indexes

 163      */
 164     @ForceInline
 165     public static <E> VectorShuffle<E> shuffleOffset(VectorSpecies<E> species, int start) {
 166         return ((AbstractSpecies<E>) species).shuffleFromOpFactory.apply(i -> (i + start) & (species.length() - 1));
 167     }
 168 
 169     /**
 170      * Returns a shuffle where each lane element is set to a given
 171      * {@code int} value logically AND'ed by the species length minus one.
 172      * <p>
 173      * For each shuffle lane, where {@code N} is the shuffle lane index, the
 174      * the {@code int} value at index {@code N} logically AND'ed by
 175      * {@code species.length() - 1} is placed into the resulting shuffle at
 176      * lane index {@code N}.
 177      *
 178      * @param species shuffle species
 179      * @param ixs the given {@code int} values
 180      * @return a shuffle where each lane element is set to a given
 181      * {@code int} value
 182      * @throws IndexOutOfBoundsException if the number of int values is
 183      * {@code < species.length()}

 184      */
 185     @ForceInline
 186     public static <E> VectorShuffle<E> fromValues(VectorSpecies<E> species, int... ixs) {
 187         return ((AbstractSpecies<E>) species).shuffleFromArrayFactory.apply(ixs, 0);
 188     }
 189 
 190     /**
 191      * Loads a shuffle from an {@code int} array starting at an offset.
 192      * <p>
 193      * For each shuffle lane, where {@code N} is the shuffle lane index, the
 194      * array element at index {@code i + N} logically AND'ed by
 195      * {@code species.length() - 1} is placed into the resulting shuffle at lane
 196      * index {@code N}.
 197      *
 198      * @param species shuffle species
 199      * @param ixs the {@code int} array
 200      * @param offset the offset into the array
 201      * @return a shuffle loaded from the {@code int} array
 202      * @throws IndexOutOfBoundsException if {@code offset < 0}, or
 203      * {@code offset > a.length - species.length()}

 204      */
 205     @ForceInline
 206     public static <E> VectorShuffle<E> fromArray(VectorSpecies<E> species, int[] ixs, int offset) {
 207         return ((AbstractSpecies<E>) species).shuffleFromArrayFactory.apply(ixs, offset);
 208     }
 209 
 210     /**
 211      * Returns an {@code int} array containing the lane elements of this
 212      * shuffle.
 213      * <p>
 214      * This method behaves as if it {@link #intoArray(int[], int)} stores}
 215      * this shuffle into an allocated array and returns that array as
 216      * follows:
 217      * <pre>{@code
 218      *   int[] a = new int[this.length()];
 219      *   VectorShuffle.intoArray(a, 0);
 220      *   return a;
 221      * }</pre>
 222      *
 223      * @return an array containing the the lane elements of this vector




  88      * index.
  89      * <p>
  90      * Care should be taken to ensure VectorShuffle values produced from this
  91      * method are consumed as constants to ensure optimal generation of
  92      * code.  For example, values held in static final fields or values
  93      * held in loop constant local variables.
  94      * <p>
  95      * This method behaves as if a shuffle is created from an array of
  96      * mapped indexes as follows:
  97      * <pre>{@code
  98      *   int[] a = new int[species.length()];
  99      *   for (int i = 0; i < a.length; i++) {
 100      *       a[i] = f.applyAsInt(i);
 101      *   }
 102      *   return VectorShuffle.fromValues(a);
 103      * }</pre>
 104      *
 105      * @param species shuffle species
 106      * @param f the lane index mapping function
 107      * @return a shuffle of mapped indexes
 108      * @see Vector#shuffle(IntUnaryOperator)
 109      */
 110     @ForceInline
 111     public static <E> VectorShuffle<E> shuffle(VectorSpecies<E> species, IntUnaryOperator f) {
 112         return ((AbstractSpecies<E>) species).shuffleFromOpFactory.apply(f);
 113     }
 114 
 115     /**
 116      * Returns a shuffle where each lane element is the value of its
 117      * corresponding lane index.
 118      * <p>
 119      * This method behaves as if a shuffle is created from an identity
 120      * index mapping function as follows:
 121      * <pre>{@code
 122      *   return VectorShuffle.shuffle(i -> i);
 123      * }</pre>
 124      *
 125      * @param species shuffle species
 126      * @return a shuffle of lane indexes
 127      * @see Vector#shuffleIota()
 128      */
 129     @ForceInline
 130     public static <E> VectorShuffle<E> shuffleIota(VectorSpecies<E> species) {
 131         return ((AbstractSpecies<E>) species).shuffleFromOpFactory.apply(AbstractShuffle.IDENTITY);
 132     }
 133 
 134     /**
 135      * Returns a shuffle with lane elements set to sequential {@code int} values starting from {@code start}.
 136      * <p>
 137      * This method behaves as if a shuffle is created from an identity
 138      * index mapping function as follows:
 139      * <pre>{@code
 140      *   return VectorShuffle.shuffle(i -> i + start);
 141      * }</pre>
 142      *
 143      * @param species shuffle species
 144      * @param start starting value of sequence
 145      * @return a shuffle of lane indexes
 146      * @see Vector#shuffleIota(int)
 147      */
 148     @ForceInline
 149     public static <E> VectorShuffle<E> shuffleIota(VectorSpecies<E> species, int start) {
 150         return ((AbstractSpecies<E>) species).shuffleFromOpFactory.apply(i -> i + start);
 151     }
 152 
 153     /**
 154      * Returns a shuffle with lane elements set to sequential {@code int} values starting from {@code start}
 155      * and looping around species length.
 156      * <p>
 157      * This method behaves as if a shuffle is created from an identity
 158      * index mapping function as follows:
 159      * <pre>{@code
 160      *   return VectorShuffle.shuffle(i -> (i + start) & (species.length() - 1));
 161      * }</pre>
 162      *
 163      * @param species shuffle species
 164      * @param start starting value of sequence
 165      * @return a shuffle of lane indexes
 166      * @see Vector#shuffleOffset(int)
 167      */
 168     @ForceInline
 169     public static <E> VectorShuffle<E> shuffleOffset(VectorSpecies<E> species, int start) {
 170         return ((AbstractSpecies<E>) species).shuffleFromOpFactory.apply(i -> (i + start) & (species.length() - 1));
 171     }
 172 
 173     /**
 174      * Returns a shuffle where each lane element is set to a given
 175      * {@code int} value logically AND'ed by the species length minus one.
 176      * <p>
 177      * For each shuffle lane, where {@code N} is the shuffle lane index, the
 178      * the {@code int} value at index {@code N} logically AND'ed by
 179      * {@code species.length() - 1} is placed into the resulting shuffle at
 180      * lane index {@code N}.
 181      *
 182      * @param species shuffle species
 183      * @param ixs the given {@code int} values
 184      * @return a shuffle where each lane element is set to a given
 185      * {@code int} value
 186      * @throws IndexOutOfBoundsException if the number of int values is
 187      * {@code < species.length()}
 188      * @see Vector#shuffleFromValues(int...)
 189      */
 190     @ForceInline
 191     public static <E> VectorShuffle<E> fromValues(VectorSpecies<E> species, int... ixs) {
 192         return ((AbstractSpecies<E>) species).shuffleFromArrayFactory.apply(ixs, 0);
 193     }
 194 
 195     /**
 196      * Loads a shuffle from an {@code int} array starting at an offset.
 197      * <p>
 198      * For each shuffle lane, where {@code N} is the shuffle lane index, the
 199      * array element at index {@code i + N} logically AND'ed by
 200      * {@code species.length() - 1} is placed into the resulting shuffle at lane
 201      * index {@code N}.
 202      *
 203      * @param species shuffle species
 204      * @param ixs the {@code int} array
 205      * @param offset the offset into the array
 206      * @return a shuffle loaded from the {@code int} array
 207      * @throws IndexOutOfBoundsException if {@code offset < 0}, or
 208      * {@code offset > ixs.length - species.length()}
 209      * @see Vector#shuffleFromArray(int[], int)
 210      */
 211     @ForceInline
 212     public static <E> VectorShuffle<E> fromArray(VectorSpecies<E> species, int[] ixs, int offset) {
 213         return ((AbstractSpecies<E>) species).shuffleFromArrayFactory.apply(ixs, offset);
 214     }
 215 
 216     /**
 217      * Returns an {@code int} array containing the lane elements of this
 218      * shuffle.
 219      * <p>
 220      * This method behaves as if it {@link #intoArray(int[], int)} stores}
 221      * this shuffle into an allocated array and returns that array as
 222      * follows:
 223      * <pre>{@code
 224      *   int[] a = new int[this.length()];
 225      *   VectorShuffle.intoArray(a, 0);
 226      *   return a;
 227      * }</pre>
 228      *
 229      * @return an array containing the the lane elements of this vector


< prev index next >