< prev index next >

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

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


 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 DoubleVector fromArray(DoubleSpecies species, double[] a, int i, int[] indexMap, int j) {
 257         Objects.requireNonNull(a);
 258         Objects.requireNonNull(indexMap);
 259 
 260         if (species.length() == 1) {
 261           return DoubleVector.fromArray(species, a, i + indexMap[j]);
 262         }
 263 
 264         // Index vector: vix[0:n] = k -> i + indexMap[j + i]
 265         IntVector vix = IntVector.fromArray(species.indexSpecies(), indexMap, j).add(i);





 266 
 267         vix = VectorIntrinsics.checkIndex(vix, a.length);
 268 
 269         return VectorIntrinsics.loadWithMap((Class<DoubleVector>) species.boxType(), double.class, species.length(),
 270                                             species.indexSpecies().vectorType(), a, Unsafe.ARRAY_DOUBLE_BASE_OFFSET, vix,
 271                                             a, i, indexMap, j, species,
 272                                            (c, idx, iMap, idy, s) -> ((DoubleSpecies)s).op(n -> c[idx + iMap[idy+n]]));
 273         }
 274 
 275     /**
 276      * Loads a vector from an array using indexes obtained from an index
 277      * map and using a mask.
 278      * <p>
 279      * For each vector lane, where {@code N} is the vector lane index,
 280      * if the mask lane at index {@code N} is set then the array element at
 281      * index {@code i + indexMap[j + N]} is placed into the resulting vector
 282      * at lane index {@code N}.
 283      *
 284      * @param species species of desired vector
 285      * @param a the array


2027     /**
2028      * Class representing {@link DoubleVector}'s of the same {@link Vector.Shape Shape}.
2029      */
2030     public static abstract class DoubleSpecies extends Vector.Species<Double> {
2031         interface FOp {
2032             double apply(int i);
2033         }
2034 
2035         abstract DoubleVector op(FOp f);
2036 
2037         abstract DoubleVector op(Mask<Double> m, FOp f);
2038 
2039         interface FOpm {
2040             boolean apply(int i);
2041         }
2042 
2043         abstract Mask<Double> opm(FOpm f);
2044 
2045         abstract IntVector.IntSpecies indexSpecies();
2046 

2047 
2048         // Factories
2049 
2050         @Override
2051         public abstract DoubleVector zero();
2052 
2053         /**
2054          * Returns a vector where all lane elements are set to the primitive
2055          * value {@code e}.
2056          *
2057          * @param e the value
2058          * @return a vector of vector where all lane elements are set to
2059          * the primitive value {@code e}
2060          */
2061         public abstract DoubleVector broadcast(double e);
2062 
2063         /**
2064          * Returns a vector where the first lane element is set to the primtive
2065          * value {@code e}, all other lane elements are set to the default
2066          * value.




 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 DoubleVector fromArray(DoubleSpecies species, double[] a, int i, int[] indexMap, int j) {
 257         Objects.requireNonNull(a);
 258         Objects.requireNonNull(indexMap);
 259 
 260         if (species.length() == 1) {
 261           return DoubleVector.fromArray(species, a, i + indexMap[j]);
 262         }
 263 
 264         // Index vector: vix[0:n] = k -> i + indexMap[j + i]
 265         IntVector vix;
 266         if (species.indexMask() != null) {
 267             vix = IntVector.fromArray(species.indexSpecies(), indexMap, j, species.indexMask()).add(i);
 268         } else {
 269             vix = IntVector.fromArray(species.indexSpecies(), indexMap, j).add(i);
 270         }
 271 
 272         vix = VectorIntrinsics.checkIndex(vix, a.length);
 273 
 274         return VectorIntrinsics.loadWithMap((Class<DoubleVector>) species.boxType(), double.class, species.length(),
 275                                             species.indexSpecies().vectorType(), a, Unsafe.ARRAY_DOUBLE_BASE_OFFSET, vix,
 276                                             a, i, indexMap, j, species,
 277                                            (c, idx, iMap, idy, s) -> ((DoubleSpecies)s).op(n -> c[idx + iMap[idy+n]]));
 278         }
 279 
 280     /**
 281      * Loads a vector from an array using indexes obtained from an index
 282      * map and using a mask.
 283      * <p>
 284      * For each vector lane, where {@code N} is the vector lane index,
 285      * if the mask lane at index {@code N} is set then the array element at
 286      * index {@code i + indexMap[j + N]} is placed into the resulting vector
 287      * at lane index {@code N}.
 288      *
 289      * @param species species of desired vector
 290      * @param a the array


2032     /**
2033      * Class representing {@link DoubleVector}'s of the same {@link Vector.Shape Shape}.
2034      */
2035     public static abstract class DoubleSpecies extends Vector.Species<Double> {
2036         interface FOp {
2037             double apply(int i);
2038         }
2039 
2040         abstract DoubleVector op(FOp f);
2041 
2042         abstract DoubleVector op(Mask<Double> m, FOp f);
2043 
2044         interface FOpm {
2045             boolean apply(int i);
2046         }
2047 
2048         abstract Mask<Double> opm(FOpm f);
2049 
2050         abstract IntVector.IntSpecies indexSpecies();
2051 
2052         abstract Mask<Integer> indexMask();
2053 
2054         // Factories
2055 
2056         @Override
2057         public abstract DoubleVector zero();
2058 
2059         /**
2060          * Returns a vector where all lane elements are set to the primitive
2061          * value {@code e}.
2062          *
2063          * @param e the value
2064          * @return a vector of vector where all lane elements are set to
2065          * the primitive value {@code e}
2066          */
2067         public abstract DoubleVector broadcast(double e);
2068 
2069         /**
2070          * Returns a vector where the first lane element is set to the primtive
2071          * value {@code e}, all other lane elements are set to the default
2072          * value.


< prev index next >