< prev index next >

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

Print this page




 802     @Override
 803     @ForceInline
 804     public short minAll(Mask<Short> m) {
 805         return blend((Short512Vector)ShortVector.broadcast(SPECIES, Short.MAX_VALUE), m).minAll();
 806     }
 807 
 808     @Override
 809     @ForceInline
 810     public short maxAll(Mask<Short> m) {
 811         return blend((Short512Vector)ShortVector.broadcast(SPECIES, Short.MIN_VALUE), m).maxAll();
 812     }
 813 
 814     @Override
 815     @ForceInline
 816     public Shuffle<Short> toShuffle() {
 817         short[] a = toArray();
 818         int[] sa = new int[a.length];
 819         for (int i = 0; i < a.length; i++) {
 820             sa[i] = (int) a[i];
 821         }
 822         return ShortVector.shuffleFromArray(SPECIES, sa, 0);
 823     }
 824 
 825     // Memory operations
 826 
 827     private static final int ARRAY_SHIFT         = 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_SHORT_INDEX_SCALE);
 828     private static final int BOOLEAN_ARRAY_SHIFT = 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_BOOLEAN_INDEX_SCALE);
 829 
 830     @Override
 831     @ForceInline
 832     public void intoArray(short[] a, int ix) {
 833         Objects.requireNonNull(a);
 834         ix = VectorIntrinsics.checkIndex(ix, a.length, LENGTH);
 835         VectorIntrinsics.store(Short512Vector.class, short.class, LENGTH,
 836                                a, (((long) ix) << ARRAY_SHIFT) + Unsafe.ARRAY_SHORT_BASE_OFFSET,
 837                                this,
 838                                a, ix,
 839                                (arr, idx, v) -> v.forEach((i, e) -> arr[idx + i] = e));
 840     }
 841 
 842     @Override


1263             Short512Mask m = (Short512Mask)o;
1264             return VectorIntrinsics.binaryOp(VECTOR_OP_OR, Short512Mask.class, short.class, LENGTH,
1265                                              this, m,
1266                                              (m1, m2) -> m1.bOp(m2, (i, a, b) -> a | b));
1267         }
1268 
1269         // Reductions
1270 
1271         @Override
1272         @ForceInline
1273         public boolean anyTrue() {
1274             return VectorIntrinsics.test(BT_ne, Short512Mask.class, short.class, LENGTH,
1275                                          this, this,
1276                                          (m, __) -> anyTrueHelper(((Short512Mask)m).getBits()));
1277         }
1278 
1279         @Override
1280         @ForceInline
1281         public boolean allTrue() {
1282             return VectorIntrinsics.test(BT_overflow, Short512Mask.class, short.class, LENGTH,
1283                                          this, ShortVector.maskAllTrue(species()),
1284                                          (m, __) -> allTrueHelper(((Short512Mask)m).getBits()));
1285         }
1286     }
1287 
1288     // Shuffle
1289 
1290     static final class Short512Shuffle extends AbstractShuffle<Short> {
1291         Short512Shuffle(byte[] reorder) {
1292             super(reorder);
1293         }
1294 
1295         public Short512Shuffle(int[] reorder) {
1296             super(reorder);
1297         }
1298 
1299         public Short512Shuffle(int[] reorder, int i) {
1300             super(reorder, i);
1301         }
1302 
1303         public Short512Shuffle(IntUnaryOperator f) {


1327             Class<?> stype = species.elementType();
1328             int [] shuffleArray = toArray();
1329             if (stype == byte.class) {
1330                 return (Shuffle<F>) new Byte512Vector.Byte512Shuffle(shuffleArray);
1331             } else if (stype == short.class) {
1332                 return (Shuffle<F>) new Short512Vector.Short512Shuffle(shuffleArray);
1333             } else if (stype == int.class) {
1334                 return (Shuffle<F>) new Int512Vector.Int512Shuffle(shuffleArray);
1335             } else if (stype == long.class) {
1336                 return (Shuffle<F>) new Long512Vector.Long512Shuffle(shuffleArray);
1337             } else if (stype == float.class) {
1338                 return (Shuffle<F>) new Float512Vector.Float512Shuffle(shuffleArray);
1339             } else if (stype == double.class) {
1340                 return (Shuffle<F>) new Double512Vector.Double512Shuffle(shuffleArray);
1341             } else {
1342                 throw new UnsupportedOperationException("Bad lane type for casting.");
1343             }
1344         }
1345 
1346         @Override
1347         public Short512Shuffle rearrange(Vector.Shuffle<Short> o) {
1348             Short512Shuffle s = (Short512Shuffle) o;
1349             byte[] r = new byte[reorder.length];
1350             for (int i = 0; i < reorder.length; i++) {
1351                 r[i] = reorder[s.reorder[i]];
1352             }
1353             return new Short512Shuffle(r);
1354         }
1355     }
1356 
1357     // Species
1358 
1359     @Override
1360     public Species<Short> species() {
1361         return SPECIES;
1362     }
1363 }


 802     @Override
 803     @ForceInline
 804     public short minAll(Mask<Short> m) {
 805         return blend((Short512Vector)ShortVector.broadcast(SPECIES, Short.MAX_VALUE), m).minAll();
 806     }
 807 
 808     @Override
 809     @ForceInline
 810     public short maxAll(Mask<Short> m) {
 811         return blend((Short512Vector)ShortVector.broadcast(SPECIES, Short.MIN_VALUE), m).maxAll();
 812     }
 813 
 814     @Override
 815     @ForceInline
 816     public Shuffle<Short> toShuffle() {
 817         short[] a = toArray();
 818         int[] sa = new int[a.length];
 819         for (int i = 0; i < a.length; i++) {
 820             sa[i] = (int) a[i];
 821         }
 822         return Shuffle.fromArray(SPECIES, sa, 0);
 823     }
 824 
 825     // Memory operations
 826 
 827     private static final int ARRAY_SHIFT         = 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_SHORT_INDEX_SCALE);
 828     private static final int BOOLEAN_ARRAY_SHIFT = 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_BOOLEAN_INDEX_SCALE);
 829 
 830     @Override
 831     @ForceInline
 832     public void intoArray(short[] a, int ix) {
 833         Objects.requireNonNull(a);
 834         ix = VectorIntrinsics.checkIndex(ix, a.length, LENGTH);
 835         VectorIntrinsics.store(Short512Vector.class, short.class, LENGTH,
 836                                a, (((long) ix) << ARRAY_SHIFT) + Unsafe.ARRAY_SHORT_BASE_OFFSET,
 837                                this,
 838                                a, ix,
 839                                (arr, idx, v) -> v.forEach((i, e) -> arr[idx + i] = e));
 840     }
 841 
 842     @Override


1263             Short512Mask m = (Short512Mask)o;
1264             return VectorIntrinsics.binaryOp(VECTOR_OP_OR, Short512Mask.class, short.class, LENGTH,
1265                                              this, m,
1266                                              (m1, m2) -> m1.bOp(m2, (i, a, b) -> a | b));
1267         }
1268 
1269         // Reductions
1270 
1271         @Override
1272         @ForceInline
1273         public boolean anyTrue() {
1274             return VectorIntrinsics.test(BT_ne, Short512Mask.class, short.class, LENGTH,
1275                                          this, this,
1276                                          (m, __) -> anyTrueHelper(((Short512Mask)m).getBits()));
1277         }
1278 
1279         @Override
1280         @ForceInline
1281         public boolean allTrue() {
1282             return VectorIntrinsics.test(BT_overflow, Short512Mask.class, short.class, LENGTH,
1283                                          this, Mask.maskAllTrue(species()),
1284                                          (m, __) -> allTrueHelper(((Short512Mask)m).getBits()));
1285         }
1286     }
1287 
1288     // Shuffle
1289 
1290     static final class Short512Shuffle extends AbstractShuffle<Short> {
1291         Short512Shuffle(byte[] reorder) {
1292             super(reorder);
1293         }
1294 
1295         public Short512Shuffle(int[] reorder) {
1296             super(reorder);
1297         }
1298 
1299         public Short512Shuffle(int[] reorder, int i) {
1300             super(reorder, i);
1301         }
1302 
1303         public Short512Shuffle(IntUnaryOperator f) {


1327             Class<?> stype = species.elementType();
1328             int [] shuffleArray = toArray();
1329             if (stype == byte.class) {
1330                 return (Shuffle<F>) new Byte512Vector.Byte512Shuffle(shuffleArray);
1331             } else if (stype == short.class) {
1332                 return (Shuffle<F>) new Short512Vector.Short512Shuffle(shuffleArray);
1333             } else if (stype == int.class) {
1334                 return (Shuffle<F>) new Int512Vector.Int512Shuffle(shuffleArray);
1335             } else if (stype == long.class) {
1336                 return (Shuffle<F>) new Long512Vector.Long512Shuffle(shuffleArray);
1337             } else if (stype == float.class) {
1338                 return (Shuffle<F>) new Float512Vector.Float512Shuffle(shuffleArray);
1339             } else if (stype == double.class) {
1340                 return (Shuffle<F>) new Double512Vector.Double512Shuffle(shuffleArray);
1341             } else {
1342                 throw new UnsupportedOperationException("Bad lane type for casting.");
1343             }
1344         }
1345 
1346         @Override
1347         public Short512Shuffle rearrange(Shuffle<Short> o) {
1348             Short512Shuffle s = (Short512Shuffle) o;
1349             byte[] r = new byte[reorder.length];
1350             for (int i = 0; i < reorder.length; i++) {
1351                 r[i] = reorder[s.reorder[i]];
1352             }
1353             return new Short512Shuffle(r);
1354         }
1355     }
1356 
1357     // Species
1358 
1359     @Override
1360     public Species<Short> species() {
1361         return SPECIES;
1362     }
1363 }
< prev index next >