< prev index next >

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

Print this page
rev 49509 : [vector] Intrinsic support for resize

@@ -671,13 +671,13 @@
     public <F> Vector<F, Shapes.S512Bit> rebracket(Species<F, Shapes.S512Bit> species) {
         Objects.requireNonNull(species);
         // TODO: check proper element type
         // TODO: update to pass the two species as an arguments and ideally
         // push down intrinsic call into species implementation
-        return VectorIntrinsics.rebracket(
+        return VectorIntrinsics.reinterpret(
             Byte512Vector.class, byte.class, LENGTH,
-            species.elementType(), this,
+            species.elementType(), species.length(), this,
             (v, t) -> species.reshape(v)
         );
     }
 
     // Accessors

@@ -762,13 +762,13 @@
         @ForceInline
         @SuppressWarnings("unchecked")
         public <Z> Mask<Z, Shapes.S512Bit> rebracket(Species<Z, Shapes.S512Bit> species) {
             Objects.requireNonNull(species);
             // TODO: check proper element type
-            return VectorIntrinsics.rebracket(
+            return VectorIntrinsics.reinterpret(
                 Byte512Mask.class, byte.class, LENGTH,
-                species.elementType(), this,
+                species.elementType(), species.length(), this,
                 (m, t) -> m.reshape(species)
             );
         }
 
         // Unary operations

@@ -861,30 +861,35 @@
            sb.append("]");
            return sb.toString();
         }
 
         @Override
+        @ForceInline
         public int bitSize() {
             return BIT_SIZE;
         }
 
         @Override
+        @ForceInline
         public int length() {
             return LENGTH;
         }
 
         @Override
+        @ForceInline
         public Class<Byte> elementType() {
             return Byte.class;
         }
 
         @Override
+        @ForceInline
         public int elementSize() {
             return Byte.SIZE;
         }
 
         @Override
+        @ForceInline
         public Shapes.S512Bit shape() {
             return Shapes.S_512_BIT;
         }
 
         @Override

@@ -976,7 +981,45 @@
         @Override
         @ForceInline
         public Byte512Vector fromArray(byte[] a, int ax, Mask<Byte, Shapes.S512Bit> m) {
             return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]);
         }
+
+        @Override
+        @ForceInline
+        @SuppressWarnings("unchecked")
+        public <T extends Shape> Byte512Vector resize(Vector<Byte, T> o) {
+            Objects.requireNonNull(o);
+            if (o.bitSize() == 64) {
+                Byte64Vector so = (Byte64Vector)o;
+                return VectorIntrinsics.reinterpret(
+                    Byte64Vector.class, byte.class, so.length(),
+                    Byte.class, LENGTH, so,
+                    (v, t) -> (Byte512Vector)reshape(v)
+                );
+            } else if (o.bitSize() == 128) {
+                Byte128Vector so = (Byte128Vector)o;
+                return VectorIntrinsics.reinterpret(
+                    Byte128Vector.class, byte.class, so.length(),
+                    Byte.class, LENGTH, so,
+                    (v, t) -> (Byte512Vector)reshape(v)
+                );
+            } else if (o.bitSize() == 256) {
+                Byte256Vector so = (Byte256Vector)o;
+                return VectorIntrinsics.reinterpret(
+                    Byte256Vector.class, byte.class, so.length(),
+                    Byte.class, LENGTH, so,
+                    (v, t) -> (Byte512Vector)reshape(v)
+                );
+            } else if (o.bitSize() == 512) {
+                Byte512Vector so = (Byte512Vector)o;
+                return VectorIntrinsics.reinterpret(
+                    Byte512Vector.class, byte.class, so.length(),
+                    Byte.class, LENGTH, so,
+                    (v, t) -> (Byte512Vector)reshape(v)
+                );
+            } else {
+                throw new InternalError("Unimplemented size");
+            }
+        }
     }
 }
< prev index next >