--- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java 2019-04-11 15:40:24.717668700 -0700
+++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java 2019-04-11 15:40:24.099859600 -0700
@@ -464,230 +464,6 @@
return ((DoubleSpecies)s).op(i -> r.nextDouble());
}
- /**
- * Returns a mask where each lane is set or unset according to given
- * {@code boolean} values
- *
- * 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 species mask species
- * @param bits the given {@code boolean} values
- * @return a mask where each lane is set or unset according to the given {@code boolean} value
- * @throws IndexOutOfBoundsException if {@code bits.length < species.length()}
- */
- @ForceInline
- public static Mask maskFromValues(Species species, boolean... bits) {
- if (species.boxType() == DoubleMaxVector.class)
- return new DoubleMaxVector.DoubleMaxMask(bits);
- switch (species.bitSize()) {
- case 64: return new Double64Vector.Double64Mask(bits);
- case 128: return new Double128Vector.Double128Mask(bits);
- case 256: return new Double256Vector.Double256Mask(bits);
- case 512: return new Double512Vector.Double512Mask(bits);
- default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
- }
- }
-
- // @@@ This is a bad implementation -- makes lambdas capturing -- fix this
- static Mask trueMask(Species species) {
- if (species.boxType() == DoubleMaxVector.class)
- return DoubleMaxVector.DoubleMaxMask.TRUE_MASK;
- switch (species.bitSize()) {
- case 64: return Double64Vector.Double64Mask.TRUE_MASK;
- case 128: return Double128Vector.Double128Mask.TRUE_MASK;
- case 256: return Double256Vector.Double256Mask.TRUE_MASK;
- case 512: return Double512Vector.Double512Mask.TRUE_MASK;
- default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
- }
- }
-
- static Mask falseMask(Species species) {
- if (species.boxType() == DoubleMaxVector.class)
- return DoubleMaxVector.DoubleMaxMask.FALSE_MASK;
- switch (species.bitSize()) {
- case 64: return Double64Vector.Double64Mask.FALSE_MASK;
- case 128: return Double128Vector.Double128Mask.FALSE_MASK;
- case 256: return Double256Vector.Double256Mask.FALSE_MASK;
- case 512: return Double512Vector.Double512Mask.FALSE_MASK;
- default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
- }
- }
-
- /**
- * Loads a mask from a {@code boolean} array starting at an offset.
- *
- * For each mask lane, where {@code N} is the mask lane index,
- * if the array element at index {@code ix + N} is {@code true} then the
- * mask lane at index {@code N} is set, otherwise it is unset.
- *
- * @param species mask species
- * @param bits the {@code boolean} array
- * @param ix the offset into the array
- * @return the mask loaded from a {@code boolean} array
- * @throws IndexOutOfBoundsException if {@code ix < 0}, or
- * {@code ix > bits.length - species.length()}
- */
- @ForceInline
- @SuppressWarnings("unchecked")
- public static Mask maskFromArray(Species species, boolean[] bits, int ix) {
- Objects.requireNonNull(bits);
- ix = VectorIntrinsics.checkIndex(ix, bits.length, species.length());
- return VectorIntrinsics.load((Class>) species.maskType(), long.class, species.length(),
- bits, (((long) ix) << ARRAY_SHIFT) + Unsafe.ARRAY_BOOLEAN_BASE_OFFSET,
- bits, ix, species,
- (c, idx, s) -> (Mask) ((DoubleSpecies)s).opm(n -> c[idx + n]));
- }
-
- /**
- * Returns a mask where all lanes are set.
- *
- * @param species mask species
- * @return a mask where all lanes are set
- */
- @ForceInline
- @SuppressWarnings("unchecked")
- public static Mask maskAllTrue(Species species) {
- return VectorIntrinsics.broadcastCoerced((Class>) species.maskType(), long.class, species.length(),
- (long)-1, species,
- ((z, s) -> trueMask(s)));
- }
-
- /**
- * Returns a mask where all lanes are unset.
- *
- * @param species mask species
- * @return a mask where all lanes are unset
- */
- @ForceInline
- @SuppressWarnings("unchecked")
- public static Mask maskAllFalse(Species species) {
- return VectorIntrinsics.broadcastCoerced((Class>) species.maskType(), long.class, species.length(),
- 0, species,
- ((z, s) -> falseMask(s)));
- }
-
- /**
- * Returns a shuffle of mapped indexes where each lane element is
- * the result of applying a mapping function to the corresponding lane
- * index.
- *
- * 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.
- *
- * This method behaves as if a shuffle is created from an array of
- * mapped indexes as follows:
- *
{@code
- * int[] a = new int[species.length()];
- * for (int i = 0; i < a.length; i++) {
- * a[i] = f.applyAsInt(i);
- * }
- * return this.shuffleFromValues(a);
- * }
- *
- * @param species shuffle species
- * @param f the lane index mapping function
- * @return a shuffle of mapped indexes
- */
- @ForceInline
- public static Shuffle shuffle(Species species, IntUnaryOperator f) {
- if (species.boxType() == DoubleMaxVector.class)
- return new DoubleMaxVector.DoubleMaxShuffle(f);
- switch (species.bitSize()) {
- case 64: return new Double64Vector.Double64Shuffle(f);
- case 128: return new Double128Vector.Double128Shuffle(f);
- case 256: return new Double256Vector.Double256Shuffle(f);
- case 512: return new Double512Vector.Double512Shuffle(f);
- default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
- }
- }
-
- /**
- * Returns a shuffle where each lane element is the value of its
- * corresponding lane index.
- *
- * This method behaves as if a shuffle is created from an identity
- * index mapping function as follows:
- *
{@code
- * return this.shuffle(i -> i);
- * }
- *
- * @param species shuffle species
- * @return a shuffle of lane indexes
- */
- @ForceInline
- public static Shuffle shuffleIota(Species species) {
- if (species.boxType() == DoubleMaxVector.class)
- return new DoubleMaxVector.DoubleMaxShuffle(AbstractShuffle.IDENTITY);
- switch (species.bitSize()) {
- case 64: return new Double64Vector.Double64Shuffle(AbstractShuffle.IDENTITY);
- case 128: return new Double128Vector.Double128Shuffle(AbstractShuffle.IDENTITY);
- case 256: return new Double256Vector.Double256Shuffle(AbstractShuffle.IDENTITY);
- case 512: return new Double512Vector.Double512Shuffle(AbstractShuffle.IDENTITY);
- default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
- }
- }
-
- /**
- * Returns a shuffle where each lane element is set to a given
- * {@code int} value logically AND'ed by the species length minus one.
- *
- * 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 species.length() - 1} is placed into the resulting shuffle at
- * lane index {@code N}.
- *
- * @param species shuffle species
- * @param ixs 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 < species.length()}
- */
- @ForceInline
- public static Shuffle shuffleFromValues(Species species, int... ixs) {
- if (species.boxType() == DoubleMaxVector.class)
- return new DoubleMaxVector.DoubleMaxShuffle(ixs);
- switch (species.bitSize()) {
- case 64: return new Double64Vector.Double64Shuffle(ixs);
- case 128: return new Double128Vector.Double128Shuffle(ixs);
- case 256: return new Double256Vector.Double256Shuffle(ixs);
- case 512: return new Double512Vector.Double512Shuffle(ixs);
- default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
- }
- }
-
- /**
- * Loads a shuffle from an {@code int} array starting at an offset.
- *
- * 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 species.length() - 1} is placed into the resulting shuffle at lane
- * index {@code N}.
- *
- * @param species shuffle species
- * @param ixs the {@code int} array
- * @param i the offset into the array
- * @return a shuffle loaded from the {@code int} array
- * @throws IndexOutOfBoundsException if {@code i < 0}, or
- * {@code i > a.length - species.length()}
- */
- @ForceInline
- public static Shuffle shuffleFromArray(Species species, int[] ixs, int i) {
- if (species.boxType() == DoubleMaxVector.class)
- return new DoubleMaxVector.DoubleMaxShuffle(ixs, i);
- switch (species.bitSize()) {
- case 64: return new Double64Vector.Double64Shuffle(ixs, i);
- case 128: return new Double128Vector.Double128Shuffle(ixs, i);
- case 256: return new Double256Vector.Double256Shuffle(ixs, i);
- case 512: return new Double512Vector.Double512Shuffle(ixs, i);
- default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
- }
- }
-
// Ops
@Override
@@ -2102,20 +1878,21 @@
public abstract Species species();
/**
- * Class representing {@link DoubleVector}'s of the same {@link Vector.Shape Shape}.
+ * Class representing {@link DoubleVector}'s of the same {@link Shape Shape}.
*/
- static final class DoubleSpecies extends Vector.AbstractSpecies {
+ static final class DoubleSpecies extends AbstractSpecies {
final Function vectorFactory;
- final Function> maskFactory;
- private DoubleSpecies(Vector.Shape shape,
+ private DoubleSpecies(Shape shape,
Class> boxType,
Class> maskType,
Function vectorFactory,
- Function> maskFactory) {
- super(shape, double.class, Double.SIZE, boxType, maskType);
+ Function> maskFactory,
+ Function> shuffleFromArrayFactory,
+ fShuffleFromArray shuffleFromOpFactory) {
+ super(shape, double.class, Double.SIZE, boxType, maskType, maskFactory,
+ shuffleFromArrayFactory, shuffleFromOpFactory);
this.vectorFactory = vectorFactory;
- this.maskFactory = maskFactory;
}
interface FOp {
@@ -2134,7 +1911,7 @@
return vectorFactory.apply(res);
}
- DoubleVector op(Vector.Mask o, FOp f) {
+ DoubleVector op(Mask o, FOp f) {
double[] res = new double[length()];
boolean[] mbits = ((AbstractMask)o).getBits();
for (int i = 0; i < length(); i++) {
@@ -2144,14 +1921,6 @@
}
return vectorFactory.apply(res);
}
-
- Vector.Mask opm(IntVector.IntSpecies.FOpm f) {
- boolean[] res = new boolean[length()];
- for (int i = 0; i < length(); i++) {
- res[i] = (boolean)f.apply(i);
- }
- return maskFactory.apply(res);
- }
}
/**
@@ -2175,7 +1944,7 @@
* @return a species for an element type of {@code double} and shape
* @throws IllegalArgumentException if no such species exists for the shape
*/
- static DoubleSpecies species(Vector.Shape s) {
+ static DoubleSpecies species(Shape s) {
Objects.requireNonNull(s);
switch (s) {
case S_64_BIT: return (DoubleSpecies) SPECIES_64;
@@ -2187,25 +1956,30 @@
}
}
- /** Species representing {@link DoubleVector}s of {@link Vector.Shape#S_64_BIT Shape.S_64_BIT}. */
+ /** Species representing {@link DoubleVector}s of {@link Shape#S_64_BIT Shape.S_64_BIT}. */
public static final Species SPECIES_64 = new DoubleSpecies(Shape.S_64_BIT, Double64Vector.class, Double64Vector.Double64Mask.class,
- Double64Vector::new, Double64Vector.Double64Mask::new);
+ Double64Vector::new, Double64Vector.Double64Mask::new,
+ Double64Vector.Double64Shuffle::new, Double64Vector.Double64Shuffle::new);
- /** Species representing {@link DoubleVector}s of {@link Vector.Shape#S_128_BIT Shape.S_128_BIT}. */
+ /** Species representing {@link DoubleVector}s of {@link Shape#S_128_BIT Shape.S_128_BIT}. */
public static final Species SPECIES_128 = new DoubleSpecies(Shape.S_128_BIT, Double128Vector.class, Double128Vector.Double128Mask.class,
- Double128Vector::new, Double128Vector.Double128Mask::new);
+ Double128Vector::new, Double128Vector.Double128Mask::new,
+ Double128Vector.Double128Shuffle::new, Double128Vector.Double128Shuffle::new);
- /** Species representing {@link DoubleVector}s of {@link Vector.Shape#S_256_BIT Shape.S_256_BIT}. */
+ /** Species representing {@link DoubleVector}s of {@link Shape#S_256_BIT Shape.S_256_BIT}. */
public static final Species SPECIES_256 = new DoubleSpecies(Shape.S_256_BIT, Double256Vector.class, Double256Vector.Double256Mask.class,
- Double256Vector::new, Double256Vector.Double256Mask::new);
+ Double256Vector::new, Double256Vector.Double256Mask::new,
+ Double256Vector.Double256Shuffle::new, Double256Vector.Double256Shuffle::new);
- /** Species representing {@link DoubleVector}s of {@link Vector.Shape#S_512_BIT Shape.S_512_BIT}. */
+ /** Species representing {@link DoubleVector}s of {@link Shape#S_512_BIT Shape.S_512_BIT}. */
public static final Species SPECIES_512 = new DoubleSpecies(Shape.S_512_BIT, Double512Vector.class, Double512Vector.Double512Mask.class,
- Double512Vector::new, Double512Vector.Double512Mask::new);
+ Double512Vector::new, Double512Vector.Double512Mask::new,
+ Double512Vector.Double512Shuffle::new, Double512Vector.Double512Shuffle::new);
- /** Species representing {@link DoubleVector}s of {@link Vector.Shape#S_Max_BIT Shape.S_Max_BIT}. */
+ /** Species representing {@link DoubleVector}s of {@link Shape#S_Max_BIT Shape.S_Max_BIT}. */
public static final Species SPECIES_MAX = new DoubleSpecies(Shape.S_Max_BIT, DoubleMaxVector.class, DoubleMaxVector.DoubleMaxMask.class,
- DoubleMaxVector::new, DoubleMaxVector.DoubleMaxMask::new);
+ DoubleMaxVector::new, DoubleMaxVector.DoubleMaxMask::new,
+ DoubleMaxVector.DoubleMaxShuffle::new, DoubleMaxVector.DoubleMaxShuffle::new);
/**
* Preferred species for {@link DoubleVector}s.