< prev index next >

test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/AbstractVectorBenchmark.java

Print this page
rev 55589 : Species-phase2
rev 55594 : tests and benchmark changes

*** 22,67 **** */ package benchmark.jdk.incubator.vector; import jdk.incubator.vector.ByteVector; - import jdk.incubator.vector.ByteVector.ByteSpecies; import jdk.incubator.vector.IntVector; - import jdk.incubator.vector.IntVector.IntSpecies; import jdk.incubator.vector.ShortVector; - import jdk.incubator.vector.ShortVector.ShortSpecies; import jdk.incubator.vector.LongVector; - import jdk.incubator.vector.LongVector.LongSpecies; import jdk.incubator.vector.Vector; import jdk.incubator.vector.Vector.Shape; import jdk.incubator.vector.Vector.Species; import java.util.Random; import java.util.function.IntFunction; public class AbstractVectorBenchmark { static final Random RANDOM = new Random(Integer.getInteger("jdk.incubator.vector.random-seed", 1337)); ! static final ByteSpecies B64 = ByteVector.species(Shape.S_64_BIT); ! static final ByteSpecies B128 = ByteVector.species(Shape.S_128_BIT); ! static final ByteSpecies B256 = ByteVector.species(Shape.S_256_BIT); ! static final ByteSpecies B512 = ByteVector.species(Shape.S_512_BIT); ! ! static final ShortSpecies S64 = ShortVector.species(Shape.S_64_BIT); ! static final ShortSpecies S128 = ShortVector.species(Shape.S_128_BIT); ! static final ShortSpecies S256 = ShortVector.species(Shape.S_256_BIT); ! static final ShortSpecies S512 = ShortVector.species(Shape.S_512_BIT); ! ! static final IntSpecies I64 = IntVector.species(Vector.Shape.S_64_BIT); ! static final IntSpecies I128 = IntVector.species(Vector.Shape.S_128_BIT); ! static final IntSpecies I256 = IntVector.species(Vector.Shape.S_256_BIT); ! static final IntSpecies I512 = IntVector.species(Vector.Shape.S_512_BIT); ! ! static final LongSpecies L64 = LongVector.species(Vector.Shape.S_64_BIT); ! static final LongSpecies L128 = LongVector.species(Vector.Shape.S_128_BIT); ! static final LongSpecies L256 = LongVector.species(Vector.Shape.S_256_BIT); ! static final LongSpecies L512 = LongVector.species(Vector.Shape.S_512_BIT); static Shape widen(Shape s) { switch (s) { case S_64_BIT: return Shape.S_128_BIT; case S_128_BIT: return Shape.S_256_BIT; --- 22,63 ---- */ package benchmark.jdk.incubator.vector; import jdk.incubator.vector.ByteVector; import jdk.incubator.vector.IntVector; import jdk.incubator.vector.ShortVector; import jdk.incubator.vector.LongVector; import jdk.incubator.vector.Vector; import jdk.incubator.vector.Vector.Shape; import jdk.incubator.vector.Vector.Species; import java.util.Random; import java.util.function.IntFunction; public class AbstractVectorBenchmark { static final Random RANDOM = new Random(Integer.getInteger("jdk.incubator.vector.random-seed", 1337)); ! static final Species<Byte> B64 = ByteVector.SPECIES_64; ! static final Species<Byte> B128 = ByteVector.SPECIES_128; ! static final Species<Byte> B256 = ByteVector.SPECIES_256; ! static final Species<Byte> B512 = ByteVector.SPECIES_512; ! ! static final Species<Short> S64 = ShortVector.SPECIES_64; ! static final Species<Short> S128 = ShortVector.SPECIES_128; ! static final Species<Short> S256 = ShortVector.SPECIES_256; ! static final Species<Short> S512 = ShortVector.SPECIES_512; ! ! static final Species<Integer> I64 = IntVector.SPECIES_64; ! static final Species<Integer> I128 = IntVector.SPECIES_128; ! static final Species<Integer> I256 = IntVector.SPECIES_256; ! static final Species<Integer> I512 = IntVector.SPECIES_512; ! ! static final Species<Long> L64 = LongVector.SPECIES_64; ! static final Species<Long> L128 = LongVector.SPECIES_128; ! static final Species<Long> L256 = LongVector.SPECIES_256; ! static final Species<Long> L512 = LongVector.SPECIES_512; static Shape widen(Shape s) { switch (s) { case S_64_BIT: return Shape.S_128_BIT; case S_128_BIT: return Shape.S_256_BIT;
*** 85,95 **** static <E> Species<E> narrow(Species<E> s) { return Vector.Species.of(s.elementType(), narrow(s.shape())); } ! static IntVector join(IntVector.IntSpecies from, IntVector.IntSpecies to, IntVector lo, IntVector hi) { assert 2 * from.length() == to.length(); int vlen = from.length(); var lo_mask = mask(from, to, 0); --- 81,91 ---- static <E> Species<E> narrow(Species<E> s) { return Vector.Species.of(s.elementType(), narrow(s.shape())); } ! static IntVector join(Species<Integer> from, Species<Integer> to, IntVector lo, IntVector hi) { assert 2 * from.length() == to.length(); int vlen = from.length(); var lo_mask = mask(from, to, 0);
*** 97,116 **** var v2 = hi.reshape(to).shiftER(vlen); var r = v2.blend(v1, lo_mask); return r; } ! static Vector.Mask<Integer> mask(IntVector.IntSpecies from, IntVector.IntSpecies to, int i) { int vlen = from.length(); ! var v1 = from.broadcast(1); // [1 1 ... 1] var v2 = v1.reshape(to); // [0 0 ... 0 | ... | 1 1 ... 1] var v3 = v2.shiftER(i * vlen); // [0 0 ... 0 | 1 1 ... 1 | 0 0 ... 0] return v3.notEqual(0); // [F F ... F | T T ... T | F F ... F] } static <E> IntVector sum(ByteVector va) { ! IntSpecies species = IntVector.species(va.shape()); var acc = IntVector.zero(species); int limit = va.length() / species.length(); for (int k = 0; k < limit; k++) { var vb = ((IntVector)(va.shiftEL(k * B64.length()).reshape(B64).cast(species))).and(0xFF); acc = acc.add(vb); --- 93,112 ---- var v2 = hi.reshape(to).shiftER(vlen); var r = v2.blend(v1, lo_mask); return r; } ! static Vector.Mask<Integer> mask(Species<Integer> from, Species<Integer> to, int i) { int vlen = from.length(); ! var v1 = IntVector.broadcast(from, 1); // [1 1 ... 1] var v2 = v1.reshape(to); // [0 0 ... 0 | ... | 1 1 ... 1] var v3 = v2.shiftER(i * vlen); // [0 0 ... 0 | 1 1 ... 1 | 0 0 ... 0] return v3.notEqual(0); // [F F ... F | T T ... T | F F ... F] } static <E> IntVector sum(ByteVector va) { ! Species<Integer> species = Species.of(Integer.class, va.shape()); var acc = IntVector.zero(species); int limit = va.length() / species.length(); for (int k = 0; k < limit; k++) { var vb = ((IntVector)(va.shiftEL(k * B64.length()).reshape(B64).cast(species))).and(0xFF); acc = acc.add(vb);
< prev index next >