< prev index next >

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

Print this page




  29 import java.util.function.Function;
  30 import java.util.function.IntUnaryOperator;
  31 
  32 abstract class AbstractSpecies<E> implements VectorSpecies<E> {
  33     @FunctionalInterface
  34     interface fShuffleFromArray<E> {
  35         VectorShuffle<E> apply(int[] reorder, int idx);
  36     }
  37 
  38     final Function<boolean[], VectorMask<E>> maskFactory;
  39     final Function<IntUnaryOperator, VectorShuffle<E>> shuffleFromOpFactory;
  40     final fShuffleFromArray<E> shuffleFromArrayFactory;
  41 
  42     @Stable
  43     protected final VectorShape shape;
  44     @Stable
  45     protected final Class<E> elementType;
  46     @Stable
  47     protected final int elementSize;
  48     @Stable
  49     protected final Class<?> boxType;
  50     @Stable
  51     protected final Class<?> maskType;
  52     @Stable
  53     protected final VectorShape indexShape;
  54 
  55     AbstractSpecies(VectorShape shape, Class<E> elementType, int elementSize,
  56                     Class<?> boxType, Class<?> maskType, Function<boolean[], VectorMask<E>> maskFactory,
  57                     Function<IntUnaryOperator, VectorShuffle<E>> shuffleFromOpFactory,
  58                     fShuffleFromArray<E> shuffleFromArrayFactory) {
  59 
  60         this.maskFactory = maskFactory;
  61         this.shuffleFromArrayFactory = shuffleFromArrayFactory;
  62         this.shuffleFromOpFactory = shuffleFromOpFactory;
  63 
  64         this.shape = shape;
  65         this.elementType = elementType;
  66         this.elementSize = elementSize;
  67         this.boxType = boxType;
  68         this.maskType = maskType;
  69 
  70         if (boxType == Long64Vector.class || boxType == Double64Vector.class) {
  71             indexShape = VectorShape.S_64_BIT;
  72         }
  73         else {
  74             int bitSize = Vector.bitSizeForVectorLength(int.class, shape.bitSize() / elementSize);
  75             indexShape = VectorShape.forBitSize(bitSize);
  76         }
  77     }
  78 
  79     @Override
  80     @ForceInline
  81     public int bitSize() {
  82         return shape.bitSize();
  83     }
  84 
  85     @Override
  86     @ForceInline
  87     public int length() {
  88         return shape.bitSize() / elementSize;
  89     }
  90 
  91     @Override
  92     @ForceInline
  93     public Class<E> elementType() {
  94         return elementType;
  95     }
  96 
  97     @Override
  98     @ForceInline
  99     public Class<?> boxType() {
 100         return boxType;
 101     }
 102 
 103     @Override
 104     @ForceInline
 105     public Class<?> maskType() {
 106         return maskType;
 107     }
 108 
 109     @Override
 110     @ForceInline
 111     public int elementSize() {
 112         return elementSize;
 113     }
 114 
 115     @Override
 116     @ForceInline
 117     public VectorShape shape() {
 118         return shape;
 119     }
 120 




  29 import java.util.function.Function;
  30 import java.util.function.IntUnaryOperator;
  31 
  32 abstract class AbstractSpecies<E> implements VectorSpecies<E> {
  33     @FunctionalInterface
  34     interface fShuffleFromArray<E> {
  35         VectorShuffle<E> apply(int[] reorder, int idx);
  36     }
  37 
  38     final Function<boolean[], VectorMask<E>> maskFactory;
  39     final Function<IntUnaryOperator, VectorShuffle<E>> shuffleFromOpFactory;
  40     final fShuffleFromArray<E> shuffleFromArrayFactory;
  41 
  42     @Stable
  43     protected final VectorShape shape;
  44     @Stable
  45     protected final Class<E> elementType;
  46     @Stable
  47     protected final int elementSize;
  48     @Stable
  49     protected final Class<?> vectorType;
  50     @Stable
  51     protected final Class<?> maskType;
  52     @Stable
  53     protected final VectorShape indexShape;
  54 
  55     AbstractSpecies(VectorShape shape, Class<E> elementType, int elementSize,
  56                     Class<?> vectorType, Class<?> maskType, Function<boolean[], VectorMask<E>> maskFactory,
  57                     Function<IntUnaryOperator, VectorShuffle<E>> shuffleFromOpFactory,
  58                     fShuffleFromArray<E> shuffleFromArrayFactory) {
  59 
  60         this.maskFactory = maskFactory;
  61         this.shuffleFromArrayFactory = shuffleFromArrayFactory;
  62         this.shuffleFromOpFactory = shuffleFromOpFactory;
  63 
  64         this.shape = shape;
  65         this.elementType = elementType;
  66         this.elementSize = elementSize;
  67         this.vectorType = vectorType;
  68         this.maskType = maskType;
  69 
  70         if (vectorType == Long64Vector.class || vectorType == Double64Vector.class) {
  71             indexShape = VectorShape.S_64_BIT;
  72         } else {

  73             int bitSize = Vector.bitSizeForVectorLength(int.class, shape.bitSize() / elementSize);
  74             indexShape = VectorShape.forBitSize(bitSize);
  75         }
  76     }
  77 
  78     @Override
  79     @ForceInline
  80     public int bitSize() {
  81         return shape.bitSize();
  82     }
  83 
  84     @Override
  85     @ForceInline
  86     public int length() {
  87         return shape.bitSize() / elementSize;
  88     }
  89 
  90     @Override
  91     @ForceInline
  92     public Class<E> elementType() {
  93         return elementType;
  94     }
  95 
  96     @Override
  97     @ForceInline
  98     public Class<?> vectorType() {
  99         return vectorType;
 100     }
 101 
 102     @Override
 103     @ForceInline
 104     public Class<?> maskType() {
 105         return maskType;
 106     }
 107 
 108     @Override
 109     @ForceInline
 110     public int elementSize() {
 111         return elementSize;
 112     }
 113 
 114     @Override
 115     @ForceInline
 116     public VectorShape shape() {
 117         return shape;
 118     }
 119 


< prev index next >