< prev index next >
src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int128Vector.java
Print this page
rev 49509 : [vector] Intrinsic support for resize
@@ -742,13 +742,13 @@
public <F> Vector<F, Shapes.S128Bit> rebracket(Species<F, Shapes.S128Bit> 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(
Int128Vector.class, int.class, LENGTH,
- species.elementType(), this,
+ species.elementType(), species.length(), this,
(v, t) -> species.reshape(v)
);
}
// Accessors
@@ -833,13 +833,13 @@
@ForceInline
@SuppressWarnings("unchecked")
public <Z> Mask<Z, Shapes.S128Bit> rebracket(Species<Z, Shapes.S128Bit> species) {
Objects.requireNonNull(species);
// TODO: check proper element type
- return VectorIntrinsics.rebracket(
+ return VectorIntrinsics.reinterpret(
Int128Mask.class, int.class, LENGTH,
- species.elementType(), this,
+ species.elementType(), species.length(), this,
(m, t) -> m.reshape(species)
);
}
// Unary operations
@@ -932,30 +932,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<Integer> elementType() {
return Integer.class;
}
@Override
+ @ForceInline
public int elementSize() {
return Integer.SIZE;
}
@Override
+ @ForceInline
public Shapes.S128Bit shape() {
return Shapes.S_128_BIT;
}
@Override
@@ -1047,7 +1052,45 @@
@Override
@ForceInline
public Int128Vector fromArray(int[] a, int ax, Mask<Integer, Shapes.S128Bit> 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> Int128Vector resize(Vector<Integer, T> o) {
+ Objects.requireNonNull(o);
+ if (o.bitSize() == 64) {
+ Int64Vector so = (Int64Vector)o;
+ return VectorIntrinsics.reinterpret(
+ Int64Vector.class, int.class, so.length(),
+ Integer.class, LENGTH, so,
+ (v, t) -> (Int128Vector)reshape(v)
+ );
+ } else if (o.bitSize() == 128) {
+ Int128Vector so = (Int128Vector)o;
+ return VectorIntrinsics.reinterpret(
+ Int128Vector.class, int.class, so.length(),
+ Integer.class, LENGTH, so,
+ (v, t) -> (Int128Vector)reshape(v)
+ );
+ } else if (o.bitSize() == 256) {
+ Int256Vector so = (Int256Vector)o;
+ return VectorIntrinsics.reinterpret(
+ Int256Vector.class, int.class, so.length(),
+ Integer.class, LENGTH, so,
+ (v, t) -> (Int128Vector)reshape(v)
+ );
+ } else if (o.bitSize() == 512) {
+ Int512Vector so = (Int512Vector)o;
+ return VectorIntrinsics.reinterpret(
+ Int512Vector.class, int.class, so.length(),
+ Integer.class, LENGTH, so,
+ (v, t) -> (Int128Vector)reshape(v)
+ );
+ } else {
+ throw new InternalError("Unimplemented size");
+ }
+ }
}
}
< prev index next >