mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8310459: [BACKOUT] 8304450: [vectorapi] Refactor VectorShuffle implementation
Reviewed-by: thartmann, sviswanathan
This commit is contained in:
parent
815ac6eeb3
commit
ff9a754109
64 changed files with 2086 additions and 2736 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -26,16 +26,53 @@ package jdk.incubator.vector;
|
|||
|
||||
import java.util.function.IntUnaryOperator;
|
||||
import jdk.internal.vm.annotation.ForceInline;
|
||||
import jdk.internal.vm.vector.VectorSupport;
|
||||
|
||||
abstract class AbstractShuffle<E> extends VectorShuffle<E> {
|
||||
static final IntUnaryOperator IDENTITY = i -> i;
|
||||
|
||||
// Internal representation allows for a maximum index of E.MAX_VALUE - 1
|
||||
// Internal representation allows for a maximum index of 256
|
||||
// Values are clipped to [-VLENGTH..VLENGTH-1].
|
||||
|
||||
AbstractShuffle(Object indices) {
|
||||
super(indices);
|
||||
AbstractShuffle(int length, byte[] reorder) {
|
||||
super(reorder);
|
||||
assert(length == reorder.length);
|
||||
assert(indexesInRange(reorder));
|
||||
}
|
||||
|
||||
AbstractShuffle(int length, int[] reorder) {
|
||||
this(length, reorder, 0);
|
||||
}
|
||||
|
||||
AbstractShuffle(int length, int[] reorder, int offset) {
|
||||
super(prepare(length, reorder, offset));
|
||||
}
|
||||
|
||||
AbstractShuffle(int length, IntUnaryOperator f) {
|
||||
super(prepare(length, f));
|
||||
}
|
||||
|
||||
private static byte[] prepare(int length, int[] reorder, int offset) {
|
||||
byte[] a = new byte[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
int si = reorder[offset + i];
|
||||
si = partiallyWrapIndex(si, length);
|
||||
a[i] = (byte) si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static byte[] prepare(int length, IntUnaryOperator f) {
|
||||
byte[] a = new byte[length];
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
int si = f.applyAsInt(i);
|
||||
si = partiallyWrapIndex(si, length);
|
||||
a[i] = (byte) si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
byte[] reorder() {
|
||||
return (byte[])getPayload();
|
||||
}
|
||||
|
||||
/*package-private*/
|
||||
|
@ -47,90 +84,89 @@ abstract class AbstractShuffle<E> extends VectorShuffle<E> {
|
|||
return vspecies();
|
||||
}
|
||||
|
||||
/*package-private*/
|
||||
abstract AbstractVector<?> toBitsVector();
|
||||
|
||||
final AbstractVector<?> toBitsVectorTemplate() {
|
||||
AbstractSpecies<?> dsp = vspecies().asIntegral();
|
||||
Class<?> etype = dsp.elementType();
|
||||
Class<?> rvtype = dsp.dummyVector().getClass();
|
||||
return VectorSupport.convert(VectorSupport.VECTOR_OP_REINTERPRET,
|
||||
getClass(), etype, length(),
|
||||
rvtype, etype, length(),
|
||||
this, dsp,
|
||||
(v, s) -> v.toBitsVector0());
|
||||
}
|
||||
|
||||
abstract AbstractVector<?> toBitsVector0();
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final Vector<E> toVector() {
|
||||
return toBitsVector().castShape(vspecies(), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final int[] toArray() {
|
||||
int[] res = new int[length()];
|
||||
intoArray(res, 0);
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
|
||||
if (length() != s.length()) {
|
||||
throw new IllegalArgumentException("VectorShuffle length and species length differ");
|
||||
public void intoArray(int[] a, int offset) {
|
||||
byte[] reorder = reorder();
|
||||
int vlen = reorder.length;
|
||||
for (int i = 0; i < vlen; i++) {
|
||||
int sourceIndex = reorder[i];
|
||||
assert(sourceIndex >= -vlen && sourceIndex < vlen);
|
||||
a[offset + i] = sourceIndex;
|
||||
}
|
||||
return toBitsVector().toShuffle((AbstractSpecies<F>) s);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public int[] toArray() {
|
||||
byte[] reorder = reorder();
|
||||
int[] a = new int[reorder.length];
|
||||
intoArray(a, 0);
|
||||
return a;
|
||||
}
|
||||
|
||||
/*package-private*/
|
||||
@ForceInline
|
||||
final
|
||||
AbstractVector<E>
|
||||
toVectorTemplate() {
|
||||
// Note that the values produced by laneSource
|
||||
// are already clipped. At this point we convert
|
||||
// them from internal ints (or bytes) into the ETYPE.
|
||||
// FIXME: Use a conversion intrinsic for this operation.
|
||||
// https://bugs.openjdk.org/browse/JDK-8225740
|
||||
return (AbstractVector<E>) vspecies().fromIntValues(toArray());
|
||||
}
|
||||
|
||||
@ForceInline
|
||||
public final VectorShuffle<E> checkIndexes() {
|
||||
if (VectorIntrinsics.VECTOR_ACCESS_OOB_CHECK == 0) {
|
||||
return this;
|
||||
}
|
||||
Vector<?> shufvec = this.toBitsVector();
|
||||
VectorMask<?> vecmask = shufvec.compare(VectorOperators.LT, 0);
|
||||
Vector<E> shufvec = this.toVector();
|
||||
VectorMask<E> vecmask = shufvec.compare(VectorOperators.LT, vspecies().zero());
|
||||
if (vecmask.anyTrue()) {
|
||||
int[] indices = toArray();
|
||||
throw checkIndexFailed(indices[vecmask.firstTrue()], length());
|
||||
byte[] reorder = reorder();
|
||||
throw checkIndexFailed(reorder[vecmask.firstTrue()], length());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final VectorShuffle<E> wrapIndexes() {
|
||||
Vector<E> shufvec = this.toVector();
|
||||
VectorMask<E> vecmask = shufvec.compare(VectorOperators.LT, vspecies().zero());
|
||||
if (vecmask.anyTrue()) {
|
||||
// FIXME: vectorize this
|
||||
byte[] reorder = reorder();
|
||||
return wrapAndRebuild(reorder);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@ForceInline
|
||||
public final VectorShuffle<E> wrapAndRebuild(byte[] oldReorder) {
|
||||
int length = oldReorder.length;
|
||||
byte[] reorder = new byte[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
int si = oldReorder[i];
|
||||
// FIXME: This does not work unless it's a power of 2.
|
||||
if ((length & (length - 1)) == 0) {
|
||||
si += si & length; // power-of-two optimization
|
||||
} else if (si < 0) {
|
||||
// non-POT code requires a conditional add
|
||||
si += length;
|
||||
}
|
||||
assert(si >= 0 && si < length);
|
||||
reorder[i] = (byte) si;
|
||||
}
|
||||
return vspecies().dummyVector().shuffleFromBytes(reorder);
|
||||
}
|
||||
|
||||
@ForceInline
|
||||
public final VectorMask<E> laneIsValid() {
|
||||
Vector<?> shufvec = this.toBitsVector();
|
||||
return shufvec.compare(VectorOperators.GE, 0)
|
||||
.cast(vspecies());
|
||||
}
|
||||
|
||||
@ForceInline
|
||||
@Override
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public final VectorShuffle<E> rearrange(VectorShuffle<E> shuffle) {
|
||||
Vector v = toBitsVector();
|
||||
return (VectorShuffle<E>) v.rearrange(shuffle.cast(vspecies().asIntegral()))
|
||||
.toShuffle()
|
||||
.cast(vspecies());
|
||||
}
|
||||
|
||||
@ForceInline
|
||||
@Override
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public final VectorShuffle<E> wrapIndexes() {
|
||||
Vector v = toBitsVector();
|
||||
if ((length() & (length() - 1)) == 0) {
|
||||
v = v.lanewise(VectorOperators.AND, length() - 1);
|
||||
} else {
|
||||
v = v.blend(v.lanewise(VectorOperators.ADD, length()),
|
||||
v.compare(VectorOperators.LT, 0));
|
||||
}
|
||||
return (VectorShuffle<E>) v.toShuffle().cast(vspecies());
|
||||
Vector<E> shufvec = this.toVector();
|
||||
return shufvec.compare(VectorOperators.GE, vspecies().zero());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -184,4 +220,21 @@ abstract class AbstractShuffle<E> extends VectorShuffle<E> {
|
|||
String msg = "required an index in [0.."+max+"] but found "+index;
|
||||
return new IndexOutOfBoundsException(msg);
|
||||
}
|
||||
|
||||
static boolean indexesInRange(byte[] reorder) {
|
||||
int length = reorder.length;
|
||||
for (byte si : reorder) {
|
||||
if (si >= length || si < -length) {
|
||||
boolean assertsEnabled = false;
|
||||
assert(assertsEnabled = true);
|
||||
if (assertsEnabled) {
|
||||
String msg = ("index "+si+"out of range ["+length+"] in "+
|
||||
java.util.Arrays.toString(reorder));
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -48,8 +48,6 @@ abstract class AbstractSpecies<E> extends jdk.internal.vm.vector.VectorSupport.V
|
|||
@Stable
|
||||
final Class<? extends AbstractMask<E>> maskType;
|
||||
@Stable
|
||||
final Class<? extends AbstractShuffle<E>> shuffleType;
|
||||
@Stable
|
||||
final Function<Object, ? extends AbstractVector<E>> vectorFactory;
|
||||
|
||||
@Stable
|
||||
|
@ -63,13 +61,11 @@ abstract class AbstractSpecies<E> extends jdk.internal.vm.vector.VectorSupport.V
|
|||
LaneType laneType,
|
||||
Class<? extends AbstractVector<E>> vectorType,
|
||||
Class<? extends AbstractMask<E>> maskType,
|
||||
Class<? extends AbstractShuffle<E>> shuffleType,
|
||||
Function<Object, ? extends AbstractVector<E>> vectorFactory) {
|
||||
this.vectorShape = vectorShape;
|
||||
this.laneType = laneType;
|
||||
this.vectorType = vectorType;
|
||||
this.maskType = maskType;
|
||||
this.shuffleType = shuffleType;
|
||||
this.vectorFactory = vectorFactory;
|
||||
|
||||
// derived values:
|
||||
|
@ -166,11 +162,6 @@ abstract class AbstractSpecies<E> extends jdk.internal.vm.vector.VectorSupport.V
|
|||
return maskType;
|
||||
}
|
||||
|
||||
@ForceInline
|
||||
final Class<? extends AbstractShuffle<E>> shuffleType() {
|
||||
return shuffleType;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final int elementSize() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -188,57 +188,12 @@ abstract class AbstractVector<E> extends Vector<E> {
|
|||
|
||||
abstract AbstractMask<E> maskFromArray(boolean[] bits);
|
||||
|
||||
abstract <F> VectorShuffle<F> toShuffle(AbstractSpecies<F> dsp);
|
||||
abstract AbstractShuffle<E> iotaShuffle();
|
||||
|
||||
/*package-private*/
|
||||
@ForceInline
|
||||
final <F> VectorShuffle<F> toShuffleTemplate(AbstractSpecies<F> dsp) {
|
||||
Class<?> etype = vspecies().elementType();
|
||||
Class<?> dvtype = dsp.shuffleType();
|
||||
Class<?> dtype = dsp.asIntegral().elementType();
|
||||
int dlength = dsp.dummyVector().length();
|
||||
return VectorSupport.convert(VectorSupport.VECTOR_OP_CAST,
|
||||
getClass(), etype, length(),
|
||||
dvtype, dtype, dlength,
|
||||
this, dsp,
|
||||
AbstractVector::toShuffle0);
|
||||
}
|
||||
abstract AbstractShuffle<E> iotaShuffle(int start, int step, boolean wrap);
|
||||
|
||||
abstract <F> VectorShuffle<F> toShuffle0(AbstractSpecies<F> dsp);
|
||||
|
||||
@ForceInline
|
||||
public final
|
||||
VectorShuffle<E> toShuffle() {
|
||||
return toShuffle(vspecies());
|
||||
}
|
||||
|
||||
abstract VectorShuffle<E> iotaShuffle();
|
||||
|
||||
@ForceInline
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
final VectorShuffle<E> iotaShuffle(int start, int step, boolean wrap) {
|
||||
if (start == 0 && step == 1) {
|
||||
return iotaShuffle();
|
||||
}
|
||||
|
||||
if ((length() & (length() - 1)) != 0) {
|
||||
return wrap ? shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i * step + start, length())))
|
||||
: shuffleFromOp(i -> i * step + start);
|
||||
}
|
||||
|
||||
AbstractSpecies<?> species = vspecies().asIntegral();
|
||||
Vector iota = species.iota();
|
||||
iota = iota.lanewise(VectorOperators.MUL, step)
|
||||
.lanewise(VectorOperators.ADD, start);
|
||||
Vector wrapped = iota.lanewise(VectorOperators.AND, length() - 1);
|
||||
|
||||
if (!wrap) {
|
||||
Vector wrappedEx = wrapped.lanewise(VectorOperators.SUB, length());
|
||||
VectorMask<?> mask = wrapped.compare(VectorOperators.EQ, iota);
|
||||
wrapped = wrappedEx.blend(wrapped, mask);
|
||||
}
|
||||
return ((AbstractVector) wrapped).toShuffle(vspecies());
|
||||
}
|
||||
/*do not alias this byte array*/
|
||||
abstract AbstractShuffle<E> shuffleFromBytes(byte[] reorder);
|
||||
|
||||
abstract AbstractShuffle<E> shuffleFromArray(int[] indexes, int i);
|
||||
|
||||
|
|
|
@ -141,9 +141,24 @@ final class Byte128Vector extends ByteVector {
|
|||
@ForceInline
|
||||
Byte128Shuffle iotaShuffle() { return Byte128Shuffle.IOTA; }
|
||||
|
||||
@ForceInline
|
||||
Byte128Shuffle iotaShuffle(int start, int step, boolean wrap) {
|
||||
if (wrap) {
|
||||
return (Byte128Shuffle)VectorSupport.shuffleIota(ETYPE, Byte128Shuffle.class, VSPECIES, VLENGTH, start, step, 1,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
|
||||
} else {
|
||||
return (Byte128Shuffle)VectorSupport.shuffleIota(ETYPE, Byte128Shuffle.class, VSPECIES, VLENGTH, start, step, 0,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (i*lstep + lstart)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Byte128Shuffle shuffleFromArray(int[] indices, int i) { return new Byte128Shuffle(indices, i); }
|
||||
Byte128Shuffle shuffleFromBytes(byte[] reorder) { return new Byte128Shuffle(reorder); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Byte128Shuffle shuffleFromArray(int[] indexes, int i) { return new Byte128Shuffle(indexes, i); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
|
@ -342,11 +357,9 @@ final class Byte128Vector extends ByteVector {
|
|||
return (long) super.reduceLanesTemplate(op, Byte128Mask.class, (Byte128Mask) m); // specialized
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final
|
||||
<F> VectorShuffle<F> toShuffle(AbstractSpecies<F> dsp) {
|
||||
return super.toShuffleTemplate(dsp);
|
||||
public VectorShuffle<Byte> toShuffle() {
|
||||
return super.toShuffleTemplate(Byte128Shuffle.class); // specialize
|
||||
}
|
||||
|
||||
// Specialized unary testing
|
||||
|
@ -791,26 +804,23 @@ final class Byte128Vector extends ByteVector {
|
|||
static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM
|
||||
static final Class<Byte> ETYPE = byte.class; // used by the JVM
|
||||
|
||||
Byte128Shuffle(byte[] indices) {
|
||||
super(indices);
|
||||
assert(VLENGTH == indices.length);
|
||||
assert(indicesInRange(indices));
|
||||
Byte128Shuffle(byte[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Byte128Shuffle(int[] indices, int i) {
|
||||
this(prepare(indices, i));
|
||||
public Byte128Shuffle(int[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Byte128Shuffle(IntUnaryOperator fn) {
|
||||
this(prepare(fn));
|
||||
public Byte128Shuffle(int[] reorder, int i) {
|
||||
super(VLENGTH, reorder, i);
|
||||
}
|
||||
|
||||
byte[] indices() {
|
||||
return (byte[])getPayload();
|
||||
public Byte128Shuffle(IntUnaryOperator fn) {
|
||||
super(VLENGTH, fn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public ByteSpecies vspecies() {
|
||||
return VSPECIES;
|
||||
}
|
||||
|
@ -825,76 +835,33 @@ final class Byte128Vector extends ByteVector {
|
|||
|
||||
@Override
|
||||
@ForceInline
|
||||
Byte128Vector toBitsVector() {
|
||||
return (Byte128Vector) super.toBitsVectorTemplate();
|
||||
public Byte128Vector toVector() {
|
||||
return VectorSupport.shuffleToVector(VCLASS, ETYPE, Byte128Shuffle.class, this, VLENGTH,
|
||||
(s) -> ((Byte128Vector)(((AbstractShuffle<Byte>)(s)).toVectorTemplate())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
ByteVector toBitsVector0() {
|
||||
return Byte128Vector.VSPECIES.dummyVector().vectorFactory(indices());
|
||||
public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
|
||||
AbstractSpecies<F> species = (AbstractSpecies<F>) s;
|
||||
if (length() != species.laneCount())
|
||||
throw new IllegalArgumentException("VectorShuffle length and species length differ");
|
||||
int[] shuffleArray = toArray();
|
||||
return s.shuffleFromArray(shuffleArray, 0).check(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public int laneSource(int i) {
|
||||
return (int)toBitsVector().lane(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoArray(int[] a, int offset) {
|
||||
VectorSpecies<Integer> species = IntVector.SPECIES_128;
|
||||
Vector<Byte> v = toBitsVector();
|
||||
v.convertShape(VectorOperators.B2I, species, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
v.convertShape(VectorOperators.B2I, species, 1)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset + species.length());
|
||||
v.convertShape(VectorOperators.B2I, species, 2)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset + species.length() * 2);
|
||||
v.convertShape(VectorOperators.B2I, species, 3)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset + species.length() * 3);
|
||||
}
|
||||
|
||||
private static byte[] prepare(int[] indices, int offset) {
|
||||
byte[] a = new byte[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = indices[offset + i];
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (byte)si;
|
||||
public Byte128Shuffle rearrange(VectorShuffle<Byte> shuffle) {
|
||||
Byte128Shuffle s = (Byte128Shuffle) shuffle;
|
||||
byte[] reorder1 = reorder();
|
||||
byte[] reorder2 = s.reorder();
|
||||
byte[] r = new byte[reorder1.length];
|
||||
for (int i = 0; i < reorder1.length; i++) {
|
||||
int ssi = reorder2[i];
|
||||
r[i] = reorder1[ssi]; // throws on exceptional index
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static byte[] prepare(IntUnaryOperator f) {
|
||||
byte[] a = new byte[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = f.applyAsInt(i);
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (byte)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static boolean indicesInRange(byte[] indices) {
|
||||
int length = indices.length;
|
||||
for (byte si : indices) {
|
||||
if (si >= (byte)length || si < (byte)(-length)) {
|
||||
boolean assertsEnabled = false;
|
||||
assert(assertsEnabled = true);
|
||||
if (assertsEnabled) {
|
||||
String msg = ("index "+si+"out of range ["+length+"] in "+
|
||||
java.util.Arrays.toString(indices));
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return new Byte128Shuffle(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -141,9 +141,24 @@ final class Byte256Vector extends ByteVector {
|
|||
@ForceInline
|
||||
Byte256Shuffle iotaShuffle() { return Byte256Shuffle.IOTA; }
|
||||
|
||||
@ForceInline
|
||||
Byte256Shuffle iotaShuffle(int start, int step, boolean wrap) {
|
||||
if (wrap) {
|
||||
return (Byte256Shuffle)VectorSupport.shuffleIota(ETYPE, Byte256Shuffle.class, VSPECIES, VLENGTH, start, step, 1,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
|
||||
} else {
|
||||
return (Byte256Shuffle)VectorSupport.shuffleIota(ETYPE, Byte256Shuffle.class, VSPECIES, VLENGTH, start, step, 0,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (i*lstep + lstart)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Byte256Shuffle shuffleFromArray(int[] indices, int i) { return new Byte256Shuffle(indices, i); }
|
||||
Byte256Shuffle shuffleFromBytes(byte[] reorder) { return new Byte256Shuffle(reorder); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Byte256Shuffle shuffleFromArray(int[] indexes, int i) { return new Byte256Shuffle(indexes, i); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
|
@ -342,11 +357,9 @@ final class Byte256Vector extends ByteVector {
|
|||
return (long) super.reduceLanesTemplate(op, Byte256Mask.class, (Byte256Mask) m); // specialized
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final
|
||||
<F> VectorShuffle<F> toShuffle(AbstractSpecies<F> dsp) {
|
||||
return super.toShuffleTemplate(dsp);
|
||||
public VectorShuffle<Byte> toShuffle() {
|
||||
return super.toShuffleTemplate(Byte256Shuffle.class); // specialize
|
||||
}
|
||||
|
||||
// Specialized unary testing
|
||||
|
@ -823,26 +836,23 @@ final class Byte256Vector extends ByteVector {
|
|||
static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM
|
||||
static final Class<Byte> ETYPE = byte.class; // used by the JVM
|
||||
|
||||
Byte256Shuffle(byte[] indices) {
|
||||
super(indices);
|
||||
assert(VLENGTH == indices.length);
|
||||
assert(indicesInRange(indices));
|
||||
Byte256Shuffle(byte[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Byte256Shuffle(int[] indices, int i) {
|
||||
this(prepare(indices, i));
|
||||
public Byte256Shuffle(int[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Byte256Shuffle(IntUnaryOperator fn) {
|
||||
this(prepare(fn));
|
||||
public Byte256Shuffle(int[] reorder, int i) {
|
||||
super(VLENGTH, reorder, i);
|
||||
}
|
||||
|
||||
byte[] indices() {
|
||||
return (byte[])getPayload();
|
||||
public Byte256Shuffle(IntUnaryOperator fn) {
|
||||
super(VLENGTH, fn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public ByteSpecies vspecies() {
|
||||
return VSPECIES;
|
||||
}
|
||||
|
@ -857,76 +867,33 @@ final class Byte256Vector extends ByteVector {
|
|||
|
||||
@Override
|
||||
@ForceInline
|
||||
Byte256Vector toBitsVector() {
|
||||
return (Byte256Vector) super.toBitsVectorTemplate();
|
||||
public Byte256Vector toVector() {
|
||||
return VectorSupport.shuffleToVector(VCLASS, ETYPE, Byte256Shuffle.class, this, VLENGTH,
|
||||
(s) -> ((Byte256Vector)(((AbstractShuffle<Byte>)(s)).toVectorTemplate())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
ByteVector toBitsVector0() {
|
||||
return Byte256Vector.VSPECIES.dummyVector().vectorFactory(indices());
|
||||
public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
|
||||
AbstractSpecies<F> species = (AbstractSpecies<F>) s;
|
||||
if (length() != species.laneCount())
|
||||
throw new IllegalArgumentException("VectorShuffle length and species length differ");
|
||||
int[] shuffleArray = toArray();
|
||||
return s.shuffleFromArray(shuffleArray, 0).check(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public int laneSource(int i) {
|
||||
return (int)toBitsVector().lane(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoArray(int[] a, int offset) {
|
||||
VectorSpecies<Integer> species = IntVector.SPECIES_256;
|
||||
Vector<Byte> v = toBitsVector();
|
||||
v.convertShape(VectorOperators.B2I, species, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
v.convertShape(VectorOperators.B2I, species, 1)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset + species.length());
|
||||
v.convertShape(VectorOperators.B2I, species, 2)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset + species.length() * 2);
|
||||
v.convertShape(VectorOperators.B2I, species, 3)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset + species.length() * 3);
|
||||
}
|
||||
|
||||
private static byte[] prepare(int[] indices, int offset) {
|
||||
byte[] a = new byte[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = indices[offset + i];
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (byte)si;
|
||||
public Byte256Shuffle rearrange(VectorShuffle<Byte> shuffle) {
|
||||
Byte256Shuffle s = (Byte256Shuffle) shuffle;
|
||||
byte[] reorder1 = reorder();
|
||||
byte[] reorder2 = s.reorder();
|
||||
byte[] r = new byte[reorder1.length];
|
||||
for (int i = 0; i < reorder1.length; i++) {
|
||||
int ssi = reorder2[i];
|
||||
r[i] = reorder1[ssi]; // throws on exceptional index
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static byte[] prepare(IntUnaryOperator f) {
|
||||
byte[] a = new byte[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = f.applyAsInt(i);
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (byte)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static boolean indicesInRange(byte[] indices) {
|
||||
int length = indices.length;
|
||||
for (byte si : indices) {
|
||||
if (si >= (byte)length || si < (byte)(-length)) {
|
||||
boolean assertsEnabled = false;
|
||||
assert(assertsEnabled = true);
|
||||
if (assertsEnabled) {
|
||||
String msg = ("index "+si+"out of range ["+length+"] in "+
|
||||
java.util.Arrays.toString(indices));
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return new Byte256Shuffle(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -141,9 +141,24 @@ final class Byte512Vector extends ByteVector {
|
|||
@ForceInline
|
||||
Byte512Shuffle iotaShuffle() { return Byte512Shuffle.IOTA; }
|
||||
|
||||
@ForceInline
|
||||
Byte512Shuffle iotaShuffle(int start, int step, boolean wrap) {
|
||||
if (wrap) {
|
||||
return (Byte512Shuffle)VectorSupport.shuffleIota(ETYPE, Byte512Shuffle.class, VSPECIES, VLENGTH, start, step, 1,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
|
||||
} else {
|
||||
return (Byte512Shuffle)VectorSupport.shuffleIota(ETYPE, Byte512Shuffle.class, VSPECIES, VLENGTH, start, step, 0,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (i*lstep + lstart)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Byte512Shuffle shuffleFromArray(int[] indices, int i) { return new Byte512Shuffle(indices, i); }
|
||||
Byte512Shuffle shuffleFromBytes(byte[] reorder) { return new Byte512Shuffle(reorder); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Byte512Shuffle shuffleFromArray(int[] indexes, int i) { return new Byte512Shuffle(indexes, i); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
|
@ -342,11 +357,9 @@ final class Byte512Vector extends ByteVector {
|
|||
return (long) super.reduceLanesTemplate(op, Byte512Mask.class, (Byte512Mask) m); // specialized
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final
|
||||
<F> VectorShuffle<F> toShuffle(AbstractSpecies<F> dsp) {
|
||||
return super.toShuffleTemplate(dsp);
|
||||
public VectorShuffle<Byte> toShuffle() {
|
||||
return super.toShuffleTemplate(Byte512Shuffle.class); // specialize
|
||||
}
|
||||
|
||||
// Specialized unary testing
|
||||
|
@ -887,26 +900,23 @@ final class Byte512Vector extends ByteVector {
|
|||
static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM
|
||||
static final Class<Byte> ETYPE = byte.class; // used by the JVM
|
||||
|
||||
Byte512Shuffle(byte[] indices) {
|
||||
super(indices);
|
||||
assert(VLENGTH == indices.length);
|
||||
assert(indicesInRange(indices));
|
||||
Byte512Shuffle(byte[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Byte512Shuffle(int[] indices, int i) {
|
||||
this(prepare(indices, i));
|
||||
public Byte512Shuffle(int[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Byte512Shuffle(IntUnaryOperator fn) {
|
||||
this(prepare(fn));
|
||||
public Byte512Shuffle(int[] reorder, int i) {
|
||||
super(VLENGTH, reorder, i);
|
||||
}
|
||||
|
||||
byte[] indices() {
|
||||
return (byte[])getPayload();
|
||||
public Byte512Shuffle(IntUnaryOperator fn) {
|
||||
super(VLENGTH, fn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public ByteSpecies vspecies() {
|
||||
return VSPECIES;
|
||||
}
|
||||
|
@ -921,76 +931,33 @@ final class Byte512Vector extends ByteVector {
|
|||
|
||||
@Override
|
||||
@ForceInline
|
||||
Byte512Vector toBitsVector() {
|
||||
return (Byte512Vector) super.toBitsVectorTemplate();
|
||||
public Byte512Vector toVector() {
|
||||
return VectorSupport.shuffleToVector(VCLASS, ETYPE, Byte512Shuffle.class, this, VLENGTH,
|
||||
(s) -> ((Byte512Vector)(((AbstractShuffle<Byte>)(s)).toVectorTemplate())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
ByteVector toBitsVector0() {
|
||||
return Byte512Vector.VSPECIES.dummyVector().vectorFactory(indices());
|
||||
public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
|
||||
AbstractSpecies<F> species = (AbstractSpecies<F>) s;
|
||||
if (length() != species.laneCount())
|
||||
throw new IllegalArgumentException("VectorShuffle length and species length differ");
|
||||
int[] shuffleArray = toArray();
|
||||
return s.shuffleFromArray(shuffleArray, 0).check(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public int laneSource(int i) {
|
||||
return (int)toBitsVector().lane(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoArray(int[] a, int offset) {
|
||||
VectorSpecies<Integer> species = IntVector.SPECIES_512;
|
||||
Vector<Byte> v = toBitsVector();
|
||||
v.convertShape(VectorOperators.B2I, species, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
v.convertShape(VectorOperators.B2I, species, 1)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset + species.length());
|
||||
v.convertShape(VectorOperators.B2I, species, 2)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset + species.length() * 2);
|
||||
v.convertShape(VectorOperators.B2I, species, 3)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset + species.length() * 3);
|
||||
}
|
||||
|
||||
private static byte[] prepare(int[] indices, int offset) {
|
||||
byte[] a = new byte[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = indices[offset + i];
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (byte)si;
|
||||
public Byte512Shuffle rearrange(VectorShuffle<Byte> shuffle) {
|
||||
Byte512Shuffle s = (Byte512Shuffle) shuffle;
|
||||
byte[] reorder1 = reorder();
|
||||
byte[] reorder2 = s.reorder();
|
||||
byte[] r = new byte[reorder1.length];
|
||||
for (int i = 0; i < reorder1.length; i++) {
|
||||
int ssi = reorder2[i];
|
||||
r[i] = reorder1[ssi]; // throws on exceptional index
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static byte[] prepare(IntUnaryOperator f) {
|
||||
byte[] a = new byte[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = f.applyAsInt(i);
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (byte)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static boolean indicesInRange(byte[] indices) {
|
||||
int length = indices.length;
|
||||
for (byte si : indices) {
|
||||
if (si >= (byte)length || si < (byte)(-length)) {
|
||||
boolean assertsEnabled = false;
|
||||
assert(assertsEnabled = true);
|
||||
if (assertsEnabled) {
|
||||
String msg = ("index "+si+"out of range ["+length+"] in "+
|
||||
java.util.Arrays.toString(indices));
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return new Byte512Shuffle(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -141,9 +141,24 @@ final class Byte64Vector extends ByteVector {
|
|||
@ForceInline
|
||||
Byte64Shuffle iotaShuffle() { return Byte64Shuffle.IOTA; }
|
||||
|
||||
@ForceInline
|
||||
Byte64Shuffle iotaShuffle(int start, int step, boolean wrap) {
|
||||
if (wrap) {
|
||||
return (Byte64Shuffle)VectorSupport.shuffleIota(ETYPE, Byte64Shuffle.class, VSPECIES, VLENGTH, start, step, 1,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
|
||||
} else {
|
||||
return (Byte64Shuffle)VectorSupport.shuffleIota(ETYPE, Byte64Shuffle.class, VSPECIES, VLENGTH, start, step, 0,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (i*lstep + lstart)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Byte64Shuffle shuffleFromArray(int[] indices, int i) { return new Byte64Shuffle(indices, i); }
|
||||
Byte64Shuffle shuffleFromBytes(byte[] reorder) { return new Byte64Shuffle(reorder); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Byte64Shuffle shuffleFromArray(int[] indexes, int i) { return new Byte64Shuffle(indexes, i); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
|
@ -342,11 +357,9 @@ final class Byte64Vector extends ByteVector {
|
|||
return (long) super.reduceLanesTemplate(op, Byte64Mask.class, (Byte64Mask) m); // specialized
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final
|
||||
<F> VectorShuffle<F> toShuffle(AbstractSpecies<F> dsp) {
|
||||
return super.toShuffleTemplate(dsp);
|
||||
public VectorShuffle<Byte> toShuffle() {
|
||||
return super.toShuffleTemplate(Byte64Shuffle.class); // specialize
|
||||
}
|
||||
|
||||
// Specialized unary testing
|
||||
|
@ -775,26 +788,23 @@ final class Byte64Vector extends ByteVector {
|
|||
static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM
|
||||
static final Class<Byte> ETYPE = byte.class; // used by the JVM
|
||||
|
||||
Byte64Shuffle(byte[] indices) {
|
||||
super(indices);
|
||||
assert(VLENGTH == indices.length);
|
||||
assert(indicesInRange(indices));
|
||||
Byte64Shuffle(byte[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Byte64Shuffle(int[] indices, int i) {
|
||||
this(prepare(indices, i));
|
||||
public Byte64Shuffle(int[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Byte64Shuffle(IntUnaryOperator fn) {
|
||||
this(prepare(fn));
|
||||
public Byte64Shuffle(int[] reorder, int i) {
|
||||
super(VLENGTH, reorder, i);
|
||||
}
|
||||
|
||||
byte[] indices() {
|
||||
return (byte[])getPayload();
|
||||
public Byte64Shuffle(IntUnaryOperator fn) {
|
||||
super(VLENGTH, fn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public ByteSpecies vspecies() {
|
||||
return VSPECIES;
|
||||
}
|
||||
|
@ -809,76 +819,33 @@ final class Byte64Vector extends ByteVector {
|
|||
|
||||
@Override
|
||||
@ForceInline
|
||||
Byte64Vector toBitsVector() {
|
||||
return (Byte64Vector) super.toBitsVectorTemplate();
|
||||
public Byte64Vector toVector() {
|
||||
return VectorSupport.shuffleToVector(VCLASS, ETYPE, Byte64Shuffle.class, this, VLENGTH,
|
||||
(s) -> ((Byte64Vector)(((AbstractShuffle<Byte>)(s)).toVectorTemplate())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
ByteVector toBitsVector0() {
|
||||
return Byte64Vector.VSPECIES.dummyVector().vectorFactory(indices());
|
||||
public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
|
||||
AbstractSpecies<F> species = (AbstractSpecies<F>) s;
|
||||
if (length() != species.laneCount())
|
||||
throw new IllegalArgumentException("VectorShuffle length and species length differ");
|
||||
int[] shuffleArray = toArray();
|
||||
return s.shuffleFromArray(shuffleArray, 0).check(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public int laneSource(int i) {
|
||||
return (int)toBitsVector().lane(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoArray(int[] a, int offset) {
|
||||
VectorSpecies<Integer> species = IntVector.SPECIES_64;
|
||||
Vector<Byte> v = toBitsVector();
|
||||
v.convertShape(VectorOperators.B2I, species, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
v.convertShape(VectorOperators.B2I, species, 1)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset + species.length());
|
||||
v.convertShape(VectorOperators.B2I, species, 2)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset + species.length() * 2);
|
||||
v.convertShape(VectorOperators.B2I, species, 3)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset + species.length() * 3);
|
||||
}
|
||||
|
||||
private static byte[] prepare(int[] indices, int offset) {
|
||||
byte[] a = new byte[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = indices[offset + i];
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (byte)si;
|
||||
public Byte64Shuffle rearrange(VectorShuffle<Byte> shuffle) {
|
||||
Byte64Shuffle s = (Byte64Shuffle) shuffle;
|
||||
byte[] reorder1 = reorder();
|
||||
byte[] reorder2 = s.reorder();
|
||||
byte[] r = new byte[reorder1.length];
|
||||
for (int i = 0; i < reorder1.length; i++) {
|
||||
int ssi = reorder2[i];
|
||||
r[i] = reorder1[ssi]; // throws on exceptional index
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static byte[] prepare(IntUnaryOperator f) {
|
||||
byte[] a = new byte[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = f.applyAsInt(i);
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (byte)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static boolean indicesInRange(byte[] indices) {
|
||||
int length = indices.length;
|
||||
for (byte si : indices) {
|
||||
if (si >= (byte)length || si < (byte)(-length)) {
|
||||
boolean assertsEnabled = false;
|
||||
assert(assertsEnabled = true);
|
||||
if (assertsEnabled) {
|
||||
String msg = ("index "+si+"out of range ["+length+"] in "+
|
||||
java.util.Arrays.toString(indices));
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return new Byte64Shuffle(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -141,9 +141,24 @@ final class ByteMaxVector extends ByteVector {
|
|||
@ForceInline
|
||||
ByteMaxShuffle iotaShuffle() { return ByteMaxShuffle.IOTA; }
|
||||
|
||||
@ForceInline
|
||||
ByteMaxShuffle iotaShuffle(int start, int step, boolean wrap) {
|
||||
if (wrap) {
|
||||
return (ByteMaxShuffle)VectorSupport.shuffleIota(ETYPE, ByteMaxShuffle.class, VSPECIES, VLENGTH, start, step, 1,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
|
||||
} else {
|
||||
return (ByteMaxShuffle)VectorSupport.shuffleIota(ETYPE, ByteMaxShuffle.class, VSPECIES, VLENGTH, start, step, 0,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (i*lstep + lstart)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
ByteMaxShuffle shuffleFromArray(int[] indices, int i) { return new ByteMaxShuffle(indices, i); }
|
||||
ByteMaxShuffle shuffleFromBytes(byte[] reorder) { return new ByteMaxShuffle(reorder); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
ByteMaxShuffle shuffleFromArray(int[] indexes, int i) { return new ByteMaxShuffle(indexes, i); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
|
@ -342,11 +357,9 @@ final class ByteMaxVector extends ByteVector {
|
|||
return (long) super.reduceLanesTemplate(op, ByteMaxMask.class, (ByteMaxMask) m); // specialized
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final
|
||||
<F> VectorShuffle<F> toShuffle(AbstractSpecies<F> dsp) {
|
||||
return super.toShuffleTemplate(dsp);
|
||||
public VectorShuffle<Byte> toShuffle() {
|
||||
return super.toShuffleTemplate(ByteMaxShuffle.class); // specialize
|
||||
}
|
||||
|
||||
// Specialized unary testing
|
||||
|
@ -761,26 +774,23 @@ final class ByteMaxVector extends ByteVector {
|
|||
static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM
|
||||
static final Class<Byte> ETYPE = byte.class; // used by the JVM
|
||||
|
||||
ByteMaxShuffle(byte[] indices) {
|
||||
super(indices);
|
||||
assert(VLENGTH == indices.length);
|
||||
assert(indicesInRange(indices));
|
||||
ByteMaxShuffle(byte[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
ByteMaxShuffle(int[] indices, int i) {
|
||||
this(prepare(indices, i));
|
||||
public ByteMaxShuffle(int[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
ByteMaxShuffle(IntUnaryOperator fn) {
|
||||
this(prepare(fn));
|
||||
public ByteMaxShuffle(int[] reorder, int i) {
|
||||
super(VLENGTH, reorder, i);
|
||||
}
|
||||
|
||||
byte[] indices() {
|
||||
return (byte[])getPayload();
|
||||
public ByteMaxShuffle(IntUnaryOperator fn) {
|
||||
super(VLENGTH, fn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public ByteSpecies vspecies() {
|
||||
return VSPECIES;
|
||||
}
|
||||
|
@ -795,76 +805,33 @@ final class ByteMaxVector extends ByteVector {
|
|||
|
||||
@Override
|
||||
@ForceInline
|
||||
ByteMaxVector toBitsVector() {
|
||||
return (ByteMaxVector) super.toBitsVectorTemplate();
|
||||
public ByteMaxVector toVector() {
|
||||
return VectorSupport.shuffleToVector(VCLASS, ETYPE, ByteMaxShuffle.class, this, VLENGTH,
|
||||
(s) -> ((ByteMaxVector)(((AbstractShuffle<Byte>)(s)).toVectorTemplate())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
ByteVector toBitsVector0() {
|
||||
return ByteMaxVector.VSPECIES.dummyVector().vectorFactory(indices());
|
||||
public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
|
||||
AbstractSpecies<F> species = (AbstractSpecies<F>) s;
|
||||
if (length() != species.laneCount())
|
||||
throw new IllegalArgumentException("VectorShuffle length and species length differ");
|
||||
int[] shuffleArray = toArray();
|
||||
return s.shuffleFromArray(shuffleArray, 0).check(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public int laneSource(int i) {
|
||||
return (int)toBitsVector().lane(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoArray(int[] a, int offset) {
|
||||
VectorSpecies<Integer> species = IntVector.SPECIES_MAX;
|
||||
Vector<Byte> v = toBitsVector();
|
||||
v.convertShape(VectorOperators.B2I, species, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
v.convertShape(VectorOperators.B2I, species, 1)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset + species.length());
|
||||
v.convertShape(VectorOperators.B2I, species, 2)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset + species.length() * 2);
|
||||
v.convertShape(VectorOperators.B2I, species, 3)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset + species.length() * 3);
|
||||
}
|
||||
|
||||
private static byte[] prepare(int[] indices, int offset) {
|
||||
byte[] a = new byte[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = indices[offset + i];
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (byte)si;
|
||||
public ByteMaxShuffle rearrange(VectorShuffle<Byte> shuffle) {
|
||||
ByteMaxShuffle s = (ByteMaxShuffle) shuffle;
|
||||
byte[] reorder1 = reorder();
|
||||
byte[] reorder2 = s.reorder();
|
||||
byte[] r = new byte[reorder1.length];
|
||||
for (int i = 0; i < reorder1.length; i++) {
|
||||
int ssi = reorder2[i];
|
||||
r[i] = reorder1[ssi]; // throws on exceptional index
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static byte[] prepare(IntUnaryOperator f) {
|
||||
byte[] a = new byte[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = f.applyAsInt(i);
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (byte)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static boolean indicesInRange(byte[] indices) {
|
||||
int length = indices.length;
|
||||
for (byte si : indices) {
|
||||
if (si >= (byte)length || si < (byte)(-length)) {
|
||||
boolean assertsEnabled = false;
|
||||
assert(assertsEnabled = true);
|
||||
if (assertsEnabled) {
|
||||
String msg = ("index "+si+"out of range ["+length+"] in "+
|
||||
java.util.Arrays.toString(indices));
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return new ByteMaxShuffle(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -1071,7 +1071,7 @@ public abstract class ByteVector extends AbstractVector<Byte> {
|
|||
// and broadcast, but it would be more surprising not to continue
|
||||
// the obvious pattern started by unary and binary.
|
||||
|
||||
/**
|
||||
/**
|
||||
* {@inheritDoc} <!--workaround-->
|
||||
* @see #lanewise(VectorOperators.Ternary,byte,byte,VectorMask)
|
||||
* @see #lanewise(VectorOperators.Ternary,Vector,byte,VectorMask)
|
||||
|
@ -2480,8 +2480,8 @@ public abstract class ByteVector extends AbstractVector<Byte> {
|
|||
}
|
||||
|
||||
@ForceInline
|
||||
final <F>
|
||||
VectorShuffle<F> toShuffle0(AbstractSpecies<F> dsp) {
|
||||
private final
|
||||
VectorShuffle<Byte> toShuffle0(ByteSpecies dsp) {
|
||||
byte[] a = toArray();
|
||||
int[] sa = new int[a.length];
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
|
@ -2490,6 +2490,18 @@ public abstract class ByteVector extends AbstractVector<Byte> {
|
|||
return VectorShuffle.fromArray(dsp, sa, 0);
|
||||
}
|
||||
|
||||
/*package-private*/
|
||||
@ForceInline
|
||||
final
|
||||
VectorShuffle<Byte> toShuffleTemplate(Class<?> shuffleType) {
|
||||
ByteSpecies vsp = vspecies();
|
||||
return VectorSupport.convert(VectorSupport.VECTOR_OP_CAST,
|
||||
getClass(), byte.class, length(),
|
||||
shuffleType, byte.class, length(),
|
||||
this, vsp,
|
||||
ByteVector::toShuffle0);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} <!--workaround-->
|
||||
* @since 19
|
||||
|
@ -4084,10 +4096,9 @@ public abstract class ByteVector extends AbstractVector<Byte> {
|
|||
private ByteSpecies(VectorShape shape,
|
||||
Class<? extends ByteVector> vectorType,
|
||||
Class<? extends AbstractMask<Byte>> maskType,
|
||||
Class<? extends AbstractShuffle<Byte>> shuffleType,
|
||||
Function<Object, ByteVector> vectorFactory) {
|
||||
super(shape, LaneType.of(byte.class),
|
||||
vectorType, maskType, shuffleType,
|
||||
vectorType, maskType,
|
||||
vectorFactory);
|
||||
assert(this.elementSize() == Byte.SIZE);
|
||||
}
|
||||
|
@ -4363,7 +4374,6 @@ public abstract class ByteVector extends AbstractVector<Byte> {
|
|||
= new ByteSpecies(VectorShape.S_64_BIT,
|
||||
Byte64Vector.class,
|
||||
Byte64Vector.Byte64Mask.class,
|
||||
Byte64Vector.Byte64Shuffle.class,
|
||||
Byte64Vector::new);
|
||||
|
||||
/** Species representing {@link ByteVector}s of {@link VectorShape#S_128_BIT VectorShape.S_128_BIT}. */
|
||||
|
@ -4371,7 +4381,6 @@ public abstract class ByteVector extends AbstractVector<Byte> {
|
|||
= new ByteSpecies(VectorShape.S_128_BIT,
|
||||
Byte128Vector.class,
|
||||
Byte128Vector.Byte128Mask.class,
|
||||
Byte128Vector.Byte128Shuffle.class,
|
||||
Byte128Vector::new);
|
||||
|
||||
/** Species representing {@link ByteVector}s of {@link VectorShape#S_256_BIT VectorShape.S_256_BIT}. */
|
||||
|
@ -4379,7 +4388,6 @@ public abstract class ByteVector extends AbstractVector<Byte> {
|
|||
= new ByteSpecies(VectorShape.S_256_BIT,
|
||||
Byte256Vector.class,
|
||||
Byte256Vector.Byte256Mask.class,
|
||||
Byte256Vector.Byte256Shuffle.class,
|
||||
Byte256Vector::new);
|
||||
|
||||
/** Species representing {@link ByteVector}s of {@link VectorShape#S_512_BIT VectorShape.S_512_BIT}. */
|
||||
|
@ -4387,7 +4395,6 @@ public abstract class ByteVector extends AbstractVector<Byte> {
|
|||
= new ByteSpecies(VectorShape.S_512_BIT,
|
||||
Byte512Vector.class,
|
||||
Byte512Vector.Byte512Mask.class,
|
||||
Byte512Vector.Byte512Shuffle.class,
|
||||
Byte512Vector::new);
|
||||
|
||||
/** Species representing {@link ByteVector}s of {@link VectorShape#S_Max_BIT VectorShape.S_Max_BIT}. */
|
||||
|
@ -4395,7 +4402,6 @@ public abstract class ByteVector extends AbstractVector<Byte> {
|
|||
= new ByteSpecies(VectorShape.S_Max_BIT,
|
||||
ByteMaxVector.class,
|
||||
ByteMaxVector.ByteMaxMask.class,
|
||||
ByteMaxVector.ByteMaxShuffle.class,
|
||||
ByteMaxVector::new);
|
||||
|
||||
/**
|
||||
|
|
|
@ -141,9 +141,24 @@ final class Double128Vector extends DoubleVector {
|
|||
@ForceInline
|
||||
Double128Shuffle iotaShuffle() { return Double128Shuffle.IOTA; }
|
||||
|
||||
@ForceInline
|
||||
Double128Shuffle iotaShuffle(int start, int step, boolean wrap) {
|
||||
if (wrap) {
|
||||
return (Double128Shuffle)VectorSupport.shuffleIota(ETYPE, Double128Shuffle.class, VSPECIES, VLENGTH, start, step, 1,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
|
||||
} else {
|
||||
return (Double128Shuffle)VectorSupport.shuffleIota(ETYPE, Double128Shuffle.class, VSPECIES, VLENGTH, start, step, 0,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (i*lstep + lstart)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Double128Shuffle shuffleFromArray(int[] indices, int i) { return new Double128Shuffle(indices, i); }
|
||||
Double128Shuffle shuffleFromBytes(byte[] reorder) { return new Double128Shuffle(reorder); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Double128Shuffle shuffleFromArray(int[] indexes, int i) { return new Double128Shuffle(indexes, i); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
|
@ -329,11 +344,9 @@ final class Double128Vector extends DoubleVector {
|
|||
return (long) super.reduceLanesTemplate(op, Double128Mask.class, (Double128Mask) m); // specialized
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final
|
||||
<F> VectorShuffle<F> toShuffle(AbstractSpecies<F> dsp) {
|
||||
return super.toShuffleTemplate(dsp);
|
||||
public VectorShuffle<Double> toShuffle() {
|
||||
return super.toShuffleTemplate(Double128Shuffle.class); // specialize
|
||||
}
|
||||
|
||||
// Specialized unary testing
|
||||
|
@ -750,28 +763,25 @@ final class Double128Vector extends DoubleVector {
|
|||
|
||||
static final class Double128Shuffle extends AbstractShuffle<Double> {
|
||||
static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM
|
||||
static final Class<Long> ETYPE = long.class; // used by the JVM
|
||||
static final Class<Double> ETYPE = double.class; // used by the JVM
|
||||
|
||||
Double128Shuffle(long[] indices) {
|
||||
super(indices);
|
||||
assert(VLENGTH == indices.length);
|
||||
assert(indicesInRange(indices));
|
||||
Double128Shuffle(byte[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Double128Shuffle(int[] indices, int i) {
|
||||
this(prepare(indices, i));
|
||||
public Double128Shuffle(int[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Double128Shuffle(IntUnaryOperator fn) {
|
||||
this(prepare(fn));
|
||||
public Double128Shuffle(int[] reorder, int i) {
|
||||
super(VLENGTH, reorder, i);
|
||||
}
|
||||
|
||||
long[] indices() {
|
||||
return (long[])getPayload();
|
||||
public Double128Shuffle(IntUnaryOperator fn) {
|
||||
super(VLENGTH, fn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public DoubleSpecies vspecies() {
|
||||
return VSPECIES;
|
||||
}
|
||||
|
@ -779,94 +789,40 @@ final class Double128Vector extends DoubleVector {
|
|||
static {
|
||||
// There must be enough bits in the shuffle lanes to encode
|
||||
// VLENGTH valid indexes and VLENGTH exceptional ones.
|
||||
assert(VLENGTH < Long.MAX_VALUE);
|
||||
assert(Long.MIN_VALUE <= -VLENGTH);
|
||||
assert(VLENGTH < Byte.MAX_VALUE);
|
||||
assert(Byte.MIN_VALUE <= -VLENGTH);
|
||||
}
|
||||
static final Double128Shuffle IOTA = new Double128Shuffle(IDENTITY);
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Long128Vector toBitsVector() {
|
||||
return (Long128Vector) super.toBitsVectorTemplate();
|
||||
public Double128Vector toVector() {
|
||||
return VectorSupport.shuffleToVector(VCLASS, ETYPE, Double128Shuffle.class, this, VLENGTH,
|
||||
(s) -> ((Double128Vector)(((AbstractShuffle<Double>)(s)).toVectorTemplate())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
LongVector toBitsVector0() {
|
||||
return Long128Vector.VSPECIES.dummyVector().vectorFactory(indices());
|
||||
public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
|
||||
AbstractSpecies<F> species = (AbstractSpecies<F>) s;
|
||||
if (length() != species.laneCount())
|
||||
throw new IllegalArgumentException("VectorShuffle length and species length differ");
|
||||
int[] shuffleArray = toArray();
|
||||
return s.shuffleFromArray(shuffleArray, 0).check(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public int laneSource(int i) {
|
||||
return (int)toBitsVector().lane(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoArray(int[] a, int offset) {
|
||||
switch (length()) {
|
||||
case 1 -> a[offset] = laneSource(0);
|
||||
case 2 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_64, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
case 4 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_128, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
case 8 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_256, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
case 16 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_512, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
default -> {
|
||||
VectorIntrinsics.checkFromIndexSize(offset, length(), a.length);
|
||||
for (int i = 0; i < length(); i++) {
|
||||
a[offset + i] = laneSource(i);
|
||||
}
|
||||
}
|
||||
public Double128Shuffle rearrange(VectorShuffle<Double> shuffle) {
|
||||
Double128Shuffle s = (Double128Shuffle) shuffle;
|
||||
byte[] reorder1 = reorder();
|
||||
byte[] reorder2 = s.reorder();
|
||||
byte[] r = new byte[reorder1.length];
|
||||
for (int i = 0; i < reorder1.length; i++) {
|
||||
int ssi = reorder2[i];
|
||||
r[i] = reorder1[ssi]; // throws on exceptional index
|
||||
}
|
||||
}
|
||||
|
||||
private static long[] prepare(int[] indices, int offset) {
|
||||
long[] a = new long[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = indices[offset + i];
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (long)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static long[] prepare(IntUnaryOperator f) {
|
||||
long[] a = new long[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = f.applyAsInt(i);
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (long)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static boolean indicesInRange(long[] indices) {
|
||||
int length = indices.length;
|
||||
for (long si : indices) {
|
||||
if (si >= (long)length || si < (long)(-length)) {
|
||||
boolean assertsEnabled = false;
|
||||
assert(assertsEnabled = true);
|
||||
if (assertsEnabled) {
|
||||
String msg = ("index "+si+"out of range ["+length+"] in "+
|
||||
java.util.Arrays.toString(indices));
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return new Double128Shuffle(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -141,9 +141,24 @@ final class Double256Vector extends DoubleVector {
|
|||
@ForceInline
|
||||
Double256Shuffle iotaShuffle() { return Double256Shuffle.IOTA; }
|
||||
|
||||
@ForceInline
|
||||
Double256Shuffle iotaShuffle(int start, int step, boolean wrap) {
|
||||
if (wrap) {
|
||||
return (Double256Shuffle)VectorSupport.shuffleIota(ETYPE, Double256Shuffle.class, VSPECIES, VLENGTH, start, step, 1,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
|
||||
} else {
|
||||
return (Double256Shuffle)VectorSupport.shuffleIota(ETYPE, Double256Shuffle.class, VSPECIES, VLENGTH, start, step, 0,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (i*lstep + lstart)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Double256Shuffle shuffleFromArray(int[] indices, int i) { return new Double256Shuffle(indices, i); }
|
||||
Double256Shuffle shuffleFromBytes(byte[] reorder) { return new Double256Shuffle(reorder); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Double256Shuffle shuffleFromArray(int[] indexes, int i) { return new Double256Shuffle(indexes, i); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
|
@ -329,11 +344,9 @@ final class Double256Vector extends DoubleVector {
|
|||
return (long) super.reduceLanesTemplate(op, Double256Mask.class, (Double256Mask) m); // specialized
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final
|
||||
<F> VectorShuffle<F> toShuffle(AbstractSpecies<F> dsp) {
|
||||
return super.toShuffleTemplate(dsp);
|
||||
public VectorShuffle<Double> toShuffle() {
|
||||
return super.toShuffleTemplate(Double256Shuffle.class); // specialize
|
||||
}
|
||||
|
||||
// Specialized unary testing
|
||||
|
@ -754,28 +767,25 @@ final class Double256Vector extends DoubleVector {
|
|||
|
||||
static final class Double256Shuffle extends AbstractShuffle<Double> {
|
||||
static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM
|
||||
static final Class<Long> ETYPE = long.class; // used by the JVM
|
||||
static final Class<Double> ETYPE = double.class; // used by the JVM
|
||||
|
||||
Double256Shuffle(long[] indices) {
|
||||
super(indices);
|
||||
assert(VLENGTH == indices.length);
|
||||
assert(indicesInRange(indices));
|
||||
Double256Shuffle(byte[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Double256Shuffle(int[] indices, int i) {
|
||||
this(prepare(indices, i));
|
||||
public Double256Shuffle(int[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Double256Shuffle(IntUnaryOperator fn) {
|
||||
this(prepare(fn));
|
||||
public Double256Shuffle(int[] reorder, int i) {
|
||||
super(VLENGTH, reorder, i);
|
||||
}
|
||||
|
||||
long[] indices() {
|
||||
return (long[])getPayload();
|
||||
public Double256Shuffle(IntUnaryOperator fn) {
|
||||
super(VLENGTH, fn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public DoubleSpecies vspecies() {
|
||||
return VSPECIES;
|
||||
}
|
||||
|
@ -783,94 +793,40 @@ final class Double256Vector extends DoubleVector {
|
|||
static {
|
||||
// There must be enough bits in the shuffle lanes to encode
|
||||
// VLENGTH valid indexes and VLENGTH exceptional ones.
|
||||
assert(VLENGTH < Long.MAX_VALUE);
|
||||
assert(Long.MIN_VALUE <= -VLENGTH);
|
||||
assert(VLENGTH < Byte.MAX_VALUE);
|
||||
assert(Byte.MIN_VALUE <= -VLENGTH);
|
||||
}
|
||||
static final Double256Shuffle IOTA = new Double256Shuffle(IDENTITY);
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Long256Vector toBitsVector() {
|
||||
return (Long256Vector) super.toBitsVectorTemplate();
|
||||
public Double256Vector toVector() {
|
||||
return VectorSupport.shuffleToVector(VCLASS, ETYPE, Double256Shuffle.class, this, VLENGTH,
|
||||
(s) -> ((Double256Vector)(((AbstractShuffle<Double>)(s)).toVectorTemplate())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
LongVector toBitsVector0() {
|
||||
return Long256Vector.VSPECIES.dummyVector().vectorFactory(indices());
|
||||
public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
|
||||
AbstractSpecies<F> species = (AbstractSpecies<F>) s;
|
||||
if (length() != species.laneCount())
|
||||
throw new IllegalArgumentException("VectorShuffle length and species length differ");
|
||||
int[] shuffleArray = toArray();
|
||||
return s.shuffleFromArray(shuffleArray, 0).check(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public int laneSource(int i) {
|
||||
return (int)toBitsVector().lane(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoArray(int[] a, int offset) {
|
||||
switch (length()) {
|
||||
case 1 -> a[offset] = laneSource(0);
|
||||
case 2 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_64, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
case 4 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_128, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
case 8 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_256, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
case 16 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_512, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
default -> {
|
||||
VectorIntrinsics.checkFromIndexSize(offset, length(), a.length);
|
||||
for (int i = 0; i < length(); i++) {
|
||||
a[offset + i] = laneSource(i);
|
||||
}
|
||||
}
|
||||
public Double256Shuffle rearrange(VectorShuffle<Double> shuffle) {
|
||||
Double256Shuffle s = (Double256Shuffle) shuffle;
|
||||
byte[] reorder1 = reorder();
|
||||
byte[] reorder2 = s.reorder();
|
||||
byte[] r = new byte[reorder1.length];
|
||||
for (int i = 0; i < reorder1.length; i++) {
|
||||
int ssi = reorder2[i];
|
||||
r[i] = reorder1[ssi]; // throws on exceptional index
|
||||
}
|
||||
}
|
||||
|
||||
private static long[] prepare(int[] indices, int offset) {
|
||||
long[] a = new long[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = indices[offset + i];
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (long)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static long[] prepare(IntUnaryOperator f) {
|
||||
long[] a = new long[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = f.applyAsInt(i);
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (long)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static boolean indicesInRange(long[] indices) {
|
||||
int length = indices.length;
|
||||
for (long si : indices) {
|
||||
if (si >= (long)length || si < (long)(-length)) {
|
||||
boolean assertsEnabled = false;
|
||||
assert(assertsEnabled = true);
|
||||
if (assertsEnabled) {
|
||||
String msg = ("index "+si+"out of range ["+length+"] in "+
|
||||
java.util.Arrays.toString(indices));
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return new Double256Shuffle(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -141,9 +141,24 @@ final class Double512Vector extends DoubleVector {
|
|||
@ForceInline
|
||||
Double512Shuffle iotaShuffle() { return Double512Shuffle.IOTA; }
|
||||
|
||||
@ForceInline
|
||||
Double512Shuffle iotaShuffle(int start, int step, boolean wrap) {
|
||||
if (wrap) {
|
||||
return (Double512Shuffle)VectorSupport.shuffleIota(ETYPE, Double512Shuffle.class, VSPECIES, VLENGTH, start, step, 1,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
|
||||
} else {
|
||||
return (Double512Shuffle)VectorSupport.shuffleIota(ETYPE, Double512Shuffle.class, VSPECIES, VLENGTH, start, step, 0,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (i*lstep + lstart)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Double512Shuffle shuffleFromArray(int[] indices, int i) { return new Double512Shuffle(indices, i); }
|
||||
Double512Shuffle shuffleFromBytes(byte[] reorder) { return new Double512Shuffle(reorder); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Double512Shuffle shuffleFromArray(int[] indexes, int i) { return new Double512Shuffle(indexes, i); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
|
@ -329,11 +344,9 @@ final class Double512Vector extends DoubleVector {
|
|||
return (long) super.reduceLanesTemplate(op, Double512Mask.class, (Double512Mask) m); // specialized
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final
|
||||
<F> VectorShuffle<F> toShuffle(AbstractSpecies<F> dsp) {
|
||||
return super.toShuffleTemplate(dsp);
|
||||
public VectorShuffle<Double> toShuffle() {
|
||||
return super.toShuffleTemplate(Double512Shuffle.class); // specialize
|
||||
}
|
||||
|
||||
// Specialized unary testing
|
||||
|
@ -762,28 +775,25 @@ final class Double512Vector extends DoubleVector {
|
|||
|
||||
static final class Double512Shuffle extends AbstractShuffle<Double> {
|
||||
static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM
|
||||
static final Class<Long> ETYPE = long.class; // used by the JVM
|
||||
static final Class<Double> ETYPE = double.class; // used by the JVM
|
||||
|
||||
Double512Shuffle(long[] indices) {
|
||||
super(indices);
|
||||
assert(VLENGTH == indices.length);
|
||||
assert(indicesInRange(indices));
|
||||
Double512Shuffle(byte[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Double512Shuffle(int[] indices, int i) {
|
||||
this(prepare(indices, i));
|
||||
public Double512Shuffle(int[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Double512Shuffle(IntUnaryOperator fn) {
|
||||
this(prepare(fn));
|
||||
public Double512Shuffle(int[] reorder, int i) {
|
||||
super(VLENGTH, reorder, i);
|
||||
}
|
||||
|
||||
long[] indices() {
|
||||
return (long[])getPayload();
|
||||
public Double512Shuffle(IntUnaryOperator fn) {
|
||||
super(VLENGTH, fn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public DoubleSpecies vspecies() {
|
||||
return VSPECIES;
|
||||
}
|
||||
|
@ -791,94 +801,40 @@ final class Double512Vector extends DoubleVector {
|
|||
static {
|
||||
// There must be enough bits in the shuffle lanes to encode
|
||||
// VLENGTH valid indexes and VLENGTH exceptional ones.
|
||||
assert(VLENGTH < Long.MAX_VALUE);
|
||||
assert(Long.MIN_VALUE <= -VLENGTH);
|
||||
assert(VLENGTH < Byte.MAX_VALUE);
|
||||
assert(Byte.MIN_VALUE <= -VLENGTH);
|
||||
}
|
||||
static final Double512Shuffle IOTA = new Double512Shuffle(IDENTITY);
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Long512Vector toBitsVector() {
|
||||
return (Long512Vector) super.toBitsVectorTemplate();
|
||||
public Double512Vector toVector() {
|
||||
return VectorSupport.shuffleToVector(VCLASS, ETYPE, Double512Shuffle.class, this, VLENGTH,
|
||||
(s) -> ((Double512Vector)(((AbstractShuffle<Double>)(s)).toVectorTemplate())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
LongVector toBitsVector0() {
|
||||
return Long512Vector.VSPECIES.dummyVector().vectorFactory(indices());
|
||||
public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
|
||||
AbstractSpecies<F> species = (AbstractSpecies<F>) s;
|
||||
if (length() != species.laneCount())
|
||||
throw new IllegalArgumentException("VectorShuffle length and species length differ");
|
||||
int[] shuffleArray = toArray();
|
||||
return s.shuffleFromArray(shuffleArray, 0).check(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public int laneSource(int i) {
|
||||
return (int)toBitsVector().lane(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoArray(int[] a, int offset) {
|
||||
switch (length()) {
|
||||
case 1 -> a[offset] = laneSource(0);
|
||||
case 2 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_64, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
case 4 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_128, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
case 8 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_256, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
case 16 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_512, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
default -> {
|
||||
VectorIntrinsics.checkFromIndexSize(offset, length(), a.length);
|
||||
for (int i = 0; i < length(); i++) {
|
||||
a[offset + i] = laneSource(i);
|
||||
}
|
||||
}
|
||||
public Double512Shuffle rearrange(VectorShuffle<Double> shuffle) {
|
||||
Double512Shuffle s = (Double512Shuffle) shuffle;
|
||||
byte[] reorder1 = reorder();
|
||||
byte[] reorder2 = s.reorder();
|
||||
byte[] r = new byte[reorder1.length];
|
||||
for (int i = 0; i < reorder1.length; i++) {
|
||||
int ssi = reorder2[i];
|
||||
r[i] = reorder1[ssi]; // throws on exceptional index
|
||||
}
|
||||
}
|
||||
|
||||
private static long[] prepare(int[] indices, int offset) {
|
||||
long[] a = new long[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = indices[offset + i];
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (long)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static long[] prepare(IntUnaryOperator f) {
|
||||
long[] a = new long[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = f.applyAsInt(i);
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (long)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static boolean indicesInRange(long[] indices) {
|
||||
int length = indices.length;
|
||||
for (long si : indices) {
|
||||
if (si >= (long)length || si < (long)(-length)) {
|
||||
boolean assertsEnabled = false;
|
||||
assert(assertsEnabled = true);
|
||||
if (assertsEnabled) {
|
||||
String msg = ("index "+si+"out of range ["+length+"] in "+
|
||||
java.util.Arrays.toString(indices));
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return new Double512Shuffle(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -141,9 +141,24 @@ final class Double64Vector extends DoubleVector {
|
|||
@ForceInline
|
||||
Double64Shuffle iotaShuffle() { return Double64Shuffle.IOTA; }
|
||||
|
||||
@ForceInline
|
||||
Double64Shuffle iotaShuffle(int start, int step, boolean wrap) {
|
||||
if (wrap) {
|
||||
return (Double64Shuffle)VectorSupport.shuffleIota(ETYPE, Double64Shuffle.class, VSPECIES, VLENGTH, start, step, 1,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
|
||||
} else {
|
||||
return (Double64Shuffle)VectorSupport.shuffleIota(ETYPE, Double64Shuffle.class, VSPECIES, VLENGTH, start, step, 0,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (i*lstep + lstart)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Double64Shuffle shuffleFromArray(int[] indices, int i) { return new Double64Shuffle(indices, i); }
|
||||
Double64Shuffle shuffleFromBytes(byte[] reorder) { return new Double64Shuffle(reorder); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Double64Shuffle shuffleFromArray(int[] indexes, int i) { return new Double64Shuffle(indexes, i); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
|
@ -329,11 +344,9 @@ final class Double64Vector extends DoubleVector {
|
|||
return (long) super.reduceLanesTemplate(op, Double64Mask.class, (Double64Mask) m); // specialized
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final
|
||||
<F> VectorShuffle<F> toShuffle(AbstractSpecies<F> dsp) {
|
||||
return super.toShuffleTemplate(dsp);
|
||||
public VectorShuffle<Double> toShuffle() {
|
||||
return super.toShuffleTemplate(Double64Shuffle.class); // specialize
|
||||
}
|
||||
|
||||
// Specialized unary testing
|
||||
|
@ -748,28 +761,25 @@ final class Double64Vector extends DoubleVector {
|
|||
|
||||
static final class Double64Shuffle extends AbstractShuffle<Double> {
|
||||
static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM
|
||||
static final Class<Long> ETYPE = long.class; // used by the JVM
|
||||
static final Class<Double> ETYPE = double.class; // used by the JVM
|
||||
|
||||
Double64Shuffle(long[] indices) {
|
||||
super(indices);
|
||||
assert(VLENGTH == indices.length);
|
||||
assert(indicesInRange(indices));
|
||||
Double64Shuffle(byte[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Double64Shuffle(int[] indices, int i) {
|
||||
this(prepare(indices, i));
|
||||
public Double64Shuffle(int[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Double64Shuffle(IntUnaryOperator fn) {
|
||||
this(prepare(fn));
|
||||
public Double64Shuffle(int[] reorder, int i) {
|
||||
super(VLENGTH, reorder, i);
|
||||
}
|
||||
|
||||
long[] indices() {
|
||||
return (long[])getPayload();
|
||||
public Double64Shuffle(IntUnaryOperator fn) {
|
||||
super(VLENGTH, fn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public DoubleSpecies vspecies() {
|
||||
return VSPECIES;
|
||||
}
|
||||
|
@ -777,94 +787,40 @@ final class Double64Vector extends DoubleVector {
|
|||
static {
|
||||
// There must be enough bits in the shuffle lanes to encode
|
||||
// VLENGTH valid indexes and VLENGTH exceptional ones.
|
||||
assert(VLENGTH < Long.MAX_VALUE);
|
||||
assert(Long.MIN_VALUE <= -VLENGTH);
|
||||
assert(VLENGTH < Byte.MAX_VALUE);
|
||||
assert(Byte.MIN_VALUE <= -VLENGTH);
|
||||
}
|
||||
static final Double64Shuffle IOTA = new Double64Shuffle(IDENTITY);
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Long64Vector toBitsVector() {
|
||||
return (Long64Vector) super.toBitsVectorTemplate();
|
||||
public Double64Vector toVector() {
|
||||
return VectorSupport.shuffleToVector(VCLASS, ETYPE, Double64Shuffle.class, this, VLENGTH,
|
||||
(s) -> ((Double64Vector)(((AbstractShuffle<Double>)(s)).toVectorTemplate())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
LongVector toBitsVector0() {
|
||||
return Long64Vector.VSPECIES.dummyVector().vectorFactory(indices());
|
||||
public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
|
||||
AbstractSpecies<F> species = (AbstractSpecies<F>) s;
|
||||
if (length() != species.laneCount())
|
||||
throw new IllegalArgumentException("VectorShuffle length and species length differ");
|
||||
int[] shuffleArray = toArray();
|
||||
return s.shuffleFromArray(shuffleArray, 0).check(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public int laneSource(int i) {
|
||||
return (int)toBitsVector().lane(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoArray(int[] a, int offset) {
|
||||
switch (length()) {
|
||||
case 1 -> a[offset] = laneSource(0);
|
||||
case 2 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_64, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
case 4 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_128, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
case 8 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_256, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
case 16 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_512, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
default -> {
|
||||
VectorIntrinsics.checkFromIndexSize(offset, length(), a.length);
|
||||
for (int i = 0; i < length(); i++) {
|
||||
a[offset + i] = laneSource(i);
|
||||
}
|
||||
}
|
||||
public Double64Shuffle rearrange(VectorShuffle<Double> shuffle) {
|
||||
Double64Shuffle s = (Double64Shuffle) shuffle;
|
||||
byte[] reorder1 = reorder();
|
||||
byte[] reorder2 = s.reorder();
|
||||
byte[] r = new byte[reorder1.length];
|
||||
for (int i = 0; i < reorder1.length; i++) {
|
||||
int ssi = reorder2[i];
|
||||
r[i] = reorder1[ssi]; // throws on exceptional index
|
||||
}
|
||||
}
|
||||
|
||||
private static long[] prepare(int[] indices, int offset) {
|
||||
long[] a = new long[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = indices[offset + i];
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (long)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static long[] prepare(IntUnaryOperator f) {
|
||||
long[] a = new long[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = f.applyAsInt(i);
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (long)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static boolean indicesInRange(long[] indices) {
|
||||
int length = indices.length;
|
||||
for (long si : indices) {
|
||||
if (si >= (long)length || si < (long)(-length)) {
|
||||
boolean assertsEnabled = false;
|
||||
assert(assertsEnabled = true);
|
||||
if (assertsEnabled) {
|
||||
String msg = ("index "+si+"out of range ["+length+"] in "+
|
||||
java.util.Arrays.toString(indices));
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return new Double64Shuffle(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -141,9 +141,24 @@ final class DoubleMaxVector extends DoubleVector {
|
|||
@ForceInline
|
||||
DoubleMaxShuffle iotaShuffle() { return DoubleMaxShuffle.IOTA; }
|
||||
|
||||
@ForceInline
|
||||
DoubleMaxShuffle iotaShuffle(int start, int step, boolean wrap) {
|
||||
if (wrap) {
|
||||
return (DoubleMaxShuffle)VectorSupport.shuffleIota(ETYPE, DoubleMaxShuffle.class, VSPECIES, VLENGTH, start, step, 1,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
|
||||
} else {
|
||||
return (DoubleMaxShuffle)VectorSupport.shuffleIota(ETYPE, DoubleMaxShuffle.class, VSPECIES, VLENGTH, start, step, 0,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (i*lstep + lstart)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
DoubleMaxShuffle shuffleFromArray(int[] indices, int i) { return new DoubleMaxShuffle(indices, i); }
|
||||
DoubleMaxShuffle shuffleFromBytes(byte[] reorder) { return new DoubleMaxShuffle(reorder); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
DoubleMaxShuffle shuffleFromArray(int[] indexes, int i) { return new DoubleMaxShuffle(indexes, i); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
|
@ -329,11 +344,9 @@ final class DoubleMaxVector extends DoubleVector {
|
|||
return (long) super.reduceLanesTemplate(op, DoubleMaxMask.class, (DoubleMaxMask) m); // specialized
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final
|
||||
<F> VectorShuffle<F> toShuffle(AbstractSpecies<F> dsp) {
|
||||
return super.toShuffleTemplate(dsp);
|
||||
public VectorShuffle<Double> toShuffle() {
|
||||
return super.toShuffleTemplate(DoubleMaxShuffle.class); // specialize
|
||||
}
|
||||
|
||||
// Specialized unary testing
|
||||
|
@ -747,28 +760,25 @@ final class DoubleMaxVector extends DoubleVector {
|
|||
|
||||
static final class DoubleMaxShuffle extends AbstractShuffle<Double> {
|
||||
static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM
|
||||
static final Class<Long> ETYPE = long.class; // used by the JVM
|
||||
static final Class<Double> ETYPE = double.class; // used by the JVM
|
||||
|
||||
DoubleMaxShuffle(long[] indices) {
|
||||
super(indices);
|
||||
assert(VLENGTH == indices.length);
|
||||
assert(indicesInRange(indices));
|
||||
DoubleMaxShuffle(byte[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
DoubleMaxShuffle(int[] indices, int i) {
|
||||
this(prepare(indices, i));
|
||||
public DoubleMaxShuffle(int[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
DoubleMaxShuffle(IntUnaryOperator fn) {
|
||||
this(prepare(fn));
|
||||
public DoubleMaxShuffle(int[] reorder, int i) {
|
||||
super(VLENGTH, reorder, i);
|
||||
}
|
||||
|
||||
long[] indices() {
|
||||
return (long[])getPayload();
|
||||
public DoubleMaxShuffle(IntUnaryOperator fn) {
|
||||
super(VLENGTH, fn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public DoubleSpecies vspecies() {
|
||||
return VSPECIES;
|
||||
}
|
||||
|
@ -776,94 +786,40 @@ final class DoubleMaxVector extends DoubleVector {
|
|||
static {
|
||||
// There must be enough bits in the shuffle lanes to encode
|
||||
// VLENGTH valid indexes and VLENGTH exceptional ones.
|
||||
assert(VLENGTH < Long.MAX_VALUE);
|
||||
assert(Long.MIN_VALUE <= -VLENGTH);
|
||||
assert(VLENGTH < Byte.MAX_VALUE);
|
||||
assert(Byte.MIN_VALUE <= -VLENGTH);
|
||||
}
|
||||
static final DoubleMaxShuffle IOTA = new DoubleMaxShuffle(IDENTITY);
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
LongMaxVector toBitsVector() {
|
||||
return (LongMaxVector) super.toBitsVectorTemplate();
|
||||
public DoubleMaxVector toVector() {
|
||||
return VectorSupport.shuffleToVector(VCLASS, ETYPE, DoubleMaxShuffle.class, this, VLENGTH,
|
||||
(s) -> ((DoubleMaxVector)(((AbstractShuffle<Double>)(s)).toVectorTemplate())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
LongVector toBitsVector0() {
|
||||
return LongMaxVector.VSPECIES.dummyVector().vectorFactory(indices());
|
||||
public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
|
||||
AbstractSpecies<F> species = (AbstractSpecies<F>) s;
|
||||
if (length() != species.laneCount())
|
||||
throw new IllegalArgumentException("VectorShuffle length and species length differ");
|
||||
int[] shuffleArray = toArray();
|
||||
return s.shuffleFromArray(shuffleArray, 0).check(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public int laneSource(int i) {
|
||||
return (int)toBitsVector().lane(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoArray(int[] a, int offset) {
|
||||
switch (length()) {
|
||||
case 1 -> a[offset] = laneSource(0);
|
||||
case 2 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_64, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
case 4 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_128, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
case 8 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_256, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
case 16 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_512, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
default -> {
|
||||
VectorIntrinsics.checkFromIndexSize(offset, length(), a.length);
|
||||
for (int i = 0; i < length(); i++) {
|
||||
a[offset + i] = laneSource(i);
|
||||
}
|
||||
}
|
||||
public DoubleMaxShuffle rearrange(VectorShuffle<Double> shuffle) {
|
||||
DoubleMaxShuffle s = (DoubleMaxShuffle) shuffle;
|
||||
byte[] reorder1 = reorder();
|
||||
byte[] reorder2 = s.reorder();
|
||||
byte[] r = new byte[reorder1.length];
|
||||
for (int i = 0; i < reorder1.length; i++) {
|
||||
int ssi = reorder2[i];
|
||||
r[i] = reorder1[ssi]; // throws on exceptional index
|
||||
}
|
||||
}
|
||||
|
||||
private static long[] prepare(int[] indices, int offset) {
|
||||
long[] a = new long[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = indices[offset + i];
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (long)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static long[] prepare(IntUnaryOperator f) {
|
||||
long[] a = new long[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = f.applyAsInt(i);
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (long)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static boolean indicesInRange(long[] indices) {
|
||||
int length = indices.length;
|
||||
for (long si : indices) {
|
||||
if (si >= (long)length || si < (long)(-length)) {
|
||||
boolean assertsEnabled = false;
|
||||
assert(assertsEnabled = true);
|
||||
if (assertsEnabled) {
|
||||
String msg = ("index "+si+"out of range ["+length+"] in "+
|
||||
java.util.Arrays.toString(indices));
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return new DoubleMaxShuffle(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -953,7 +953,7 @@ public abstract class DoubleVector extends AbstractVector<Double> {
|
|||
// and broadcast, but it would be more surprising not to continue
|
||||
// the obvious pattern started by unary and binary.
|
||||
|
||||
/**
|
||||
/**
|
||||
* {@inheritDoc} <!--workaround-->
|
||||
* @see #lanewise(VectorOperators.Ternary,double,double,VectorMask)
|
||||
* @see #lanewise(VectorOperators.Ternary,Vector,double,VectorMask)
|
||||
|
@ -2322,8 +2322,8 @@ public abstract class DoubleVector extends AbstractVector<Double> {
|
|||
}
|
||||
|
||||
@ForceInline
|
||||
final <F>
|
||||
VectorShuffle<F> toShuffle0(AbstractSpecies<F> dsp) {
|
||||
private final
|
||||
VectorShuffle<Double> toShuffle0(DoubleSpecies dsp) {
|
||||
double[] a = toArray();
|
||||
int[] sa = new int[a.length];
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
|
@ -2332,6 +2332,18 @@ public abstract class DoubleVector extends AbstractVector<Double> {
|
|||
return VectorShuffle.fromArray(dsp, sa, 0);
|
||||
}
|
||||
|
||||
/*package-private*/
|
||||
@ForceInline
|
||||
final
|
||||
VectorShuffle<Double> toShuffleTemplate(Class<?> shuffleType) {
|
||||
DoubleSpecies vsp = vspecies();
|
||||
return VectorSupport.convert(VectorSupport.VECTOR_OP_CAST,
|
||||
getClass(), double.class, length(),
|
||||
shuffleType, byte.class, length(),
|
||||
this, vsp,
|
||||
DoubleVector::toShuffle0);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} <!--workaround-->
|
||||
* @since 19
|
||||
|
@ -3687,10 +3699,9 @@ public abstract class DoubleVector extends AbstractVector<Double> {
|
|||
private DoubleSpecies(VectorShape shape,
|
||||
Class<? extends DoubleVector> vectorType,
|
||||
Class<? extends AbstractMask<Double>> maskType,
|
||||
Class<? extends AbstractShuffle<Double>> shuffleType,
|
||||
Function<Object, DoubleVector> vectorFactory) {
|
||||
super(shape, LaneType.of(double.class),
|
||||
vectorType, maskType, shuffleType,
|
||||
vectorType, maskType,
|
||||
vectorFactory);
|
||||
assert(this.elementSize() == Double.SIZE);
|
||||
}
|
||||
|
@ -3966,7 +3977,6 @@ public abstract class DoubleVector extends AbstractVector<Double> {
|
|||
= new DoubleSpecies(VectorShape.S_64_BIT,
|
||||
Double64Vector.class,
|
||||
Double64Vector.Double64Mask.class,
|
||||
Double64Vector.Double64Shuffle.class,
|
||||
Double64Vector::new);
|
||||
|
||||
/** Species representing {@link DoubleVector}s of {@link VectorShape#S_128_BIT VectorShape.S_128_BIT}. */
|
||||
|
@ -3974,7 +3984,6 @@ public abstract class DoubleVector extends AbstractVector<Double> {
|
|||
= new DoubleSpecies(VectorShape.S_128_BIT,
|
||||
Double128Vector.class,
|
||||
Double128Vector.Double128Mask.class,
|
||||
Double128Vector.Double128Shuffle.class,
|
||||
Double128Vector::new);
|
||||
|
||||
/** Species representing {@link DoubleVector}s of {@link VectorShape#S_256_BIT VectorShape.S_256_BIT}. */
|
||||
|
@ -3982,7 +3991,6 @@ public abstract class DoubleVector extends AbstractVector<Double> {
|
|||
= new DoubleSpecies(VectorShape.S_256_BIT,
|
||||
Double256Vector.class,
|
||||
Double256Vector.Double256Mask.class,
|
||||
Double256Vector.Double256Shuffle.class,
|
||||
Double256Vector::new);
|
||||
|
||||
/** Species representing {@link DoubleVector}s of {@link VectorShape#S_512_BIT VectorShape.S_512_BIT}. */
|
||||
|
@ -3990,7 +3998,6 @@ public abstract class DoubleVector extends AbstractVector<Double> {
|
|||
= new DoubleSpecies(VectorShape.S_512_BIT,
|
||||
Double512Vector.class,
|
||||
Double512Vector.Double512Mask.class,
|
||||
Double512Vector.Double512Shuffle.class,
|
||||
Double512Vector::new);
|
||||
|
||||
/** Species representing {@link DoubleVector}s of {@link VectorShape#S_Max_BIT VectorShape.S_Max_BIT}. */
|
||||
|
@ -3998,7 +4005,6 @@ public abstract class DoubleVector extends AbstractVector<Double> {
|
|||
= new DoubleSpecies(VectorShape.S_Max_BIT,
|
||||
DoubleMaxVector.class,
|
||||
DoubleMaxVector.DoubleMaxMask.class,
|
||||
DoubleMaxVector.DoubleMaxShuffle.class,
|
||||
DoubleMaxVector::new);
|
||||
|
||||
/**
|
||||
|
|
|
@ -141,9 +141,24 @@ final class Float128Vector extends FloatVector {
|
|||
@ForceInline
|
||||
Float128Shuffle iotaShuffle() { return Float128Shuffle.IOTA; }
|
||||
|
||||
@ForceInline
|
||||
Float128Shuffle iotaShuffle(int start, int step, boolean wrap) {
|
||||
if (wrap) {
|
||||
return (Float128Shuffle)VectorSupport.shuffleIota(ETYPE, Float128Shuffle.class, VSPECIES, VLENGTH, start, step, 1,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
|
||||
} else {
|
||||
return (Float128Shuffle)VectorSupport.shuffleIota(ETYPE, Float128Shuffle.class, VSPECIES, VLENGTH, start, step, 0,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (i*lstep + lstart)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Float128Shuffle shuffleFromArray(int[] indices, int i) { return new Float128Shuffle(indices, i); }
|
||||
Float128Shuffle shuffleFromBytes(byte[] reorder) { return new Float128Shuffle(reorder); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Float128Shuffle shuffleFromArray(int[] indexes, int i) { return new Float128Shuffle(indexes, i); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
|
@ -329,11 +344,9 @@ final class Float128Vector extends FloatVector {
|
|||
return (long) super.reduceLanesTemplate(op, Float128Mask.class, (Float128Mask) m); // specialized
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final
|
||||
<F> VectorShuffle<F> toShuffle(AbstractSpecies<F> dsp) {
|
||||
return super.toShuffleTemplate(dsp);
|
||||
public VectorShuffle<Float> toShuffle() {
|
||||
return super.toShuffleTemplate(Float128Shuffle.class); // specialize
|
||||
}
|
||||
|
||||
// Specialized unary testing
|
||||
|
@ -754,28 +767,25 @@ final class Float128Vector extends FloatVector {
|
|||
|
||||
static final class Float128Shuffle extends AbstractShuffle<Float> {
|
||||
static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM
|
||||
static final Class<Integer> ETYPE = int.class; // used by the JVM
|
||||
static final Class<Float> ETYPE = float.class; // used by the JVM
|
||||
|
||||
Float128Shuffle(int[] indices) {
|
||||
super(indices);
|
||||
assert(VLENGTH == indices.length);
|
||||
assert(indicesInRange(indices));
|
||||
Float128Shuffle(byte[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Float128Shuffle(int[] indices, int i) {
|
||||
this(prepare(indices, i));
|
||||
public Float128Shuffle(int[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Float128Shuffle(IntUnaryOperator fn) {
|
||||
this(prepare(fn));
|
||||
public Float128Shuffle(int[] reorder, int i) {
|
||||
super(VLENGTH, reorder, i);
|
||||
}
|
||||
|
||||
int[] indices() {
|
||||
return (int[])getPayload();
|
||||
public Float128Shuffle(IntUnaryOperator fn) {
|
||||
super(VLENGTH, fn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public FloatSpecies vspecies() {
|
||||
return VSPECIES;
|
||||
}
|
||||
|
@ -783,70 +793,40 @@ final class Float128Vector extends FloatVector {
|
|||
static {
|
||||
// There must be enough bits in the shuffle lanes to encode
|
||||
// VLENGTH valid indexes and VLENGTH exceptional ones.
|
||||
assert(VLENGTH < Integer.MAX_VALUE);
|
||||
assert(Integer.MIN_VALUE <= -VLENGTH);
|
||||
assert(VLENGTH < Byte.MAX_VALUE);
|
||||
assert(Byte.MIN_VALUE <= -VLENGTH);
|
||||
}
|
||||
static final Float128Shuffle IOTA = new Float128Shuffle(IDENTITY);
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Int128Vector toBitsVector() {
|
||||
return (Int128Vector) super.toBitsVectorTemplate();
|
||||
public Float128Vector toVector() {
|
||||
return VectorSupport.shuffleToVector(VCLASS, ETYPE, Float128Shuffle.class, this, VLENGTH,
|
||||
(s) -> ((Float128Vector)(((AbstractShuffle<Float>)(s)).toVectorTemplate())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
IntVector toBitsVector0() {
|
||||
return Int128Vector.VSPECIES.dummyVector().vectorFactory(indices());
|
||||
public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
|
||||
AbstractSpecies<F> species = (AbstractSpecies<F>) s;
|
||||
if (length() != species.laneCount())
|
||||
throw new IllegalArgumentException("VectorShuffle length and species length differ");
|
||||
int[] shuffleArray = toArray();
|
||||
return s.shuffleFromArray(shuffleArray, 0).check(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public int laneSource(int i) {
|
||||
return (int)toBitsVector().lane(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoArray(int[] a, int offset) {
|
||||
toBitsVector().intoArray(a, offset);
|
||||
}
|
||||
|
||||
private static int[] prepare(int[] indices, int offset) {
|
||||
int[] a = new int[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = indices[offset + i];
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (int)si;
|
||||
public Float128Shuffle rearrange(VectorShuffle<Float> shuffle) {
|
||||
Float128Shuffle s = (Float128Shuffle) shuffle;
|
||||
byte[] reorder1 = reorder();
|
||||
byte[] reorder2 = s.reorder();
|
||||
byte[] r = new byte[reorder1.length];
|
||||
for (int i = 0; i < reorder1.length; i++) {
|
||||
int ssi = reorder2[i];
|
||||
r[i] = reorder1[ssi]; // throws on exceptional index
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static int[] prepare(IntUnaryOperator f) {
|
||||
int[] a = new int[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = f.applyAsInt(i);
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (int)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static boolean indicesInRange(int[] indices) {
|
||||
int length = indices.length;
|
||||
for (int si : indices) {
|
||||
if (si >= (int)length || si < (int)(-length)) {
|
||||
boolean assertsEnabled = false;
|
||||
assert(assertsEnabled = true);
|
||||
if (assertsEnabled) {
|
||||
String msg = ("index "+si+"out of range ["+length+"] in "+
|
||||
java.util.Arrays.toString(indices));
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return new Float128Shuffle(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -141,9 +141,24 @@ final class Float256Vector extends FloatVector {
|
|||
@ForceInline
|
||||
Float256Shuffle iotaShuffle() { return Float256Shuffle.IOTA; }
|
||||
|
||||
@ForceInline
|
||||
Float256Shuffle iotaShuffle(int start, int step, boolean wrap) {
|
||||
if (wrap) {
|
||||
return (Float256Shuffle)VectorSupport.shuffleIota(ETYPE, Float256Shuffle.class, VSPECIES, VLENGTH, start, step, 1,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
|
||||
} else {
|
||||
return (Float256Shuffle)VectorSupport.shuffleIota(ETYPE, Float256Shuffle.class, VSPECIES, VLENGTH, start, step, 0,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (i*lstep + lstart)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Float256Shuffle shuffleFromArray(int[] indices, int i) { return new Float256Shuffle(indices, i); }
|
||||
Float256Shuffle shuffleFromBytes(byte[] reorder) { return new Float256Shuffle(reorder); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Float256Shuffle shuffleFromArray(int[] indexes, int i) { return new Float256Shuffle(indexes, i); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
|
@ -329,11 +344,9 @@ final class Float256Vector extends FloatVector {
|
|||
return (long) super.reduceLanesTemplate(op, Float256Mask.class, (Float256Mask) m); // specialized
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final
|
||||
<F> VectorShuffle<F> toShuffle(AbstractSpecies<F> dsp) {
|
||||
return super.toShuffleTemplate(dsp);
|
||||
public VectorShuffle<Float> toShuffle() {
|
||||
return super.toShuffleTemplate(Float256Shuffle.class); // specialize
|
||||
}
|
||||
|
||||
// Specialized unary testing
|
||||
|
@ -762,28 +775,25 @@ final class Float256Vector extends FloatVector {
|
|||
|
||||
static final class Float256Shuffle extends AbstractShuffle<Float> {
|
||||
static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM
|
||||
static final Class<Integer> ETYPE = int.class; // used by the JVM
|
||||
static final Class<Float> ETYPE = float.class; // used by the JVM
|
||||
|
||||
Float256Shuffle(int[] indices) {
|
||||
super(indices);
|
||||
assert(VLENGTH == indices.length);
|
||||
assert(indicesInRange(indices));
|
||||
Float256Shuffle(byte[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Float256Shuffle(int[] indices, int i) {
|
||||
this(prepare(indices, i));
|
||||
public Float256Shuffle(int[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Float256Shuffle(IntUnaryOperator fn) {
|
||||
this(prepare(fn));
|
||||
public Float256Shuffle(int[] reorder, int i) {
|
||||
super(VLENGTH, reorder, i);
|
||||
}
|
||||
|
||||
int[] indices() {
|
||||
return (int[])getPayload();
|
||||
public Float256Shuffle(IntUnaryOperator fn) {
|
||||
super(VLENGTH, fn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public FloatSpecies vspecies() {
|
||||
return VSPECIES;
|
||||
}
|
||||
|
@ -791,70 +801,40 @@ final class Float256Vector extends FloatVector {
|
|||
static {
|
||||
// There must be enough bits in the shuffle lanes to encode
|
||||
// VLENGTH valid indexes and VLENGTH exceptional ones.
|
||||
assert(VLENGTH < Integer.MAX_VALUE);
|
||||
assert(Integer.MIN_VALUE <= -VLENGTH);
|
||||
assert(VLENGTH < Byte.MAX_VALUE);
|
||||
assert(Byte.MIN_VALUE <= -VLENGTH);
|
||||
}
|
||||
static final Float256Shuffle IOTA = new Float256Shuffle(IDENTITY);
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Int256Vector toBitsVector() {
|
||||
return (Int256Vector) super.toBitsVectorTemplate();
|
||||
public Float256Vector toVector() {
|
||||
return VectorSupport.shuffleToVector(VCLASS, ETYPE, Float256Shuffle.class, this, VLENGTH,
|
||||
(s) -> ((Float256Vector)(((AbstractShuffle<Float>)(s)).toVectorTemplate())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
IntVector toBitsVector0() {
|
||||
return Int256Vector.VSPECIES.dummyVector().vectorFactory(indices());
|
||||
public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
|
||||
AbstractSpecies<F> species = (AbstractSpecies<F>) s;
|
||||
if (length() != species.laneCount())
|
||||
throw new IllegalArgumentException("VectorShuffle length and species length differ");
|
||||
int[] shuffleArray = toArray();
|
||||
return s.shuffleFromArray(shuffleArray, 0).check(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public int laneSource(int i) {
|
||||
return (int)toBitsVector().lane(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoArray(int[] a, int offset) {
|
||||
toBitsVector().intoArray(a, offset);
|
||||
}
|
||||
|
||||
private static int[] prepare(int[] indices, int offset) {
|
||||
int[] a = new int[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = indices[offset + i];
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (int)si;
|
||||
public Float256Shuffle rearrange(VectorShuffle<Float> shuffle) {
|
||||
Float256Shuffle s = (Float256Shuffle) shuffle;
|
||||
byte[] reorder1 = reorder();
|
||||
byte[] reorder2 = s.reorder();
|
||||
byte[] r = new byte[reorder1.length];
|
||||
for (int i = 0; i < reorder1.length; i++) {
|
||||
int ssi = reorder2[i];
|
||||
r[i] = reorder1[ssi]; // throws on exceptional index
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static int[] prepare(IntUnaryOperator f) {
|
||||
int[] a = new int[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = f.applyAsInt(i);
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (int)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static boolean indicesInRange(int[] indices) {
|
||||
int length = indices.length;
|
||||
for (int si : indices) {
|
||||
if (si >= (int)length || si < (int)(-length)) {
|
||||
boolean assertsEnabled = false;
|
||||
assert(assertsEnabled = true);
|
||||
if (assertsEnabled) {
|
||||
String msg = ("index "+si+"out of range ["+length+"] in "+
|
||||
java.util.Arrays.toString(indices));
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return new Float256Shuffle(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -141,9 +141,24 @@ final class Float512Vector extends FloatVector {
|
|||
@ForceInline
|
||||
Float512Shuffle iotaShuffle() { return Float512Shuffle.IOTA; }
|
||||
|
||||
@ForceInline
|
||||
Float512Shuffle iotaShuffle(int start, int step, boolean wrap) {
|
||||
if (wrap) {
|
||||
return (Float512Shuffle)VectorSupport.shuffleIota(ETYPE, Float512Shuffle.class, VSPECIES, VLENGTH, start, step, 1,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
|
||||
} else {
|
||||
return (Float512Shuffle)VectorSupport.shuffleIota(ETYPE, Float512Shuffle.class, VSPECIES, VLENGTH, start, step, 0,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (i*lstep + lstart)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Float512Shuffle shuffleFromArray(int[] indices, int i) { return new Float512Shuffle(indices, i); }
|
||||
Float512Shuffle shuffleFromBytes(byte[] reorder) { return new Float512Shuffle(reorder); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Float512Shuffle shuffleFromArray(int[] indexes, int i) { return new Float512Shuffle(indexes, i); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
|
@ -329,11 +344,9 @@ final class Float512Vector extends FloatVector {
|
|||
return (long) super.reduceLanesTemplate(op, Float512Mask.class, (Float512Mask) m); // specialized
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final
|
||||
<F> VectorShuffle<F> toShuffle(AbstractSpecies<F> dsp) {
|
||||
return super.toShuffleTemplate(dsp);
|
||||
public VectorShuffle<Float> toShuffle() {
|
||||
return super.toShuffleTemplate(Float512Shuffle.class); // specialize
|
||||
}
|
||||
|
||||
// Specialized unary testing
|
||||
|
@ -778,28 +791,25 @@ final class Float512Vector extends FloatVector {
|
|||
|
||||
static final class Float512Shuffle extends AbstractShuffle<Float> {
|
||||
static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM
|
||||
static final Class<Integer> ETYPE = int.class; // used by the JVM
|
||||
static final Class<Float> ETYPE = float.class; // used by the JVM
|
||||
|
||||
Float512Shuffle(int[] indices) {
|
||||
super(indices);
|
||||
assert(VLENGTH == indices.length);
|
||||
assert(indicesInRange(indices));
|
||||
Float512Shuffle(byte[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Float512Shuffle(int[] indices, int i) {
|
||||
this(prepare(indices, i));
|
||||
public Float512Shuffle(int[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Float512Shuffle(IntUnaryOperator fn) {
|
||||
this(prepare(fn));
|
||||
public Float512Shuffle(int[] reorder, int i) {
|
||||
super(VLENGTH, reorder, i);
|
||||
}
|
||||
|
||||
int[] indices() {
|
||||
return (int[])getPayload();
|
||||
public Float512Shuffle(IntUnaryOperator fn) {
|
||||
super(VLENGTH, fn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public FloatSpecies vspecies() {
|
||||
return VSPECIES;
|
||||
}
|
||||
|
@ -807,70 +817,40 @@ final class Float512Vector extends FloatVector {
|
|||
static {
|
||||
// There must be enough bits in the shuffle lanes to encode
|
||||
// VLENGTH valid indexes and VLENGTH exceptional ones.
|
||||
assert(VLENGTH < Integer.MAX_VALUE);
|
||||
assert(Integer.MIN_VALUE <= -VLENGTH);
|
||||
assert(VLENGTH < Byte.MAX_VALUE);
|
||||
assert(Byte.MIN_VALUE <= -VLENGTH);
|
||||
}
|
||||
static final Float512Shuffle IOTA = new Float512Shuffle(IDENTITY);
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Int512Vector toBitsVector() {
|
||||
return (Int512Vector) super.toBitsVectorTemplate();
|
||||
public Float512Vector toVector() {
|
||||
return VectorSupport.shuffleToVector(VCLASS, ETYPE, Float512Shuffle.class, this, VLENGTH,
|
||||
(s) -> ((Float512Vector)(((AbstractShuffle<Float>)(s)).toVectorTemplate())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
IntVector toBitsVector0() {
|
||||
return Int512Vector.VSPECIES.dummyVector().vectorFactory(indices());
|
||||
public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
|
||||
AbstractSpecies<F> species = (AbstractSpecies<F>) s;
|
||||
if (length() != species.laneCount())
|
||||
throw new IllegalArgumentException("VectorShuffle length and species length differ");
|
||||
int[] shuffleArray = toArray();
|
||||
return s.shuffleFromArray(shuffleArray, 0).check(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public int laneSource(int i) {
|
||||
return (int)toBitsVector().lane(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoArray(int[] a, int offset) {
|
||||
toBitsVector().intoArray(a, offset);
|
||||
}
|
||||
|
||||
private static int[] prepare(int[] indices, int offset) {
|
||||
int[] a = new int[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = indices[offset + i];
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (int)si;
|
||||
public Float512Shuffle rearrange(VectorShuffle<Float> shuffle) {
|
||||
Float512Shuffle s = (Float512Shuffle) shuffle;
|
||||
byte[] reorder1 = reorder();
|
||||
byte[] reorder2 = s.reorder();
|
||||
byte[] r = new byte[reorder1.length];
|
||||
for (int i = 0; i < reorder1.length; i++) {
|
||||
int ssi = reorder2[i];
|
||||
r[i] = reorder1[ssi]; // throws on exceptional index
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static int[] prepare(IntUnaryOperator f) {
|
||||
int[] a = new int[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = f.applyAsInt(i);
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (int)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static boolean indicesInRange(int[] indices) {
|
||||
int length = indices.length;
|
||||
for (int si : indices) {
|
||||
if (si >= (int)length || si < (int)(-length)) {
|
||||
boolean assertsEnabled = false;
|
||||
assert(assertsEnabled = true);
|
||||
if (assertsEnabled) {
|
||||
String msg = ("index "+si+"out of range ["+length+"] in "+
|
||||
java.util.Arrays.toString(indices));
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return new Float512Shuffle(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -141,9 +141,24 @@ final class Float64Vector extends FloatVector {
|
|||
@ForceInline
|
||||
Float64Shuffle iotaShuffle() { return Float64Shuffle.IOTA; }
|
||||
|
||||
@ForceInline
|
||||
Float64Shuffle iotaShuffle(int start, int step, boolean wrap) {
|
||||
if (wrap) {
|
||||
return (Float64Shuffle)VectorSupport.shuffleIota(ETYPE, Float64Shuffle.class, VSPECIES, VLENGTH, start, step, 1,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
|
||||
} else {
|
||||
return (Float64Shuffle)VectorSupport.shuffleIota(ETYPE, Float64Shuffle.class, VSPECIES, VLENGTH, start, step, 0,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (i*lstep + lstart)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Float64Shuffle shuffleFromArray(int[] indices, int i) { return new Float64Shuffle(indices, i); }
|
||||
Float64Shuffle shuffleFromBytes(byte[] reorder) { return new Float64Shuffle(reorder); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Float64Shuffle shuffleFromArray(int[] indexes, int i) { return new Float64Shuffle(indexes, i); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
|
@ -329,11 +344,9 @@ final class Float64Vector extends FloatVector {
|
|||
return (long) super.reduceLanesTemplate(op, Float64Mask.class, (Float64Mask) m); // specialized
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final
|
||||
<F> VectorShuffle<F> toShuffle(AbstractSpecies<F> dsp) {
|
||||
return super.toShuffleTemplate(dsp);
|
||||
public VectorShuffle<Float> toShuffle() {
|
||||
return super.toShuffleTemplate(Float64Shuffle.class); // specialize
|
||||
}
|
||||
|
||||
// Specialized unary testing
|
||||
|
@ -750,28 +763,25 @@ final class Float64Vector extends FloatVector {
|
|||
|
||||
static final class Float64Shuffle extends AbstractShuffle<Float> {
|
||||
static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM
|
||||
static final Class<Integer> ETYPE = int.class; // used by the JVM
|
||||
static final Class<Float> ETYPE = float.class; // used by the JVM
|
||||
|
||||
Float64Shuffle(int[] indices) {
|
||||
super(indices);
|
||||
assert(VLENGTH == indices.length);
|
||||
assert(indicesInRange(indices));
|
||||
Float64Shuffle(byte[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Float64Shuffle(int[] indices, int i) {
|
||||
this(prepare(indices, i));
|
||||
public Float64Shuffle(int[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Float64Shuffle(IntUnaryOperator fn) {
|
||||
this(prepare(fn));
|
||||
public Float64Shuffle(int[] reorder, int i) {
|
||||
super(VLENGTH, reorder, i);
|
||||
}
|
||||
|
||||
int[] indices() {
|
||||
return (int[])getPayload();
|
||||
public Float64Shuffle(IntUnaryOperator fn) {
|
||||
super(VLENGTH, fn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public FloatSpecies vspecies() {
|
||||
return VSPECIES;
|
||||
}
|
||||
|
@ -779,70 +789,40 @@ final class Float64Vector extends FloatVector {
|
|||
static {
|
||||
// There must be enough bits in the shuffle lanes to encode
|
||||
// VLENGTH valid indexes and VLENGTH exceptional ones.
|
||||
assert(VLENGTH < Integer.MAX_VALUE);
|
||||
assert(Integer.MIN_VALUE <= -VLENGTH);
|
||||
assert(VLENGTH < Byte.MAX_VALUE);
|
||||
assert(Byte.MIN_VALUE <= -VLENGTH);
|
||||
}
|
||||
static final Float64Shuffle IOTA = new Float64Shuffle(IDENTITY);
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Int64Vector toBitsVector() {
|
||||
return (Int64Vector) super.toBitsVectorTemplate();
|
||||
public Float64Vector toVector() {
|
||||
return VectorSupport.shuffleToVector(VCLASS, ETYPE, Float64Shuffle.class, this, VLENGTH,
|
||||
(s) -> ((Float64Vector)(((AbstractShuffle<Float>)(s)).toVectorTemplate())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
IntVector toBitsVector0() {
|
||||
return Int64Vector.VSPECIES.dummyVector().vectorFactory(indices());
|
||||
public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
|
||||
AbstractSpecies<F> species = (AbstractSpecies<F>) s;
|
||||
if (length() != species.laneCount())
|
||||
throw new IllegalArgumentException("VectorShuffle length and species length differ");
|
||||
int[] shuffleArray = toArray();
|
||||
return s.shuffleFromArray(shuffleArray, 0).check(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public int laneSource(int i) {
|
||||
return (int)toBitsVector().lane(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoArray(int[] a, int offset) {
|
||||
toBitsVector().intoArray(a, offset);
|
||||
}
|
||||
|
||||
private static int[] prepare(int[] indices, int offset) {
|
||||
int[] a = new int[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = indices[offset + i];
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (int)si;
|
||||
public Float64Shuffle rearrange(VectorShuffle<Float> shuffle) {
|
||||
Float64Shuffle s = (Float64Shuffle) shuffle;
|
||||
byte[] reorder1 = reorder();
|
||||
byte[] reorder2 = s.reorder();
|
||||
byte[] r = new byte[reorder1.length];
|
||||
for (int i = 0; i < reorder1.length; i++) {
|
||||
int ssi = reorder2[i];
|
||||
r[i] = reorder1[ssi]; // throws on exceptional index
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static int[] prepare(IntUnaryOperator f) {
|
||||
int[] a = new int[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = f.applyAsInt(i);
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (int)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static boolean indicesInRange(int[] indices) {
|
||||
int length = indices.length;
|
||||
for (int si : indices) {
|
||||
if (si >= (int)length || si < (int)(-length)) {
|
||||
boolean assertsEnabled = false;
|
||||
assert(assertsEnabled = true);
|
||||
if (assertsEnabled) {
|
||||
String msg = ("index "+si+"out of range ["+length+"] in "+
|
||||
java.util.Arrays.toString(indices));
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return new Float64Shuffle(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -141,9 +141,24 @@ final class FloatMaxVector extends FloatVector {
|
|||
@ForceInline
|
||||
FloatMaxShuffle iotaShuffle() { return FloatMaxShuffle.IOTA; }
|
||||
|
||||
@ForceInline
|
||||
FloatMaxShuffle iotaShuffle(int start, int step, boolean wrap) {
|
||||
if (wrap) {
|
||||
return (FloatMaxShuffle)VectorSupport.shuffleIota(ETYPE, FloatMaxShuffle.class, VSPECIES, VLENGTH, start, step, 1,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
|
||||
} else {
|
||||
return (FloatMaxShuffle)VectorSupport.shuffleIota(ETYPE, FloatMaxShuffle.class, VSPECIES, VLENGTH, start, step, 0,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (i*lstep + lstart)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
FloatMaxShuffle shuffleFromArray(int[] indices, int i) { return new FloatMaxShuffle(indices, i); }
|
||||
FloatMaxShuffle shuffleFromBytes(byte[] reorder) { return new FloatMaxShuffle(reorder); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
FloatMaxShuffle shuffleFromArray(int[] indexes, int i) { return new FloatMaxShuffle(indexes, i); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
|
@ -329,11 +344,9 @@ final class FloatMaxVector extends FloatVector {
|
|||
return (long) super.reduceLanesTemplate(op, FloatMaxMask.class, (FloatMaxMask) m); // specialized
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final
|
||||
<F> VectorShuffle<F> toShuffle(AbstractSpecies<F> dsp) {
|
||||
return super.toShuffleTemplate(dsp);
|
||||
public VectorShuffle<Float> toShuffle() {
|
||||
return super.toShuffleTemplate(FloatMaxShuffle.class); // specialize
|
||||
}
|
||||
|
||||
// Specialized unary testing
|
||||
|
@ -747,28 +760,25 @@ final class FloatMaxVector extends FloatVector {
|
|||
|
||||
static final class FloatMaxShuffle extends AbstractShuffle<Float> {
|
||||
static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM
|
||||
static final Class<Integer> ETYPE = int.class; // used by the JVM
|
||||
static final Class<Float> ETYPE = float.class; // used by the JVM
|
||||
|
||||
FloatMaxShuffle(int[] indices) {
|
||||
super(indices);
|
||||
assert(VLENGTH == indices.length);
|
||||
assert(indicesInRange(indices));
|
||||
FloatMaxShuffle(byte[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
FloatMaxShuffle(int[] indices, int i) {
|
||||
this(prepare(indices, i));
|
||||
public FloatMaxShuffle(int[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
FloatMaxShuffle(IntUnaryOperator fn) {
|
||||
this(prepare(fn));
|
||||
public FloatMaxShuffle(int[] reorder, int i) {
|
||||
super(VLENGTH, reorder, i);
|
||||
}
|
||||
|
||||
int[] indices() {
|
||||
return (int[])getPayload();
|
||||
public FloatMaxShuffle(IntUnaryOperator fn) {
|
||||
super(VLENGTH, fn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public FloatSpecies vspecies() {
|
||||
return VSPECIES;
|
||||
}
|
||||
|
@ -776,70 +786,40 @@ final class FloatMaxVector extends FloatVector {
|
|||
static {
|
||||
// There must be enough bits in the shuffle lanes to encode
|
||||
// VLENGTH valid indexes and VLENGTH exceptional ones.
|
||||
assert(VLENGTH < Integer.MAX_VALUE);
|
||||
assert(Integer.MIN_VALUE <= -VLENGTH);
|
||||
assert(VLENGTH < Byte.MAX_VALUE);
|
||||
assert(Byte.MIN_VALUE <= -VLENGTH);
|
||||
}
|
||||
static final FloatMaxShuffle IOTA = new FloatMaxShuffle(IDENTITY);
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
IntMaxVector toBitsVector() {
|
||||
return (IntMaxVector) super.toBitsVectorTemplate();
|
||||
public FloatMaxVector toVector() {
|
||||
return VectorSupport.shuffleToVector(VCLASS, ETYPE, FloatMaxShuffle.class, this, VLENGTH,
|
||||
(s) -> ((FloatMaxVector)(((AbstractShuffle<Float>)(s)).toVectorTemplate())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
IntVector toBitsVector0() {
|
||||
return IntMaxVector.VSPECIES.dummyVector().vectorFactory(indices());
|
||||
public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
|
||||
AbstractSpecies<F> species = (AbstractSpecies<F>) s;
|
||||
if (length() != species.laneCount())
|
||||
throw new IllegalArgumentException("VectorShuffle length and species length differ");
|
||||
int[] shuffleArray = toArray();
|
||||
return s.shuffleFromArray(shuffleArray, 0).check(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public int laneSource(int i) {
|
||||
return (int)toBitsVector().lane(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoArray(int[] a, int offset) {
|
||||
toBitsVector().intoArray(a, offset);
|
||||
}
|
||||
|
||||
private static int[] prepare(int[] indices, int offset) {
|
||||
int[] a = new int[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = indices[offset + i];
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (int)si;
|
||||
public FloatMaxShuffle rearrange(VectorShuffle<Float> shuffle) {
|
||||
FloatMaxShuffle s = (FloatMaxShuffle) shuffle;
|
||||
byte[] reorder1 = reorder();
|
||||
byte[] reorder2 = s.reorder();
|
||||
byte[] r = new byte[reorder1.length];
|
||||
for (int i = 0; i < reorder1.length; i++) {
|
||||
int ssi = reorder2[i];
|
||||
r[i] = reorder1[ssi]; // throws on exceptional index
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static int[] prepare(IntUnaryOperator f) {
|
||||
int[] a = new int[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = f.applyAsInt(i);
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (int)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static boolean indicesInRange(int[] indices) {
|
||||
int length = indices.length;
|
||||
for (int si : indices) {
|
||||
if (si >= (int)length || si < (int)(-length)) {
|
||||
boolean assertsEnabled = false;
|
||||
assert(assertsEnabled = true);
|
||||
if (assertsEnabled) {
|
||||
String msg = ("index "+si+"out of range ["+length+"] in "+
|
||||
java.util.Arrays.toString(indices));
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return new FloatMaxShuffle(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -953,7 +953,7 @@ public abstract class FloatVector extends AbstractVector<Float> {
|
|||
// and broadcast, but it would be more surprising not to continue
|
||||
// the obvious pattern started by unary and binary.
|
||||
|
||||
/**
|
||||
/**
|
||||
* {@inheritDoc} <!--workaround-->
|
||||
* @see #lanewise(VectorOperators.Ternary,float,float,VectorMask)
|
||||
* @see #lanewise(VectorOperators.Ternary,Vector,float,VectorMask)
|
||||
|
@ -2334,8 +2334,8 @@ public abstract class FloatVector extends AbstractVector<Float> {
|
|||
}
|
||||
|
||||
@ForceInline
|
||||
final <F>
|
||||
VectorShuffle<F> toShuffle0(AbstractSpecies<F> dsp) {
|
||||
private final
|
||||
VectorShuffle<Float> toShuffle0(FloatSpecies dsp) {
|
||||
float[] a = toArray();
|
||||
int[] sa = new int[a.length];
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
|
@ -2344,6 +2344,18 @@ public abstract class FloatVector extends AbstractVector<Float> {
|
|||
return VectorShuffle.fromArray(dsp, sa, 0);
|
||||
}
|
||||
|
||||
/*package-private*/
|
||||
@ForceInline
|
||||
final
|
||||
VectorShuffle<Float> toShuffleTemplate(Class<?> shuffleType) {
|
||||
FloatSpecies vsp = vspecies();
|
||||
return VectorSupport.convert(VectorSupport.VECTOR_OP_CAST,
|
||||
getClass(), float.class, length(),
|
||||
shuffleType, byte.class, length(),
|
||||
this, vsp,
|
||||
FloatVector::toShuffle0);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} <!--workaround-->
|
||||
* @since 19
|
||||
|
@ -3637,10 +3649,9 @@ public abstract class FloatVector extends AbstractVector<Float> {
|
|||
private FloatSpecies(VectorShape shape,
|
||||
Class<? extends FloatVector> vectorType,
|
||||
Class<? extends AbstractMask<Float>> maskType,
|
||||
Class<? extends AbstractShuffle<Float>> shuffleType,
|
||||
Function<Object, FloatVector> vectorFactory) {
|
||||
super(shape, LaneType.of(float.class),
|
||||
vectorType, maskType, shuffleType,
|
||||
vectorType, maskType,
|
||||
vectorFactory);
|
||||
assert(this.elementSize() == Float.SIZE);
|
||||
}
|
||||
|
@ -3916,7 +3927,6 @@ public abstract class FloatVector extends AbstractVector<Float> {
|
|||
= new FloatSpecies(VectorShape.S_64_BIT,
|
||||
Float64Vector.class,
|
||||
Float64Vector.Float64Mask.class,
|
||||
Float64Vector.Float64Shuffle.class,
|
||||
Float64Vector::new);
|
||||
|
||||
/** Species representing {@link FloatVector}s of {@link VectorShape#S_128_BIT VectorShape.S_128_BIT}. */
|
||||
|
@ -3924,7 +3934,6 @@ public abstract class FloatVector extends AbstractVector<Float> {
|
|||
= new FloatSpecies(VectorShape.S_128_BIT,
|
||||
Float128Vector.class,
|
||||
Float128Vector.Float128Mask.class,
|
||||
Float128Vector.Float128Shuffle.class,
|
||||
Float128Vector::new);
|
||||
|
||||
/** Species representing {@link FloatVector}s of {@link VectorShape#S_256_BIT VectorShape.S_256_BIT}. */
|
||||
|
@ -3932,7 +3941,6 @@ public abstract class FloatVector extends AbstractVector<Float> {
|
|||
= new FloatSpecies(VectorShape.S_256_BIT,
|
||||
Float256Vector.class,
|
||||
Float256Vector.Float256Mask.class,
|
||||
Float256Vector.Float256Shuffle.class,
|
||||
Float256Vector::new);
|
||||
|
||||
/** Species representing {@link FloatVector}s of {@link VectorShape#S_512_BIT VectorShape.S_512_BIT}. */
|
||||
|
@ -3940,7 +3948,6 @@ public abstract class FloatVector extends AbstractVector<Float> {
|
|||
= new FloatSpecies(VectorShape.S_512_BIT,
|
||||
Float512Vector.class,
|
||||
Float512Vector.Float512Mask.class,
|
||||
Float512Vector.Float512Shuffle.class,
|
||||
Float512Vector::new);
|
||||
|
||||
/** Species representing {@link FloatVector}s of {@link VectorShape#S_Max_BIT VectorShape.S_Max_BIT}. */
|
||||
|
@ -3948,7 +3955,6 @@ public abstract class FloatVector extends AbstractVector<Float> {
|
|||
= new FloatSpecies(VectorShape.S_Max_BIT,
|
||||
FloatMaxVector.class,
|
||||
FloatMaxVector.FloatMaxMask.class,
|
||||
FloatMaxVector.FloatMaxShuffle.class,
|
||||
FloatMaxVector::new);
|
||||
|
||||
/**
|
||||
|
|
|
@ -141,9 +141,24 @@ final class Int128Vector extends IntVector {
|
|||
@ForceInline
|
||||
Int128Shuffle iotaShuffle() { return Int128Shuffle.IOTA; }
|
||||
|
||||
@ForceInline
|
||||
Int128Shuffle iotaShuffle(int start, int step, boolean wrap) {
|
||||
if (wrap) {
|
||||
return (Int128Shuffle)VectorSupport.shuffleIota(ETYPE, Int128Shuffle.class, VSPECIES, VLENGTH, start, step, 1,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
|
||||
} else {
|
||||
return (Int128Shuffle)VectorSupport.shuffleIota(ETYPE, Int128Shuffle.class, VSPECIES, VLENGTH, start, step, 0,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (i*lstep + lstart)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Int128Shuffle shuffleFromArray(int[] indices, int i) { return new Int128Shuffle(indices, i); }
|
||||
Int128Shuffle shuffleFromBytes(byte[] reorder) { return new Int128Shuffle(reorder); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Int128Shuffle shuffleFromArray(int[] indexes, int i) { return new Int128Shuffle(indexes, i); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
|
@ -342,11 +357,9 @@ final class Int128Vector extends IntVector {
|
|||
return (long) super.reduceLanesTemplate(op, Int128Mask.class, (Int128Mask) m); // specialized
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final
|
||||
<F> VectorShuffle<F> toShuffle(AbstractSpecies<F> dsp) {
|
||||
return super.toShuffleTemplate(dsp);
|
||||
public VectorShuffle<Integer> toShuffle() {
|
||||
return super.toShuffleTemplate(Int128Shuffle.class); // specialize
|
||||
}
|
||||
|
||||
// Specialized unary testing
|
||||
|
@ -767,26 +780,23 @@ final class Int128Vector extends IntVector {
|
|||
static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM
|
||||
static final Class<Integer> ETYPE = int.class; // used by the JVM
|
||||
|
||||
Int128Shuffle(int[] indices) {
|
||||
super(indices);
|
||||
assert(VLENGTH == indices.length);
|
||||
assert(indicesInRange(indices));
|
||||
Int128Shuffle(byte[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Int128Shuffle(int[] indices, int i) {
|
||||
this(prepare(indices, i));
|
||||
public Int128Shuffle(int[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Int128Shuffle(IntUnaryOperator fn) {
|
||||
this(prepare(fn));
|
||||
public Int128Shuffle(int[] reorder, int i) {
|
||||
super(VLENGTH, reorder, i);
|
||||
}
|
||||
|
||||
int[] indices() {
|
||||
return (int[])getPayload();
|
||||
public Int128Shuffle(IntUnaryOperator fn) {
|
||||
super(VLENGTH, fn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public IntSpecies vspecies() {
|
||||
return VSPECIES;
|
||||
}
|
||||
|
@ -794,70 +804,40 @@ final class Int128Vector extends IntVector {
|
|||
static {
|
||||
// There must be enough bits in the shuffle lanes to encode
|
||||
// VLENGTH valid indexes and VLENGTH exceptional ones.
|
||||
assert(VLENGTH < Integer.MAX_VALUE);
|
||||
assert(Integer.MIN_VALUE <= -VLENGTH);
|
||||
assert(VLENGTH < Byte.MAX_VALUE);
|
||||
assert(Byte.MIN_VALUE <= -VLENGTH);
|
||||
}
|
||||
static final Int128Shuffle IOTA = new Int128Shuffle(IDENTITY);
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Int128Vector toBitsVector() {
|
||||
return (Int128Vector) super.toBitsVectorTemplate();
|
||||
public Int128Vector toVector() {
|
||||
return VectorSupport.shuffleToVector(VCLASS, ETYPE, Int128Shuffle.class, this, VLENGTH,
|
||||
(s) -> ((Int128Vector)(((AbstractShuffle<Integer>)(s)).toVectorTemplate())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
IntVector toBitsVector0() {
|
||||
return Int128Vector.VSPECIES.dummyVector().vectorFactory(indices());
|
||||
public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
|
||||
AbstractSpecies<F> species = (AbstractSpecies<F>) s;
|
||||
if (length() != species.laneCount())
|
||||
throw new IllegalArgumentException("VectorShuffle length and species length differ");
|
||||
int[] shuffleArray = toArray();
|
||||
return s.shuffleFromArray(shuffleArray, 0).check(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public int laneSource(int i) {
|
||||
return (int)toBitsVector().lane(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoArray(int[] a, int offset) {
|
||||
toBitsVector().intoArray(a, offset);
|
||||
}
|
||||
|
||||
private static int[] prepare(int[] indices, int offset) {
|
||||
int[] a = new int[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = indices[offset + i];
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (int)si;
|
||||
public Int128Shuffle rearrange(VectorShuffle<Integer> shuffle) {
|
||||
Int128Shuffle s = (Int128Shuffle) shuffle;
|
||||
byte[] reorder1 = reorder();
|
||||
byte[] reorder2 = s.reorder();
|
||||
byte[] r = new byte[reorder1.length];
|
||||
for (int i = 0; i < reorder1.length; i++) {
|
||||
int ssi = reorder2[i];
|
||||
r[i] = reorder1[ssi]; // throws on exceptional index
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static int[] prepare(IntUnaryOperator f) {
|
||||
int[] a = new int[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = f.applyAsInt(i);
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (int)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static boolean indicesInRange(int[] indices) {
|
||||
int length = indices.length;
|
||||
for (int si : indices) {
|
||||
if (si >= (int)length || si < (int)(-length)) {
|
||||
boolean assertsEnabled = false;
|
||||
assert(assertsEnabled = true);
|
||||
if (assertsEnabled) {
|
||||
String msg = ("index "+si+"out of range ["+length+"] in "+
|
||||
java.util.Arrays.toString(indices));
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return new Int128Shuffle(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -141,9 +141,24 @@ final class Int256Vector extends IntVector {
|
|||
@ForceInline
|
||||
Int256Shuffle iotaShuffle() { return Int256Shuffle.IOTA; }
|
||||
|
||||
@ForceInline
|
||||
Int256Shuffle iotaShuffle(int start, int step, boolean wrap) {
|
||||
if (wrap) {
|
||||
return (Int256Shuffle)VectorSupport.shuffleIota(ETYPE, Int256Shuffle.class, VSPECIES, VLENGTH, start, step, 1,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
|
||||
} else {
|
||||
return (Int256Shuffle)VectorSupport.shuffleIota(ETYPE, Int256Shuffle.class, VSPECIES, VLENGTH, start, step, 0,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (i*lstep + lstart)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Int256Shuffle shuffleFromArray(int[] indices, int i) { return new Int256Shuffle(indices, i); }
|
||||
Int256Shuffle shuffleFromBytes(byte[] reorder) { return new Int256Shuffle(reorder); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Int256Shuffle shuffleFromArray(int[] indexes, int i) { return new Int256Shuffle(indexes, i); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
|
@ -342,11 +357,9 @@ final class Int256Vector extends IntVector {
|
|||
return (long) super.reduceLanesTemplate(op, Int256Mask.class, (Int256Mask) m); // specialized
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final
|
||||
<F> VectorShuffle<F> toShuffle(AbstractSpecies<F> dsp) {
|
||||
return super.toShuffleTemplate(dsp);
|
||||
public VectorShuffle<Integer> toShuffle() {
|
||||
return super.toShuffleTemplate(Int256Shuffle.class); // specialize
|
||||
}
|
||||
|
||||
// Specialized unary testing
|
||||
|
@ -775,26 +788,23 @@ final class Int256Vector extends IntVector {
|
|||
static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM
|
||||
static final Class<Integer> ETYPE = int.class; // used by the JVM
|
||||
|
||||
Int256Shuffle(int[] indices) {
|
||||
super(indices);
|
||||
assert(VLENGTH == indices.length);
|
||||
assert(indicesInRange(indices));
|
||||
Int256Shuffle(byte[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Int256Shuffle(int[] indices, int i) {
|
||||
this(prepare(indices, i));
|
||||
public Int256Shuffle(int[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Int256Shuffle(IntUnaryOperator fn) {
|
||||
this(prepare(fn));
|
||||
public Int256Shuffle(int[] reorder, int i) {
|
||||
super(VLENGTH, reorder, i);
|
||||
}
|
||||
|
||||
int[] indices() {
|
||||
return (int[])getPayload();
|
||||
public Int256Shuffle(IntUnaryOperator fn) {
|
||||
super(VLENGTH, fn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public IntSpecies vspecies() {
|
||||
return VSPECIES;
|
||||
}
|
||||
|
@ -802,70 +812,40 @@ final class Int256Vector extends IntVector {
|
|||
static {
|
||||
// There must be enough bits in the shuffle lanes to encode
|
||||
// VLENGTH valid indexes and VLENGTH exceptional ones.
|
||||
assert(VLENGTH < Integer.MAX_VALUE);
|
||||
assert(Integer.MIN_VALUE <= -VLENGTH);
|
||||
assert(VLENGTH < Byte.MAX_VALUE);
|
||||
assert(Byte.MIN_VALUE <= -VLENGTH);
|
||||
}
|
||||
static final Int256Shuffle IOTA = new Int256Shuffle(IDENTITY);
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Int256Vector toBitsVector() {
|
||||
return (Int256Vector) super.toBitsVectorTemplate();
|
||||
public Int256Vector toVector() {
|
||||
return VectorSupport.shuffleToVector(VCLASS, ETYPE, Int256Shuffle.class, this, VLENGTH,
|
||||
(s) -> ((Int256Vector)(((AbstractShuffle<Integer>)(s)).toVectorTemplate())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
IntVector toBitsVector0() {
|
||||
return Int256Vector.VSPECIES.dummyVector().vectorFactory(indices());
|
||||
public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
|
||||
AbstractSpecies<F> species = (AbstractSpecies<F>) s;
|
||||
if (length() != species.laneCount())
|
||||
throw new IllegalArgumentException("VectorShuffle length and species length differ");
|
||||
int[] shuffleArray = toArray();
|
||||
return s.shuffleFromArray(shuffleArray, 0).check(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public int laneSource(int i) {
|
||||
return (int)toBitsVector().lane(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoArray(int[] a, int offset) {
|
||||
toBitsVector().intoArray(a, offset);
|
||||
}
|
||||
|
||||
private static int[] prepare(int[] indices, int offset) {
|
||||
int[] a = new int[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = indices[offset + i];
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (int)si;
|
||||
public Int256Shuffle rearrange(VectorShuffle<Integer> shuffle) {
|
||||
Int256Shuffle s = (Int256Shuffle) shuffle;
|
||||
byte[] reorder1 = reorder();
|
||||
byte[] reorder2 = s.reorder();
|
||||
byte[] r = new byte[reorder1.length];
|
||||
for (int i = 0; i < reorder1.length; i++) {
|
||||
int ssi = reorder2[i];
|
||||
r[i] = reorder1[ssi]; // throws on exceptional index
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static int[] prepare(IntUnaryOperator f) {
|
||||
int[] a = new int[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = f.applyAsInt(i);
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (int)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static boolean indicesInRange(int[] indices) {
|
||||
int length = indices.length;
|
||||
for (int si : indices) {
|
||||
if (si >= (int)length || si < (int)(-length)) {
|
||||
boolean assertsEnabled = false;
|
||||
assert(assertsEnabled = true);
|
||||
if (assertsEnabled) {
|
||||
String msg = ("index "+si+"out of range ["+length+"] in "+
|
||||
java.util.Arrays.toString(indices));
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return new Int256Shuffle(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -141,9 +141,24 @@ final class Int512Vector extends IntVector {
|
|||
@ForceInline
|
||||
Int512Shuffle iotaShuffle() { return Int512Shuffle.IOTA; }
|
||||
|
||||
@ForceInline
|
||||
Int512Shuffle iotaShuffle(int start, int step, boolean wrap) {
|
||||
if (wrap) {
|
||||
return (Int512Shuffle)VectorSupport.shuffleIota(ETYPE, Int512Shuffle.class, VSPECIES, VLENGTH, start, step, 1,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
|
||||
} else {
|
||||
return (Int512Shuffle)VectorSupport.shuffleIota(ETYPE, Int512Shuffle.class, VSPECIES, VLENGTH, start, step, 0,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (i*lstep + lstart)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Int512Shuffle shuffleFromArray(int[] indices, int i) { return new Int512Shuffle(indices, i); }
|
||||
Int512Shuffle shuffleFromBytes(byte[] reorder) { return new Int512Shuffle(reorder); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Int512Shuffle shuffleFromArray(int[] indexes, int i) { return new Int512Shuffle(indexes, i); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
|
@ -342,11 +357,9 @@ final class Int512Vector extends IntVector {
|
|||
return (long) super.reduceLanesTemplate(op, Int512Mask.class, (Int512Mask) m); // specialized
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final
|
||||
<F> VectorShuffle<F> toShuffle(AbstractSpecies<F> dsp) {
|
||||
return super.toShuffleTemplate(dsp);
|
||||
public VectorShuffle<Integer> toShuffle() {
|
||||
return super.toShuffleTemplate(Int512Shuffle.class); // specialize
|
||||
}
|
||||
|
||||
// Specialized unary testing
|
||||
|
@ -791,26 +804,23 @@ final class Int512Vector extends IntVector {
|
|||
static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM
|
||||
static final Class<Integer> ETYPE = int.class; // used by the JVM
|
||||
|
||||
Int512Shuffle(int[] indices) {
|
||||
super(indices);
|
||||
assert(VLENGTH == indices.length);
|
||||
assert(indicesInRange(indices));
|
||||
Int512Shuffle(byte[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Int512Shuffle(int[] indices, int i) {
|
||||
this(prepare(indices, i));
|
||||
public Int512Shuffle(int[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Int512Shuffle(IntUnaryOperator fn) {
|
||||
this(prepare(fn));
|
||||
public Int512Shuffle(int[] reorder, int i) {
|
||||
super(VLENGTH, reorder, i);
|
||||
}
|
||||
|
||||
int[] indices() {
|
||||
return (int[])getPayload();
|
||||
public Int512Shuffle(IntUnaryOperator fn) {
|
||||
super(VLENGTH, fn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public IntSpecies vspecies() {
|
||||
return VSPECIES;
|
||||
}
|
||||
|
@ -818,70 +828,40 @@ final class Int512Vector extends IntVector {
|
|||
static {
|
||||
// There must be enough bits in the shuffle lanes to encode
|
||||
// VLENGTH valid indexes and VLENGTH exceptional ones.
|
||||
assert(VLENGTH < Integer.MAX_VALUE);
|
||||
assert(Integer.MIN_VALUE <= -VLENGTH);
|
||||
assert(VLENGTH < Byte.MAX_VALUE);
|
||||
assert(Byte.MIN_VALUE <= -VLENGTH);
|
||||
}
|
||||
static final Int512Shuffle IOTA = new Int512Shuffle(IDENTITY);
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Int512Vector toBitsVector() {
|
||||
return (Int512Vector) super.toBitsVectorTemplate();
|
||||
public Int512Vector toVector() {
|
||||
return VectorSupport.shuffleToVector(VCLASS, ETYPE, Int512Shuffle.class, this, VLENGTH,
|
||||
(s) -> ((Int512Vector)(((AbstractShuffle<Integer>)(s)).toVectorTemplate())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
IntVector toBitsVector0() {
|
||||
return Int512Vector.VSPECIES.dummyVector().vectorFactory(indices());
|
||||
public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
|
||||
AbstractSpecies<F> species = (AbstractSpecies<F>) s;
|
||||
if (length() != species.laneCount())
|
||||
throw new IllegalArgumentException("VectorShuffle length and species length differ");
|
||||
int[] shuffleArray = toArray();
|
||||
return s.shuffleFromArray(shuffleArray, 0).check(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public int laneSource(int i) {
|
||||
return (int)toBitsVector().lane(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoArray(int[] a, int offset) {
|
||||
toBitsVector().intoArray(a, offset);
|
||||
}
|
||||
|
||||
private static int[] prepare(int[] indices, int offset) {
|
||||
int[] a = new int[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = indices[offset + i];
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (int)si;
|
||||
public Int512Shuffle rearrange(VectorShuffle<Integer> shuffle) {
|
||||
Int512Shuffle s = (Int512Shuffle) shuffle;
|
||||
byte[] reorder1 = reorder();
|
||||
byte[] reorder2 = s.reorder();
|
||||
byte[] r = new byte[reorder1.length];
|
||||
for (int i = 0; i < reorder1.length; i++) {
|
||||
int ssi = reorder2[i];
|
||||
r[i] = reorder1[ssi]; // throws on exceptional index
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static int[] prepare(IntUnaryOperator f) {
|
||||
int[] a = new int[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = f.applyAsInt(i);
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (int)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static boolean indicesInRange(int[] indices) {
|
||||
int length = indices.length;
|
||||
for (int si : indices) {
|
||||
if (si >= (int)length || si < (int)(-length)) {
|
||||
boolean assertsEnabled = false;
|
||||
assert(assertsEnabled = true);
|
||||
if (assertsEnabled) {
|
||||
String msg = ("index "+si+"out of range ["+length+"] in "+
|
||||
java.util.Arrays.toString(indices));
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return new Int512Shuffle(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -141,9 +141,24 @@ final class Int64Vector extends IntVector {
|
|||
@ForceInline
|
||||
Int64Shuffle iotaShuffle() { return Int64Shuffle.IOTA; }
|
||||
|
||||
@ForceInline
|
||||
Int64Shuffle iotaShuffle(int start, int step, boolean wrap) {
|
||||
if (wrap) {
|
||||
return (Int64Shuffle)VectorSupport.shuffleIota(ETYPE, Int64Shuffle.class, VSPECIES, VLENGTH, start, step, 1,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
|
||||
} else {
|
||||
return (Int64Shuffle)VectorSupport.shuffleIota(ETYPE, Int64Shuffle.class, VSPECIES, VLENGTH, start, step, 0,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (i*lstep + lstart)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Int64Shuffle shuffleFromArray(int[] indices, int i) { return new Int64Shuffle(indices, i); }
|
||||
Int64Shuffle shuffleFromBytes(byte[] reorder) { return new Int64Shuffle(reorder); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Int64Shuffle shuffleFromArray(int[] indexes, int i) { return new Int64Shuffle(indexes, i); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
|
@ -342,11 +357,9 @@ final class Int64Vector extends IntVector {
|
|||
return (long) super.reduceLanesTemplate(op, Int64Mask.class, (Int64Mask) m); // specialized
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final
|
||||
<F> VectorShuffle<F> toShuffle(AbstractSpecies<F> dsp) {
|
||||
return super.toShuffleTemplate(dsp);
|
||||
public VectorShuffle<Integer> toShuffle() {
|
||||
return super.toShuffleTemplate(Int64Shuffle.class); // specialize
|
||||
}
|
||||
|
||||
// Specialized unary testing
|
||||
|
@ -763,26 +776,23 @@ final class Int64Vector extends IntVector {
|
|||
static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM
|
||||
static final Class<Integer> ETYPE = int.class; // used by the JVM
|
||||
|
||||
Int64Shuffle(int[] indices) {
|
||||
super(indices);
|
||||
assert(VLENGTH == indices.length);
|
||||
assert(indicesInRange(indices));
|
||||
Int64Shuffle(byte[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Int64Shuffle(int[] indices, int i) {
|
||||
this(prepare(indices, i));
|
||||
public Int64Shuffle(int[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Int64Shuffle(IntUnaryOperator fn) {
|
||||
this(prepare(fn));
|
||||
public Int64Shuffle(int[] reorder, int i) {
|
||||
super(VLENGTH, reorder, i);
|
||||
}
|
||||
|
||||
int[] indices() {
|
||||
return (int[])getPayload();
|
||||
public Int64Shuffle(IntUnaryOperator fn) {
|
||||
super(VLENGTH, fn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public IntSpecies vspecies() {
|
||||
return VSPECIES;
|
||||
}
|
||||
|
@ -790,70 +800,40 @@ final class Int64Vector extends IntVector {
|
|||
static {
|
||||
// There must be enough bits in the shuffle lanes to encode
|
||||
// VLENGTH valid indexes and VLENGTH exceptional ones.
|
||||
assert(VLENGTH < Integer.MAX_VALUE);
|
||||
assert(Integer.MIN_VALUE <= -VLENGTH);
|
||||
assert(VLENGTH < Byte.MAX_VALUE);
|
||||
assert(Byte.MIN_VALUE <= -VLENGTH);
|
||||
}
|
||||
static final Int64Shuffle IOTA = new Int64Shuffle(IDENTITY);
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Int64Vector toBitsVector() {
|
||||
return (Int64Vector) super.toBitsVectorTemplate();
|
||||
public Int64Vector toVector() {
|
||||
return VectorSupport.shuffleToVector(VCLASS, ETYPE, Int64Shuffle.class, this, VLENGTH,
|
||||
(s) -> ((Int64Vector)(((AbstractShuffle<Integer>)(s)).toVectorTemplate())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
IntVector toBitsVector0() {
|
||||
return Int64Vector.VSPECIES.dummyVector().vectorFactory(indices());
|
||||
public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
|
||||
AbstractSpecies<F> species = (AbstractSpecies<F>) s;
|
||||
if (length() != species.laneCount())
|
||||
throw new IllegalArgumentException("VectorShuffle length and species length differ");
|
||||
int[] shuffleArray = toArray();
|
||||
return s.shuffleFromArray(shuffleArray, 0).check(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public int laneSource(int i) {
|
||||
return (int)toBitsVector().lane(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoArray(int[] a, int offset) {
|
||||
toBitsVector().intoArray(a, offset);
|
||||
}
|
||||
|
||||
private static int[] prepare(int[] indices, int offset) {
|
||||
int[] a = new int[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = indices[offset + i];
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (int)si;
|
||||
public Int64Shuffle rearrange(VectorShuffle<Integer> shuffle) {
|
||||
Int64Shuffle s = (Int64Shuffle) shuffle;
|
||||
byte[] reorder1 = reorder();
|
||||
byte[] reorder2 = s.reorder();
|
||||
byte[] r = new byte[reorder1.length];
|
||||
for (int i = 0; i < reorder1.length; i++) {
|
||||
int ssi = reorder2[i];
|
||||
r[i] = reorder1[ssi]; // throws on exceptional index
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static int[] prepare(IntUnaryOperator f) {
|
||||
int[] a = new int[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = f.applyAsInt(i);
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (int)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static boolean indicesInRange(int[] indices) {
|
||||
int length = indices.length;
|
||||
for (int si : indices) {
|
||||
if (si >= (int)length || si < (int)(-length)) {
|
||||
boolean assertsEnabled = false;
|
||||
assert(assertsEnabled = true);
|
||||
if (assertsEnabled) {
|
||||
String msg = ("index "+si+"out of range ["+length+"] in "+
|
||||
java.util.Arrays.toString(indices));
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return new Int64Shuffle(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -141,9 +141,24 @@ final class IntMaxVector extends IntVector {
|
|||
@ForceInline
|
||||
IntMaxShuffle iotaShuffle() { return IntMaxShuffle.IOTA; }
|
||||
|
||||
@ForceInline
|
||||
IntMaxShuffle iotaShuffle(int start, int step, boolean wrap) {
|
||||
if (wrap) {
|
||||
return (IntMaxShuffle)VectorSupport.shuffleIota(ETYPE, IntMaxShuffle.class, VSPECIES, VLENGTH, start, step, 1,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
|
||||
} else {
|
||||
return (IntMaxShuffle)VectorSupport.shuffleIota(ETYPE, IntMaxShuffle.class, VSPECIES, VLENGTH, start, step, 0,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (i*lstep + lstart)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
IntMaxShuffle shuffleFromArray(int[] indices, int i) { return new IntMaxShuffle(indices, i); }
|
||||
IntMaxShuffle shuffleFromBytes(byte[] reorder) { return new IntMaxShuffle(reorder); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
IntMaxShuffle shuffleFromArray(int[] indexes, int i) { return new IntMaxShuffle(indexes, i); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
|
@ -342,11 +357,9 @@ final class IntMaxVector extends IntVector {
|
|||
return (long) super.reduceLanesTemplate(op, IntMaxMask.class, (IntMaxMask) m); // specialized
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final
|
||||
<F> VectorShuffle<F> toShuffle(AbstractSpecies<F> dsp) {
|
||||
return super.toShuffleTemplate(dsp);
|
||||
public VectorShuffle<Integer> toShuffle() {
|
||||
return super.toShuffleTemplate(IntMaxShuffle.class); // specialize
|
||||
}
|
||||
|
||||
// Specialized unary testing
|
||||
|
@ -772,26 +785,23 @@ final class IntMaxVector extends IntVector {
|
|||
static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM
|
||||
static final Class<Integer> ETYPE = int.class; // used by the JVM
|
||||
|
||||
IntMaxShuffle(int[] indices) {
|
||||
super(indices);
|
||||
assert(VLENGTH == indices.length);
|
||||
assert(indicesInRange(indices));
|
||||
IntMaxShuffle(byte[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
IntMaxShuffle(int[] indices, int i) {
|
||||
this(prepare(indices, i));
|
||||
public IntMaxShuffle(int[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
IntMaxShuffle(IntUnaryOperator fn) {
|
||||
this(prepare(fn));
|
||||
public IntMaxShuffle(int[] reorder, int i) {
|
||||
super(VLENGTH, reorder, i);
|
||||
}
|
||||
|
||||
int[] indices() {
|
||||
return (int[])getPayload();
|
||||
public IntMaxShuffle(IntUnaryOperator fn) {
|
||||
super(VLENGTH, fn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public IntSpecies vspecies() {
|
||||
return VSPECIES;
|
||||
}
|
||||
|
@ -799,70 +809,40 @@ final class IntMaxVector extends IntVector {
|
|||
static {
|
||||
// There must be enough bits in the shuffle lanes to encode
|
||||
// VLENGTH valid indexes and VLENGTH exceptional ones.
|
||||
assert(VLENGTH < Integer.MAX_VALUE);
|
||||
assert(Integer.MIN_VALUE <= -VLENGTH);
|
||||
assert(VLENGTH < Byte.MAX_VALUE);
|
||||
assert(Byte.MIN_VALUE <= -VLENGTH);
|
||||
}
|
||||
static final IntMaxShuffle IOTA = new IntMaxShuffle(IDENTITY);
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
IntMaxVector toBitsVector() {
|
||||
return (IntMaxVector) super.toBitsVectorTemplate();
|
||||
public IntMaxVector toVector() {
|
||||
return VectorSupport.shuffleToVector(VCLASS, ETYPE, IntMaxShuffle.class, this, VLENGTH,
|
||||
(s) -> ((IntMaxVector)(((AbstractShuffle<Integer>)(s)).toVectorTemplate())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
IntVector toBitsVector0() {
|
||||
return IntMaxVector.VSPECIES.dummyVector().vectorFactory(indices());
|
||||
public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
|
||||
AbstractSpecies<F> species = (AbstractSpecies<F>) s;
|
||||
if (length() != species.laneCount())
|
||||
throw new IllegalArgumentException("VectorShuffle length and species length differ");
|
||||
int[] shuffleArray = toArray();
|
||||
return s.shuffleFromArray(shuffleArray, 0).check(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public int laneSource(int i) {
|
||||
return (int)toBitsVector().lane(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoArray(int[] a, int offset) {
|
||||
toBitsVector().intoArray(a, offset);
|
||||
}
|
||||
|
||||
private static int[] prepare(int[] indices, int offset) {
|
||||
int[] a = new int[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = indices[offset + i];
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (int)si;
|
||||
public IntMaxShuffle rearrange(VectorShuffle<Integer> shuffle) {
|
||||
IntMaxShuffle s = (IntMaxShuffle) shuffle;
|
||||
byte[] reorder1 = reorder();
|
||||
byte[] reorder2 = s.reorder();
|
||||
byte[] r = new byte[reorder1.length];
|
||||
for (int i = 0; i < reorder1.length; i++) {
|
||||
int ssi = reorder2[i];
|
||||
r[i] = reorder1[ssi]; // throws on exceptional index
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static int[] prepare(IntUnaryOperator f) {
|
||||
int[] a = new int[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = f.applyAsInt(i);
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (int)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static boolean indicesInRange(int[] indices) {
|
||||
int length = indices.length;
|
||||
for (int si : indices) {
|
||||
if (si >= (int)length || si < (int)(-length)) {
|
||||
boolean assertsEnabled = false;
|
||||
assert(assertsEnabled = true);
|
||||
if (assertsEnabled) {
|
||||
String msg = ("index "+si+"out of range ["+length+"] in "+
|
||||
java.util.Arrays.toString(indices));
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return new IntMaxShuffle(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -1074,7 +1074,7 @@ public abstract class IntVector extends AbstractVector<Integer> {
|
|||
// and broadcast, but it would be more surprising not to continue
|
||||
// the obvious pattern started by unary and binary.
|
||||
|
||||
/**
|
||||
/**
|
||||
* {@inheritDoc} <!--workaround-->
|
||||
* @see #lanewise(VectorOperators.Ternary,int,int,VectorMask)
|
||||
* @see #lanewise(VectorOperators.Ternary,Vector,int,VectorMask)
|
||||
|
@ -2465,8 +2465,8 @@ public abstract class IntVector extends AbstractVector<Integer> {
|
|||
}
|
||||
|
||||
@ForceInline
|
||||
final <F>
|
||||
VectorShuffle<F> toShuffle0(AbstractSpecies<F> dsp) {
|
||||
private final
|
||||
VectorShuffle<Integer> toShuffle0(IntSpecies dsp) {
|
||||
int[] a = toArray();
|
||||
int[] sa = new int[a.length];
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
|
@ -2475,6 +2475,18 @@ public abstract class IntVector extends AbstractVector<Integer> {
|
|||
return VectorShuffle.fromArray(dsp, sa, 0);
|
||||
}
|
||||
|
||||
/*package-private*/
|
||||
@ForceInline
|
||||
final
|
||||
VectorShuffle<Integer> toShuffleTemplate(Class<?> shuffleType) {
|
||||
IntSpecies vsp = vspecies();
|
||||
return VectorSupport.convert(VectorSupport.VECTOR_OP_CAST,
|
||||
getClass(), int.class, length(),
|
||||
shuffleType, byte.class, length(),
|
||||
this, vsp,
|
||||
IntVector::toShuffle0);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} <!--workaround-->
|
||||
* @since 19
|
||||
|
@ -3793,10 +3805,9 @@ public abstract class IntVector extends AbstractVector<Integer> {
|
|||
private IntSpecies(VectorShape shape,
|
||||
Class<? extends IntVector> vectorType,
|
||||
Class<? extends AbstractMask<Integer>> maskType,
|
||||
Class<? extends AbstractShuffle<Integer>> shuffleType,
|
||||
Function<Object, IntVector> vectorFactory) {
|
||||
super(shape, LaneType.of(int.class),
|
||||
vectorType, maskType, shuffleType,
|
||||
vectorType, maskType,
|
||||
vectorFactory);
|
||||
assert(this.elementSize() == Integer.SIZE);
|
||||
}
|
||||
|
@ -4072,7 +4083,6 @@ public abstract class IntVector extends AbstractVector<Integer> {
|
|||
= new IntSpecies(VectorShape.S_64_BIT,
|
||||
Int64Vector.class,
|
||||
Int64Vector.Int64Mask.class,
|
||||
Int64Vector.Int64Shuffle.class,
|
||||
Int64Vector::new);
|
||||
|
||||
/** Species representing {@link IntVector}s of {@link VectorShape#S_128_BIT VectorShape.S_128_BIT}. */
|
||||
|
@ -4080,7 +4090,6 @@ public abstract class IntVector extends AbstractVector<Integer> {
|
|||
= new IntSpecies(VectorShape.S_128_BIT,
|
||||
Int128Vector.class,
|
||||
Int128Vector.Int128Mask.class,
|
||||
Int128Vector.Int128Shuffle.class,
|
||||
Int128Vector::new);
|
||||
|
||||
/** Species representing {@link IntVector}s of {@link VectorShape#S_256_BIT VectorShape.S_256_BIT}. */
|
||||
|
@ -4088,7 +4097,6 @@ public abstract class IntVector extends AbstractVector<Integer> {
|
|||
= new IntSpecies(VectorShape.S_256_BIT,
|
||||
Int256Vector.class,
|
||||
Int256Vector.Int256Mask.class,
|
||||
Int256Vector.Int256Shuffle.class,
|
||||
Int256Vector::new);
|
||||
|
||||
/** Species representing {@link IntVector}s of {@link VectorShape#S_512_BIT VectorShape.S_512_BIT}. */
|
||||
|
@ -4096,7 +4104,6 @@ public abstract class IntVector extends AbstractVector<Integer> {
|
|||
= new IntSpecies(VectorShape.S_512_BIT,
|
||||
Int512Vector.class,
|
||||
Int512Vector.Int512Mask.class,
|
||||
Int512Vector.Int512Shuffle.class,
|
||||
Int512Vector::new);
|
||||
|
||||
/** Species representing {@link IntVector}s of {@link VectorShape#S_Max_BIT VectorShape.S_Max_BIT}. */
|
||||
|
@ -4104,7 +4111,6 @@ public abstract class IntVector extends AbstractVector<Integer> {
|
|||
= new IntSpecies(VectorShape.S_Max_BIT,
|
||||
IntMaxVector.class,
|
||||
IntMaxVector.IntMaxMask.class,
|
||||
IntMaxVector.IntMaxShuffle.class,
|
||||
IntMaxVector::new);
|
||||
|
||||
/**
|
||||
|
|
|
@ -136,9 +136,24 @@ final class Long128Vector extends LongVector {
|
|||
@ForceInline
|
||||
Long128Shuffle iotaShuffle() { return Long128Shuffle.IOTA; }
|
||||
|
||||
@ForceInline
|
||||
Long128Shuffle iotaShuffle(int start, int step, boolean wrap) {
|
||||
if (wrap) {
|
||||
return (Long128Shuffle)VectorSupport.shuffleIota(ETYPE, Long128Shuffle.class, VSPECIES, VLENGTH, start, step, 1,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
|
||||
} else {
|
||||
return (Long128Shuffle)VectorSupport.shuffleIota(ETYPE, Long128Shuffle.class, VSPECIES, VLENGTH, start, step, 0,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (i*lstep + lstart)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Long128Shuffle shuffleFromArray(int[] indices, int i) { return new Long128Shuffle(indices, i); }
|
||||
Long128Shuffle shuffleFromBytes(byte[] reorder) { return new Long128Shuffle(reorder); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Long128Shuffle shuffleFromArray(int[] indexes, int i) { return new Long128Shuffle(indexes, i); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
|
@ -337,11 +352,9 @@ final class Long128Vector extends LongVector {
|
|||
return (long) super.reduceLanesTemplate(op, Long128Mask.class, (Long128Mask) m); // specialized
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final
|
||||
<F> VectorShuffle<F> toShuffle(AbstractSpecies<F> dsp) {
|
||||
return super.toShuffleTemplate(dsp);
|
||||
public VectorShuffle<Long> toShuffle() {
|
||||
return super.toShuffleTemplate(Long128Shuffle.class); // specialize
|
||||
}
|
||||
|
||||
// Specialized unary testing
|
||||
|
@ -753,26 +766,23 @@ final class Long128Vector extends LongVector {
|
|||
static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM
|
||||
static final Class<Long> ETYPE = long.class; // used by the JVM
|
||||
|
||||
Long128Shuffle(long[] indices) {
|
||||
super(indices);
|
||||
assert(VLENGTH == indices.length);
|
||||
assert(indicesInRange(indices));
|
||||
Long128Shuffle(byte[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Long128Shuffle(int[] indices, int i) {
|
||||
this(prepare(indices, i));
|
||||
public Long128Shuffle(int[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Long128Shuffle(IntUnaryOperator fn) {
|
||||
this(prepare(fn));
|
||||
public Long128Shuffle(int[] reorder, int i) {
|
||||
super(VLENGTH, reorder, i);
|
||||
}
|
||||
|
||||
long[] indices() {
|
||||
return (long[])getPayload();
|
||||
public Long128Shuffle(IntUnaryOperator fn) {
|
||||
super(VLENGTH, fn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public LongSpecies vspecies() {
|
||||
return VSPECIES;
|
||||
}
|
||||
|
@ -780,94 +790,40 @@ final class Long128Vector extends LongVector {
|
|||
static {
|
||||
// There must be enough bits in the shuffle lanes to encode
|
||||
// VLENGTH valid indexes and VLENGTH exceptional ones.
|
||||
assert(VLENGTH < Long.MAX_VALUE);
|
||||
assert(Long.MIN_VALUE <= -VLENGTH);
|
||||
assert(VLENGTH < Byte.MAX_VALUE);
|
||||
assert(Byte.MIN_VALUE <= -VLENGTH);
|
||||
}
|
||||
static final Long128Shuffle IOTA = new Long128Shuffle(IDENTITY);
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Long128Vector toBitsVector() {
|
||||
return (Long128Vector) super.toBitsVectorTemplate();
|
||||
public Long128Vector toVector() {
|
||||
return VectorSupport.shuffleToVector(VCLASS, ETYPE, Long128Shuffle.class, this, VLENGTH,
|
||||
(s) -> ((Long128Vector)(((AbstractShuffle<Long>)(s)).toVectorTemplate())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
LongVector toBitsVector0() {
|
||||
return Long128Vector.VSPECIES.dummyVector().vectorFactory(indices());
|
||||
public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
|
||||
AbstractSpecies<F> species = (AbstractSpecies<F>) s;
|
||||
if (length() != species.laneCount())
|
||||
throw new IllegalArgumentException("VectorShuffle length and species length differ");
|
||||
int[] shuffleArray = toArray();
|
||||
return s.shuffleFromArray(shuffleArray, 0).check(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public int laneSource(int i) {
|
||||
return (int)toBitsVector().lane(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoArray(int[] a, int offset) {
|
||||
switch (length()) {
|
||||
case 1 -> a[offset] = laneSource(0);
|
||||
case 2 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_64, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
case 4 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_128, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
case 8 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_256, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
case 16 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_512, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
default -> {
|
||||
VectorIntrinsics.checkFromIndexSize(offset, length(), a.length);
|
||||
for (int i = 0; i < length(); i++) {
|
||||
a[offset + i] = laneSource(i);
|
||||
}
|
||||
}
|
||||
public Long128Shuffle rearrange(VectorShuffle<Long> shuffle) {
|
||||
Long128Shuffle s = (Long128Shuffle) shuffle;
|
||||
byte[] reorder1 = reorder();
|
||||
byte[] reorder2 = s.reorder();
|
||||
byte[] r = new byte[reorder1.length];
|
||||
for (int i = 0; i < reorder1.length; i++) {
|
||||
int ssi = reorder2[i];
|
||||
r[i] = reorder1[ssi]; // throws on exceptional index
|
||||
}
|
||||
}
|
||||
|
||||
private static long[] prepare(int[] indices, int offset) {
|
||||
long[] a = new long[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = indices[offset + i];
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (long)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static long[] prepare(IntUnaryOperator f) {
|
||||
long[] a = new long[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = f.applyAsInt(i);
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (long)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static boolean indicesInRange(long[] indices) {
|
||||
int length = indices.length;
|
||||
for (long si : indices) {
|
||||
if (si >= (long)length || si < (long)(-length)) {
|
||||
boolean assertsEnabled = false;
|
||||
assert(assertsEnabled = true);
|
||||
if (assertsEnabled) {
|
||||
String msg = ("index "+si+"out of range ["+length+"] in "+
|
||||
java.util.Arrays.toString(indices));
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return new Long128Shuffle(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -136,9 +136,24 @@ final class Long256Vector extends LongVector {
|
|||
@ForceInline
|
||||
Long256Shuffle iotaShuffle() { return Long256Shuffle.IOTA; }
|
||||
|
||||
@ForceInline
|
||||
Long256Shuffle iotaShuffle(int start, int step, boolean wrap) {
|
||||
if (wrap) {
|
||||
return (Long256Shuffle)VectorSupport.shuffleIota(ETYPE, Long256Shuffle.class, VSPECIES, VLENGTH, start, step, 1,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
|
||||
} else {
|
||||
return (Long256Shuffle)VectorSupport.shuffleIota(ETYPE, Long256Shuffle.class, VSPECIES, VLENGTH, start, step, 0,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (i*lstep + lstart)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Long256Shuffle shuffleFromArray(int[] indices, int i) { return new Long256Shuffle(indices, i); }
|
||||
Long256Shuffle shuffleFromBytes(byte[] reorder) { return new Long256Shuffle(reorder); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Long256Shuffle shuffleFromArray(int[] indexes, int i) { return new Long256Shuffle(indexes, i); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
|
@ -337,11 +352,9 @@ final class Long256Vector extends LongVector {
|
|||
return (long) super.reduceLanesTemplate(op, Long256Mask.class, (Long256Mask) m); // specialized
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final
|
||||
<F> VectorShuffle<F> toShuffle(AbstractSpecies<F> dsp) {
|
||||
return super.toShuffleTemplate(dsp);
|
||||
public VectorShuffle<Long> toShuffle() {
|
||||
return super.toShuffleTemplate(Long256Shuffle.class); // specialize
|
||||
}
|
||||
|
||||
// Specialized unary testing
|
||||
|
@ -757,26 +770,23 @@ final class Long256Vector extends LongVector {
|
|||
static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM
|
||||
static final Class<Long> ETYPE = long.class; // used by the JVM
|
||||
|
||||
Long256Shuffle(long[] indices) {
|
||||
super(indices);
|
||||
assert(VLENGTH == indices.length);
|
||||
assert(indicesInRange(indices));
|
||||
Long256Shuffle(byte[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Long256Shuffle(int[] indices, int i) {
|
||||
this(prepare(indices, i));
|
||||
public Long256Shuffle(int[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Long256Shuffle(IntUnaryOperator fn) {
|
||||
this(prepare(fn));
|
||||
public Long256Shuffle(int[] reorder, int i) {
|
||||
super(VLENGTH, reorder, i);
|
||||
}
|
||||
|
||||
long[] indices() {
|
||||
return (long[])getPayload();
|
||||
public Long256Shuffle(IntUnaryOperator fn) {
|
||||
super(VLENGTH, fn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public LongSpecies vspecies() {
|
||||
return VSPECIES;
|
||||
}
|
||||
|
@ -784,94 +794,40 @@ final class Long256Vector extends LongVector {
|
|||
static {
|
||||
// There must be enough bits in the shuffle lanes to encode
|
||||
// VLENGTH valid indexes and VLENGTH exceptional ones.
|
||||
assert(VLENGTH < Long.MAX_VALUE);
|
||||
assert(Long.MIN_VALUE <= -VLENGTH);
|
||||
assert(VLENGTH < Byte.MAX_VALUE);
|
||||
assert(Byte.MIN_VALUE <= -VLENGTH);
|
||||
}
|
||||
static final Long256Shuffle IOTA = new Long256Shuffle(IDENTITY);
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Long256Vector toBitsVector() {
|
||||
return (Long256Vector) super.toBitsVectorTemplate();
|
||||
public Long256Vector toVector() {
|
||||
return VectorSupport.shuffleToVector(VCLASS, ETYPE, Long256Shuffle.class, this, VLENGTH,
|
||||
(s) -> ((Long256Vector)(((AbstractShuffle<Long>)(s)).toVectorTemplate())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
LongVector toBitsVector0() {
|
||||
return Long256Vector.VSPECIES.dummyVector().vectorFactory(indices());
|
||||
public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
|
||||
AbstractSpecies<F> species = (AbstractSpecies<F>) s;
|
||||
if (length() != species.laneCount())
|
||||
throw new IllegalArgumentException("VectorShuffle length and species length differ");
|
||||
int[] shuffleArray = toArray();
|
||||
return s.shuffleFromArray(shuffleArray, 0).check(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public int laneSource(int i) {
|
||||
return (int)toBitsVector().lane(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoArray(int[] a, int offset) {
|
||||
switch (length()) {
|
||||
case 1 -> a[offset] = laneSource(0);
|
||||
case 2 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_64, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
case 4 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_128, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
case 8 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_256, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
case 16 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_512, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
default -> {
|
||||
VectorIntrinsics.checkFromIndexSize(offset, length(), a.length);
|
||||
for (int i = 0; i < length(); i++) {
|
||||
a[offset + i] = laneSource(i);
|
||||
}
|
||||
}
|
||||
public Long256Shuffle rearrange(VectorShuffle<Long> shuffle) {
|
||||
Long256Shuffle s = (Long256Shuffle) shuffle;
|
||||
byte[] reorder1 = reorder();
|
||||
byte[] reorder2 = s.reorder();
|
||||
byte[] r = new byte[reorder1.length];
|
||||
for (int i = 0; i < reorder1.length; i++) {
|
||||
int ssi = reorder2[i];
|
||||
r[i] = reorder1[ssi]; // throws on exceptional index
|
||||
}
|
||||
}
|
||||
|
||||
private static long[] prepare(int[] indices, int offset) {
|
||||
long[] a = new long[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = indices[offset + i];
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (long)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static long[] prepare(IntUnaryOperator f) {
|
||||
long[] a = new long[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = f.applyAsInt(i);
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (long)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static boolean indicesInRange(long[] indices) {
|
||||
int length = indices.length;
|
||||
for (long si : indices) {
|
||||
if (si >= (long)length || si < (long)(-length)) {
|
||||
boolean assertsEnabled = false;
|
||||
assert(assertsEnabled = true);
|
||||
if (assertsEnabled) {
|
||||
String msg = ("index "+si+"out of range ["+length+"] in "+
|
||||
java.util.Arrays.toString(indices));
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return new Long256Shuffle(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -136,9 +136,24 @@ final class Long512Vector extends LongVector {
|
|||
@ForceInline
|
||||
Long512Shuffle iotaShuffle() { return Long512Shuffle.IOTA; }
|
||||
|
||||
@ForceInline
|
||||
Long512Shuffle iotaShuffle(int start, int step, boolean wrap) {
|
||||
if (wrap) {
|
||||
return (Long512Shuffle)VectorSupport.shuffleIota(ETYPE, Long512Shuffle.class, VSPECIES, VLENGTH, start, step, 1,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
|
||||
} else {
|
||||
return (Long512Shuffle)VectorSupport.shuffleIota(ETYPE, Long512Shuffle.class, VSPECIES, VLENGTH, start, step, 0,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (i*lstep + lstart)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Long512Shuffle shuffleFromArray(int[] indices, int i) { return new Long512Shuffle(indices, i); }
|
||||
Long512Shuffle shuffleFromBytes(byte[] reorder) { return new Long512Shuffle(reorder); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Long512Shuffle shuffleFromArray(int[] indexes, int i) { return new Long512Shuffle(indexes, i); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
|
@ -337,11 +352,9 @@ final class Long512Vector extends LongVector {
|
|||
return (long) super.reduceLanesTemplate(op, Long512Mask.class, (Long512Mask) m); // specialized
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final
|
||||
<F> VectorShuffle<F> toShuffle(AbstractSpecies<F> dsp) {
|
||||
return super.toShuffleTemplate(dsp);
|
||||
public VectorShuffle<Long> toShuffle() {
|
||||
return super.toShuffleTemplate(Long512Shuffle.class); // specialize
|
||||
}
|
||||
|
||||
// Specialized unary testing
|
||||
|
@ -765,26 +778,23 @@ final class Long512Vector extends LongVector {
|
|||
static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM
|
||||
static final Class<Long> ETYPE = long.class; // used by the JVM
|
||||
|
||||
Long512Shuffle(long[] indices) {
|
||||
super(indices);
|
||||
assert(VLENGTH == indices.length);
|
||||
assert(indicesInRange(indices));
|
||||
Long512Shuffle(byte[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Long512Shuffle(int[] indices, int i) {
|
||||
this(prepare(indices, i));
|
||||
public Long512Shuffle(int[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Long512Shuffle(IntUnaryOperator fn) {
|
||||
this(prepare(fn));
|
||||
public Long512Shuffle(int[] reorder, int i) {
|
||||
super(VLENGTH, reorder, i);
|
||||
}
|
||||
|
||||
long[] indices() {
|
||||
return (long[])getPayload();
|
||||
public Long512Shuffle(IntUnaryOperator fn) {
|
||||
super(VLENGTH, fn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public LongSpecies vspecies() {
|
||||
return VSPECIES;
|
||||
}
|
||||
|
@ -792,94 +802,40 @@ final class Long512Vector extends LongVector {
|
|||
static {
|
||||
// There must be enough bits in the shuffle lanes to encode
|
||||
// VLENGTH valid indexes and VLENGTH exceptional ones.
|
||||
assert(VLENGTH < Long.MAX_VALUE);
|
||||
assert(Long.MIN_VALUE <= -VLENGTH);
|
||||
assert(VLENGTH < Byte.MAX_VALUE);
|
||||
assert(Byte.MIN_VALUE <= -VLENGTH);
|
||||
}
|
||||
static final Long512Shuffle IOTA = new Long512Shuffle(IDENTITY);
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Long512Vector toBitsVector() {
|
||||
return (Long512Vector) super.toBitsVectorTemplate();
|
||||
public Long512Vector toVector() {
|
||||
return VectorSupport.shuffleToVector(VCLASS, ETYPE, Long512Shuffle.class, this, VLENGTH,
|
||||
(s) -> ((Long512Vector)(((AbstractShuffle<Long>)(s)).toVectorTemplate())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
LongVector toBitsVector0() {
|
||||
return Long512Vector.VSPECIES.dummyVector().vectorFactory(indices());
|
||||
public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
|
||||
AbstractSpecies<F> species = (AbstractSpecies<F>) s;
|
||||
if (length() != species.laneCount())
|
||||
throw new IllegalArgumentException("VectorShuffle length and species length differ");
|
||||
int[] shuffleArray = toArray();
|
||||
return s.shuffleFromArray(shuffleArray, 0).check(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public int laneSource(int i) {
|
||||
return (int)toBitsVector().lane(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoArray(int[] a, int offset) {
|
||||
switch (length()) {
|
||||
case 1 -> a[offset] = laneSource(0);
|
||||
case 2 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_64, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
case 4 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_128, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
case 8 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_256, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
case 16 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_512, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
default -> {
|
||||
VectorIntrinsics.checkFromIndexSize(offset, length(), a.length);
|
||||
for (int i = 0; i < length(); i++) {
|
||||
a[offset + i] = laneSource(i);
|
||||
}
|
||||
}
|
||||
public Long512Shuffle rearrange(VectorShuffle<Long> shuffle) {
|
||||
Long512Shuffle s = (Long512Shuffle) shuffle;
|
||||
byte[] reorder1 = reorder();
|
||||
byte[] reorder2 = s.reorder();
|
||||
byte[] r = new byte[reorder1.length];
|
||||
for (int i = 0; i < reorder1.length; i++) {
|
||||
int ssi = reorder2[i];
|
||||
r[i] = reorder1[ssi]; // throws on exceptional index
|
||||
}
|
||||
}
|
||||
|
||||
private static long[] prepare(int[] indices, int offset) {
|
||||
long[] a = new long[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = indices[offset + i];
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (long)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static long[] prepare(IntUnaryOperator f) {
|
||||
long[] a = new long[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = f.applyAsInt(i);
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (long)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static boolean indicesInRange(long[] indices) {
|
||||
int length = indices.length;
|
||||
for (long si : indices) {
|
||||
if (si >= (long)length || si < (long)(-length)) {
|
||||
boolean assertsEnabled = false;
|
||||
assert(assertsEnabled = true);
|
||||
if (assertsEnabled) {
|
||||
String msg = ("index "+si+"out of range ["+length+"] in "+
|
||||
java.util.Arrays.toString(indices));
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return new Long512Shuffle(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -136,9 +136,24 @@ final class Long64Vector extends LongVector {
|
|||
@ForceInline
|
||||
Long64Shuffle iotaShuffle() { return Long64Shuffle.IOTA; }
|
||||
|
||||
@ForceInline
|
||||
Long64Shuffle iotaShuffle(int start, int step, boolean wrap) {
|
||||
if (wrap) {
|
||||
return (Long64Shuffle)VectorSupport.shuffleIota(ETYPE, Long64Shuffle.class, VSPECIES, VLENGTH, start, step, 1,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
|
||||
} else {
|
||||
return (Long64Shuffle)VectorSupport.shuffleIota(ETYPE, Long64Shuffle.class, VSPECIES, VLENGTH, start, step, 0,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (i*lstep + lstart)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Long64Shuffle shuffleFromArray(int[] indices, int i) { return new Long64Shuffle(indices, i); }
|
||||
Long64Shuffle shuffleFromBytes(byte[] reorder) { return new Long64Shuffle(reorder); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Long64Shuffle shuffleFromArray(int[] indexes, int i) { return new Long64Shuffle(indexes, i); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
|
@ -337,11 +352,9 @@ final class Long64Vector extends LongVector {
|
|||
return (long) super.reduceLanesTemplate(op, Long64Mask.class, (Long64Mask) m); // specialized
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final
|
||||
<F> VectorShuffle<F> toShuffle(AbstractSpecies<F> dsp) {
|
||||
return super.toShuffleTemplate(dsp);
|
||||
public VectorShuffle<Long> toShuffle() {
|
||||
return super.toShuffleTemplate(Long64Shuffle.class); // specialize
|
||||
}
|
||||
|
||||
// Specialized unary testing
|
||||
|
@ -751,26 +764,23 @@ final class Long64Vector extends LongVector {
|
|||
static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM
|
||||
static final Class<Long> ETYPE = long.class; // used by the JVM
|
||||
|
||||
Long64Shuffle(long[] indices) {
|
||||
super(indices);
|
||||
assert(VLENGTH == indices.length);
|
||||
assert(indicesInRange(indices));
|
||||
Long64Shuffle(byte[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Long64Shuffle(int[] indices, int i) {
|
||||
this(prepare(indices, i));
|
||||
public Long64Shuffle(int[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Long64Shuffle(IntUnaryOperator fn) {
|
||||
this(prepare(fn));
|
||||
public Long64Shuffle(int[] reorder, int i) {
|
||||
super(VLENGTH, reorder, i);
|
||||
}
|
||||
|
||||
long[] indices() {
|
||||
return (long[])getPayload();
|
||||
public Long64Shuffle(IntUnaryOperator fn) {
|
||||
super(VLENGTH, fn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public LongSpecies vspecies() {
|
||||
return VSPECIES;
|
||||
}
|
||||
|
@ -778,94 +788,40 @@ final class Long64Vector extends LongVector {
|
|||
static {
|
||||
// There must be enough bits in the shuffle lanes to encode
|
||||
// VLENGTH valid indexes and VLENGTH exceptional ones.
|
||||
assert(VLENGTH < Long.MAX_VALUE);
|
||||
assert(Long.MIN_VALUE <= -VLENGTH);
|
||||
assert(VLENGTH < Byte.MAX_VALUE);
|
||||
assert(Byte.MIN_VALUE <= -VLENGTH);
|
||||
}
|
||||
static final Long64Shuffle IOTA = new Long64Shuffle(IDENTITY);
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Long64Vector toBitsVector() {
|
||||
return (Long64Vector) super.toBitsVectorTemplate();
|
||||
public Long64Vector toVector() {
|
||||
return VectorSupport.shuffleToVector(VCLASS, ETYPE, Long64Shuffle.class, this, VLENGTH,
|
||||
(s) -> ((Long64Vector)(((AbstractShuffle<Long>)(s)).toVectorTemplate())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
LongVector toBitsVector0() {
|
||||
return Long64Vector.VSPECIES.dummyVector().vectorFactory(indices());
|
||||
public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
|
||||
AbstractSpecies<F> species = (AbstractSpecies<F>) s;
|
||||
if (length() != species.laneCount())
|
||||
throw new IllegalArgumentException("VectorShuffle length and species length differ");
|
||||
int[] shuffleArray = toArray();
|
||||
return s.shuffleFromArray(shuffleArray, 0).check(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public int laneSource(int i) {
|
||||
return (int)toBitsVector().lane(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoArray(int[] a, int offset) {
|
||||
switch (length()) {
|
||||
case 1 -> a[offset] = laneSource(0);
|
||||
case 2 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_64, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
case 4 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_128, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
case 8 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_256, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
case 16 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_512, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
default -> {
|
||||
VectorIntrinsics.checkFromIndexSize(offset, length(), a.length);
|
||||
for (int i = 0; i < length(); i++) {
|
||||
a[offset + i] = laneSource(i);
|
||||
}
|
||||
}
|
||||
public Long64Shuffle rearrange(VectorShuffle<Long> shuffle) {
|
||||
Long64Shuffle s = (Long64Shuffle) shuffle;
|
||||
byte[] reorder1 = reorder();
|
||||
byte[] reorder2 = s.reorder();
|
||||
byte[] r = new byte[reorder1.length];
|
||||
for (int i = 0; i < reorder1.length; i++) {
|
||||
int ssi = reorder2[i];
|
||||
r[i] = reorder1[ssi]; // throws on exceptional index
|
||||
}
|
||||
}
|
||||
|
||||
private static long[] prepare(int[] indices, int offset) {
|
||||
long[] a = new long[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = indices[offset + i];
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (long)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static long[] prepare(IntUnaryOperator f) {
|
||||
long[] a = new long[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = f.applyAsInt(i);
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (long)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static boolean indicesInRange(long[] indices) {
|
||||
int length = indices.length;
|
||||
for (long si : indices) {
|
||||
if (si >= (long)length || si < (long)(-length)) {
|
||||
boolean assertsEnabled = false;
|
||||
assert(assertsEnabled = true);
|
||||
if (assertsEnabled) {
|
||||
String msg = ("index "+si+"out of range ["+length+"] in "+
|
||||
java.util.Arrays.toString(indices));
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return new Long64Shuffle(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -136,9 +136,24 @@ final class LongMaxVector extends LongVector {
|
|||
@ForceInline
|
||||
LongMaxShuffle iotaShuffle() { return LongMaxShuffle.IOTA; }
|
||||
|
||||
@ForceInline
|
||||
LongMaxShuffle iotaShuffle(int start, int step, boolean wrap) {
|
||||
if (wrap) {
|
||||
return (LongMaxShuffle)VectorSupport.shuffleIota(ETYPE, LongMaxShuffle.class, VSPECIES, VLENGTH, start, step, 1,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
|
||||
} else {
|
||||
return (LongMaxShuffle)VectorSupport.shuffleIota(ETYPE, LongMaxShuffle.class, VSPECIES, VLENGTH, start, step, 0,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (i*lstep + lstart)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
LongMaxShuffle shuffleFromArray(int[] indices, int i) { return new LongMaxShuffle(indices, i); }
|
||||
LongMaxShuffle shuffleFromBytes(byte[] reorder) { return new LongMaxShuffle(reorder); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
LongMaxShuffle shuffleFromArray(int[] indexes, int i) { return new LongMaxShuffle(indexes, i); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
|
@ -337,11 +352,9 @@ final class LongMaxVector extends LongVector {
|
|||
return (long) super.reduceLanesTemplate(op, LongMaxMask.class, (LongMaxMask) m); // specialized
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final
|
||||
<F> VectorShuffle<F> toShuffle(AbstractSpecies<F> dsp) {
|
||||
return super.toShuffleTemplate(dsp);
|
||||
public VectorShuffle<Long> toShuffle() {
|
||||
return super.toShuffleTemplate(LongMaxShuffle.class); // specialize
|
||||
}
|
||||
|
||||
// Specialized unary testing
|
||||
|
@ -751,26 +764,23 @@ final class LongMaxVector extends LongVector {
|
|||
static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM
|
||||
static final Class<Long> ETYPE = long.class; // used by the JVM
|
||||
|
||||
LongMaxShuffle(long[] indices) {
|
||||
super(indices);
|
||||
assert(VLENGTH == indices.length);
|
||||
assert(indicesInRange(indices));
|
||||
LongMaxShuffle(byte[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
LongMaxShuffle(int[] indices, int i) {
|
||||
this(prepare(indices, i));
|
||||
public LongMaxShuffle(int[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
LongMaxShuffle(IntUnaryOperator fn) {
|
||||
this(prepare(fn));
|
||||
public LongMaxShuffle(int[] reorder, int i) {
|
||||
super(VLENGTH, reorder, i);
|
||||
}
|
||||
|
||||
long[] indices() {
|
||||
return (long[])getPayload();
|
||||
public LongMaxShuffle(IntUnaryOperator fn) {
|
||||
super(VLENGTH, fn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public LongSpecies vspecies() {
|
||||
return VSPECIES;
|
||||
}
|
||||
|
@ -778,94 +788,40 @@ final class LongMaxVector extends LongVector {
|
|||
static {
|
||||
// There must be enough bits in the shuffle lanes to encode
|
||||
// VLENGTH valid indexes and VLENGTH exceptional ones.
|
||||
assert(VLENGTH < Long.MAX_VALUE);
|
||||
assert(Long.MIN_VALUE <= -VLENGTH);
|
||||
assert(VLENGTH < Byte.MAX_VALUE);
|
||||
assert(Byte.MIN_VALUE <= -VLENGTH);
|
||||
}
|
||||
static final LongMaxShuffle IOTA = new LongMaxShuffle(IDENTITY);
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
LongMaxVector toBitsVector() {
|
||||
return (LongMaxVector) super.toBitsVectorTemplate();
|
||||
public LongMaxVector toVector() {
|
||||
return VectorSupport.shuffleToVector(VCLASS, ETYPE, LongMaxShuffle.class, this, VLENGTH,
|
||||
(s) -> ((LongMaxVector)(((AbstractShuffle<Long>)(s)).toVectorTemplate())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
LongVector toBitsVector0() {
|
||||
return LongMaxVector.VSPECIES.dummyVector().vectorFactory(indices());
|
||||
public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
|
||||
AbstractSpecies<F> species = (AbstractSpecies<F>) s;
|
||||
if (length() != species.laneCount())
|
||||
throw new IllegalArgumentException("VectorShuffle length and species length differ");
|
||||
int[] shuffleArray = toArray();
|
||||
return s.shuffleFromArray(shuffleArray, 0).check(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public int laneSource(int i) {
|
||||
return (int)toBitsVector().lane(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoArray(int[] a, int offset) {
|
||||
switch (length()) {
|
||||
case 1 -> a[offset] = laneSource(0);
|
||||
case 2 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_64, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
case 4 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_128, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
case 8 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_256, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
case 16 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_512, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
default -> {
|
||||
VectorIntrinsics.checkFromIndexSize(offset, length(), a.length);
|
||||
for (int i = 0; i < length(); i++) {
|
||||
a[offset + i] = laneSource(i);
|
||||
}
|
||||
}
|
||||
public LongMaxShuffle rearrange(VectorShuffle<Long> shuffle) {
|
||||
LongMaxShuffle s = (LongMaxShuffle) shuffle;
|
||||
byte[] reorder1 = reorder();
|
||||
byte[] reorder2 = s.reorder();
|
||||
byte[] r = new byte[reorder1.length];
|
||||
for (int i = 0; i < reorder1.length; i++) {
|
||||
int ssi = reorder2[i];
|
||||
r[i] = reorder1[ssi]; // throws on exceptional index
|
||||
}
|
||||
}
|
||||
|
||||
private static long[] prepare(int[] indices, int offset) {
|
||||
long[] a = new long[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = indices[offset + i];
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (long)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static long[] prepare(IntUnaryOperator f) {
|
||||
long[] a = new long[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = f.applyAsInt(i);
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (long)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static boolean indicesInRange(long[] indices) {
|
||||
int length = indices.length;
|
||||
for (long si : indices) {
|
||||
if (si >= (long)length || si < (long)(-length)) {
|
||||
boolean assertsEnabled = false;
|
||||
assert(assertsEnabled = true);
|
||||
if (assertsEnabled) {
|
||||
String msg = ("index "+si+"out of range ["+length+"] in "+
|
||||
java.util.Arrays.toString(indices));
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return new LongMaxShuffle(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -987,7 +987,7 @@ public abstract class LongVector extends AbstractVector<Long> {
|
|||
// and broadcast, but it would be more surprising not to continue
|
||||
// the obvious pattern started by unary and binary.
|
||||
|
||||
/**
|
||||
/**
|
||||
* {@inheritDoc} <!--workaround-->
|
||||
* @see #lanewise(VectorOperators.Ternary,long,long,VectorMask)
|
||||
* @see #lanewise(VectorOperators.Ternary,Vector,long,VectorMask)
|
||||
|
@ -2331,8 +2331,8 @@ public abstract class LongVector extends AbstractVector<Long> {
|
|||
}
|
||||
|
||||
@ForceInline
|
||||
final <F>
|
||||
VectorShuffle<F> toShuffle0(AbstractSpecies<F> dsp) {
|
||||
private final
|
||||
VectorShuffle<Long> toShuffle0(LongSpecies dsp) {
|
||||
long[] a = toArray();
|
||||
int[] sa = new int[a.length];
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
|
@ -2341,6 +2341,18 @@ public abstract class LongVector extends AbstractVector<Long> {
|
|||
return VectorShuffle.fromArray(dsp, sa, 0);
|
||||
}
|
||||
|
||||
/*package-private*/
|
||||
@ForceInline
|
||||
final
|
||||
VectorShuffle<Long> toShuffleTemplate(Class<?> shuffleType) {
|
||||
LongSpecies vsp = vspecies();
|
||||
return VectorSupport.convert(VectorSupport.VECTOR_OP_CAST,
|
||||
getClass(), long.class, length(),
|
||||
shuffleType, byte.class, length(),
|
||||
this, vsp,
|
||||
LongVector::toShuffle0);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} <!--workaround-->
|
||||
* @since 19
|
||||
|
@ -3728,10 +3740,9 @@ public abstract class LongVector extends AbstractVector<Long> {
|
|||
private LongSpecies(VectorShape shape,
|
||||
Class<? extends LongVector> vectorType,
|
||||
Class<? extends AbstractMask<Long>> maskType,
|
||||
Class<? extends AbstractShuffle<Long>> shuffleType,
|
||||
Function<Object, LongVector> vectorFactory) {
|
||||
super(shape, LaneType.of(long.class),
|
||||
vectorType, maskType, shuffleType,
|
||||
vectorType, maskType,
|
||||
vectorFactory);
|
||||
assert(this.elementSize() == Long.SIZE);
|
||||
}
|
||||
|
@ -3998,7 +4009,6 @@ public abstract class LongVector extends AbstractVector<Long> {
|
|||
= new LongSpecies(VectorShape.S_64_BIT,
|
||||
Long64Vector.class,
|
||||
Long64Vector.Long64Mask.class,
|
||||
Long64Vector.Long64Shuffle.class,
|
||||
Long64Vector::new);
|
||||
|
||||
/** Species representing {@link LongVector}s of {@link VectorShape#S_128_BIT VectorShape.S_128_BIT}. */
|
||||
|
@ -4006,7 +4016,6 @@ public abstract class LongVector extends AbstractVector<Long> {
|
|||
= new LongSpecies(VectorShape.S_128_BIT,
|
||||
Long128Vector.class,
|
||||
Long128Vector.Long128Mask.class,
|
||||
Long128Vector.Long128Shuffle.class,
|
||||
Long128Vector::new);
|
||||
|
||||
/** Species representing {@link LongVector}s of {@link VectorShape#S_256_BIT VectorShape.S_256_BIT}. */
|
||||
|
@ -4014,7 +4023,6 @@ public abstract class LongVector extends AbstractVector<Long> {
|
|||
= new LongSpecies(VectorShape.S_256_BIT,
|
||||
Long256Vector.class,
|
||||
Long256Vector.Long256Mask.class,
|
||||
Long256Vector.Long256Shuffle.class,
|
||||
Long256Vector::new);
|
||||
|
||||
/** Species representing {@link LongVector}s of {@link VectorShape#S_512_BIT VectorShape.S_512_BIT}. */
|
||||
|
@ -4022,7 +4030,6 @@ public abstract class LongVector extends AbstractVector<Long> {
|
|||
= new LongSpecies(VectorShape.S_512_BIT,
|
||||
Long512Vector.class,
|
||||
Long512Vector.Long512Mask.class,
|
||||
Long512Vector.Long512Shuffle.class,
|
||||
Long512Vector::new);
|
||||
|
||||
/** Species representing {@link LongVector}s of {@link VectorShape#S_Max_BIT VectorShape.S_Max_BIT}. */
|
||||
|
@ -4030,7 +4037,6 @@ public abstract class LongVector extends AbstractVector<Long> {
|
|||
= new LongSpecies(VectorShape.S_Max_BIT,
|
||||
LongMaxVector.class,
|
||||
LongMaxVector.LongMaxMask.class,
|
||||
LongMaxVector.LongMaxShuffle.class,
|
||||
LongMaxVector::new);
|
||||
|
||||
/**
|
||||
|
|
|
@ -141,9 +141,24 @@ final class Short128Vector extends ShortVector {
|
|||
@ForceInline
|
||||
Short128Shuffle iotaShuffle() { return Short128Shuffle.IOTA; }
|
||||
|
||||
@ForceInline
|
||||
Short128Shuffle iotaShuffle(int start, int step, boolean wrap) {
|
||||
if (wrap) {
|
||||
return (Short128Shuffle)VectorSupport.shuffleIota(ETYPE, Short128Shuffle.class, VSPECIES, VLENGTH, start, step, 1,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
|
||||
} else {
|
||||
return (Short128Shuffle)VectorSupport.shuffleIota(ETYPE, Short128Shuffle.class, VSPECIES, VLENGTH, start, step, 0,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (i*lstep + lstart)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Short128Shuffle shuffleFromArray(int[] indices, int i) { return new Short128Shuffle(indices, i); }
|
||||
Short128Shuffle shuffleFromBytes(byte[] reorder) { return new Short128Shuffle(reorder); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Short128Shuffle shuffleFromArray(int[] indexes, int i) { return new Short128Shuffle(indexes, i); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
|
@ -342,11 +357,9 @@ final class Short128Vector extends ShortVector {
|
|||
return (long) super.reduceLanesTemplate(op, Short128Mask.class, (Short128Mask) m); // specialized
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final
|
||||
<F> VectorShuffle<F> toShuffle(AbstractSpecies<F> dsp) {
|
||||
return super.toShuffleTemplate(dsp);
|
||||
public VectorShuffle<Short> toShuffle() {
|
||||
return super.toShuffleTemplate(Short128Shuffle.class); // specialize
|
||||
}
|
||||
|
||||
// Specialized unary testing
|
||||
|
@ -775,26 +788,23 @@ final class Short128Vector extends ShortVector {
|
|||
static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM
|
||||
static final Class<Short> ETYPE = short.class; // used by the JVM
|
||||
|
||||
Short128Shuffle(short[] indices) {
|
||||
super(indices);
|
||||
assert(VLENGTH == indices.length);
|
||||
assert(indicesInRange(indices));
|
||||
Short128Shuffle(byte[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Short128Shuffle(int[] indices, int i) {
|
||||
this(prepare(indices, i));
|
||||
public Short128Shuffle(int[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Short128Shuffle(IntUnaryOperator fn) {
|
||||
this(prepare(fn));
|
||||
public Short128Shuffle(int[] reorder, int i) {
|
||||
super(VLENGTH, reorder, i);
|
||||
}
|
||||
|
||||
short[] indices() {
|
||||
return (short[])getPayload();
|
||||
public Short128Shuffle(IntUnaryOperator fn) {
|
||||
super(VLENGTH, fn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public ShortSpecies vspecies() {
|
||||
return VSPECIES;
|
||||
}
|
||||
|
@ -802,77 +812,40 @@ final class Short128Vector extends ShortVector {
|
|||
static {
|
||||
// There must be enough bits in the shuffle lanes to encode
|
||||
// VLENGTH valid indexes and VLENGTH exceptional ones.
|
||||
assert(VLENGTH < Short.MAX_VALUE);
|
||||
assert(Short.MIN_VALUE <= -VLENGTH);
|
||||
assert(VLENGTH < Byte.MAX_VALUE);
|
||||
assert(Byte.MIN_VALUE <= -VLENGTH);
|
||||
}
|
||||
static final Short128Shuffle IOTA = new Short128Shuffle(IDENTITY);
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Short128Vector toBitsVector() {
|
||||
return (Short128Vector) super.toBitsVectorTemplate();
|
||||
public Short128Vector toVector() {
|
||||
return VectorSupport.shuffleToVector(VCLASS, ETYPE, Short128Shuffle.class, this, VLENGTH,
|
||||
(s) -> ((Short128Vector)(((AbstractShuffle<Short>)(s)).toVectorTemplate())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
ShortVector toBitsVector0() {
|
||||
return Short128Vector.VSPECIES.dummyVector().vectorFactory(indices());
|
||||
public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
|
||||
AbstractSpecies<F> species = (AbstractSpecies<F>) s;
|
||||
if (length() != species.laneCount())
|
||||
throw new IllegalArgumentException("VectorShuffle length and species length differ");
|
||||
int[] shuffleArray = toArray();
|
||||
return s.shuffleFromArray(shuffleArray, 0).check(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public int laneSource(int i) {
|
||||
return (int)toBitsVector().lane(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoArray(int[] a, int offset) {
|
||||
VectorSpecies<Integer> species = IntVector.SPECIES_128;
|
||||
Vector<Short> v = toBitsVector();
|
||||
v.convertShape(VectorOperators.S2I, species, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
v.convertShape(VectorOperators.S2I, species, 1)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset + species.length());
|
||||
}
|
||||
|
||||
private static short[] prepare(int[] indices, int offset) {
|
||||
short[] a = new short[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = indices[offset + i];
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (short)si;
|
||||
public Short128Shuffle rearrange(VectorShuffle<Short> shuffle) {
|
||||
Short128Shuffle s = (Short128Shuffle) shuffle;
|
||||
byte[] reorder1 = reorder();
|
||||
byte[] reorder2 = s.reorder();
|
||||
byte[] r = new byte[reorder1.length];
|
||||
for (int i = 0; i < reorder1.length; i++) {
|
||||
int ssi = reorder2[i];
|
||||
r[i] = reorder1[ssi]; // throws on exceptional index
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static short[] prepare(IntUnaryOperator f) {
|
||||
short[] a = new short[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = f.applyAsInt(i);
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (short)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static boolean indicesInRange(short[] indices) {
|
||||
int length = indices.length;
|
||||
for (short si : indices) {
|
||||
if (si >= (short)length || si < (short)(-length)) {
|
||||
boolean assertsEnabled = false;
|
||||
assert(assertsEnabled = true);
|
||||
if (assertsEnabled) {
|
||||
String msg = ("index "+si+"out of range ["+length+"] in "+
|
||||
java.util.Arrays.toString(indices));
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return new Short128Shuffle(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -141,9 +141,24 @@ final class Short256Vector extends ShortVector {
|
|||
@ForceInline
|
||||
Short256Shuffle iotaShuffle() { return Short256Shuffle.IOTA; }
|
||||
|
||||
@ForceInline
|
||||
Short256Shuffle iotaShuffle(int start, int step, boolean wrap) {
|
||||
if (wrap) {
|
||||
return (Short256Shuffle)VectorSupport.shuffleIota(ETYPE, Short256Shuffle.class, VSPECIES, VLENGTH, start, step, 1,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
|
||||
} else {
|
||||
return (Short256Shuffle)VectorSupport.shuffleIota(ETYPE, Short256Shuffle.class, VSPECIES, VLENGTH, start, step, 0,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (i*lstep + lstart)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Short256Shuffle shuffleFromArray(int[] indices, int i) { return new Short256Shuffle(indices, i); }
|
||||
Short256Shuffle shuffleFromBytes(byte[] reorder) { return new Short256Shuffle(reorder); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Short256Shuffle shuffleFromArray(int[] indexes, int i) { return new Short256Shuffle(indexes, i); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
|
@ -342,11 +357,9 @@ final class Short256Vector extends ShortVector {
|
|||
return (long) super.reduceLanesTemplate(op, Short256Mask.class, (Short256Mask) m); // specialized
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final
|
||||
<F> VectorShuffle<F> toShuffle(AbstractSpecies<F> dsp) {
|
||||
return super.toShuffleTemplate(dsp);
|
||||
public VectorShuffle<Short> toShuffle() {
|
||||
return super.toShuffleTemplate(Short256Shuffle.class); // specialize
|
||||
}
|
||||
|
||||
// Specialized unary testing
|
||||
|
@ -791,26 +804,23 @@ final class Short256Vector extends ShortVector {
|
|||
static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM
|
||||
static final Class<Short> ETYPE = short.class; // used by the JVM
|
||||
|
||||
Short256Shuffle(short[] indices) {
|
||||
super(indices);
|
||||
assert(VLENGTH == indices.length);
|
||||
assert(indicesInRange(indices));
|
||||
Short256Shuffle(byte[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Short256Shuffle(int[] indices, int i) {
|
||||
this(prepare(indices, i));
|
||||
public Short256Shuffle(int[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Short256Shuffle(IntUnaryOperator fn) {
|
||||
this(prepare(fn));
|
||||
public Short256Shuffle(int[] reorder, int i) {
|
||||
super(VLENGTH, reorder, i);
|
||||
}
|
||||
|
||||
short[] indices() {
|
||||
return (short[])getPayload();
|
||||
public Short256Shuffle(IntUnaryOperator fn) {
|
||||
super(VLENGTH, fn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public ShortSpecies vspecies() {
|
||||
return VSPECIES;
|
||||
}
|
||||
|
@ -818,77 +828,40 @@ final class Short256Vector extends ShortVector {
|
|||
static {
|
||||
// There must be enough bits in the shuffle lanes to encode
|
||||
// VLENGTH valid indexes and VLENGTH exceptional ones.
|
||||
assert(VLENGTH < Short.MAX_VALUE);
|
||||
assert(Short.MIN_VALUE <= -VLENGTH);
|
||||
assert(VLENGTH < Byte.MAX_VALUE);
|
||||
assert(Byte.MIN_VALUE <= -VLENGTH);
|
||||
}
|
||||
static final Short256Shuffle IOTA = new Short256Shuffle(IDENTITY);
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Short256Vector toBitsVector() {
|
||||
return (Short256Vector) super.toBitsVectorTemplate();
|
||||
public Short256Vector toVector() {
|
||||
return VectorSupport.shuffleToVector(VCLASS, ETYPE, Short256Shuffle.class, this, VLENGTH,
|
||||
(s) -> ((Short256Vector)(((AbstractShuffle<Short>)(s)).toVectorTemplate())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
ShortVector toBitsVector0() {
|
||||
return Short256Vector.VSPECIES.dummyVector().vectorFactory(indices());
|
||||
public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
|
||||
AbstractSpecies<F> species = (AbstractSpecies<F>) s;
|
||||
if (length() != species.laneCount())
|
||||
throw new IllegalArgumentException("VectorShuffle length and species length differ");
|
||||
int[] shuffleArray = toArray();
|
||||
return s.shuffleFromArray(shuffleArray, 0).check(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public int laneSource(int i) {
|
||||
return (int)toBitsVector().lane(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoArray(int[] a, int offset) {
|
||||
VectorSpecies<Integer> species = IntVector.SPECIES_256;
|
||||
Vector<Short> v = toBitsVector();
|
||||
v.convertShape(VectorOperators.S2I, species, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
v.convertShape(VectorOperators.S2I, species, 1)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset + species.length());
|
||||
}
|
||||
|
||||
private static short[] prepare(int[] indices, int offset) {
|
||||
short[] a = new short[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = indices[offset + i];
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (short)si;
|
||||
public Short256Shuffle rearrange(VectorShuffle<Short> shuffle) {
|
||||
Short256Shuffle s = (Short256Shuffle) shuffle;
|
||||
byte[] reorder1 = reorder();
|
||||
byte[] reorder2 = s.reorder();
|
||||
byte[] r = new byte[reorder1.length];
|
||||
for (int i = 0; i < reorder1.length; i++) {
|
||||
int ssi = reorder2[i];
|
||||
r[i] = reorder1[ssi]; // throws on exceptional index
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static short[] prepare(IntUnaryOperator f) {
|
||||
short[] a = new short[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = f.applyAsInt(i);
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (short)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static boolean indicesInRange(short[] indices) {
|
||||
int length = indices.length;
|
||||
for (short si : indices) {
|
||||
if (si >= (short)length || si < (short)(-length)) {
|
||||
boolean assertsEnabled = false;
|
||||
assert(assertsEnabled = true);
|
||||
if (assertsEnabled) {
|
||||
String msg = ("index "+si+"out of range ["+length+"] in "+
|
||||
java.util.Arrays.toString(indices));
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return new Short256Shuffle(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -141,9 +141,24 @@ final class Short512Vector extends ShortVector {
|
|||
@ForceInline
|
||||
Short512Shuffle iotaShuffle() { return Short512Shuffle.IOTA; }
|
||||
|
||||
@ForceInline
|
||||
Short512Shuffle iotaShuffle(int start, int step, boolean wrap) {
|
||||
if (wrap) {
|
||||
return (Short512Shuffle)VectorSupport.shuffleIota(ETYPE, Short512Shuffle.class, VSPECIES, VLENGTH, start, step, 1,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
|
||||
} else {
|
||||
return (Short512Shuffle)VectorSupport.shuffleIota(ETYPE, Short512Shuffle.class, VSPECIES, VLENGTH, start, step, 0,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (i*lstep + lstart)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Short512Shuffle shuffleFromArray(int[] indices, int i) { return new Short512Shuffle(indices, i); }
|
||||
Short512Shuffle shuffleFromBytes(byte[] reorder) { return new Short512Shuffle(reorder); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Short512Shuffle shuffleFromArray(int[] indexes, int i) { return new Short512Shuffle(indexes, i); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
|
@ -342,11 +357,9 @@ final class Short512Vector extends ShortVector {
|
|||
return (long) super.reduceLanesTemplate(op, Short512Mask.class, (Short512Mask) m); // specialized
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final
|
||||
<F> VectorShuffle<F> toShuffle(AbstractSpecies<F> dsp) {
|
||||
return super.toShuffleTemplate(dsp);
|
||||
public VectorShuffle<Short> toShuffle() {
|
||||
return super.toShuffleTemplate(Short512Shuffle.class); // specialize
|
||||
}
|
||||
|
||||
// Specialized unary testing
|
||||
|
@ -823,26 +836,23 @@ final class Short512Vector extends ShortVector {
|
|||
static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM
|
||||
static final Class<Short> ETYPE = short.class; // used by the JVM
|
||||
|
||||
Short512Shuffle(short[] indices) {
|
||||
super(indices);
|
||||
assert(VLENGTH == indices.length);
|
||||
assert(indicesInRange(indices));
|
||||
Short512Shuffle(byte[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Short512Shuffle(int[] indices, int i) {
|
||||
this(prepare(indices, i));
|
||||
public Short512Shuffle(int[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Short512Shuffle(IntUnaryOperator fn) {
|
||||
this(prepare(fn));
|
||||
public Short512Shuffle(int[] reorder, int i) {
|
||||
super(VLENGTH, reorder, i);
|
||||
}
|
||||
|
||||
short[] indices() {
|
||||
return (short[])getPayload();
|
||||
public Short512Shuffle(IntUnaryOperator fn) {
|
||||
super(VLENGTH, fn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public ShortSpecies vspecies() {
|
||||
return VSPECIES;
|
||||
}
|
||||
|
@ -850,77 +860,40 @@ final class Short512Vector extends ShortVector {
|
|||
static {
|
||||
// There must be enough bits in the shuffle lanes to encode
|
||||
// VLENGTH valid indexes and VLENGTH exceptional ones.
|
||||
assert(VLENGTH < Short.MAX_VALUE);
|
||||
assert(Short.MIN_VALUE <= -VLENGTH);
|
||||
assert(VLENGTH < Byte.MAX_VALUE);
|
||||
assert(Byte.MIN_VALUE <= -VLENGTH);
|
||||
}
|
||||
static final Short512Shuffle IOTA = new Short512Shuffle(IDENTITY);
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Short512Vector toBitsVector() {
|
||||
return (Short512Vector) super.toBitsVectorTemplate();
|
||||
public Short512Vector toVector() {
|
||||
return VectorSupport.shuffleToVector(VCLASS, ETYPE, Short512Shuffle.class, this, VLENGTH,
|
||||
(s) -> ((Short512Vector)(((AbstractShuffle<Short>)(s)).toVectorTemplate())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
ShortVector toBitsVector0() {
|
||||
return Short512Vector.VSPECIES.dummyVector().vectorFactory(indices());
|
||||
public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
|
||||
AbstractSpecies<F> species = (AbstractSpecies<F>) s;
|
||||
if (length() != species.laneCount())
|
||||
throw new IllegalArgumentException("VectorShuffle length and species length differ");
|
||||
int[] shuffleArray = toArray();
|
||||
return s.shuffleFromArray(shuffleArray, 0).check(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public int laneSource(int i) {
|
||||
return (int)toBitsVector().lane(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoArray(int[] a, int offset) {
|
||||
VectorSpecies<Integer> species = IntVector.SPECIES_512;
|
||||
Vector<Short> v = toBitsVector();
|
||||
v.convertShape(VectorOperators.S2I, species, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
v.convertShape(VectorOperators.S2I, species, 1)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset + species.length());
|
||||
}
|
||||
|
||||
private static short[] prepare(int[] indices, int offset) {
|
||||
short[] a = new short[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = indices[offset + i];
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (short)si;
|
||||
public Short512Shuffle rearrange(VectorShuffle<Short> shuffle) {
|
||||
Short512Shuffle s = (Short512Shuffle) shuffle;
|
||||
byte[] reorder1 = reorder();
|
||||
byte[] reorder2 = s.reorder();
|
||||
byte[] r = new byte[reorder1.length];
|
||||
for (int i = 0; i < reorder1.length; i++) {
|
||||
int ssi = reorder2[i];
|
||||
r[i] = reorder1[ssi]; // throws on exceptional index
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static short[] prepare(IntUnaryOperator f) {
|
||||
short[] a = new short[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = f.applyAsInt(i);
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (short)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static boolean indicesInRange(short[] indices) {
|
||||
int length = indices.length;
|
||||
for (short si : indices) {
|
||||
if (si >= (short)length || si < (short)(-length)) {
|
||||
boolean assertsEnabled = false;
|
||||
assert(assertsEnabled = true);
|
||||
if (assertsEnabled) {
|
||||
String msg = ("index "+si+"out of range ["+length+"] in "+
|
||||
java.util.Arrays.toString(indices));
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return new Short512Shuffle(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -141,9 +141,24 @@ final class Short64Vector extends ShortVector {
|
|||
@ForceInline
|
||||
Short64Shuffle iotaShuffle() { return Short64Shuffle.IOTA; }
|
||||
|
||||
@ForceInline
|
||||
Short64Shuffle iotaShuffle(int start, int step, boolean wrap) {
|
||||
if (wrap) {
|
||||
return (Short64Shuffle)VectorSupport.shuffleIota(ETYPE, Short64Shuffle.class, VSPECIES, VLENGTH, start, step, 1,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
|
||||
} else {
|
||||
return (Short64Shuffle)VectorSupport.shuffleIota(ETYPE, Short64Shuffle.class, VSPECIES, VLENGTH, start, step, 0,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (i*lstep + lstart)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Short64Shuffle shuffleFromArray(int[] indices, int i) { return new Short64Shuffle(indices, i); }
|
||||
Short64Shuffle shuffleFromBytes(byte[] reorder) { return new Short64Shuffle(reorder); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Short64Shuffle shuffleFromArray(int[] indexes, int i) { return new Short64Shuffle(indexes, i); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
|
@ -342,11 +357,9 @@ final class Short64Vector extends ShortVector {
|
|||
return (long) super.reduceLanesTemplate(op, Short64Mask.class, (Short64Mask) m); // specialized
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final
|
||||
<F> VectorShuffle<F> toShuffle(AbstractSpecies<F> dsp) {
|
||||
return super.toShuffleTemplate(dsp);
|
||||
public VectorShuffle<Short> toShuffle() {
|
||||
return super.toShuffleTemplate(Short64Shuffle.class); // specialize
|
||||
}
|
||||
|
||||
// Specialized unary testing
|
||||
|
@ -767,26 +780,23 @@ final class Short64Vector extends ShortVector {
|
|||
static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM
|
||||
static final Class<Short> ETYPE = short.class; // used by the JVM
|
||||
|
||||
Short64Shuffle(short[] indices) {
|
||||
super(indices);
|
||||
assert(VLENGTH == indices.length);
|
||||
assert(indicesInRange(indices));
|
||||
Short64Shuffle(byte[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Short64Shuffle(int[] indices, int i) {
|
||||
this(prepare(indices, i));
|
||||
public Short64Shuffle(int[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
Short64Shuffle(IntUnaryOperator fn) {
|
||||
this(prepare(fn));
|
||||
public Short64Shuffle(int[] reorder, int i) {
|
||||
super(VLENGTH, reorder, i);
|
||||
}
|
||||
|
||||
short[] indices() {
|
||||
return (short[])getPayload();
|
||||
public Short64Shuffle(IntUnaryOperator fn) {
|
||||
super(VLENGTH, fn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public ShortSpecies vspecies() {
|
||||
return VSPECIES;
|
||||
}
|
||||
|
@ -794,77 +804,40 @@ final class Short64Vector extends ShortVector {
|
|||
static {
|
||||
// There must be enough bits in the shuffle lanes to encode
|
||||
// VLENGTH valid indexes and VLENGTH exceptional ones.
|
||||
assert(VLENGTH < Short.MAX_VALUE);
|
||||
assert(Short.MIN_VALUE <= -VLENGTH);
|
||||
assert(VLENGTH < Byte.MAX_VALUE);
|
||||
assert(Byte.MIN_VALUE <= -VLENGTH);
|
||||
}
|
||||
static final Short64Shuffle IOTA = new Short64Shuffle(IDENTITY);
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
Short64Vector toBitsVector() {
|
||||
return (Short64Vector) super.toBitsVectorTemplate();
|
||||
public Short64Vector toVector() {
|
||||
return VectorSupport.shuffleToVector(VCLASS, ETYPE, Short64Shuffle.class, this, VLENGTH,
|
||||
(s) -> ((Short64Vector)(((AbstractShuffle<Short>)(s)).toVectorTemplate())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
ShortVector toBitsVector0() {
|
||||
return Short64Vector.VSPECIES.dummyVector().vectorFactory(indices());
|
||||
public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
|
||||
AbstractSpecies<F> species = (AbstractSpecies<F>) s;
|
||||
if (length() != species.laneCount())
|
||||
throw new IllegalArgumentException("VectorShuffle length and species length differ");
|
||||
int[] shuffleArray = toArray();
|
||||
return s.shuffleFromArray(shuffleArray, 0).check(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public int laneSource(int i) {
|
||||
return (int)toBitsVector().lane(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoArray(int[] a, int offset) {
|
||||
VectorSpecies<Integer> species = IntVector.SPECIES_64;
|
||||
Vector<Short> v = toBitsVector();
|
||||
v.convertShape(VectorOperators.S2I, species, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
v.convertShape(VectorOperators.S2I, species, 1)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset + species.length());
|
||||
}
|
||||
|
||||
private static short[] prepare(int[] indices, int offset) {
|
||||
short[] a = new short[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = indices[offset + i];
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (short)si;
|
||||
public Short64Shuffle rearrange(VectorShuffle<Short> shuffle) {
|
||||
Short64Shuffle s = (Short64Shuffle) shuffle;
|
||||
byte[] reorder1 = reorder();
|
||||
byte[] reorder2 = s.reorder();
|
||||
byte[] r = new byte[reorder1.length];
|
||||
for (int i = 0; i < reorder1.length; i++) {
|
||||
int ssi = reorder2[i];
|
||||
r[i] = reorder1[ssi]; // throws on exceptional index
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static short[] prepare(IntUnaryOperator f) {
|
||||
short[] a = new short[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = f.applyAsInt(i);
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (short)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static boolean indicesInRange(short[] indices) {
|
||||
int length = indices.length;
|
||||
for (short si : indices) {
|
||||
if (si >= (short)length || si < (short)(-length)) {
|
||||
boolean assertsEnabled = false;
|
||||
assert(assertsEnabled = true);
|
||||
if (assertsEnabled) {
|
||||
String msg = ("index "+si+"out of range ["+length+"] in "+
|
||||
java.util.Arrays.toString(indices));
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return new Short64Shuffle(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -141,9 +141,24 @@ final class ShortMaxVector extends ShortVector {
|
|||
@ForceInline
|
||||
ShortMaxShuffle iotaShuffle() { return ShortMaxShuffle.IOTA; }
|
||||
|
||||
@ForceInline
|
||||
ShortMaxShuffle iotaShuffle(int start, int step, boolean wrap) {
|
||||
if (wrap) {
|
||||
return (ShortMaxShuffle)VectorSupport.shuffleIota(ETYPE, ShortMaxShuffle.class, VSPECIES, VLENGTH, start, step, 1,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
|
||||
} else {
|
||||
return (ShortMaxShuffle)VectorSupport.shuffleIota(ETYPE, ShortMaxShuffle.class, VSPECIES, VLENGTH, start, step, 0,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (i*lstep + lstart)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
ShortMaxShuffle shuffleFromArray(int[] indices, int i) { return new ShortMaxShuffle(indices, i); }
|
||||
ShortMaxShuffle shuffleFromBytes(byte[] reorder) { return new ShortMaxShuffle(reorder); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
ShortMaxShuffle shuffleFromArray(int[] indexes, int i) { return new ShortMaxShuffle(indexes, i); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
|
@ -342,11 +357,9 @@ final class ShortMaxVector extends ShortVector {
|
|||
return (long) super.reduceLanesTemplate(op, ShortMaxMask.class, (ShortMaxMask) m); // specialized
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final
|
||||
<F> VectorShuffle<F> toShuffle(AbstractSpecies<F> dsp) {
|
||||
return super.toShuffleTemplate(dsp);
|
||||
public VectorShuffle<Short> toShuffle() {
|
||||
return super.toShuffleTemplate(ShortMaxShuffle.class); // specialize
|
||||
}
|
||||
|
||||
// Specialized unary testing
|
||||
|
@ -761,26 +774,23 @@ final class ShortMaxVector extends ShortVector {
|
|||
static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM
|
||||
static final Class<Short> ETYPE = short.class; // used by the JVM
|
||||
|
||||
ShortMaxShuffle(short[] indices) {
|
||||
super(indices);
|
||||
assert(VLENGTH == indices.length);
|
||||
assert(indicesInRange(indices));
|
||||
ShortMaxShuffle(byte[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
ShortMaxShuffle(int[] indices, int i) {
|
||||
this(prepare(indices, i));
|
||||
public ShortMaxShuffle(int[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
ShortMaxShuffle(IntUnaryOperator fn) {
|
||||
this(prepare(fn));
|
||||
public ShortMaxShuffle(int[] reorder, int i) {
|
||||
super(VLENGTH, reorder, i);
|
||||
}
|
||||
|
||||
short[] indices() {
|
||||
return (short[])getPayload();
|
||||
public ShortMaxShuffle(IntUnaryOperator fn) {
|
||||
super(VLENGTH, fn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public ShortSpecies vspecies() {
|
||||
return VSPECIES;
|
||||
}
|
||||
|
@ -788,77 +798,40 @@ final class ShortMaxVector extends ShortVector {
|
|||
static {
|
||||
// There must be enough bits in the shuffle lanes to encode
|
||||
// VLENGTH valid indexes and VLENGTH exceptional ones.
|
||||
assert(VLENGTH < Short.MAX_VALUE);
|
||||
assert(Short.MIN_VALUE <= -VLENGTH);
|
||||
assert(VLENGTH < Byte.MAX_VALUE);
|
||||
assert(Byte.MIN_VALUE <= -VLENGTH);
|
||||
}
|
||||
static final ShortMaxShuffle IOTA = new ShortMaxShuffle(IDENTITY);
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
ShortMaxVector toBitsVector() {
|
||||
return (ShortMaxVector) super.toBitsVectorTemplate();
|
||||
public ShortMaxVector toVector() {
|
||||
return VectorSupport.shuffleToVector(VCLASS, ETYPE, ShortMaxShuffle.class, this, VLENGTH,
|
||||
(s) -> ((ShortMaxVector)(((AbstractShuffle<Short>)(s)).toVectorTemplate())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
ShortVector toBitsVector0() {
|
||||
return ShortMaxVector.VSPECIES.dummyVector().vectorFactory(indices());
|
||||
public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
|
||||
AbstractSpecies<F> species = (AbstractSpecies<F>) s;
|
||||
if (length() != species.laneCount())
|
||||
throw new IllegalArgumentException("VectorShuffle length and species length differ");
|
||||
int[] shuffleArray = toArray();
|
||||
return s.shuffleFromArray(shuffleArray, 0).check(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public int laneSource(int i) {
|
||||
return (int)toBitsVector().lane(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoArray(int[] a, int offset) {
|
||||
VectorSpecies<Integer> species = IntVector.SPECIES_MAX;
|
||||
Vector<Short> v = toBitsVector();
|
||||
v.convertShape(VectorOperators.S2I, species, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
v.convertShape(VectorOperators.S2I, species, 1)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset + species.length());
|
||||
}
|
||||
|
||||
private static short[] prepare(int[] indices, int offset) {
|
||||
short[] a = new short[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = indices[offset + i];
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (short)si;
|
||||
public ShortMaxShuffle rearrange(VectorShuffle<Short> shuffle) {
|
||||
ShortMaxShuffle s = (ShortMaxShuffle) shuffle;
|
||||
byte[] reorder1 = reorder();
|
||||
byte[] reorder2 = s.reorder();
|
||||
byte[] r = new byte[reorder1.length];
|
||||
for (int i = 0; i < reorder1.length; i++) {
|
||||
int ssi = reorder2[i];
|
||||
r[i] = reorder1[ssi]; // throws on exceptional index
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static short[] prepare(IntUnaryOperator f) {
|
||||
short[] a = new short[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = f.applyAsInt(i);
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = (short)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static boolean indicesInRange(short[] indices) {
|
||||
int length = indices.length;
|
||||
for (short si : indices) {
|
||||
if (si >= (short)length || si < (short)(-length)) {
|
||||
boolean assertsEnabled = false;
|
||||
assert(assertsEnabled = true);
|
||||
if (assertsEnabled) {
|
||||
String msg = ("index "+si+"out of range ["+length+"] in "+
|
||||
java.util.Arrays.toString(indices));
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return new ShortMaxShuffle(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -1071,7 +1071,7 @@ public abstract class ShortVector extends AbstractVector<Short> {
|
|||
// and broadcast, but it would be more surprising not to continue
|
||||
// the obvious pattern started by unary and binary.
|
||||
|
||||
/**
|
||||
/**
|
||||
* {@inheritDoc} <!--workaround-->
|
||||
* @see #lanewise(VectorOperators.Ternary,short,short,VectorMask)
|
||||
* @see #lanewise(VectorOperators.Ternary,Vector,short,VectorMask)
|
||||
|
@ -2481,8 +2481,8 @@ public abstract class ShortVector extends AbstractVector<Short> {
|
|||
}
|
||||
|
||||
@ForceInline
|
||||
final <F>
|
||||
VectorShuffle<F> toShuffle0(AbstractSpecies<F> dsp) {
|
||||
private final
|
||||
VectorShuffle<Short> toShuffle0(ShortSpecies dsp) {
|
||||
short[] a = toArray();
|
||||
int[] sa = new int[a.length];
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
|
@ -2491,6 +2491,18 @@ public abstract class ShortVector extends AbstractVector<Short> {
|
|||
return VectorShuffle.fromArray(dsp, sa, 0);
|
||||
}
|
||||
|
||||
/*package-private*/
|
||||
@ForceInline
|
||||
final
|
||||
VectorShuffle<Short> toShuffleTemplate(Class<?> shuffleType) {
|
||||
ShortSpecies vsp = vspecies();
|
||||
return VectorSupport.convert(VectorSupport.VECTOR_OP_CAST,
|
||||
getClass(), short.class, length(),
|
||||
shuffleType, byte.class, length(),
|
||||
this, vsp,
|
||||
ShortVector::toShuffle0);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} <!--workaround-->
|
||||
* @since 19
|
||||
|
@ -4078,10 +4090,9 @@ public abstract class ShortVector extends AbstractVector<Short> {
|
|||
private ShortSpecies(VectorShape shape,
|
||||
Class<? extends ShortVector> vectorType,
|
||||
Class<? extends AbstractMask<Short>> maskType,
|
||||
Class<? extends AbstractShuffle<Short>> shuffleType,
|
||||
Function<Object, ShortVector> vectorFactory) {
|
||||
super(shape, LaneType.of(short.class),
|
||||
vectorType, maskType, shuffleType,
|
||||
vectorType, maskType,
|
||||
vectorFactory);
|
||||
assert(this.elementSize() == Short.SIZE);
|
||||
}
|
||||
|
@ -4357,7 +4368,6 @@ public abstract class ShortVector extends AbstractVector<Short> {
|
|||
= new ShortSpecies(VectorShape.S_64_BIT,
|
||||
Short64Vector.class,
|
||||
Short64Vector.Short64Mask.class,
|
||||
Short64Vector.Short64Shuffle.class,
|
||||
Short64Vector::new);
|
||||
|
||||
/** Species representing {@link ShortVector}s of {@link VectorShape#S_128_BIT VectorShape.S_128_BIT}. */
|
||||
|
@ -4365,7 +4375,6 @@ public abstract class ShortVector extends AbstractVector<Short> {
|
|||
= new ShortSpecies(VectorShape.S_128_BIT,
|
||||
Short128Vector.class,
|
||||
Short128Vector.Short128Mask.class,
|
||||
Short128Vector.Short128Shuffle.class,
|
||||
Short128Vector::new);
|
||||
|
||||
/** Species representing {@link ShortVector}s of {@link VectorShape#S_256_BIT VectorShape.S_256_BIT}. */
|
||||
|
@ -4373,7 +4382,6 @@ public abstract class ShortVector extends AbstractVector<Short> {
|
|||
= new ShortSpecies(VectorShape.S_256_BIT,
|
||||
Short256Vector.class,
|
||||
Short256Vector.Short256Mask.class,
|
||||
Short256Vector.Short256Shuffle.class,
|
||||
Short256Vector::new);
|
||||
|
||||
/** Species representing {@link ShortVector}s of {@link VectorShape#S_512_BIT VectorShape.S_512_BIT}. */
|
||||
|
@ -4381,7 +4389,6 @@ public abstract class ShortVector extends AbstractVector<Short> {
|
|||
= new ShortSpecies(VectorShape.S_512_BIT,
|
||||
Short512Vector.class,
|
||||
Short512Vector.Short512Mask.class,
|
||||
Short512Vector.Short512Shuffle.class,
|
||||
Short512Vector::new);
|
||||
|
||||
/** Species representing {@link ShortVector}s of {@link VectorShape#S_Max_BIT VectorShape.S_Max_BIT}. */
|
||||
|
@ -4389,7 +4396,6 @@ public abstract class ShortVector extends AbstractVector<Short> {
|
|||
= new ShortSpecies(VectorShape.S_Max_BIT,
|
||||
ShortMaxVector.class,
|
||||
ShortMaxVector.ShortMaxMask.class,
|
||||
ShortMaxVector.ShortMaxShuffle.class,
|
||||
ShortMaxVector::new);
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -124,7 +124,6 @@ public enum VectorShape {
|
|||
* @throws IllegalArgumentException if no such vector shape exists
|
||||
* @see #vectorBitSize()
|
||||
*/
|
||||
@ForceInline
|
||||
public static VectorShape forBitSize(int bitSize) {
|
||||
switch (bitSize) {
|
||||
case 64:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -133,8 +133,8 @@ import java.util.function.IntUnaryOperator;
|
|||
*/
|
||||
@SuppressWarnings("exports")
|
||||
public abstract class VectorShuffle<E> extends jdk.internal.vm.vector.VectorSupport.VectorShuffle<E> {
|
||||
VectorShuffle(Object indices) {
|
||||
super(indices);
|
||||
VectorShuffle(byte[] reorder) {
|
||||
super(reorder);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -556,7 +556,7 @@ public abstract class VectorShuffle<E> extends jdk.internal.vm.vector.VectorSupp
|
|||
* @param i the lane index
|
||||
* @return the {@code int} lane element at lane index {@code i}
|
||||
*/
|
||||
public abstract int laneSource(int i);
|
||||
public int laneSource(int i) { return toArray()[i]; }
|
||||
|
||||
/**
|
||||
* Rearranges the lane elements of this shuffle selecting lane indexes
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -24,8 +24,6 @@
|
|||
*/
|
||||
package jdk.incubator.vector;
|
||||
|
||||
import jdk.internal.vm.annotation.ForceInline;
|
||||
|
||||
import java.lang.foreign.MemorySegment;
|
||||
|
||||
import java.nio.ByteOrder;
|
||||
|
@ -344,7 +342,6 @@ public interface VectorSpecies<E> {
|
|||
* @see #withLanes(Class)
|
||||
* @see #withShape(VectorShape)
|
||||
*/
|
||||
@ForceInline
|
||||
static <E> VectorSpecies<E> of(Class<E> elementType, VectorShape shape) {
|
||||
LaneType laneType = LaneType.of(elementType);
|
||||
return AbstractSpecies.findSpecies(elementType, laneType, shape);
|
||||
|
@ -370,7 +367,6 @@ public interface VectorSpecies<E> {
|
|||
* or if the given type is not a valid {@code ETYPE}
|
||||
* @see VectorSpecies#ofPreferred(Class)
|
||||
*/
|
||||
@ForceInline
|
||||
static <E> VectorSpecies<E> ofLargestShape(Class<E> etype) {
|
||||
return VectorSpecies.of(etype, VectorShape.largestShapeFor(etype));
|
||||
}
|
||||
|
@ -414,7 +410,6 @@ public interface VectorSpecies<E> {
|
|||
* @see VectorShape#preferredShape()
|
||||
* @see VectorSpecies#ofLargestShape(Class)
|
||||
*/
|
||||
@ForceInline
|
||||
public static <E> VectorSpecies<E> ofPreferred(Class<E> etype) {
|
||||
return of(etype, VectorShape.preferredShape());
|
||||
}
|
||||
|
@ -437,7 +432,6 @@ public interface VectorSpecies<E> {
|
|||
* if the given {@code elementType} argument is not
|
||||
* a valid vector {@code ETYPE}
|
||||
*/
|
||||
@ForceInline
|
||||
static int elementSize(Class<?> elementType) {
|
||||
return LaneType.of(elementType).elementSize;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -1204,7 +1204,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> {
|
|||
// and broadcast, but it would be more surprising not to continue
|
||||
// the obvious pattern started by unary and binary.
|
||||
|
||||
/**
|
||||
/**
|
||||
* {@inheritDoc} <!--workaround-->
|
||||
* @see #lanewise(VectorOperators.Ternary,$type$,$type$,VectorMask)
|
||||
* @see #lanewise(VectorOperators.Ternary,Vector,$type$,VectorMask)
|
||||
|
@ -2857,8 +2857,8 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> {
|
|||
}
|
||||
|
||||
@ForceInline
|
||||
final <F>
|
||||
VectorShuffle<F> toShuffle0(AbstractSpecies<F> dsp) {
|
||||
private final
|
||||
VectorShuffle<$Boxtype$> toShuffle0($Type$Species dsp) {
|
||||
$type$[] a = toArray();
|
||||
int[] sa = new int[a.length];
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
|
@ -2867,6 +2867,18 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> {
|
|||
return VectorShuffle.fromArray(dsp, sa, 0);
|
||||
}
|
||||
|
||||
/*package-private*/
|
||||
@ForceInline
|
||||
final
|
||||
VectorShuffle<$Boxtype$> toShuffleTemplate(Class<?> shuffleType) {
|
||||
$Type$Species vsp = vspecies();
|
||||
return VectorSupport.convert(VectorSupport.VECTOR_OP_CAST,
|
||||
getClass(), $type$.class, length(),
|
||||
shuffleType, byte.class, length(),
|
||||
this, vsp,
|
||||
$Type$Vector::toShuffle0);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} <!--workaround-->
|
||||
* @since 19
|
||||
|
@ -5336,10 +5348,9 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> {
|
|||
private $Type$Species(VectorShape shape,
|
||||
Class<? extends $abstractvectortype$> vectorType,
|
||||
Class<? extends AbstractMask<$Boxtype$>> maskType,
|
||||
Class<? extends AbstractShuffle<$Boxtype$>> shuffleType,
|
||||
Function<Object, $abstractvectortype$> vectorFactory) {
|
||||
super(shape, LaneType.of($type$.class),
|
||||
vectorType, maskType, shuffleType,
|
||||
vectorType, maskType,
|
||||
vectorFactory);
|
||||
assert(this.elementSize() == $Boxtype$.SIZE);
|
||||
}
|
||||
|
@ -5622,7 +5633,6 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> {
|
|||
= new $Type$Species(VectorShape.S_64_BIT,
|
||||
$Type$64Vector.class,
|
||||
$Type$64Vector.$Type$64Mask.class,
|
||||
$Type$64Vector.$Type$64Shuffle.class,
|
||||
$Type$64Vector::new);
|
||||
|
||||
/** Species representing {@link $Type$Vector}s of {@link VectorShape#S_128_BIT VectorShape.S_128_BIT}. */
|
||||
|
@ -5630,7 +5640,6 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> {
|
|||
= new $Type$Species(VectorShape.S_128_BIT,
|
||||
$Type$128Vector.class,
|
||||
$Type$128Vector.$Type$128Mask.class,
|
||||
$Type$128Vector.$Type$128Shuffle.class,
|
||||
$Type$128Vector::new);
|
||||
|
||||
/** Species representing {@link $Type$Vector}s of {@link VectorShape#S_256_BIT VectorShape.S_256_BIT}. */
|
||||
|
@ -5638,7 +5647,6 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> {
|
|||
= new $Type$Species(VectorShape.S_256_BIT,
|
||||
$Type$256Vector.class,
|
||||
$Type$256Vector.$Type$256Mask.class,
|
||||
$Type$256Vector.$Type$256Shuffle.class,
|
||||
$Type$256Vector::new);
|
||||
|
||||
/** Species representing {@link $Type$Vector}s of {@link VectorShape#S_512_BIT VectorShape.S_512_BIT}. */
|
||||
|
@ -5646,7 +5654,6 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> {
|
|||
= new $Type$Species(VectorShape.S_512_BIT,
|
||||
$Type$512Vector.class,
|
||||
$Type$512Vector.$Type$512Mask.class,
|
||||
$Type$512Vector.$Type$512Shuffle.class,
|
||||
$Type$512Vector::new);
|
||||
|
||||
/** Species representing {@link $Type$Vector}s of {@link VectorShape#S_Max_BIT VectorShape.S_Max_BIT}. */
|
||||
|
@ -5654,7 +5661,6 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> {
|
|||
= new $Type$Species(VectorShape.S_Max_BIT,
|
||||
$Type$MaxVector.class,
|
||||
$Type$MaxVector.$Type$MaxMask.class,
|
||||
$Type$MaxVector.$Type$MaxShuffle.class,
|
||||
$Type$MaxVector::new);
|
||||
|
||||
/**
|
||||
|
|
|
@ -143,9 +143,24 @@ final class $vectortype$ extends $abstractvectortype$ {
|
|||
@ForceInline
|
||||
$shuffletype$ iotaShuffle() { return $shuffletype$.IOTA; }
|
||||
|
||||
@ForceInline
|
||||
$shuffletype$ iotaShuffle(int start, int step, boolean wrap) {
|
||||
if (wrap) {
|
||||
return ($shuffletype$)VectorSupport.shuffleIota(ETYPE, $shuffletype$.class, VSPECIES, VLENGTH, start, step, 1,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
|
||||
} else {
|
||||
return ($shuffletype$)VectorSupport.shuffleIota(ETYPE, $shuffletype$.class, VSPECIES, VLENGTH, start, step, 0,
|
||||
(l, lstart, lstep, s) -> s.shuffleFromOp(i -> (i*lstep + lstart)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
$shuffletype$ shuffleFromArray(int[] indices, int i) { return new $shuffletype$(indices, i); }
|
||||
$shuffletype$ shuffleFromBytes(byte[] reorder) { return new $shuffletype$(reorder); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
$shuffletype$ shuffleFromArray(int[] indexes, int i) { return new $shuffletype$(indexes, i); }
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
|
@ -346,11 +361,9 @@ final class $vectortype$ extends $abstractvectortype$ {
|
|||
return (long) super.reduceLanesTemplate(op, $masktype$.class, ($masktype$) m); // specialized
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final
|
||||
<F> VectorShuffle<F> toShuffle(AbstractSpecies<F> dsp) {
|
||||
return super.toShuffleTemplate(dsp);
|
||||
public VectorShuffle<$Boxtype$> toShuffle() {
|
||||
return super.toShuffleTemplate($shuffletype$.class); // specialize
|
||||
}
|
||||
|
||||
// Specialized unary testing
|
||||
|
@ -1047,28 +1060,25 @@ final class $vectortype$ extends $abstractvectortype$ {
|
|||
|
||||
static final class $shuffletype$ extends AbstractShuffle<$Boxtype$> {
|
||||
static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM
|
||||
static final Class<$Boxbitstype$> ETYPE = $bitstype$.class; // used by the JVM
|
||||
static final Class<$Boxtype$> ETYPE = $type$.class; // used by the JVM
|
||||
|
||||
$shuffletype$($bitstype$[] indices) {
|
||||
super(indices);
|
||||
assert(VLENGTH == indices.length);
|
||||
assert(indicesInRange(indices));
|
||||
$shuffletype$(byte[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
$shuffletype$(int[] indices, int i) {
|
||||
this(prepare(indices, i));
|
||||
public $shuffletype$(int[] reorder) {
|
||||
super(VLENGTH, reorder);
|
||||
}
|
||||
|
||||
$shuffletype$(IntUnaryOperator fn) {
|
||||
this(prepare(fn));
|
||||
public $shuffletype$(int[] reorder, int i) {
|
||||
super(VLENGTH, reorder, i);
|
||||
}
|
||||
|
||||
$bitstype$[] indices() {
|
||||
return ($bitstype$[])getPayload();
|
||||
public $shuffletype$(IntUnaryOperator fn) {
|
||||
super(VLENGTH, fn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public $Type$Species vspecies() {
|
||||
return VSPECIES;
|
||||
}
|
||||
|
@ -1076,125 +1086,40 @@ final class $vectortype$ extends $abstractvectortype$ {
|
|||
static {
|
||||
// There must be enough bits in the shuffle lanes to encode
|
||||
// VLENGTH valid indexes and VLENGTH exceptional ones.
|
||||
assert(VLENGTH < $Boxbitstype$.MAX_VALUE);
|
||||
assert($Boxbitstype$.MIN_VALUE <= -VLENGTH);
|
||||
assert(VLENGTH < Byte.MAX_VALUE);
|
||||
assert(Byte.MIN_VALUE <= -VLENGTH);
|
||||
}
|
||||
static final $shuffletype$ IOTA = new $shuffletype$(IDENTITY);
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
$bitsvectortype$ toBitsVector() {
|
||||
return ($bitsvectortype$) super.toBitsVectorTemplate();
|
||||
public $vectortype$ toVector() {
|
||||
return VectorSupport.shuffleToVector(VCLASS, ETYPE, $shuffletype$.class, this, VLENGTH,
|
||||
(s) -> (($vectortype$)(((AbstractShuffle<$Boxtype$>)(s)).toVectorTemplate())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
$Bitstype$Vector toBitsVector0() {
|
||||
return $bitsvectortype$.VSPECIES.dummyVector().vectorFactory(indices());
|
||||
public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
|
||||
AbstractSpecies<F> species = (AbstractSpecies<F>) s;
|
||||
if (length() != species.laneCount())
|
||||
throw new IllegalArgumentException("VectorShuffle length and species length differ");
|
||||
int[] shuffleArray = toArray();
|
||||
return s.shuffleFromArray(shuffleArray, 0).check(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public int laneSource(int i) {
|
||||
return (int)toBitsVector().lane(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoArray(int[] a, int offset) {
|
||||
#if[byte]
|
||||
VectorSpecies<Integer> species = IntVector.SPECIES_$BITS$;
|
||||
Vector<Byte> v = toBitsVector();
|
||||
v.convertShape(VectorOperators.B2I, species, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
v.convertShape(VectorOperators.B2I, species, 1)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset + species.length());
|
||||
v.convertShape(VectorOperators.B2I, species, 2)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset + species.length() * 2);
|
||||
v.convertShape(VectorOperators.B2I, species, 3)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset + species.length() * 3);
|
||||
#end[byte]
|
||||
#if[short]
|
||||
VectorSpecies<Integer> species = IntVector.SPECIES_$BITS$;
|
||||
Vector<Short> v = toBitsVector();
|
||||
v.convertShape(VectorOperators.S2I, species, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
v.convertShape(VectorOperators.S2I, species, 1)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset + species.length());
|
||||
#end[short]
|
||||
#if[intOrFloat]
|
||||
toBitsVector().intoArray(a, offset);
|
||||
#end[intOrFloat]
|
||||
#if[longOrDouble]
|
||||
switch (length()) {
|
||||
case 1 -> a[offset] = laneSource(0);
|
||||
case 2 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_64, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
case 4 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_128, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
case 8 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_256, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
case 16 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_512, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoArray(a, offset);
|
||||
default -> {
|
||||
VectorIntrinsics.checkFromIndexSize(offset, length(), a.length);
|
||||
for (int i = 0; i < length(); i++) {
|
||||
a[offset + i] = laneSource(i);
|
||||
}
|
||||
}
|
||||
public $shuffletype$ rearrange(VectorShuffle<$Boxtype$> shuffle) {
|
||||
$shuffletype$ s = ($shuffletype$) shuffle;
|
||||
byte[] reorder1 = reorder();
|
||||
byte[] reorder2 = s.reorder();
|
||||
byte[] r = new byte[reorder1.length];
|
||||
for (int i = 0; i < reorder1.length; i++) {
|
||||
int ssi = reorder2[i];
|
||||
r[i] = reorder1[ssi]; // throws on exceptional index
|
||||
}
|
||||
#end[longOrDouble]
|
||||
}
|
||||
|
||||
private static $bitstype$[] prepare(int[] indices, int offset) {
|
||||
$bitstype$[] a = new $bitstype$[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = indices[offset + i];
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = ($bitstype$)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static $bitstype$[] prepare(IntUnaryOperator f) {
|
||||
$bitstype$[] a = new $bitstype$[VLENGTH];
|
||||
for (int i = 0; i < VLENGTH; i++) {
|
||||
int si = f.applyAsInt(i);
|
||||
si = partiallyWrapIndex(si, VLENGTH);
|
||||
a[i] = ($bitstype$)si;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static boolean indicesInRange($bitstype$[] indices) {
|
||||
int length = indices.length;
|
||||
for ($bitstype$ si : indices) {
|
||||
if (si >= ($bitstype$)length || si < ($bitstype$)(-length)) {
|
||||
boolean assertsEnabled = false;
|
||||
assert(assertsEnabled = true);
|
||||
if (assertsEnabled) {
|
||||
String msg = ("index "+si+"out of range ["+length+"] in "+
|
||||
java.util.Arrays.toString(indices));
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return new $shuffletype$(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue