< prev index next >

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

Print this page




 906     @Override
 907     @ForceInline
 908     public float minAll(Mask<Float> m) {
 909         return blend((FloatMaxVector)FloatVector.broadcast(SPECIES, Float.MAX_VALUE), m).minAll();
 910     }
 911 
 912     @Override
 913     @ForceInline
 914     public float maxAll(Mask<Float> m) {
 915         return blend((FloatMaxVector)FloatVector.broadcast(SPECIES, Float.MIN_VALUE), m).maxAll();
 916     }
 917 
 918     @Override
 919     @ForceInline
 920     public Shuffle<Float> toShuffle() {
 921         float[] a = toArray();
 922         int[] sa = new int[a.length];
 923         for (int i = 0; i < a.length; i++) {
 924             sa[i] = (int) a[i];
 925         }
 926         return FloatVector.shuffleFromArray(SPECIES, sa, 0);
 927     }
 928 
 929     // Memory operations
 930 
 931     private static final int ARRAY_SHIFT         = 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_FLOAT_INDEX_SCALE);
 932     private static final int BOOLEAN_ARRAY_SHIFT = 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_BOOLEAN_INDEX_SCALE);
 933 
 934     @Override
 935     @ForceInline
 936     public void intoArray(float[] a, int ix) {
 937         Objects.requireNonNull(a);
 938         ix = VectorIntrinsics.checkIndex(ix, a.length, LENGTH);
 939         VectorIntrinsics.store(FloatMaxVector.class, float.class, LENGTH,
 940                                a, (((long) ix) << ARRAY_SHIFT) + Unsafe.ARRAY_FLOAT_BASE_OFFSET,
 941                                this,
 942                                a, ix,
 943                                (arr, idx, v) -> v.forEach((i, e) -> arr[idx + i] = e));
 944     }
 945 
 946     @Override


1402             FloatMaxMask m = (FloatMaxMask)o;
1403             return VectorIntrinsics.binaryOp(VECTOR_OP_OR, FloatMaxMask.class, int.class, LENGTH,
1404                                              this, m,
1405                                              (m1, m2) -> m1.bOp(m2, (i, a, b) -> a | b));
1406         }
1407 
1408         // Reductions
1409 
1410         @Override
1411         @ForceInline
1412         public boolean anyTrue() {
1413             return VectorIntrinsics.test(BT_ne, FloatMaxMask.class, int.class, LENGTH,
1414                                          this, this,
1415                                          (m, __) -> anyTrueHelper(((FloatMaxMask)m).getBits()));
1416         }
1417 
1418         @Override
1419         @ForceInline
1420         public boolean allTrue() {
1421             return VectorIntrinsics.test(BT_overflow, FloatMaxMask.class, int.class, LENGTH,
1422                                          this, FloatVector.maskAllTrue(species()),
1423                                          (m, __) -> allTrueHelper(((FloatMaxMask)m).getBits()));
1424         }
1425     }
1426 
1427     // Shuffle
1428 
1429     static final class FloatMaxShuffle extends AbstractShuffle<Float> {
1430         FloatMaxShuffle(byte[] reorder) {
1431             super(reorder);
1432         }
1433 
1434         public FloatMaxShuffle(int[] reorder) {
1435             super(reorder);
1436         }
1437 
1438         public FloatMaxShuffle(int[] reorder, int i) {
1439             super(reorder, i);
1440         }
1441 
1442         public FloatMaxShuffle(IntUnaryOperator f) {


1466             Class<?> stype = species.elementType();
1467             int [] shuffleArray = toArray();
1468             if (stype == byte.class) {
1469                 return (Shuffle<F>) new ByteMaxVector.ByteMaxShuffle(shuffleArray);
1470             } else if (stype == short.class) {
1471                 return (Shuffle<F>) new ShortMaxVector.ShortMaxShuffle(shuffleArray);
1472             } else if (stype == int.class) {
1473                 return (Shuffle<F>) new IntMaxVector.IntMaxShuffle(shuffleArray);
1474             } else if (stype == long.class) {
1475                 return (Shuffle<F>) new LongMaxVector.LongMaxShuffle(shuffleArray);
1476             } else if (stype == float.class) {
1477                 return (Shuffle<F>) new FloatMaxVector.FloatMaxShuffle(shuffleArray);
1478             } else if (stype == double.class) {
1479                 return (Shuffle<F>) new DoubleMaxVector.DoubleMaxShuffle(shuffleArray);
1480             } else {
1481                 throw new UnsupportedOperationException("Bad lane type for casting.");
1482             }
1483         }
1484 
1485         @Override
1486         public FloatMaxShuffle rearrange(Vector.Shuffle<Float> o) {
1487             FloatMaxShuffle s = (FloatMaxShuffle) o;
1488             byte[] r = new byte[reorder.length];
1489             for (int i = 0; i < reorder.length; i++) {
1490                 r[i] = reorder[s.reorder[i]];
1491             }
1492             return new FloatMaxShuffle(r);
1493         }
1494     }
1495 
1496     // Species
1497 
1498     @Override
1499     public Species<Float> species() {
1500         return SPECIES;
1501     }
1502 }


 906     @Override
 907     @ForceInline
 908     public float minAll(Mask<Float> m) {
 909         return blend((FloatMaxVector)FloatVector.broadcast(SPECIES, Float.MAX_VALUE), m).minAll();
 910     }
 911 
 912     @Override
 913     @ForceInline
 914     public float maxAll(Mask<Float> m) {
 915         return blend((FloatMaxVector)FloatVector.broadcast(SPECIES, Float.MIN_VALUE), m).maxAll();
 916     }
 917 
 918     @Override
 919     @ForceInline
 920     public Shuffle<Float> toShuffle() {
 921         float[] a = toArray();
 922         int[] sa = new int[a.length];
 923         for (int i = 0; i < a.length; i++) {
 924             sa[i] = (int) a[i];
 925         }
 926         return Shuffle.fromArray(SPECIES, sa, 0);
 927     }
 928 
 929     // Memory operations
 930 
 931     private static final int ARRAY_SHIFT         = 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_FLOAT_INDEX_SCALE);
 932     private static final int BOOLEAN_ARRAY_SHIFT = 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_BOOLEAN_INDEX_SCALE);
 933 
 934     @Override
 935     @ForceInline
 936     public void intoArray(float[] a, int ix) {
 937         Objects.requireNonNull(a);
 938         ix = VectorIntrinsics.checkIndex(ix, a.length, LENGTH);
 939         VectorIntrinsics.store(FloatMaxVector.class, float.class, LENGTH,
 940                                a, (((long) ix) << ARRAY_SHIFT) + Unsafe.ARRAY_FLOAT_BASE_OFFSET,
 941                                this,
 942                                a, ix,
 943                                (arr, idx, v) -> v.forEach((i, e) -> arr[idx + i] = e));
 944     }
 945 
 946     @Override


1402             FloatMaxMask m = (FloatMaxMask)o;
1403             return VectorIntrinsics.binaryOp(VECTOR_OP_OR, FloatMaxMask.class, int.class, LENGTH,
1404                                              this, m,
1405                                              (m1, m2) -> m1.bOp(m2, (i, a, b) -> a | b));
1406         }
1407 
1408         // Reductions
1409 
1410         @Override
1411         @ForceInline
1412         public boolean anyTrue() {
1413             return VectorIntrinsics.test(BT_ne, FloatMaxMask.class, int.class, LENGTH,
1414                                          this, this,
1415                                          (m, __) -> anyTrueHelper(((FloatMaxMask)m).getBits()));
1416         }
1417 
1418         @Override
1419         @ForceInline
1420         public boolean allTrue() {
1421             return VectorIntrinsics.test(BT_overflow, FloatMaxMask.class, int.class, LENGTH,
1422                                          this, Mask.maskAllTrue(species()),
1423                                          (m, __) -> allTrueHelper(((FloatMaxMask)m).getBits()));
1424         }
1425     }
1426 
1427     // Shuffle
1428 
1429     static final class FloatMaxShuffle extends AbstractShuffle<Float> {
1430         FloatMaxShuffle(byte[] reorder) {
1431             super(reorder);
1432         }
1433 
1434         public FloatMaxShuffle(int[] reorder) {
1435             super(reorder);
1436         }
1437 
1438         public FloatMaxShuffle(int[] reorder, int i) {
1439             super(reorder, i);
1440         }
1441 
1442         public FloatMaxShuffle(IntUnaryOperator f) {


1466             Class<?> stype = species.elementType();
1467             int [] shuffleArray = toArray();
1468             if (stype == byte.class) {
1469                 return (Shuffle<F>) new ByteMaxVector.ByteMaxShuffle(shuffleArray);
1470             } else if (stype == short.class) {
1471                 return (Shuffle<F>) new ShortMaxVector.ShortMaxShuffle(shuffleArray);
1472             } else if (stype == int.class) {
1473                 return (Shuffle<F>) new IntMaxVector.IntMaxShuffle(shuffleArray);
1474             } else if (stype == long.class) {
1475                 return (Shuffle<F>) new LongMaxVector.LongMaxShuffle(shuffleArray);
1476             } else if (stype == float.class) {
1477                 return (Shuffle<F>) new FloatMaxVector.FloatMaxShuffle(shuffleArray);
1478             } else if (stype == double.class) {
1479                 return (Shuffle<F>) new DoubleMaxVector.DoubleMaxShuffle(shuffleArray);
1480             } else {
1481                 throw new UnsupportedOperationException("Bad lane type for casting.");
1482             }
1483         }
1484 
1485         @Override
1486         public FloatMaxShuffle rearrange(Shuffle<Float> o) {
1487             FloatMaxShuffle s = (FloatMaxShuffle) o;
1488             byte[] r = new byte[reorder.length];
1489             for (int i = 0; i < reorder.length; i++) {
1490                 r[i] = reorder[s.reorder[i]];
1491             }
1492             return new FloatMaxShuffle(r);
1493         }
1494     }
1495 
1496     // Species
1497 
1498     @Override
1499     public Species<Float> species() {
1500         return SPECIES;
1501     }
1502 }
< prev index next >