< prev index next >

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

Print this page
rev 55589 : 8221817: [vector] No suitable species for indexMap of Gather/Scatter VectorAPI
Reviewed-by: duke


 240      *
 241      * @param species species of desired vector
 242      * @param a the array
 243      * @param i the offset into the array, may be negative if relative
 244      * indexes in the index map compensate to produce a value within the
 245      * array bounds
 246      * @param indexMap the index map
 247      * @param j the offset into the index map
 248      * @return the vector loaded from an array
 249      * @throws IndexOutOfBoundsException if {@code j < 0}, or
 250      * {@code j > indexMap.length - this.length()},
 251      * or for any vector lane index {@code N} the result of
 252      * {@code i + indexMap[j + N]} is {@code < 0} or {@code >= a.length}
 253      */
 254     @ForceInline
 255     @SuppressWarnings("unchecked")
 256     public static FloatVector fromArray(FloatSpecies species, float[] a, int i, int[] indexMap, int j) {
 257         Objects.requireNonNull(a);
 258         Objects.requireNonNull(indexMap);
 259 
 260 
 261         // Index vector: vix[0:n] = k -> i + indexMap[j + i]
 262         IntVector vix = IntVector.fromArray(species.indexSpecies(), indexMap, j).add(i);
 263 
 264         vix = VectorIntrinsics.checkIndex(vix, a.length);
 265 
 266         return VectorIntrinsics.loadWithMap((Class<FloatVector>) species.boxType(), float.class, species.length(),
 267                                             species.indexSpecies().vectorType(), a, Unsafe.ARRAY_FLOAT_BASE_OFFSET, vix,
 268                                             a, i, indexMap, j, species,
 269                                            (c, idx, iMap, idy, s) -> ((FloatSpecies)s).op(n -> c[idx + iMap[idy+n]]));
 270         }
 271 
 272     /**
 273      * Loads a vector from an array using indexes obtained from an index
 274      * map and using a mask.
 275      * <p>
 276      * For each vector lane, where {@code N} is the vector lane index,
 277      * if the mask lane at index {@code N} is set then the array element at
 278      * index {@code i + indexMap[j + N]} is placed into the resulting vector
 279      * at lane index {@code N}.
 280      *


2023 
2024     /**
2025      * Class representing {@link FloatVector}'s of the same {@link Vector.Shape Shape}.
2026      */
2027     public static abstract class FloatSpecies extends Vector.Species<Float> {
2028         interface FOp {
2029             float apply(int i);
2030         }
2031 
2032         abstract FloatVector op(FOp f);
2033 
2034         abstract FloatVector op(Mask<Float> m, FOp f);
2035 
2036         interface FOpm {
2037             boolean apply(int i);
2038         }
2039 
2040         abstract Mask<Float> opm(FOpm f);
2041 
2042         abstract IntVector.IntSpecies indexSpecies();
2043 
2044 
2045         // Factories
2046 
2047         @Override
2048         public abstract FloatVector zero();
2049 
2050         /**
2051          * Returns a vector where all lane elements are set to the primitive
2052          * value {@code e}.
2053          *
2054          * @param e the value
2055          * @return a vector of vector where all lane elements are set to
2056          * the primitive value {@code e}
2057          */
2058         public abstract FloatVector broadcast(float e);
2059 
2060         /**
2061          * Returns a vector where the first lane element is set to the primtive
2062          * value {@code e}, all other lane elements are set to the default
2063          * value.




 240      *
 241      * @param species species of desired vector
 242      * @param a the array
 243      * @param i the offset into the array, may be negative if relative
 244      * indexes in the index map compensate to produce a value within the
 245      * array bounds
 246      * @param indexMap the index map
 247      * @param j the offset into the index map
 248      * @return the vector loaded from an array
 249      * @throws IndexOutOfBoundsException if {@code j < 0}, or
 250      * {@code j > indexMap.length - this.length()},
 251      * or for any vector lane index {@code N} the result of
 252      * {@code i + indexMap[j + N]} is {@code < 0} or {@code >= a.length}
 253      */
 254     @ForceInline
 255     @SuppressWarnings("unchecked")
 256     public static FloatVector fromArray(FloatSpecies species, float[] a, int i, int[] indexMap, int j) {
 257         Objects.requireNonNull(a);
 258         Objects.requireNonNull(indexMap);
 259 

 260         // Index vector: vix[0:n] = k -> i + indexMap[j + i]
 261         IntVector vix = IntVector.fromArray(species.indexSpecies(), indexMap, j).add(i);
 262 
 263         vix = VectorIntrinsics.checkIndex(vix, a.length);
 264 
 265         return VectorIntrinsics.loadWithMap((Class<FloatVector>) species.boxType(), float.class, species.length(),
 266                                             species.indexSpecies().vectorType(), a, Unsafe.ARRAY_FLOAT_BASE_OFFSET, vix,
 267                                             a, i, indexMap, j, species,
 268                                            (c, idx, iMap, idy, s) -> ((FloatSpecies)s).op(n -> c[idx + iMap[idy+n]]));
 269         }
 270 
 271     /**
 272      * Loads a vector from an array using indexes obtained from an index
 273      * map and using a mask.
 274      * <p>
 275      * For each vector lane, where {@code N} is the vector lane index,
 276      * if the mask lane at index {@code N} is set then the array element at
 277      * index {@code i + indexMap[j + N]} is placed into the resulting vector
 278      * at lane index {@code N}.
 279      *


2022 
2023     /**
2024      * Class representing {@link FloatVector}'s of the same {@link Vector.Shape Shape}.
2025      */
2026     public static abstract class FloatSpecies extends Vector.Species<Float> {
2027         interface FOp {
2028             float apply(int i);
2029         }
2030 
2031         abstract FloatVector op(FOp f);
2032 
2033         abstract FloatVector op(Mask<Float> m, FOp f);
2034 
2035         interface FOpm {
2036             boolean apply(int i);
2037         }
2038 
2039         abstract Mask<Float> opm(FOpm f);
2040 
2041         abstract IntVector.IntSpecies indexSpecies();

2042 
2043         // Factories
2044 
2045         @Override
2046         public abstract FloatVector zero();
2047 
2048         /**
2049          * Returns a vector where all lane elements are set to the primitive
2050          * value {@code e}.
2051          *
2052          * @param e the value
2053          * @return a vector of vector where all lane elements are set to
2054          * the primitive value {@code e}
2055          */
2056         public abstract FloatVector broadcast(float e);
2057 
2058         /**
2059          * Returns a vector where the first lane element is set to the primtive
2060          * value {@code e}, all other lane elements are set to the default
2061          * value.


< prev index next >