< prev index next >

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

Print this page
rev 52233 : Add scalable shapes for Arm Scalable Vector Extension.
Summary: Add scalable vector shapes to support Arm SVE better.
Reviewed-by: duke


1752         else if (c == long.class) {
1753             return Long.SIZE * elementSize;
1754         }
1755         else {
1756             throw new IllegalArgumentException("Bad vector type: " + c.getName());
1757         }
1758     }
1759 
1760     // @@@ public static method on Shape?
1761     private static Shape shapeForVectorBitSize(int bitSize) {
1762         switch (bitSize) {
1763             case 64:
1764                 return Shapes.S_64_BIT;
1765             case 128:
1766                 return Shapes.S_128_BIT;
1767             case 256:
1768                 return Shapes.S_256_BIT;
1769             case 512:
1770                 return Shapes.S_512_BIT;
1771             default:



1772                 throw new IllegalArgumentException("Bad vector bit size: " + bitSize);

1773         }
1774     }
1775 
1776     /**
1777      * Finds a species for an element type and shape.
1778      *
1779      * @param c the element type
1780      * @param s the shape
1781      * @param <E> the boxed element type
1782      * @param <S> the type of shape
1783      * @return a species for an element type and shape
1784      * @throws IllegalArgumentException if no such species exists for the
1785      * element type and/or shape
1786      */
1787     @SuppressWarnings("unchecked")
1788     public static <E, S extends Shape> Vector.Species<E, S> species(Class<E> c, S s) {
1789         if (c == float.class) {
1790             return (Vector.Species<E, S>) FloatVector.species(s);
1791         }
1792         else if (c == double.class) {


1752         else if (c == long.class) {
1753             return Long.SIZE * elementSize;
1754         }
1755         else {
1756             throw new IllegalArgumentException("Bad vector type: " + c.getName());
1757         }
1758     }
1759 
1760     // @@@ public static method on Shape?
1761     private static Shape shapeForVectorBitSize(int bitSize) {
1762         switch (bitSize) {
1763             case 64:
1764                 return Shapes.S_64_BIT;
1765             case 128:
1766                 return Shapes.S_128_BIT;
1767             case 256:
1768                 return Shapes.S_256_BIT;
1769             case 512:
1770                 return Shapes.S_512_BIT;
1771             default:
1772                 if ((bitSize <= 2048) && (bitSize % 128 == 0)) {
1773                     return Shapes.S_Scalable_BIT;
1774                 } else {
1775                     throw new IllegalArgumentException("Bad vector bit size: " + bitSize);
1776                 }
1777         }
1778     }
1779 
1780     /**
1781      * Finds a species for an element type and shape.
1782      *
1783      * @param c the element type
1784      * @param s the shape
1785      * @param <E> the boxed element type
1786      * @param <S> the type of shape
1787      * @return a species for an element type and shape
1788      * @throws IllegalArgumentException if no such species exists for the
1789      * element type and/or shape
1790      */
1791     @SuppressWarnings("unchecked")
1792     public static <E, S extends Shape> Vector.Species<E, S> species(Class<E> c, S s) {
1793         if (c == float.class) {
1794             return (Vector.Species<E, S>) FloatVector.species(s);
1795         }
1796         else if (c == double.class) {
< prev index next >