< prev index next >

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

Print this page




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


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


1326             Class<?> stype = species.elementType();
1327             int [] shuffleArray = toArray();
1328             if (stype == byte.class) {
1329                 return (Shuffle<F>) new Byte256Vector.Byte256Shuffle(shuffleArray);
1330             } else if (stype == short.class) {
1331                 return (Shuffle<F>) new Short256Vector.Short256Shuffle(shuffleArray);
1332             } else if (stype == int.class) {
1333                 return (Shuffle<F>) new Int256Vector.Int256Shuffle(shuffleArray);
1334             } else if (stype == long.class) {
1335                 return (Shuffle<F>) new Long256Vector.Long256Shuffle(shuffleArray);
1336             } else if (stype == float.class) {
1337                 return (Shuffle<F>) new Float256Vector.Float256Shuffle(shuffleArray);
1338             } else if (stype == double.class) {
1339                 return (Shuffle<F>) new Double256Vector.Double256Shuffle(shuffleArray);
1340             } else {
1341                 throw new UnsupportedOperationException("Bad lane type for casting.");
1342             }
1343         }
1344 
1345         @Override
1346         public Byte256Shuffle rearrange(Vector.Shuffle<Byte> o) {
1347             Byte256Shuffle s = (Byte256Shuffle) o;
1348             byte[] r = new byte[reorder.length];
1349             for (int i = 0; i < reorder.length; i++) {
1350                 r[i] = reorder[s.reorder[i]];
1351             }
1352             return new Byte256Shuffle(r);
1353         }
1354     }
1355 
1356     // Species
1357 
1358     @Override
1359     public Species<Byte> species() {
1360         return SPECIES;
1361     }
1362 }


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


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


1326             Class<?> stype = species.elementType();
1327             int [] shuffleArray = toArray();
1328             if (stype == byte.class) {
1329                 return (Shuffle<F>) new Byte256Vector.Byte256Shuffle(shuffleArray);
1330             } else if (stype == short.class) {
1331                 return (Shuffle<F>) new Short256Vector.Short256Shuffle(shuffleArray);
1332             } else if (stype == int.class) {
1333                 return (Shuffle<F>) new Int256Vector.Int256Shuffle(shuffleArray);
1334             } else if (stype == long.class) {
1335                 return (Shuffle<F>) new Long256Vector.Long256Shuffle(shuffleArray);
1336             } else if (stype == float.class) {
1337                 return (Shuffle<F>) new Float256Vector.Float256Shuffle(shuffleArray);
1338             } else if (stype == double.class) {
1339                 return (Shuffle<F>) new Double256Vector.Double256Shuffle(shuffleArray);
1340             } else {
1341                 throw new UnsupportedOperationException("Bad lane type for casting.");
1342             }
1343         }
1344 
1345         @Override
1346         public Byte256Shuffle rearrange(Shuffle<Byte> o) {
1347             Byte256Shuffle s = (Byte256Shuffle) o;
1348             byte[] r = new byte[reorder.length];
1349             for (int i = 0; i < reorder.length; i++) {
1350                 r[i] = reorder[s.reorder[i]];
1351             }
1352             return new Byte256Shuffle(r);
1353         }
1354     }
1355 
1356     // Species
1357 
1358     @Override
1359     public Species<Byte> species() {
1360         return SPECIES;
1361     }
1362 }
< prev index next >