8268151: Vector API toShuffle optimization

Reviewed-by: psandoz, vlivanov
This commit is contained in:
Sandhya Viswanathan 2021-06-04 18:16:16 +00:00
parent 64ec8b3e5c
commit 20b631278c
41 changed files with 202 additions and 234 deletions

View file

@ -330,15 +330,9 @@ final class Byte128Vector extends ByteVector {
return (long) super.reduceLanesTemplate(op, m); // specialized
}
@Override
@ForceInline
public VectorShuffle<Byte> toShuffle() {
byte[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
return VectorShuffle.fromArray(VSPECIES, sa, 0);
return super.toShuffleTemplate(Byte128Shuffle.class); // specialize
}
// Specialized unary testing

View file

@ -330,15 +330,9 @@ final class Byte256Vector extends ByteVector {
return (long) super.reduceLanesTemplate(op, m); // specialized
}
@Override
@ForceInline
public VectorShuffle<Byte> toShuffle() {
byte[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
return VectorShuffle.fromArray(VSPECIES, sa, 0);
return super.toShuffleTemplate(Byte256Shuffle.class); // specialize
}
// Specialized unary testing

View file

@ -330,15 +330,9 @@ final class Byte512Vector extends ByteVector {
return (long) super.reduceLanesTemplate(op, m); // specialized
}
@Override
@ForceInline
public VectorShuffle<Byte> toShuffle() {
byte[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
return VectorShuffle.fromArray(VSPECIES, sa, 0);
return super.toShuffleTemplate(Byte512Shuffle.class); // specialize
}
// Specialized unary testing

View file

@ -330,15 +330,9 @@ final class Byte64Vector extends ByteVector {
return (long) super.reduceLanesTemplate(op, m); // specialized
}
@Override
@ForceInline
public VectorShuffle<Byte> toShuffle() {
byte[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
return VectorShuffle.fromArray(VSPECIES, sa, 0);
return super.toShuffleTemplate(Byte64Shuffle.class); // specialize
}
// Specialized unary testing

View file

@ -330,15 +330,9 @@ final class ByteMaxVector extends ByteVector {
return (long) super.reduceLanesTemplate(op, m); // specialized
}
@Override
@ForceInline
public VectorShuffle<Byte> toShuffle() {
byte[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
return VectorShuffle.fromArray(VSPECIES, sa, 0);
return super.toShuffleTemplate(ByteMaxShuffle.class); // specialize
}
// Specialized unary testing

View file

@ -2166,6 +2166,29 @@ public abstract class ByteVector extends AbstractVector<Byte> {
return r1.blend(r0, valid);
}
@ForceInline
private final
VectorShuffle<Byte> toShuffle0(ByteSpecies dsp) {
byte[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
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-->
*/

View file

@ -324,15 +324,9 @@ final class Double128Vector extends DoubleVector {
return (long) super.reduceLanesTemplate(op, m); // specialized
}
@Override
@ForceInline
public VectorShuffle<Double> toShuffle() {
double[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
return VectorShuffle.fromArray(VSPECIES, sa, 0);
return super.toShuffleTemplate(Double128Shuffle.class); // specialize
}
// Specialized unary testing

View file

@ -324,15 +324,9 @@ final class Double256Vector extends DoubleVector {
return (long) super.reduceLanesTemplate(op, m); // specialized
}
@Override
@ForceInline
public VectorShuffle<Double> toShuffle() {
double[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
return VectorShuffle.fromArray(VSPECIES, sa, 0);
return super.toShuffleTemplate(Double256Shuffle.class); // specialize
}
// Specialized unary testing

View file

@ -324,15 +324,9 @@ final class Double512Vector extends DoubleVector {
return (long) super.reduceLanesTemplate(op, m); // specialized
}
@Override
@ForceInline
public VectorShuffle<Double> toShuffle() {
double[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
return VectorShuffle.fromArray(VSPECIES, sa, 0);
return super.toShuffleTemplate(Double512Shuffle.class); // specialize
}
// Specialized unary testing

View file

@ -324,15 +324,9 @@ final class Double64Vector extends DoubleVector {
return (long) super.reduceLanesTemplate(op, m); // specialized
}
@Override
@ForceInline
public VectorShuffle<Double> toShuffle() {
double[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
return VectorShuffle.fromArray(VSPECIES, sa, 0);
return super.toShuffleTemplate(Double64Shuffle.class); // specialize
}
// Specialized unary testing

View file

@ -324,15 +324,9 @@ final class DoubleMaxVector extends DoubleVector {
return (long) super.reduceLanesTemplate(op, m); // specialized
}
@Override
@ForceInline
public VectorShuffle<Double> toShuffle() {
double[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
return VectorShuffle.fromArray(VSPECIES, sa, 0);
return super.toShuffleTemplate(DoubleMaxShuffle.class); // specialize
}
// Specialized unary testing

View file

@ -2073,6 +2073,29 @@ public abstract class DoubleVector extends AbstractVector<Double> {
return r1.blend(r0, valid);
}
@ForceInline
private final
VectorShuffle<Double> toShuffle0(DoubleSpecies dsp) {
double[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
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-->
*/

View file

@ -324,15 +324,9 @@ final class Float128Vector extends FloatVector {
return (long) super.reduceLanesTemplate(op, m); // specialized
}
@Override
@ForceInline
public VectorShuffle<Float> toShuffle() {
float[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
return VectorShuffle.fromArray(VSPECIES, sa, 0);
return super.toShuffleTemplate(Float128Shuffle.class); // specialize
}
// Specialized unary testing

View file

@ -324,15 +324,9 @@ final class Float256Vector extends FloatVector {
return (long) super.reduceLanesTemplate(op, m); // specialized
}
@Override
@ForceInline
public VectorShuffle<Float> toShuffle() {
float[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
return VectorShuffle.fromArray(VSPECIES, sa, 0);
return super.toShuffleTemplate(Float256Shuffle.class); // specialize
}
// Specialized unary testing

View file

@ -324,15 +324,9 @@ final class Float512Vector extends FloatVector {
return (long) super.reduceLanesTemplate(op, m); // specialized
}
@Override
@ForceInline
public VectorShuffle<Float> toShuffle() {
float[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
return VectorShuffle.fromArray(VSPECIES, sa, 0);
return super.toShuffleTemplate(Float512Shuffle.class); // specialize
}
// Specialized unary testing

View file

@ -324,15 +324,9 @@ final class Float64Vector extends FloatVector {
return (long) super.reduceLanesTemplate(op, m); // specialized
}
@Override
@ForceInline
public VectorShuffle<Float> toShuffle() {
float[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
return VectorShuffle.fromArray(VSPECIES, sa, 0);
return super.toShuffleTemplate(Float64Shuffle.class); // specialize
}
// Specialized unary testing

View file

@ -324,15 +324,9 @@ final class FloatMaxVector extends FloatVector {
return (long) super.reduceLanesTemplate(op, m); // specialized
}
@Override
@ForceInline
public VectorShuffle<Float> toShuffle() {
float[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
return VectorShuffle.fromArray(VSPECIES, sa, 0);
return super.toShuffleTemplate(FloatMaxShuffle.class); // specialize
}
// Specialized unary testing

View file

@ -2085,6 +2085,29 @@ public abstract class FloatVector extends AbstractVector<Float> {
return r1.blend(r0, valid);
}
@ForceInline
private final
VectorShuffle<Float> toShuffle0(FloatSpecies dsp) {
float[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
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-->
*/

View file

@ -330,15 +330,9 @@ final class Int128Vector extends IntVector {
return (long) super.reduceLanesTemplate(op, m); // specialized
}
@Override
@ForceInline
public VectorShuffle<Integer> toShuffle() {
int[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
return VectorShuffle.fromArray(VSPECIES, sa, 0);
return super.toShuffleTemplate(Int128Shuffle.class); // specialize
}
// Specialized unary testing

View file

@ -330,15 +330,9 @@ final class Int256Vector extends IntVector {
return (long) super.reduceLanesTemplate(op, m); // specialized
}
@Override
@ForceInline
public VectorShuffle<Integer> toShuffle() {
int[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
return VectorShuffle.fromArray(VSPECIES, sa, 0);
return super.toShuffleTemplate(Int256Shuffle.class); // specialize
}
// Specialized unary testing

View file

@ -330,15 +330,9 @@ final class Int512Vector extends IntVector {
return (long) super.reduceLanesTemplate(op, m); // specialized
}
@Override
@ForceInline
public VectorShuffle<Integer> toShuffle() {
int[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
return VectorShuffle.fromArray(VSPECIES, sa, 0);
return super.toShuffleTemplate(Int512Shuffle.class); // specialize
}
// Specialized unary testing

View file

@ -330,15 +330,9 @@ final class Int64Vector extends IntVector {
return (long) super.reduceLanesTemplate(op, m); // specialized
}
@Override
@ForceInline
public VectorShuffle<Integer> toShuffle() {
int[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
return VectorShuffle.fromArray(VSPECIES, sa, 0);
return super.toShuffleTemplate(Int64Shuffle.class); // specialize
}
// Specialized unary testing

View file

@ -330,15 +330,9 @@ final class IntMaxVector extends IntVector {
return (long) super.reduceLanesTemplate(op, m); // specialized
}
@Override
@ForceInline
public VectorShuffle<Integer> toShuffle() {
int[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
return VectorShuffle.fromArray(VSPECIES, sa, 0);
return super.toShuffleTemplate(IntMaxShuffle.class); // specialize
}
// Specialized unary testing

View file

@ -2165,6 +2165,29 @@ public abstract class IntVector extends AbstractVector<Integer> {
return r1.blend(r0, valid);
}
@ForceInline
private final
VectorShuffle<Integer> toShuffle0(IntSpecies dsp) {
int[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
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-->
*/

View file

@ -325,15 +325,9 @@ final class Long128Vector extends LongVector {
return (long) super.reduceLanesTemplate(op, m); // specialized
}
@Override
@ForceInline
public VectorShuffle<Long> toShuffle() {
long[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
return VectorShuffle.fromArray(VSPECIES, sa, 0);
return super.toShuffleTemplate(Long128Shuffle.class); // specialize
}
// Specialized unary testing

View file

@ -325,15 +325,9 @@ final class Long256Vector extends LongVector {
return (long) super.reduceLanesTemplate(op, m); // specialized
}
@Override
@ForceInline
public VectorShuffle<Long> toShuffle() {
long[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
return VectorShuffle.fromArray(VSPECIES, sa, 0);
return super.toShuffleTemplate(Long256Shuffle.class); // specialize
}
// Specialized unary testing

View file

@ -325,15 +325,9 @@ final class Long512Vector extends LongVector {
return (long) super.reduceLanesTemplate(op, m); // specialized
}
@Override
@ForceInline
public VectorShuffle<Long> toShuffle() {
long[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
return VectorShuffle.fromArray(VSPECIES, sa, 0);
return super.toShuffleTemplate(Long512Shuffle.class); // specialize
}
// Specialized unary testing

View file

@ -325,15 +325,9 @@ final class Long64Vector extends LongVector {
return (long) super.reduceLanesTemplate(op, m); // specialized
}
@Override
@ForceInline
public VectorShuffle<Long> toShuffle() {
long[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
return VectorShuffle.fromArray(VSPECIES, sa, 0);
return super.toShuffleTemplate(Long64Shuffle.class); // specialize
}
// Specialized unary testing

View file

@ -325,15 +325,9 @@ final class LongMaxVector extends LongVector {
return (long) super.reduceLanesTemplate(op, m); // specialized
}
@Override
@ForceInline
public VectorShuffle<Long> toShuffle() {
long[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
return VectorShuffle.fromArray(VSPECIES, sa, 0);
return super.toShuffleTemplate(LongMaxShuffle.class); // specialize
}
// Specialized unary testing

View file

@ -2036,6 +2036,29 @@ public abstract class LongVector extends AbstractVector<Long> {
return r1.blend(r0, valid);
}
@ForceInline
private final
VectorShuffle<Long> toShuffle0(LongSpecies dsp) {
long[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
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-->
*/

View file

@ -330,15 +330,9 @@ final class Short128Vector extends ShortVector {
return (long) super.reduceLanesTemplate(op, m); // specialized
}
@Override
@ForceInline
public VectorShuffle<Short> toShuffle() {
short[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
return VectorShuffle.fromArray(VSPECIES, sa, 0);
return super.toShuffleTemplate(Short128Shuffle.class); // specialize
}
// Specialized unary testing

View file

@ -330,15 +330,9 @@ final class Short256Vector extends ShortVector {
return (long) super.reduceLanesTemplate(op, m); // specialized
}
@Override
@ForceInline
public VectorShuffle<Short> toShuffle() {
short[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
return VectorShuffle.fromArray(VSPECIES, sa, 0);
return super.toShuffleTemplate(Short256Shuffle.class); // specialize
}
// Specialized unary testing

View file

@ -330,15 +330,9 @@ final class Short512Vector extends ShortVector {
return (long) super.reduceLanesTemplate(op, m); // specialized
}
@Override
@ForceInline
public VectorShuffle<Short> toShuffle() {
short[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
return VectorShuffle.fromArray(VSPECIES, sa, 0);
return super.toShuffleTemplate(Short512Shuffle.class); // specialize
}
// Specialized unary testing

View file

@ -330,15 +330,9 @@ final class Short64Vector extends ShortVector {
return (long) super.reduceLanesTemplate(op, m); // specialized
}
@Override
@ForceInline
public VectorShuffle<Short> toShuffle() {
short[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
return VectorShuffle.fromArray(VSPECIES, sa, 0);
return super.toShuffleTemplate(Short64Shuffle.class); // specialize
}
// Specialized unary testing

View file

@ -330,15 +330,9 @@ final class ShortMaxVector extends ShortVector {
return (long) super.reduceLanesTemplate(op, m); // specialized
}
@Override
@ForceInline
public VectorShuffle<Short> toShuffle() {
short[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
return VectorShuffle.fromArray(VSPECIES, sa, 0);
return super.toShuffleTemplate(ShortMaxShuffle.class); // specialize
}
// Specialized unary testing

View file

@ -2166,6 +2166,29 @@ public abstract class ShortVector extends AbstractVector<Short> {
return r1.blend(r0, valid);
}
@ForceInline
private final
VectorShuffle<Short> toShuffle0(ShortSpecies dsp) {
short[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
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-->
*/

View file

@ -2433,6 +2433,29 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> {
return r1.blend(r0, valid);
}
@ForceInline
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++) {
sa[i] = (int) a[i];
}
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-->
*/

View file

@ -334,15 +334,9 @@ final class $vectortype$ extends $abstractvectortype$ {
return (long) super.reduceLanesTemplate(op, m); // specialized
}
@Override
@ForceInline
public VectorShuffle<$Boxtype$> toShuffle() {
$type$[] a = toArray();
int[] sa = new int[a.length];
for (int i = 0; i < a.length; i++) {
sa[i] = (int) a[i];
}
return VectorShuffle.fromArray(VSPECIES, sa, 0);
return super.toShuffleTemplate($shuffletype$.class); // specialize
}
// Specialized unary testing