[vector] Vector API -- alignment with value types
Brian Goetz
brian.goetz at oracle.com
Wed Jan 30 21:54:08 UTC 2019
I've tried to attach the patches-in-progress for these. There are two,
the speciesFactories.patch I set recently, and then zero.patch. These
only include changes to Vector and the templates; you'll have to re-run
the gen-* scripts to get changes to the rest. They apply to the last
version for which the tests pass.
Perhaps someone could look at the generated code from typical operations
and see how badly this approach perturbs it?
On 1/30/2019 3:58 PM, Brian Goetz wrote:
>
>
>> Part I
>> ------
>>
>> Here's an idea for simplifying Species, which is: let's drive Species
>> down to be a simple class that is really just a constant holder for
>> (element type, shape), and move all the behavior to static methods on
>> XxxVector.
>
> I've started prototyping this, in a rather slash-and-burn manner. I am
> about halfway through. So far, its working, the set of changes I had
> to make to client code is very small (almost all transforming
> species.doSomething(args) to XxxVector.doSomething(species, args)).
>
> The question, of course, is whether the intrinsification will all
> survive the transformation. The most common case is that I have
> transformed vector intrinsic calls from
>
> VectorIntrinsic.blah(Int128Vector.class, ...)
>
> to
>
> VectorIntrinsics.blah(species.boxType(), ...)
>
> The basic assumption is that, under the same conditions that we get
> inlining now, we'll know the species is a constant, and boxType() will
> just inline to a concrete box type anyway. (The goal is to get
> species to be values, but in the meantime, they can be enum
> constants.) This should work, but we'll likely have to do some JIT
> work to get back to where we see all the inlining and
> intrinsification. (Much of this would come free in Valhalla.)
>
> There are a few cases where we can't just do the above, and have to do
> a switch in the lifted method, such as:
>
> public static Shuffle<Byte> shuffle(ByteSpecies species,
> IntUnaryOperator f) {
> if (species.boxType() == ByteMaxVector.class)
> return new ByteMaxVector.ByteMaxShuffle(f);
> switch (species.bitSize()) {
> case 64:return new Byte64Vector.Byte64Shuffle(f);
> case 128:return new Byte128Vector.Byte128Shuffle(f);
> case 256:return new Byte256Vector.Byte256Shuffle(f);
> case 512:return new Byte512Vector.Byte512Shuffle(f);
> default:throw new
> IllegalArgumentException(Integer.toString(species.bitSize()));
> }
> }
>
>
> Because again, species is a constant, this should also just inline
> down to the right thing. So far, other than reshape/rebracket, I
> haven't seen anything requiring more complicated transformations.
>
> The only code I found so far that tries to be agnostic to shape and
> size both is VectorResizeTest; there are strategies for making this
> work without the combinatorial automated specialization, so I don't
> see this as a big impediment.
>
> Where this leads to is:
> - Vector.Species becomes an interface with a handful of methods
> (bitSize, etc), and quite possibly one that no one uses directly;
> - IntSpecies and friends become enums, with enum constants for I64,
> I128, etc (or, values, with static constants for the values);
> - The specialized classes for XxxNnVector.XxxNnSpecies _go away_;
> - Users need not learn about species at all, but if they do care,
> they are just simple data constants that get fed through the API.
>
> I'm not done (and am traveling the next two weeks), but I think I've
> made progress validating the API transformation. The real question,
> then, is when do we do this. I think it would be best to do before
> previewing, simply because it is such an intrusive refactoring. But,
> we'd have to evaluate whether we can mitigate the impact in time.
>
>
-------------- next part --------------
# HG changeset patch
# Parent d3b456d84b4ed3b6f4a15a09f9e26433b0d91bd5
diff -r d3b456d84b4e -r 8ab9aad380d0 src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Vector.java
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Vector.java Wed Jan 09 22:09:11 2019 +0100
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Vector.java Tue Jan 29 16:15:44 2019 -0500
@@ -74,9 +74,9 @@
* factory called a {@link Species}. A Species has an
* element type and shape and creates Vector values of the same element type
* and shape.
- * A species can be {@link #species(Class, Shape)} obtained} given an element
+ * A species can be {@link Species#of(Class, Shape)} obtained} given an element
* type and shape, or a preferred species can be
- * {@link #preferredSpecies obtained} given just an element type where the most
+ * {@link Species#ofPreferred(Class)} obtained} given just an element type where the most
* optimal shape is selected for the current platform. It is recommended that
* Species instances be held in {@code static final} fields for optimal creation
* and usage of Vector values by the runtime compiler.
@@ -908,6 +908,32 @@
int length(Species<?> s) {
return bitSize() / s.elementSize();
}
+
+ /**
+ * Finds appropriate shape depending on bitsize.
+ *
+ * @param bitSize the size in bits
+ * @return the shape corresponding to bitsize
+ * @see #bitSize
+ */
+ public static Shape forBitSize(int bitSize) {
+ switch (bitSize) {
+ case 64:
+ return Shape.S_64_BIT;
+ case 128:
+ return Shape.S_128_BIT;
+ case 256:
+ return Shape.S_256_BIT;
+ case 512:
+ return Shape.S_512_BIT;
+ default:
+ if ((bitSize > 0) && (bitSize <= 2048) && (bitSize % 128 == 0)) {
+ return Shape.S_Max_BIT;
+ } else {
+ throw new IllegalArgumentException("Bad vector bit size: " + bitSize);
+ }
+ }
+ }
}
@@ -962,6 +988,65 @@
// Factory
/**
+ * Finds a species for an element type and shape.
+ *
+ * @param c the element type
+ * @param s the shape
+ * @param <E> the boxed element type
+ * @return a species for an element type and shape
+ * @throws IllegalArgumentException if no such species exists for the
+ * element type and/or shape
+ */
+ @SuppressWarnings("unchecked")
+ public static <E> Vector.Species<E> of(Class<E> c, Shape s) {
+ if (c == float.class) {
+ return (Vector.Species<E>) FloatVector.species(s);
+ }
+ else if (c == double.class) {
+ return (Vector.Species<E>) DoubleVector.species(s);
+ }
+ else if (c == byte.class) {
+ return (Vector.Species<E>) ByteVector.species(s);
+ }
+ else if (c == short.class) {
+ return (Vector.Species<E>) ShortVector.species(s);
+ }
+ else if (c == int.class) {
+ return (Vector.Species<E>) IntVector.species(s);
+ }
+ else if (c == long.class) {
+ return (Vector.Species<E>) LongVector.species(s);
+ }
+ else {
+ throw new IllegalArgumentException("Bad vector element type: " + c.getName());
+ }
+ }
+
+ /**
+ * Finds a preferred species for an element type.
+ * <p>
+ * A preferred species is a species chosen by the platform that has a
+ * shape of maximal bit size. A preferred species for different element
+ * types will have the same shape, and therefore vectors created from
+ * such species will be shape compatible.
+ *
+ * @param c the element type
+ * @param <E> the boxed element type
+ * @return a preferred species for an element type
+ * @throws IllegalArgumentException if no such species exists for the
+ * element type
+ */
+ @SuppressWarnings("unchecked")
+ public static <E> Vector.Species<E> ofPreferred(Class<E> c) {
+ Unsafe u = Unsafe.getUnsafe();
+
+ int vectorLength = u.getMaxVectorSize(c);
+ int vectorBitSize = bitSizeForVectorLength(c, vectorLength);
+ Shape s = Shape.forBitSize(vectorBitSize);
+ return Species.of(c, s);
+ }
+
+ /**
* Returns a vector where all lane elements are set to the default
* primitive value.
*
@@ -1726,30 +1811,6 @@
}
/**
- * Finds a preferred species for an element type.
- * <p>
- * A preferred species is a species chosen by the platform that has a
- * shape of maximal bit size. A preferred species for different element
- * types will have the same shape, and therefore vectors created from
- * such species will be shape compatible.
- *
- * @param c the element type
- * @param <E> the boxed element type
- * @return a preferred species for an element type
- * @throws IllegalArgumentException if no such species exists for the
- * element type
- */
- @SuppressWarnings("unchecked")
- public static <E> Vector.Species<E> preferredSpecies(Class<E> c) {
- Unsafe u = Unsafe.getUnsafe();
-
- int vectorLength = u.getMaxVectorSize(c);
- int vectorBitSize = bitSizeForVectorLength(c, vectorLength);
- Shape s = shapeForVectorBitSize(vectorBitSize);
- return species(c, s);
- }
-
- /**
* Find bit size based on element type and number of elements.
*
* @param c the element type
@@ -1779,65 +1840,4 @@
throw new IllegalArgumentException("Bad vector type: " + c.getName());
}
}
-
- /**
- * Finds appropriate shape depending on bitsize.
- *
- * @param bitSize the size in bits
- * @return the shape corresponding to bitsize
- * @see #bitSize
- */
- public static Shape shapeForVectorBitSize(int bitSize) {
- switch (bitSize) {
- case 64:
- return Shape.S_64_BIT;
- case 128:
- return Shape.S_128_BIT;
- case 256:
- return Shape.S_256_BIT;
- case 512:
- return Shape.S_512_BIT;
- default:
- if ((bitSize > 0) && (bitSize <= 2048) && (bitSize % 128 == 0)) {
- return Shape.S_Max_BIT;
- } else {
- throw new IllegalArgumentException("Bad vector bit size: " + bitSize);
- }
- }
- }
-
- /**
- * Finds a species for an element type and shape.
- *
- * @param c the element type
- * @param s the shape
- * @param <E> the boxed element type
- * @return a species for an element type and shape
- * @throws IllegalArgumentException if no such species exists for the
- * element type and/or shape
- */
- @SuppressWarnings("unchecked")
- public static <E> Vector.Species<E> species(Class<E> c, Shape s) {
- if (c == float.class) {
- return (Vector.Species<E>) FloatVector.species(s);
- }
- else if (c == double.class) {
- return (Vector.Species<E>) DoubleVector.species(s);
- }
- else if (c == byte.class) {
- return (Vector.Species<E>) ByteVector.species(s);
- }
- else if (c == short.class) {
- return (Vector.Species<E>) ShortVector.species(s);
- }
- else if (c == int.class) {
- return (Vector.Species<E>) IntVector.species(s);
- }
- else if (c == long.class) {
- return (Vector.Species<E>) LongVector.species(s);
- }
- else {
- throw new IllegalArgumentException("Bad vector element type: " + c.getName());
- }
- }
}
diff -r d3b456d84b4e -r 8ab9aad380d0 src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template Wed Jan 09 22:09:11 2019 +0100
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template Tue Jan 29 16:15:44 2019 -0500
@@ -2240,7 +2240,7 @@
*/
@SuppressWarnings("unchecked")
public static $Type$Species preferredSpecies() {
- return ($Type$Species) Vector.preferredSpecies($type$.class);
+ return ($Type$Species) Species.ofPreferred($type$.class);
}
/**
diff -r d3b456d84b4e -r 8ab9aad380d0 src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template Wed Jan 09 22:09:11 2019 +0100
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template Tue Jan 29 16:15:44 2019 -0500
@@ -52,8 +52,8 @@
private static final IntVector.IntSpecies INDEX_SPEC;
static {
int bitSize = Vector.bitSizeForVectorLength(int.class, LENGTH);
- Vector.Shape shape = Vector.shapeForVectorBitSize(bitSize);
- INDEX_SPEC = (IntVector.IntSpecies) Vector.species(int.class, shape);
+ Vector.Shape shape = Shape.forBitSize(bitSize);
+ INDEX_SPEC = (IntVector.IntSpecies) Species.of(int.class, shape);
}
#end[!longOrDouble64]
diff -r d3b456d84b4e -r 8ab9aad380d0 test/jdk/jdk/incubator/vector/PreferredSpeciesTest.java
--- a/test/jdk/jdk/incubator/vector/PreferredSpeciesTest.java Wed Jan 09 22:09:11 2019 +0100
+++ b/test/jdk/jdk/incubator/vector/PreferredSpeciesTest.java Tue Jan 29 16:15:44 2019 -0500
@@ -51,7 +51,7 @@
@Test(dataProvider = "classesProvider")
void testVectorLength(Class<?> c) {
Vector.Species<?> species =
- Vector.preferredSpecies(c);
+ Vector.Species.ofPreferred(c);
Assert.assertEquals(species.length(), U.getMaxVectorSize(c));
}
-------------- next part --------------
# HG changeset patch
# Parent 8ab9aad380d06fcc6831aca7721ee6c5efe9b240
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Vector.java
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Vector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Vector.java
@@ -955,6 +955,20 @@
public abstract Class<E> elementType();
/**
+ * Returns the vector box type for this species
+ *
+ * @return the box type
+ */
+ abstract Class<?> boxType();
+
+ /**
+ * Returns the vector mask type for this species
+ *
+ * @return the box type
+ */
+ abstract Class<?> maskType();
+
+ /**
* Returns the element size, in bits, of vectors produced by this
* species.
*
@@ -1054,236 +1068,6 @@
*/
public abstract Vector<E> zero();
- /**
- * Loads a vector from a byte array starting at an offset.
- * <p>
- * Bytes are composed into primitive lane elements according to the
- * native byte order of the underlying platform
- * <p>
- * This method behaves as if it returns the result of calling the
- * byte buffer, offset, and mask accepting
- * {@link #fromByteBuffer(ByteBuffer, int, Mask) method} as follows:
- * <pre>{@code
- * return this.fromByteBuffer(ByteBuffer.wrap(a), i, this.maskAllTrue());
- * }</pre>
- *
- * @param a the byte array
- * @param i the offset into the array
- * @return a vector loaded from a byte array
- * @throws IndexOutOfBoundsException if {@code i < 0} or
- * {@code i > a.length - (this.length() * this.elementSize() / Byte.SIZE)}
- */
- public abstract Vector<E> fromByteArray(byte[] a, int i);
-
- /**
- * Loads a vector from a byte array starting at an offset and using a
- * mask.
- * <p>
- * Bytes are composed into primitive lane elements according to the
- * native byte order of the underlying platform.
- * <p>
- * This method behaves as if it returns the result of calling the
- * byte buffer, offset, and mask accepting
- * {@link #fromByteBuffer(ByteBuffer, int, Mask) method} as follows:
- * <pre>{@code
- * return this.fromByteBuffer(ByteBuffer.wrap(a), i, m);
- * }</pre>
- *
- * @param a the byte array
- * @param i the offset into the array
- * @param m the mask
- * @return a vector loaded from a byte array
- * @throws IndexOutOfBoundsException if {@code i < 0} or
- * {@code i > a.length - (this.length() * this.elementSize() / Byte.SIZE)}
- * @throws IndexOutOfBoundsException if the offset is {@code < 0},
- * or {@code > a.length},
- * for any vector lane index {@code N} where the mask at lane {@code N}
- * is set
- * {@code i >= a.length - (N * this.elementSize() / Byte.SIZE)}
- */
- public abstract Vector<E> fromByteArray(byte[] a, int i, Mask<E> m);
-
- /**
- * Loads a vector from a {@link ByteBuffer byte buffer} starting at an
- * offset into the byte buffer.
- * <p>
- * Bytes are composed into primitive lane elements according to the
- * native byte order of the underlying platform.
- * <p>
- * This method behaves as if it returns the result of calling the
- * byte buffer, offset, and mask accepting
- * {@link #fromByteBuffer(ByteBuffer, int, Mask)} method} as follows:
- * <pre>{@code
- * return this.fromByteBuffer(b, i, this.maskAllTrue())
- * }</pre>
- *
- * @param b the byte buffer
- * @param i the offset into the byte buffer
- * @return a vector loaded from a byte buffer
- * @throws IndexOutOfBoundsException if the offset is {@code < 0},
- * or {@code > b.limit()},
- * or if there are fewer than
- * {@code this.length() * this.elementSize() / Byte.SIZE} bytes
- * remaining in the byte buffer from the given offset
- */
- public abstract Vector<E> fromByteBuffer(ByteBuffer b, int i);
-
- /**
- * Loads a vector from a {@link ByteBuffer byte buffer} starting at an
- * offset into the byte buffer and using a mask.
- * <p>
- * This method behaves as if the byte buffer is viewed as a primitive
- * {@link java.nio.Buffer buffer} for the primitive element type,
- * according to the native byte order of the underlying platform, and
- * the returned vector is loaded with a mask from a primitive array
- * obtained from the primitive buffer.
- * The following pseudocode expresses the behaviour, where
- * {@coce EBuffer} is the primitive buffer type, {@code e} is the
- * primitive element type, and {@code ESpecies<S>} is the primitive
- * species for {@code e}:
- * <pre>{@code
- * EBuffer eb = b.duplicate().
- * order(ByteOrder.nativeOrder()).position(i).
- * asEBuffer();
- * e[] es = new e[this.length()];
- * for (int n = 0; n < t.length; n++) {
- * if (m.isSet(n))
- * es[n] = eb.get(n);
- * }
- * Vector<E> r = ((ESpecies<S>)this).fromArray(es, 0, m);
- * }</pre>
- *
- * @param b the byte buffer
- * @param i the offset into the byte buffer
- * @return a vector loaded from a byte buffer
- * @throws IndexOutOfBoundsException if the offset is {@code < 0},
- * or {@code > b.limit()},
- * for any vector lane index {@code N} where the mask at lane {@code N}
- * is set
- * {@code i >= b.limit() - (N * this.elementSize() / Byte.SIZE)}
- */
- public abstract Vector<E> fromByteBuffer(ByteBuffer b, int i, Mask<E> m);
-
- //Mask and shuffle constructions
-
- /**
- * Returns a mask where each lane is set or unset according to a given
- * {@code boolean} value.
- * <p>
- * For each mask lane, where {@code N} is the mask lane index,
- * if the given {@code boolean} value at index {@code N} is {@code true}
- * then the mask lane at index {@code N} is set, otherwise it is unset.
- *
- * @param bits the given {@code boolean} values
- * @return a mask where each lane is set or unset according to a given
- * {@code boolean} value
- * @throws IndexOutOfBoundsException if {@code bits.length < this.length()}
- */
- public abstract Mask<E> maskFromValues(boolean... bits);
-
- /**
- * Loads a mask from a {@code boolean} array starting at an offset.
- * <p>
- * For each mask lane, where {@code N} is the mask lane index,
- * if the array element at index {@code i + N} is {@code true} then the
- * mask lane at index {@code N} is set, otherwise it is unset.
- *
- * @param a the {@code boolean} array
- * @param i the offset into the array
- * @return the mask loaded from a {@code boolean} array
- * @throws IndexOutOfBoundsException if {@code i < 0}, or
- * {@code i > a.length - this.length()}
- */
- public abstract Mask<E> maskFromArray(boolean[] a, int i);
-
- /**
- * Returns a mask where all lanes are a set.
- *
- * @return a mask where all lanes are a set
- */
- public abstract Mask<E> maskAllTrue();
-
- /**
- * Returns a mask where all lanes are unset.
- *
- * @return a mask where all lanes are unset
- */
- public abstract Mask<E> maskAllFalse();
-
- /**
- * Returns a shuffle of mapped indexes where each lane element is
- * the result of applying a mapping function to the corresponding lane
- * index.
- * <p>
- * Care should be taken to ensure Shuffle values produced from this
- * method are consumed as constants to ensure optimal generation of
- * code. For example, values held in static final fields or values
- * held in loop constant local variables.
- * <p>
- * This method behaves as if a shuffle is created from an array of
- * mapped indexes as follows:
- * <pre>{@code
- * int[] a = new int[this.length()];
- * for (int i = 0; i < a.length; i++) {
- * a[i] = f.applyAsInt(i);
- * }
- * return this.shuffleFromValues(a);
- * }</pre>
- *
- * @param f the lane index mapping function
- * @return a shuffle of mapped indexes.
- */
- public abstract Shuffle<E> shuffle(IntUnaryOperator f);
-
- /**
- * Returns a shuffle where each lane element is the value of its
- * corresponding lane index.
- * <p>
- * This method behaves as if a shuffle is created from an identity
- * index mapping function as follows:
- * <pre>{@code
- * return this.shuffle(i -> i);
- * }</pre>
- *
- * @return a shuffle of lane indexes.
- */
- public abstract Shuffle<E> shuffleIota();
-
- /**
- * Returns a shuffle where each lane element is set to a given
- * {@code int} value logically AND'ed by the species length minus one.
- * <p>
- * For each shuffle lane, where {@code N} is the shuffle lane index, the
- * the {@code int} value at index {@code N} logically AND'ed by
- * {@code this.length() - 1} is placed into the resulting shuffle at
- * lane index {@code N}.
- *
- * @param indexes the given {@code int} values
- * @return a shuffle where each lane element is set to a given
- * {@code int} value
- * @throws IndexOutOfBoundsException if the number of int values is
- * {@code < this.length()}.
- */
- public abstract Shuffle<E> shuffleFromValues(int... indexes);
-
- /**
- * Loads a shuffle from an {@code int} array starting at offset.
- * <p>
- * For each shuffle lane, where {@code N} is the shuffle lane index, the
- * array element at index {@code i + N} logically AND'ed by
- * {@code this.length() - 1} is placed into the resulting shuffle at lane
- * index {@code N}.
- *
- * @param a the {@code int} array
- * @param i the offset into the array
- * @return a shuffle loaded from an {@code int} array
- * @throws IndexOutOfBoundsException if {@code i < 0}, or
- * {@code i > a.length - this.length()}
- */
- public abstract Shuffle<E> shuffleFromArray(int[] a, int i);
-
- // Shuffle iota, 0...N
-
// Vector type/shape transformations
/**
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template
@@ -24,13 +24,19 @@
*/
package jdk.incubator.vector;
-import jdk.internal.vm.annotation.ForceInline;
-
import java.nio.ByteBuffer;
+#if[!byte]
+import java.nio.$Type$Buffer;
+#end[!byte]
import java.nio.ByteOrder;
import java.util.Objects;
+import java.util.function.IntUnaryOperator;
import java.util.concurrent.ThreadLocalRandom;
+import jdk.internal.misc.Unsafe;
+import jdk.internal.vm.annotation.ForceInline;
+import static jdk.incubator.vector.VectorIntrinsics.*;
+
/**
* A specialized {@link Vector} representing an ordered immutable sequence of
@@ -41,6 +47,8 @@
$abstractvectortype$() {}
+ private static final int ARRAY_SHIFT = 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_$TYPE$_INDEX_SCALE);
+
// Unary operator
interface FUnOp {
@@ -93,7 +101,284 @@
abstract void forEach(Mask<$Boxtype$> m, FUnCon f);
- //
+ // Static factories
+
+ /**
+ * Returns a vector where all lane elements are set to the default
+ * primitive value.
+ *
+ * @return a zero vector
+ */
+ @ForceInline
+ @SuppressWarnings("unchecked")
+ public static $abstractvectortype$ zero($Type$Species species) {
+ return VectorIntrinsics.broadcastCoerced((Class<$abstractvectortype$>) species.boxType(), $type$.class, species.length(),
+ 0,
+ (z -> species.zero()));
+ }
+
+ /**
+ * Loads a vector from a byte array starting at an offset.
+ * <p>
+ * Bytes are composed into primitive lane elements according to the
+ * native byte order of the underlying platform
+ * <p>
+ * This method behaves as if it returns the result of calling the
+ * byte buffer, offset, and mask accepting
+ * {@link #fromByteBuffer($Type$Species, ByteBuffer, int, Mask) method} as follows:
+ * <pre>{@code
+ * return this.fromByteBuffer(ByteBuffer.wrap(a), i, this.maskAllTrue());
+ * }</pre>
+ *
+ * @param a the byte array
+ * @param ix the offset into the array
+ * @return a vector loaded from a byte array
+ * @throws IndexOutOfBoundsException if {@code i < 0} or
+ * {@code i > a.length - (this.length() * this.elementSize() / Byte.SIZE)}
+ */
+ @ForceInline
+ @SuppressWarnings("unchecked")
+ public static $abstractvectortype$ fromByteArray($Type$Species species, byte[] a, int ix) {
+ Objects.requireNonNull(a);
+ ix = VectorIntrinsics.checkIndex(ix, a.length, species.bitSize() / Byte.SIZE);
+ return VectorIntrinsics.load((Class<$abstractvectortype$>) species.boxType(), $type$.class, species.length(),
+ a, ((long) ix) + Unsafe.ARRAY_BYTE_BASE_OFFSET,
+ a, ix,
+ (c, idx) -> {
+ ByteBuffer bbc = ByteBuffer.wrap(c, idx, a.length - idx).order(ByteOrder.nativeOrder());
+ $Type$Buffer tb = bbc{#if[byte]?;:.as$Type$Buffer();}
+ return species.op(i -> tb.get());
+ });
+ }
+
+ /**
+ * Loads a vector from a byte array starting at an offset and using a
+ * mask.
+ * <p>
+ * Bytes are composed into primitive lane elements according to the
+ * native byte order of the underlying platform.
+ * <p>
+ * This method behaves as if it returns the result of calling the
+ * byte buffer, offset, and mask accepting
+ * {@link #fromByteBuffer($Type$Species, ByteBuffer, int, Mask) method} as follows:
+ * <pre>{@code
+ * return this.fromByteBuffer(ByteBuffer.wrap(a), i, m);
+ * }</pre>
+ *
+ * @param a the byte array
+ * @param ix the offset into the array
+ * @param m the mask
+ * @return a vector loaded from a byte array
+ * @throws IndexOutOfBoundsException if {@code i < 0} or
+ * {@code i > a.length - (this.length() * this.elementSize() / Byte.SIZE)}
+ * @throws IndexOutOfBoundsException if the offset is {@code < 0},
+ * or {@code > a.length},
+ * for any vector lane index {@code N} where the mask at lane {@code N}
+ * is set
+ * {@code i >= a.length - (N * this.elementSize() / Byte.SIZE)}
+ */
+ @ForceInline
+ public static $abstractvectortype$ fromByteArray($Type$Species species, byte[] a, int ix, Mask<$Boxtype$> m) {
+ return zero(species).blend(fromByteArray(species, a, ix), m);
+ }
+
+ /**
+ * Loads a vector from a {@link ByteBuffer byte buffer} starting at an
+ * offset into the byte buffer.
+ * <p>
+ * Bytes are composed into primitive lane elements according to the
+ * native byte order of the underlying platform.
+ * <p>
+ * This method behaves as if it returns the result of calling the
+ * byte buffer, offset, and mask accepting
+ * {@link #fromByteBuffer($Type$Species, ByteBuffer, int, Mask)} method} as follows:
+ * <pre>{@code
+ * return this.fromByteBuffer(b, i, this.maskAllTrue())
+ * }</pre>
+ *
+ * @param bb the byte buffer
+ * @param ix the offset into the byte buffer
+ * @return a vector loaded from a byte buffer
+ * @throws IndexOutOfBoundsException if the offset is {@code < 0},
+ * or {@code > b.limit()},
+ * or if there are fewer than
+ * {@code this.length() * this.elementSize() / Byte.SIZE} bytes
+ * remaining in the byte buffer from the given offset
+ */
+ @ForceInline
+ @SuppressWarnings("unchecked")
+ public static $abstractvectortype$ fromByteBuffer($Type$Species species, ByteBuffer bb, int ix) {
+ if (bb.order() != ByteOrder.nativeOrder()) {
+ throw new IllegalArgumentException();
+ }
+ ix = VectorIntrinsics.checkIndex(ix, bb.limit(), species.bitSize() / Byte.SIZE);
+ return VectorIntrinsics.load((Class<$abstractvectortype$>) species.boxType(), $type$.class, species.length(),
+ U.getReference(bb, BYTE_BUFFER_HB), U.getLong(bb, BUFFER_ADDRESS) + ix,
+ bb, ix,
+ (c, idx) -> {
+ ByteBuffer bbc = c.duplicate().position(idx).order(ByteOrder.nativeOrder());
+ $Type$Buffer tb = bbc{#if[byte]?;:.as$Type$Buffer();}
+ return species.op(i -> tb.get());
+ });
+ }
+
+ /**
+ * Loads a vector from a {@link ByteBuffer byte buffer} starting at an
+ * offset into the byte buffer and using a mask.
+ * <p>
+ * This method behaves as if the byte buffer is viewed as a primitive
+ * {@link java.nio.Buffer buffer} for the primitive element type,
+ * according to the native byte order of the underlying platform, and
+ * the returned vector is loaded with a mask from a primitive array
+ * obtained from the primitive buffer.
+ * The following pseudocode expresses the behaviour, where
+ * {@coce EBuffer} is the primitive buffer type, {@code e} is the
+ * primitive element type, and {@code ESpecies<S>} is the primitive
+ * species for {@code e}:
+ * <pre>{@code
+ * EBuffer eb = b.duplicate().
+ * order(ByteOrder.nativeOrder()).position(i).
+ * asEBuffer();
+ * e[] es = new e[this.length()];
+ * for (int n = 0; n < t.length; n++) {
+ * if (m.isSet(n))
+ * es[n] = eb.get(n);
+ * }
+ * Vector<E> r = ((ESpecies<S>)this).fromArray(es, 0, m);
+ * }</pre>
+ *
+ * @param bb the byte buffer
+ * @param ix the offset into the byte buffer
+ * @return a vector loaded from a byte buffer
+ * @throws IndexOutOfBoundsException if the offset is {@code < 0},
+ * or {@code > b.limit()},
+ * for any vector lane index {@code N} where the mask at lane {@code N}
+ * is set
+ * {@code i >= b.limit() - (N * this.elementSize() / Byte.SIZE)}
+ */
+ @ForceInline
+ public static $abstractvectortype$ fromByteBuffer($Type$Species species, ByteBuffer bb, int ix, Mask<$Boxtype$> m) {
+ return zero(species).blend(fromByteBuffer(species, bb, ix), m);
+ }
+
+ public static Mask<$Boxtype$> maskFromValues($Type$Species species, boolean... bits) {
+ if (species.boxType() == $Type$MaxVector.class)
+ return new $Type$MaxVector.$Type$MaxMask(bits);
+ switch (species.bitSize()) {
+ case 64: return new $Type$64Vector.$Type$64Mask(bits);
+ case 128: return new $Type$128Vector.$Type$128Mask(bits);
+ case 256: return new $Type$256Vector.$Type$256Mask(bits);
+ case 512: return new $Type$512Vector.$Type$512Mask(bits);
+ default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
+ }
+ }
+
+ // @@@ This is a bad implementation -- makes lambdas capturing -- fix this
+ static Mask<$Boxtype$> trueMask($Type$Species species) {
+ if (species.boxType() == $Type$MaxVector.class)
+ return $Type$MaxVector.$Type$MaxMask.TRUE_MASK;
+ switch (species.bitSize()) {
+ case 64: return $Type$64Vector.$Type$64Mask.TRUE_MASK;
+ case 128: return $Type$128Vector.$Type$128Mask.TRUE_MASK;
+ case 256: return $Type$256Vector.$Type$256Mask.TRUE_MASK;
+ case 512: return $Type$512Vector.$Type$512Mask.TRUE_MASK;
+ default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
+ }
+ }
+
+ static Mask<$Boxtype$> falseMask($Type$Species species) {
+ if (species.boxType() == $Type$MaxVector.class)
+ return $Type$MaxVector.$Type$MaxMask.FALSE_MASK;
+ switch (species.bitSize()) {
+ case 64: return $Type$64Vector.$Type$64Mask.FALSE_MASK;
+ case 128: return $Type$128Vector.$Type$128Mask.FALSE_MASK;
+ case 256: return $Type$256Vector.$Type$256Mask.FALSE_MASK;
+ case 512: return $Type$512Vector.$Type$512Mask.FALSE_MASK;
+ default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
+ }
+ }
+
+ @ForceInline
+ @SuppressWarnings("unchecked")
+ public static Mask<$Boxtype$> maskFromArray($Type$Species species, boolean[] bits, int ix) {
+ Objects.requireNonNull(bits);
+ ix = VectorIntrinsics.checkIndex(ix, bits.length, species.length());
+ return VectorIntrinsics.load((Class<Mask<$Boxtype$>>) species.maskType(), $bitstype$.class, species.length(),
+ bits, (((long) ix) << ARRAY_SHIFT) + Unsafe.ARRAY_BOOLEAN_BASE_OFFSET,
+ bits, ix,
+ (c, idx) -> (Mask<$Boxtype$>) species.opm(n -> c[idx + n]));
+ }
+
+ @ForceInline
+ @SuppressWarnings("unchecked")
+ public static Mask<$Boxtype$> maskAllTrue($Type$Species species) {
+ return VectorIntrinsics.broadcastCoerced((Class<Mask<$Boxtype$>>) species.maskType(), $bitstype$.class, species.length(),
+ ($bitstype$)-1,
+ (z -> trueMask(species)));
+ }
+
+ @ForceInline
+ @SuppressWarnings("unchecked")
+ public static Mask<$Boxtype$> maskAllFalse($Type$Species species) {
+ return VectorIntrinsics.broadcastCoerced((Class<Mask<$Boxtype$>>) species.maskType(), $bitstype$.class, species.length(),
+ 0,
+ (z -> falseMask(species)));
+ }
+
+ @ForceInline
+ public static Shuffle<$Boxtype$> shuffle($Type$Species species, IntUnaryOperator f) {
+ if (species.boxType() == $Type$MaxVector.class)
+ return new $Type$MaxVector.$Type$MaxShuffle(f);
+ switch (species.bitSize()) {
+ case 64: return new $Type$64Vector.$Type$64Shuffle(f);
+ case 128: return new $Type$128Vector.$Type$128Shuffle(f);
+ case 256: return new $Type$256Vector.$Type$256Shuffle(f);
+ case 512: return new $Type$512Vector.$Type$512Shuffle(f);
+ default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
+ }
+ }
+
+ @ForceInline
+ public static Shuffle<$Boxtype$> shuffleIota($Type$Species species) {
+ if (species.boxType() == $Type$MaxVector.class)
+ return new $Type$MaxVector.$Type$MaxShuffle(AbstractShuffle.IDENTITY);
+ switch (species.bitSize()) {
+ case 64: return new $Type$64Vector.$Type$64Shuffle(AbstractShuffle.IDENTITY);
+ case 128: return new $Type$128Vector.$Type$128Shuffle(AbstractShuffle.IDENTITY);
+ case 256: return new $Type$256Vector.$Type$256Shuffle(AbstractShuffle.IDENTITY);
+ case 512: return new $Type$512Vector.$Type$512Shuffle(AbstractShuffle.IDENTITY);
+ default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
+ }
+ }
+
+ @ForceInline
+ public static Shuffle<$Boxtype$> shuffleFromValues($Type$Species species, int... ixs) {
+ if (species.boxType() == $Type$MaxVector.class)
+ return new $Type$MaxVector.$Type$MaxShuffle(ixs);
+ switch (species.bitSize()) {
+ case 64: return new $Type$64Vector.$Type$64Shuffle(ixs);
+ case 128: return new $Type$128Vector.$Type$128Shuffle(ixs);
+ case 256: return new $Type$256Vector.$Type$256Shuffle(ixs);
+ case 512: return new $Type$512Vector.$Type$512Shuffle(ixs);
+ default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
+ }
+ }
+
+ @ForceInline
+ public static Shuffle<$Boxtype$> shuffleFromArray($Type$Species species, int[] ixs, int i) {
+ if (species.boxType() == $Type$MaxVector.class)
+ return new $Type$MaxVector.$Type$MaxShuffle(ixs, i);
+ switch (species.bitSize()) {
+ case 64: return new $Type$64Vector.$Type$64Shuffle(ixs, i);
+ case 128: return new $Type$128Vector.$Type$128Shuffle(ixs, i);
+ case 256: return new $Type$256Vector.$Type$256Shuffle(ixs, i);
+ case 512: return new $Type$512Vector.$Type$512Shuffle(ixs, i);
+ default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
+ }
+ }
+
+
+ // Ops
@Override
public abstract $abstractvectortype$ add(Vector<$Boxtype$> v);
@@ -2014,7 +2299,7 @@
public abstract $Type$Species species();
/**
- * A specialized factory for creating {@link $Type$Vector} value of the same
+ * A specialized factory for creating {@link $abstractvectortype$} value of the same
* shape, and a {@link Mask} and {@link Shuffle} values of the same shape
* and {@code int} element type.
*/
@@ -2198,23 +2483,11 @@
#end[byteOrShort]
@Override
- public abstract $abstractvectortype$ fromByteArray(byte[] a, int ix);
-
- @Override
- public abstract $abstractvectortype$ fromByteArray(byte[] a, int ix, Mask<$Boxtype$> m);
-
- @Override
- public abstract $abstractvectortype$ fromByteBuffer(ByteBuffer bb, int ix);
-
- @Override
- public abstract $abstractvectortype$ fromByteBuffer(ByteBuffer bb, int ix, Mask<$Boxtype$> m);
-
- @Override
public <F> $abstractvectortype$ reshape(Vector<F> o) {
int blen = Math.max(o.species().bitSize(), bitSize()) / Byte.SIZE;
ByteBuffer bb = ByteBuffer.allocate(blen).order(ByteOrder.nativeOrder());
o.intoByteBuffer(bb, 0);
- return fromByteBuffer(bb, 0);
+ return $abstractvectortype$.fromByteBuffer(this, bb, 0);
}
@Override
@@ -2253,18 +2526,13 @@
@SuppressWarnings("unchecked")
public static $Type$Species species(Vector.Shape s) {
Objects.requireNonNull(s);
- if (s == Shape.S_64_BIT) {
- return $Type$64Vector.SPECIES;
- } else if (s == Shape.S_128_BIT) {
- return $Type$128Vector.SPECIES;
- } else if (s == Shape.S_256_BIT) {
- return $Type$256Vector.SPECIES;
- } else if (s == Shape.S_512_BIT) {
- return $Type$512Vector.SPECIES;
- } else if (s == Shape.S_Max_BIT) {
- return $Type$MaxVector.SPECIES;
- } else {
- throw new IllegalArgumentException("Bad shape: " + s);
+ switch (s) {
+ case S_64_BIT: return $Type$64Vector.SPECIES;
+ case S_128_BIT: return $Type$128Vector.SPECIES;
+ case S_256_BIT: return $Type$256Vector.SPECIES;
+ case S_512_BIT: return $Type$512Vector.SPECIES;
+ case S_Max_BIT: return $Type$MaxVector.SPECIES;
+ default: throw new IllegalArgumentException("Bad shape: " + s);
}
}
}
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template
@@ -1051,7 +1051,7 @@
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
- return SPECIES.shuffleFromArray(sa, 0);
+ return $abstractvectortype$.shuffleFromArray(SPECIES, sa, 0);
}
// Memory operations
@@ -1129,7 +1129,7 @@
@Override
@ForceInline
public final void intoByteArray(byte[] a, int ix, Mask<$Boxtype$> m) {
- $vectortype$ oldVal = SPECIES.fromByteArray(a, ix);
+ $vectortype$ oldVal = ($vectortype$) $abstractvectortype$.fromByteArray(SPECIES, a, ix);
$vectortype$ newVal = oldVal.blend(this, m);
newVal.intoByteArray(a, ix);
}
@@ -1158,7 +1158,7 @@
@Override
@ForceInline
public void intoByteBuffer(ByteBuffer bb, int ix, Mask<$Boxtype$> m) {
- $vectortype$ oldVal = SPECIES.fromByteBuffer(bb, ix);
+ $vectortype$ oldVal = ($vectortype$) $abstractvectortype$.fromByteBuffer(SPECIES, bb, ix);
$vectortype$ newVal = oldVal.blend(this, m);
newVal.intoByteBuffer(bb, ix);
}
@@ -1571,7 +1571,7 @@
@ForceInline
public boolean allTrue() {
return VectorIntrinsics.test(COND_carrySet, $masktype$.class, $bitstype$.class, LENGTH,
- this, species().maskAllTrue(),
+ this, $abstractvectortype$.maskAllTrue(species()),
(m1, m2) -> super.allTrue());
}
}
@@ -1662,6 +1662,18 @@
@Override
@ForceInline
+ public Class<?> boxType() {
+ return $vectortype$.class;
+ }
+
+ @Override
+ @ForceInline
+ public Class<?> maskType() {
+ return $masktype$.class;
+ }
+
+ @Override
+ @ForceInline
public int elementSize() {
return $Boxtype$.SIZE;
}
@@ -1704,31 +1716,6 @@
// Factories
- @Override
- public $masktype$ maskFromValues(boolean... bits) {
- return new $masktype$(bits);
- }
-
- @Override
- public $shuffletype$ shuffle(IntUnaryOperator f) {
- return new $shuffletype$(f);
- }
-
- @Override
- public $shuffletype$ shuffleIota() {
- return new $shuffletype$(AbstractShuffle.IDENTITY);
- }
-
- @Override
- public $shuffletype$ shuffleFromValues(int... ixs) {
- return new $shuffletype$(ixs);
- }
-
- @Override
- public $shuffletype$ shuffleFromArray(int[] ixs, int i) {
- return new $shuffletype$(ixs, i);
- }
-
#if[FP]
@Override
@ForceInline
@@ -1768,22 +1755,6 @@
@Override
@ForceInline
- public $masktype$ maskAllTrue() {
- return VectorIntrinsics.broadcastCoerced($masktype$.class, $bitstype$.class, LENGTH,
- ($bitstype$)-1,
- (z -> $masktype$.TRUE_MASK));
- }
-
- @Override
- @ForceInline
- public $masktype$ maskAllFalse() {
- return VectorIntrinsics.broadcastCoerced($masktype$.class, $bitstype$.class, LENGTH,
- 0,
- (z -> $masktype$.FALSE_MASK));
- }
-
- @Override
- @ForceInline
public $vectortype$ scalars($type$... es) {
Objects.requireNonNull(es);
int ix = VectorIntrinsics.checkIndex(0, es.length, LENGTH);
@@ -1795,17 +1766,6 @@
@Override
@ForceInline
- public $masktype$ maskFromArray(boolean[] bits, int ix) {
- Objects.requireNonNull(bits);
- ix = VectorIntrinsics.checkIndex(ix, bits.length, LENGTH);
- return VectorIntrinsics.load($masktype$.class, $bitstype$.class, LENGTH,
- bits, (((long) ix) << ARRAY_SHIFT) + Unsafe.ARRAY_BOOLEAN_BASE_OFFSET,
- bits, ix,
- (c, idx) -> opm(n -> c[idx + n]));
- }
-
- @Override
- @ForceInline
public $vectortype$ fromArray($type$[] a, int ix) {
Objects.requireNonNull(a);
ix = VectorIntrinsics.checkIndex(ix, a.length, LENGTH);
@@ -1821,20 +1781,6 @@
return zero().blend(fromArray(a, ax), m);
}
- @Override
- @ForceInline
- public $vectortype$ fromByteArray(byte[] a, int ix) {
- Objects.requireNonNull(a);
- ix = VectorIntrinsics.checkIndex(ix, a.length, bitSize() / Byte.SIZE);
- return VectorIntrinsics.load($vectortype$.class, $type$.class, LENGTH,
- a, ((long) ix) + Unsafe.ARRAY_BYTE_BASE_OFFSET,
- a, ix,
- (c, idx) -> {
- ByteBuffer bbc = ByteBuffer.wrap(c, idx, a.length - idx).order(ByteOrder.nativeOrder());
- $Type$Buffer tb = bbc{#if[byte]?;:.as$Type$Buffer();}
- return op(i -> tb.get());
- });
- }
#if[!byteOrShort]
@Override
@ForceInline
@@ -1868,35 +1814,6 @@
@Override
@ForceInline
- public $vectortype$ fromByteArray(byte[] a, int ix, Mask<$Boxtype$> m) {
- return zero().blend(fromByteArray(a, ix), m);
- }
-
- @Override
- @ForceInline
- public $vectortype$ fromByteBuffer(ByteBuffer bb, int ix) {
- if (bb.order() != ByteOrder.nativeOrder()) {
- throw new IllegalArgumentException();
- }
- ix = VectorIntrinsics.checkIndex(ix, bb.limit(), bitSize() / Byte.SIZE);
- return VectorIntrinsics.load($vectortype$.class, $type$.class, LENGTH,
- U.getReference(bb, BYTE_BUFFER_HB), U.getLong(bb, BUFFER_ADDRESS) + ix,
- bb, ix,
- (c, idx) -> {
- ByteBuffer bbc = c.duplicate().position(idx).order(ByteOrder.nativeOrder());
- $Type$Buffer tb = bbc{#if[byte]?;:.as$Type$Buffer();}
- return op(i -> tb.get());
- });
- }
-
- @Override
- @ForceInline
- public $vectortype$ fromByteBuffer(ByteBuffer bb, int ix, Mask<$Boxtype$> m) {
- return zero().blend(fromByteBuffer(bb, ix), m);
- }
-
- @Override
- @ForceInline
@SuppressWarnings("unchecked")
public <F> $vectortype$ cast(Vector<F> o) {
if (o.length() != LENGTH)
diff --git a/test/jdk/jdk/incubator/vector/templates/Kernel-Binary-Masked-op.template b/test/jdk/jdk/incubator/vector/templates/Kernel-Binary-Masked-op.template
--- a/test/jdk/jdk/incubator/vector/templates/Kernel-Binary-Masked-op.template
+++ b/test/jdk/jdk/incubator/vector/templates/Kernel-Binary-Masked-op.template
@@ -2,7 +2,7 @@
$type$[] b = fb.apply(SPECIES.length());
$type$[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
- Vector.Mask<$Wideboxtype$> vmask = SPECIES.maskFromValues(mask);
+ Vector.Mask<$Wideboxtype$> vmask = $abstractvectortype$.maskFromValues(SPECIES, mask);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
diff --git a/test/jdk/jdk/incubator/vector/templates/Kernel-Blend-op.template b/test/jdk/jdk/incubator/vector/templates/Kernel-Blend-op.template
--- a/test/jdk/jdk/incubator/vector/templates/Kernel-Blend-op.template
+++ b/test/jdk/jdk/incubator/vector/templates/Kernel-Blend-op.template
@@ -2,7 +2,7 @@
$type$[] b = fb.apply(SPECIES.length());
$type$[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
- Vector.Mask<$Wideboxtype$> vmask = SPECIES.maskFromValues(mask);
+ Vector.Mask<$Wideboxtype$> vmask = $abstractvectortype$.maskFromValues(SPECIES, mask);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
diff --git a/test/jdk/jdk/incubator/vector/templates/Kernel-BoolReduction-op.template b/test/jdk/jdk/incubator/vector/templates/Kernel-BoolReduction-op.template
--- a/test/jdk/jdk/incubator/vector/templates/Kernel-BoolReduction-op.template
+++ b/test/jdk/jdk/incubator/vector/templates/Kernel-BoolReduction-op.template
@@ -3,7 +3,7 @@
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < mask.length; i += SPECIES.length()) {
- Vector.Mask<$Wideboxtype$> vmask = SPECIES.maskFromArray(mask, i);
+ Vector.Mask<$Wideboxtype$> vmask = $abstractvectortype$.maskFromArray(SPECIES, mask, i);
r[i] = vmask.[[TEST]]();
}
}
diff --git a/test/jdk/jdk/incubator/vector/templates/Kernel-Rearrange.template b/test/jdk/jdk/incubator/vector/templates/Kernel-Rearrange.template
--- a/test/jdk/jdk/incubator/vector/templates/Kernel-Rearrange.template
+++ b/test/jdk/jdk/incubator/vector/templates/Kernel-Rearrange.template
@@ -5,7 +5,7 @@
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
$abstractvectortype$ av = SPECIES.fromArray(a, i);
- av.rearrange(SPECIES.shuffleFromArray(order, i)).intoArray(r, i);
+ av.rearrange($abstractvectortype$.shuffleFromArray(SPECIES, order, i)).intoArray(r, i);
}
}
diff --git a/test/jdk/jdk/incubator/vector/templates/Kernel-Shift-Masked-op.template b/test/jdk/jdk/incubator/vector/templates/Kernel-Shift-Masked-op.template
--- a/test/jdk/jdk/incubator/vector/templates/Kernel-Shift-Masked-op.template
+++ b/test/jdk/jdk/incubator/vector/templates/Kernel-Shift-Masked-op.template
@@ -2,7 +2,7 @@
$type$[] b = fb.apply(SPECIES.length());
$type$[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
- Vector.Mask<$Wideboxtype$> vmask = SPECIES.maskFromValues(mask);
+ Vector.Mask<$Wideboxtype$> vmask = $abstractvectortype$.maskFromValues(SPECIES, mask);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
diff --git a/test/jdk/jdk/incubator/vector/templates/Kernel-Ternary-Masked-op.template b/test/jdk/jdk/incubator/vector/templates/Kernel-Ternary-Masked-op.template
--- a/test/jdk/jdk/incubator/vector/templates/Kernel-Ternary-Masked-op.template
+++ b/test/jdk/jdk/incubator/vector/templates/Kernel-Ternary-Masked-op.template
@@ -3,7 +3,7 @@
$type$[] c = fc.apply(SPECIES.length());
$type$[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
- Vector.Mask<$Wideboxtype$> vmask = SPECIES.maskFromValues(mask);
+ Vector.Mask<$Wideboxtype$> vmask = $abstractvectortype$.maskFromValues(SPECIES, mask);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
diff --git a/test/jdk/jdk/incubator/vector/templates/Kernel-Unary-Masked-op.template b/test/jdk/jdk/incubator/vector/templates/Kernel-Unary-Masked-op.template
--- a/test/jdk/jdk/incubator/vector/templates/Kernel-Unary-Masked-op.template
+++ b/test/jdk/jdk/incubator/vector/templates/Kernel-Unary-Masked-op.template
@@ -1,7 +1,7 @@
$type$[] a = fa.apply(SPECIES.length());
$type$[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
- Vector.Mask<$Wideboxtype$> vmask = SPECIES.maskFromValues(mask);
+ Vector.Mask<$Wideboxtype$> vmask = $abstractvectortype$.maskFromValues(SPECIES, mask);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
diff --git a/test/jdk/jdk/incubator/vector/templates/Perf-Compare.template b/test/jdk/jdk/incubator/vector/templates/Perf-Compare.template
old mode 100644
new mode 100755
--- a/test/jdk/jdk/incubator/vector/templates/Perf-Compare.template
+++ b/test/jdk/jdk/incubator/vector/templates/Perf-Compare.template
@@ -4,7 +4,7 @@
$type$[] a = fa.apply(size);
$type$[] b = fb.apply(size);
boolean[] ms = fm.apply(size);
- Vector.Mask<$Wideboxtype$> m = SPECIES.maskFromArray(ms, 0);
+ Vector.Mask<$Wideboxtype$> m = $abstractvectortype$.maskFromArray(SPECIES, ms, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
diff --git a/test/jdk/jdk/incubator/vector/templates/X-LoadStoreTest.java.template b/test/jdk/jdk/incubator/vector/templates/X-LoadStoreTest.java.template
--- a/test/jdk/jdk/incubator/vector/templates/X-LoadStoreTest.java.template
+++ b/test/jdk/jdk/incubator/vector/templates/X-LoadStoreTest.java.template
@@ -222,7 +222,7 @@
$type$[] a = fa.apply(SPECIES.length());
$type$[] r = new $type$[a.length];
boolean[] mask = fm.apply(SPECIES.length());
- Vector.Mask<$Boxtype$> vmask = SPECIES.maskFromValues(mask);
+ Vector.Mask<$Boxtype$> vmask = $abstractvectortype$.maskFromValues(SPECIES, mask);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
@@ -255,7 +255,7 @@
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < l; i += s) {
- $abstractvectortype$ av = SPECIES.fromByteBuffer(a, i);
+ $abstractvectortype$ av = $abstractvectortype$.fromByteBuffer(SPECIES, a, i);
av.intoByteBuffer(r, i);
}
}
@@ -278,7 +278,7 @@
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < l; i += s) {
- $abstractvectortype$ av = SPECIES.fromByteBuffer(a, i);
+ $abstractvectortype$ av = $abstractvectortype$.fromByteBuffer(SPECIES, a, i);
av.intoByteBuffer(r, i);
}
}
@@ -296,14 +296,14 @@
ByteBuffer a = toBuffer(fa.apply(SPECIES.length()), fb);
ByteBuffer r = fb.apply(a.limit());
boolean[] mask = fm.apply(SPECIES.length());
- Vector.Mask<$Boxtype$> vmask = SPECIES.maskFromValues(mask);
+ Vector.Mask<$Boxtype$> vmask = $abstractvectortype$.maskFromValues(SPECIES, mask);
int l = a.limit();
int s = SPECIES.length() * SPECIES.elementSize() / 8;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < l; i += s) {
- $abstractvectortype$ av = SPECIES.fromByteBuffer(a, i, vmask);
+ $abstractvectortype$ av = $abstractvectortype$.fromByteBuffer(SPECIES, a, i, vmask);
av.intoByteBuffer(r, i);
}
}
@@ -317,7 +317,7 @@
r = fb.apply(a.limit());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < l; i += s) {
- $abstractvectortype$ av = SPECIES.fromByteBuffer(a, i);
+ $abstractvectortype$ av = $abstractvectortype$.fromByteBuffer(SPECIES, a, i);
av.intoByteBuffer(r, i, vmask);
}
}
@@ -336,14 +336,14 @@
a = a.asReadOnlyBuffer().order(a.order());
ByteBuffer r = fb.apply(a.limit());
boolean[] mask = fm.apply(SPECIES.length());
- Vector.Mask<$Boxtype$> vmask = SPECIES.maskFromValues(mask);
+ Vector.Mask<$Boxtype$> vmask = $abstractvectortype$.maskFromValues(SPECIES, mask);
int l = a.limit();
int s = SPECIES.length() * SPECIES.elementSize() / 8;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < l; i += s) {
- $abstractvectortype$ av = SPECIES.fromByteBuffer(a, i, vmask);
+ $abstractvectortype$ av = $abstractvectortype$.fromByteBuffer(SPECIES, a, i, vmask);
av.intoByteBuffer(r, i);
}
}
More information about the panama-dev
mailing list