< prev index next >
src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java
Print this page
rev 55891 : 8222897: [vector] Renaming of shift, rotate operations. Few other api changes.
Summary: Renaming of shift, rotate operations. Few other api changes.
Reviewed-by: jrose, briangoetz
rev 55894 : 8222897: [vector] Renaming of shift, rotate operations. Few other api changes.
Summary: Renaming of shift, rotate operations. Few other api changes.
Reviewed-by: jrose, briangoetz
*** 110,120 ****
* @return a zero vector of given species
*/
@ForceInline
@SuppressWarnings("unchecked")
public static DoubleVector zero(VectorSpecies<Double> species) {
! return VectorIntrinsics.broadcastCoerced((Class<DoubleVector>) species.boxType(), double.class, species.length(),
Double.doubleToLongBits(0.0f), species,
((bits, s) -> ((DoubleSpecies)s).op(i -> Double.longBitsToDouble((long)bits))));
}
/**
--- 110,120 ----
* @return a zero vector of given species
*/
@ForceInline
@SuppressWarnings("unchecked")
public static DoubleVector zero(VectorSpecies<Double> species) {
! return VectorIntrinsics.broadcastCoerced((Class<DoubleVector>) species.vectorType(), double.class, species.length(),
Double.doubleToLongBits(0.0f), species,
((bits, s) -> ((DoubleSpecies)s).op(i -> Double.longBitsToDouble((long)bits))));
}
/**
*** 140,150 ****
@ForceInline
@SuppressWarnings("unchecked")
public static DoubleVector fromByteArray(VectorSpecies<Double> species, byte[] a, int offset) {
Objects.requireNonNull(a);
offset = VectorIntrinsics.checkIndex(offset, a.length, species.bitSize() / Byte.SIZE);
! return VectorIntrinsics.load((Class<DoubleVector>) species.boxType(), double.class, species.length(),
a, ((long) offset) + Unsafe.ARRAY_BYTE_BASE_OFFSET,
a, offset, species,
(c, idx, s) -> {
ByteBuffer bbc = ByteBuffer.wrap(c, idx, a.length - idx).order(ByteOrder.nativeOrder());
DoubleBuffer tb = bbc.asDoubleBuffer();
--- 140,150 ----
@ForceInline
@SuppressWarnings("unchecked")
public static DoubleVector fromByteArray(VectorSpecies<Double> species, byte[] a, int offset) {
Objects.requireNonNull(a);
offset = VectorIntrinsics.checkIndex(offset, a.length, species.bitSize() / Byte.SIZE);
! return VectorIntrinsics.load((Class<DoubleVector>) species.vectorType(), double.class, species.length(),
a, ((long) offset) + Unsafe.ARRAY_BYTE_BASE_OFFSET,
a, offset, species,
(c, idx, s) -> {
ByteBuffer bbc = ByteBuffer.wrap(c, idx, a.length - idx).order(ByteOrder.nativeOrder());
DoubleBuffer tb = bbc.asDoubleBuffer();
*** 198,208 ****
@ForceInline
@SuppressWarnings("unchecked")
public static DoubleVector fromArray(VectorSpecies<Double> species, double[] a, int offset){
Objects.requireNonNull(a);
offset = VectorIntrinsics.checkIndex(offset, a.length, species.length());
! return VectorIntrinsics.load((Class<DoubleVector>) species.boxType(), double.class, species.length(),
a, (((long) offset) << ARRAY_SHIFT) + Unsafe.ARRAY_DOUBLE_BASE_OFFSET,
a, offset, species,
(c, idx, s) -> ((DoubleSpecies)s).op(n -> c[idx + n]));
}
--- 198,208 ----
@ForceInline
@SuppressWarnings("unchecked")
public static DoubleVector fromArray(VectorSpecies<Double> species, double[] a, int offset){
Objects.requireNonNull(a);
offset = VectorIntrinsics.checkIndex(offset, a.length, species.length());
! return VectorIntrinsics.load((Class<DoubleVector>) species.vectorType(), double.class, species.length(),
a, (((long) offset) << ARRAY_SHIFT) + Unsafe.ARRAY_DOUBLE_BASE_OFFSET,
a, offset, species,
(c, idx, s) -> ((DoubleSpecies)s).op(n -> c[idx + n]));
}
*** 264,275 ****
// Index vector: vix[0:n] = k -> a_offset + indexMap[i_offset + k]
IntVector vix = IntVector.fromArray(IntVector.species(species.indexShape()), indexMap, i_offset).add(a_offset);
vix = VectorIntrinsics.checkIndex(vix, a.length);
! return VectorIntrinsics.loadWithMap((Class<DoubleVector>) species.boxType(), double.class, species.length(),
! IntVector.species(species.indexShape()).boxType(), a, Unsafe.ARRAY_DOUBLE_BASE_OFFSET, vix,
a, a_offset, indexMap, i_offset, species,
(double[] c, int idx, int[] iMap, int idy, VectorSpecies<Double> s) ->
((DoubleSpecies)s).op(n -> c[idx + iMap[idy+n]]));
}
--- 264,275 ----
// Index vector: vix[0:n] = k -> a_offset + indexMap[i_offset + k]
IntVector vix = IntVector.fromArray(IntVector.species(species.indexShape()), indexMap, i_offset).add(a_offset);
vix = VectorIntrinsics.checkIndex(vix, a.length);
! return VectorIntrinsics.loadWithMap((Class<DoubleVector>) species.vectorType(), double.class, species.length(),
! IntVector.species(species.indexShape()).vectorType(), a, Unsafe.ARRAY_DOUBLE_BASE_OFFSET, vix,
a, a_offset, indexMap, i_offset, species,
(double[] c, int idx, int[] iMap, int idy, VectorSpecies<Double> s) ->
((DoubleSpecies)s).op(n -> c[idx + iMap[idy+n]]));
}
*** 334,344 ****
public static DoubleVector fromByteBuffer(VectorSpecies<Double> species, ByteBuffer bb, int offset) {
if (bb.order() != ByteOrder.nativeOrder()) {
throw new IllegalArgumentException();
}
offset = VectorIntrinsics.checkIndex(offset, bb.limit(), species.bitSize() / Byte.SIZE);
! return VectorIntrinsics.load((Class<DoubleVector>) species.boxType(), double.class, species.length(),
U.getReference(bb, BYTE_BUFFER_HB), U.getLong(bb, BUFFER_ADDRESS) + offset,
bb, offset, species,
(c, idx, s) -> {
ByteBuffer bbc = c.duplicate().position(idx).order(ByteOrder.nativeOrder());
DoubleBuffer tb = bbc.asDoubleBuffer();
--- 334,344 ----
public static DoubleVector fromByteBuffer(VectorSpecies<Double> species, ByteBuffer bb, int offset) {
if (bb.order() != ByteOrder.nativeOrder()) {
throw new IllegalArgumentException();
}
offset = VectorIntrinsics.checkIndex(offset, bb.limit(), species.bitSize() / Byte.SIZE);
! return VectorIntrinsics.load((Class<DoubleVector>) species.vectorType(), double.class, species.length(),
U.getReference(bb, BYTE_BUFFER_HB), U.getLong(bb, BUFFER_ADDRESS) + offset,
bb, offset, species,
(c, idx, s) -> {
ByteBuffer bbc = c.duplicate().position(idx).order(ByteOrder.nativeOrder());
DoubleBuffer tb = bbc.asDoubleBuffer();
*** 390,408 ****
/**
* Returns a vector where all lane elements are set to the primitive
* value {@code e}.
*
* @param species species of the desired vector
! * @param e the value
* @return a vector of vector where all lane elements are set to
* the primitive value {@code e}
*/
@ForceInline
@SuppressWarnings("unchecked")
public static DoubleVector broadcast(VectorSpecies<Double> species, double e) {
return VectorIntrinsics.broadcastCoerced(
! (Class<DoubleVector>) species.boxType(), double.class, species.length(),
Double.doubleToLongBits(e), species,
((bits, sp) -> ((DoubleSpecies)sp).op(i -> Double.longBitsToDouble((long)bits))));
}
/**
--- 390,408 ----
/**
* Returns a vector where all lane elements are set to the primitive
* value {@code e}.
*
* @param species species of the desired vector
! * @param e the value to be broadcasted
* @return a vector of vector where all lane elements are set to
* the primitive value {@code e}
*/
@ForceInline
@SuppressWarnings("unchecked")
public static DoubleVector broadcast(VectorSpecies<Double> species, double e) {
return VectorIntrinsics.broadcastCoerced(
! (Class<DoubleVector>) species.vectorType(), double.class, species.length(),
Double.doubleToLongBits(e), species,
((bits, sp) -> ((DoubleSpecies)sp).op(i -> Double.longBitsToDouble((long)bits))));
}
/**
*** 422,432 ****
@ForceInline
@SuppressWarnings("unchecked")
public static DoubleVector scalars(VectorSpecies<Double> species, double... es) {
Objects.requireNonNull(es);
int ix = VectorIntrinsics.checkIndex(0, es.length, species.length());
! return VectorIntrinsics.load((Class<DoubleVector>) species.boxType(), double.class, species.length(),
es, Unsafe.ARRAY_DOUBLE_BASE_OFFSET,
es, ix, species,
(c, idx, sp) -> ((DoubleSpecies)sp).op(n -> c[idx + n]));
}
--- 422,432 ----
@ForceInline
@SuppressWarnings("unchecked")
public static DoubleVector scalars(VectorSpecies<Double> species, double... es) {
Objects.requireNonNull(es);
int ix = VectorIntrinsics.checkIndex(0, es.length, species.length());
! return VectorIntrinsics.load((Class<DoubleVector>) species.vectorType(), double.class, species.length(),
es, Unsafe.ARRAY_DOUBLE_BASE_OFFSET,
es, ix, species,
(c, idx, sp) -> ((DoubleSpecies)sp).op(n -> c[idx + n]));
}
*** 800,828 ****
/**
* {@inheritDoc}
*/
@Override
! public abstract DoubleVector rotateEL(int i);
/**
* {@inheritDoc}
*/
@Override
! public abstract DoubleVector rotateER(int i);
/**
* {@inheritDoc}
*/
@Override
! public abstract DoubleVector shiftEL(int i);
/**
* {@inheritDoc}
*/
@Override
! public abstract DoubleVector shiftER(int i);
/**
* Divides this vector by an input vector.
* <p>
* This is a lane-wise binary operation which applies the primitive division
--- 800,828 ----
/**
* {@inheritDoc}
*/
@Override
! public abstract DoubleVector rotateLanesLeft(int i);
/**
* {@inheritDoc}
*/
@Override
! public abstract DoubleVector rotateLanesRight(int i);
/**
* {@inheritDoc}
*/
@Override
! public abstract DoubleVector shiftLanesLeft(int i);
/**
* {@inheritDoc}
*/
@Override
! public abstract DoubleVector shiftLanesRight(int i);
/**
* Divides this vector by an input vector.
* <p>
* This is a lane-wise binary operation which applies the primitive division
*** 1720,1730 ****
* the default implementation of adding vectors sequentially from left to right is used.
* For this reason, the output of this method may vary for the same input values.
*
* @return the addition of all the lane elements of this vector
*/
! public abstract double addAll();
/**
* Adds all lane elements of this vector, selecting lane elements
* controlled by a mask.
* <p>
--- 1720,1730 ----
* the default implementation of adding vectors sequentially from left to right is used.
* For this reason, the output of this method may vary for the same input values.
*
* @return the addition of all the lane elements of this vector
*/
! public abstract double addLanes();
/**
* Adds all lane elements of this vector, selecting lane elements
* controlled by a mask.
* <p>
*** 1742,1752 ****
* For this reason, the output of this method may vary on the same input values.
*
* @param m the mask controlling lane selection
* @return the addition of the selected lane elements of this vector
*/
! public abstract double addAll(VectorMask<Double> m);
/**
* Multiplies all lane elements of this vector.
* <p>
* This is a cross-lane reduction operation which applies the
--- 1742,1752 ----
* For this reason, the output of this method may vary on the same input values.
*
* @param m the mask controlling lane selection
* @return the addition of the selected lane elements of this vector
*/
! public abstract double addLanes(VectorMask<Double> m);
/**
* Multiplies all lane elements of this vector.
* <p>
* This is a cross-lane reduction operation which applies the
*** 1761,1771 ****
* the default implementation of multiplying vectors sequentially from left to right is used.
* For this reason, the output of this method may vary on the same input values.
*
* @return the multiplication of all the lane elements of this vector
*/
! public abstract double mulAll();
/**
* Multiplies all lane elements of this vector, selecting lane elements
* controlled by a mask.
* <p>
--- 1761,1771 ----
* the default implementation of multiplying vectors sequentially from left to right is used.
* For this reason, the output of this method may vary on the same input values.
*
* @return the multiplication of all the lane elements of this vector
*/
! public abstract double mulLanes();
/**
* Multiplies all lane elements of this vector, selecting lane elements
* controlled by a mask.
* <p>
*** 1782,1792 ****
* For this reason, the output of this method may vary on the same input values.
*
* @param m the mask controlling lane selection
* @return the multiplication of all the lane elements of this vector
*/
! public abstract double mulAll(VectorMask<Double> m);
/**
* Returns the minimum lane element of this vector.
* <p>
* This is an associative cross-lane reduction operation which applies the operation
--- 1782,1792 ----
* For this reason, the output of this method may vary on the same input values.
*
* @param m the mask controlling lane selection
* @return the multiplication of all the lane elements of this vector
*/
! public abstract double mulLanes(VectorMask<Double> m);
/**
* Returns the minimum lane element of this vector.
* <p>
* This is an associative cross-lane reduction operation which applies the operation
*** 1794,1804 ****
* and the identity value is
* {@link Double#POSITIVE_INFINITY}.
*
* @return the minimum lane element of this vector
*/
! public abstract double minAll();
/**
* Returns the minimum lane element of this vector, selecting lane elements
* controlled by a mask.
* <p>
--- 1794,1804 ----
* and the identity value is
* {@link Double#POSITIVE_INFINITY}.
*
* @return the minimum lane element of this vector
*/
! public abstract double minLanes();
/**
* Returns the minimum lane element of this vector, selecting lane elements
* controlled by a mask.
* <p>
*** 1808,1818 ****
* {@link Double#POSITIVE_INFINITY}.
*
* @param m the mask controlling lane selection
* @return the minimum lane element of this vector
*/
! public abstract double minAll(VectorMask<Double> m);
/**
* Returns the maximum lane element of this vector.
* <p>
* This is an associative cross-lane reduction operation which applies the operation
--- 1808,1818 ----
* {@link Double#POSITIVE_INFINITY}.
*
* @param m the mask controlling lane selection
* @return the minimum lane element of this vector
*/
! public abstract double minLanes(VectorMask<Double> m);
/**
* Returns the maximum lane element of this vector.
* <p>
* This is an associative cross-lane reduction operation which applies the operation
*** 1820,1830 ****
* and the identity value is
* {@link Double#NEGATIVE_INFINITY}.
*
* @return the maximum lane element of this vector
*/
! public abstract double maxAll();
/**
* Returns the maximum lane element of this vector, selecting lane elements
* controlled by a mask.
* <p>
--- 1820,1830 ----
* and the identity value is
* {@link Double#NEGATIVE_INFINITY}.
*
* @return the maximum lane element of this vector
*/
! public abstract double maxLanes();
/**
* Returns the maximum lane element of this vector, selecting lane elements
* controlled by a mask.
* <p>
*** 1834,1844 ****
* {@link Double#NEGATIVE_INFINITY}.
*
* @param m the mask controlling lane selection
* @return the maximum lane element of this vector
*/
! public abstract double maxAll(VectorMask<Double> m);
// Type specific accessors
/**
--- 1834,1844 ----
* {@link Double#NEGATIVE_INFINITY}.
*
* @param m the mask controlling lane selection
* @return the maximum lane element of this vector
*/
! public abstract double maxLanes(VectorMask<Double> m);
// Type specific accessors
/**
*** 1978,1994 ****
*/
static final class DoubleSpecies extends AbstractSpecies<Double> {
final Function<double[], DoubleVector> vectorFactory;
private DoubleSpecies(VectorShape shape,
! Class<?> boxType,
Class<?> maskType,
Function<double[], DoubleVector> vectorFactory,
Function<boolean[], VectorMask<Double>> maskFactory,
Function<IntUnaryOperator, VectorShuffle<Double>> shuffleFromArrayFactory,
fShuffleFromArray<Double> shuffleFromOpFactory) {
! super(shape, double.class, Double.SIZE, boxType, maskType, maskFactory,
shuffleFromArrayFactory, shuffleFromOpFactory);
this.vectorFactory = vectorFactory;
}
interface FOp {
--- 1978,1994 ----
*/
static final class DoubleSpecies extends AbstractSpecies<Double> {
final Function<double[], DoubleVector> vectorFactory;
private DoubleSpecies(VectorShape shape,
! Class<?> vectorType,
Class<?> maskType,
Function<double[], DoubleVector> vectorFactory,
Function<boolean[], VectorMask<Double>> maskFactory,
Function<IntUnaryOperator, VectorShuffle<Double>> shuffleFromArrayFactory,
fShuffleFromArray<Double> shuffleFromOpFactory) {
! super(shape, double.class, Double.SIZE, vectorType, maskType, maskFactory,
shuffleFromArrayFactory, shuffleFromOpFactory);
this.vectorFactory = vectorFactory;
}
interface FOp {
< prev index next >