< prev index next >

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

Print this page




 845     @Override
 846     @ForceInline
 847     public long minAll(Mask<Long> m) {
 848         return blend((Long64Vector)LongVector.broadcast(SPECIES, Long.MAX_VALUE), m).minAll();
 849     }
 850 
 851     @Override
 852     @ForceInline
 853     public long maxAll(Mask<Long> m) {
 854         return blend((Long64Vector)LongVector.broadcast(SPECIES, Long.MIN_VALUE), m).maxAll();
 855     }
 856 
 857     @Override
 858     @ForceInline
 859     public Shuffle<Long> toShuffle() {
 860         long[] a = toArray();
 861         int[] sa = new int[a.length];
 862         for (int i = 0; i < a.length; i++) {
 863             sa[i] = (int) a[i];
 864         }
 865         return LongVector.shuffleFromArray(SPECIES, sa, 0);
 866     }
 867 
 868     // Memory operations
 869 
 870     private static final int ARRAY_SHIFT         = 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_LONG_INDEX_SCALE);
 871     private static final int BOOLEAN_ARRAY_SHIFT = 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_BOOLEAN_INDEX_SCALE);
 872 
 873     @Override
 874     @ForceInline
 875     public void intoArray(long[] a, int ix) {
 876         Objects.requireNonNull(a);
 877         ix = VectorIntrinsics.checkIndex(ix, a.length, LENGTH);
 878         VectorIntrinsics.store(Long64Vector.class, long.class, LENGTH,
 879                                a, (((long) ix) << ARRAY_SHIFT) + Unsafe.ARRAY_LONG_BASE_OFFSET,
 880                                this,
 881                                a, ix,
 882                                (arr, idx, v) -> v.forEach((i, e) -> arr[idx + i] = e));
 883     }
 884 
 885     @Override


1328             Long64Mask m = (Long64Mask)o;
1329             return VectorIntrinsics.binaryOp(VECTOR_OP_OR, Long64Mask.class, long.class, LENGTH,
1330                                              this, m,
1331                                              (m1, m2) -> m1.bOp(m2, (i, a, b) -> a | b));
1332         }
1333 
1334         // Reductions
1335 
1336         @Override
1337         @ForceInline
1338         public boolean anyTrue() {
1339             return VectorIntrinsics.test(BT_ne, Long64Mask.class, long.class, LENGTH,
1340                                          this, this,
1341                                          (m, __) -> anyTrueHelper(((Long64Mask)m).getBits()));
1342         }
1343 
1344         @Override
1345         @ForceInline
1346         public boolean allTrue() {
1347             return VectorIntrinsics.test(BT_overflow, Long64Mask.class, long.class, LENGTH,
1348                                          this, LongVector.maskAllTrue(species()),
1349                                          (m, __) -> allTrueHelper(((Long64Mask)m).getBits()));
1350         }
1351     }
1352 
1353     // Shuffle
1354 
1355     static final class Long64Shuffle extends AbstractShuffle<Long> {
1356         Long64Shuffle(byte[] reorder) {
1357             super(reorder);
1358         }
1359 
1360         public Long64Shuffle(int[] reorder) {
1361             super(reorder);
1362         }
1363 
1364         public Long64Shuffle(int[] reorder, int i) {
1365             super(reorder, i);
1366         }
1367 
1368         public Long64Shuffle(IntUnaryOperator f) {


1392             Class<?> stype = species.elementType();
1393             int [] shuffleArray = toArray();
1394             if (stype == byte.class) {
1395                 return (Shuffle<F>) new Byte64Vector.Byte64Shuffle(shuffleArray);
1396             } else if (stype == short.class) {
1397                 return (Shuffle<F>) new Short64Vector.Short64Shuffle(shuffleArray);
1398             } else if (stype == int.class) {
1399                 return (Shuffle<F>) new Int64Vector.Int64Shuffle(shuffleArray);
1400             } else if (stype == long.class) {
1401                 return (Shuffle<F>) new Long64Vector.Long64Shuffle(shuffleArray);
1402             } else if (stype == float.class) {
1403                 return (Shuffle<F>) new Float64Vector.Float64Shuffle(shuffleArray);
1404             } else if (stype == double.class) {
1405                 return (Shuffle<F>) new Double64Vector.Double64Shuffle(shuffleArray);
1406             } else {
1407                 throw new UnsupportedOperationException("Bad lane type for casting.");
1408             }
1409         }
1410 
1411         @Override
1412         public Long64Shuffle rearrange(Vector.Shuffle<Long> o) {
1413             Long64Shuffle s = (Long64Shuffle) o;
1414             byte[] r = new byte[reorder.length];
1415             for (int i = 0; i < reorder.length; i++) {
1416                 r[i] = reorder[s.reorder[i]];
1417             }
1418             return new Long64Shuffle(r);
1419         }
1420     }
1421 
1422     // Species
1423 
1424     @Override
1425     public Species<Long> species() {
1426         return SPECIES;
1427     }
1428 }


 845     @Override
 846     @ForceInline
 847     public long minAll(Mask<Long> m) {
 848         return blend((Long64Vector)LongVector.broadcast(SPECIES, Long.MAX_VALUE), m).minAll();
 849     }
 850 
 851     @Override
 852     @ForceInline
 853     public long maxAll(Mask<Long> m) {
 854         return blend((Long64Vector)LongVector.broadcast(SPECIES, Long.MIN_VALUE), m).maxAll();
 855     }
 856 
 857     @Override
 858     @ForceInline
 859     public Shuffle<Long> toShuffle() {
 860         long[] a = toArray();
 861         int[] sa = new int[a.length];
 862         for (int i = 0; i < a.length; i++) {
 863             sa[i] = (int) a[i];
 864         }
 865         return Shuffle.fromArray(SPECIES, sa, 0);
 866     }
 867 
 868     // Memory operations
 869 
 870     private static final int ARRAY_SHIFT         = 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_LONG_INDEX_SCALE);
 871     private static final int BOOLEAN_ARRAY_SHIFT = 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_BOOLEAN_INDEX_SCALE);
 872 
 873     @Override
 874     @ForceInline
 875     public void intoArray(long[] a, int ix) {
 876         Objects.requireNonNull(a);
 877         ix = VectorIntrinsics.checkIndex(ix, a.length, LENGTH);
 878         VectorIntrinsics.store(Long64Vector.class, long.class, LENGTH,
 879                                a, (((long) ix) << ARRAY_SHIFT) + Unsafe.ARRAY_LONG_BASE_OFFSET,
 880                                this,
 881                                a, ix,
 882                                (arr, idx, v) -> v.forEach((i, e) -> arr[idx + i] = e));
 883     }
 884 
 885     @Override


1328             Long64Mask m = (Long64Mask)o;
1329             return VectorIntrinsics.binaryOp(VECTOR_OP_OR, Long64Mask.class, long.class, LENGTH,
1330                                              this, m,
1331                                              (m1, m2) -> m1.bOp(m2, (i, a, b) -> a | b));
1332         }
1333 
1334         // Reductions
1335 
1336         @Override
1337         @ForceInline
1338         public boolean anyTrue() {
1339             return VectorIntrinsics.test(BT_ne, Long64Mask.class, long.class, LENGTH,
1340                                          this, this,
1341                                          (m, __) -> anyTrueHelper(((Long64Mask)m).getBits()));
1342         }
1343 
1344         @Override
1345         @ForceInline
1346         public boolean allTrue() {
1347             return VectorIntrinsics.test(BT_overflow, Long64Mask.class, long.class, LENGTH,
1348                                          this, Mask.maskAllTrue(species()),
1349                                          (m, __) -> allTrueHelper(((Long64Mask)m).getBits()));
1350         }
1351     }
1352 
1353     // Shuffle
1354 
1355     static final class Long64Shuffle extends AbstractShuffle<Long> {
1356         Long64Shuffle(byte[] reorder) {
1357             super(reorder);
1358         }
1359 
1360         public Long64Shuffle(int[] reorder) {
1361             super(reorder);
1362         }
1363 
1364         public Long64Shuffle(int[] reorder, int i) {
1365             super(reorder, i);
1366         }
1367 
1368         public Long64Shuffle(IntUnaryOperator f) {


1392             Class<?> stype = species.elementType();
1393             int [] shuffleArray = toArray();
1394             if (stype == byte.class) {
1395                 return (Shuffle<F>) new Byte64Vector.Byte64Shuffle(shuffleArray);
1396             } else if (stype == short.class) {
1397                 return (Shuffle<F>) new Short64Vector.Short64Shuffle(shuffleArray);
1398             } else if (stype == int.class) {
1399                 return (Shuffle<F>) new Int64Vector.Int64Shuffle(shuffleArray);
1400             } else if (stype == long.class) {
1401                 return (Shuffle<F>) new Long64Vector.Long64Shuffle(shuffleArray);
1402             } else if (stype == float.class) {
1403                 return (Shuffle<F>) new Float64Vector.Float64Shuffle(shuffleArray);
1404             } else if (stype == double.class) {
1405                 return (Shuffle<F>) new Double64Vector.Double64Shuffle(shuffleArray);
1406             } else {
1407                 throw new UnsupportedOperationException("Bad lane type for casting.");
1408             }
1409         }
1410 
1411         @Override
1412         public Long64Shuffle rearrange(Shuffle<Long> o) {
1413             Long64Shuffle s = (Long64Shuffle) o;
1414             byte[] r = new byte[reorder.length];
1415             for (int i = 0; i < reorder.length; i++) {
1416                 r[i] = reorder[s.reorder[i]];
1417             }
1418             return new Long64Shuffle(r);
1419         }
1420     }
1421 
1422     // Species
1423 
1424     @Override
1425     public Species<Long> species() {
1426         return SPECIES;
1427     }
1428 }
< prev index next >