< prev index next >

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

Print this page
rev 54658 : refactored mask and shuffle creation methods, moved classes to top-level

*** 22,33 **** */ package benchmark.jdk.incubator.vector; import jdk.incubator.vector.Vector; ! import jdk.incubator.vector.Vector.Shape; ! import jdk.incubator.vector.Vector.Species; import jdk.incubator.vector.FloatVector; import java.util.concurrent.TimeUnit; import java.util.function.BiFunction; import java.util.function.IntFunction; --- 22,34 ---- */ package benchmark.jdk.incubator.vector; import jdk.incubator.vector.Vector; ! import jdk.incubator.vector.VectorShape; ! import jdk.incubator.vector.VectorSpecies; ! import jdk.incubator.vector.VectorShuffle; import jdk.incubator.vector.FloatVector; import java.util.concurrent.TimeUnit; import java.util.function.BiFunction; import java.util.function.IntFunction;
*** 40,50 **** @State(Scope.Benchmark) @Warmup(iterations = 3, time = 1) @Measurement(iterations = 5, time = 1) @Fork(value = 1, jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"}) public class Float256Vector extends AbstractVectorBenchmark { ! static final Species<Float> SPECIES = FloatVector.SPECIES_256; static final int INVOC_COUNT = 1; // get rid of outer loop @Param("1024") int size; --- 41,51 ---- @State(Scope.Benchmark) @Warmup(iterations = 3, time = 1) @Measurement(iterations = 5, time = 1) @Fork(value = 1, jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"}) public class Float256Vector extends AbstractVectorBenchmark { ! static final VectorSpecies<Float> SPECIES = FloatVector.SPECIES_256; static final int INVOC_COUNT = 1; // get rid of outer loop @Param("1024") int size;
*** 106,116 **** public void addMasked(Blackhole bh) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! Vector.Mask<Float> vmask = FloatVector.maskFromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); FloatVector bv = FloatVector.fromArray(SPECIES, b, i); --- 107,117 ---- public void addMasked(Blackhole bh) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! VectorMask<Float> vmask = VectorMask.fromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
*** 142,152 **** public void subMasked(Blackhole bh) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! Vector.Mask<Float> vmask = FloatVector.maskFromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); FloatVector bv = FloatVector.fromArray(SPECIES, b, i); --- 143,153 ---- public void subMasked(Blackhole bh) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! VectorMask<Float> vmask = VectorMask.fromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
*** 181,191 **** public void divMasked(Blackhole bh) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! Vector.Mask<Float> vmask = FloatVector.maskFromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); FloatVector bv = FloatVector.fromArray(SPECIES, b, i); --- 182,192 ---- public void divMasked(Blackhole bh) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! VectorMask<Float> vmask = VectorMask.fromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
*** 218,228 **** public void mulMasked(Blackhole bh) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! Vector.Mask<Float> vmask = FloatVector.maskFromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); FloatVector bv = FloatVector.fromArray(SPECIES, b, i); --- 219,229 ---- public void mulMasked(Blackhole bh) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! VectorMask<Float> vmask = VectorMask.fromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
*** 380,396 **** @Benchmark public Object lessThan() { float[] a = fa.apply(size); float[] b = fb.apply(size); boolean[] ms = fm.apply(size); ! Vector.Mask<Float> m = FloatVector.maskFromArray(SPECIES, ms, 0); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); FloatVector bv = FloatVector.fromArray(SPECIES, b, i); ! Vector.Mask<Float> mv = av.lessThan(bv); m = m.and(mv); // accumulate results, so JIT can't eliminate relevant computations } } return m; --- 381,397 ---- @Benchmark public Object lessThan() { float[] a = fa.apply(size); float[] b = fb.apply(size); boolean[] ms = fm.apply(size); ! VectorMask<Float> m = VectorMask.maskFromArray(SPECIES, ms, 0); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); FloatVector bv = FloatVector.fromArray(SPECIES, b, i); ! VectorMask<Float> mv = av.lessThan(bv); m = m.and(mv); // accumulate results, so JIT can't eliminate relevant computations } } return m;
*** 400,416 **** @Benchmark public Object greaterThan() { float[] a = fa.apply(size); float[] b = fb.apply(size); boolean[] ms = fm.apply(size); ! Vector.Mask<Float> m = FloatVector.maskFromArray(SPECIES, ms, 0); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); FloatVector bv = FloatVector.fromArray(SPECIES, b, i); ! Vector.Mask<Float> mv = av.greaterThan(bv); m = m.and(mv); // accumulate results, so JIT can't eliminate relevant computations } } return m; --- 401,417 ---- @Benchmark public Object greaterThan() { float[] a = fa.apply(size); float[] b = fb.apply(size); boolean[] ms = fm.apply(size); ! VectorMask<Float> m = VectorMask.maskFromArray(SPECIES, ms, 0); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); FloatVector bv = FloatVector.fromArray(SPECIES, b, i); ! VectorMask<Float> mv = av.greaterThan(bv); m = m.and(mv); // accumulate results, so JIT can't eliminate relevant computations } } return m;
*** 420,436 **** @Benchmark public Object equal() { float[] a = fa.apply(size); float[] b = fb.apply(size); boolean[] ms = fm.apply(size); ! Vector.Mask<Float> m = FloatVector.maskFromArray(SPECIES, ms, 0); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); FloatVector bv = FloatVector.fromArray(SPECIES, b, i); ! Vector.Mask<Float> mv = av.equal(bv); m = m.and(mv); // accumulate results, so JIT can't eliminate relevant computations } } return m; --- 421,437 ---- @Benchmark public Object equal() { float[] a = fa.apply(size); float[] b = fb.apply(size); boolean[] ms = fm.apply(size); ! VectorMask<Float> m = VectorMask.maskFromArray(SPECIES, ms, 0); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); FloatVector bv = FloatVector.fromArray(SPECIES, b, i); ! VectorMask<Float> mv = av.equal(bv); m = m.and(mv); // accumulate results, so JIT can't eliminate relevant computations } } return m;
*** 440,456 **** @Benchmark public Object notEqual() { float[] a = fa.apply(size); float[] b = fb.apply(size); boolean[] ms = fm.apply(size); ! Vector.Mask<Float> m = FloatVector.maskFromArray(SPECIES, ms, 0); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); FloatVector bv = FloatVector.fromArray(SPECIES, b, i); ! Vector.Mask<Float> mv = av.notEqual(bv); m = m.and(mv); // accumulate results, so JIT can't eliminate relevant computations } } return m; --- 441,457 ---- @Benchmark public Object notEqual() { float[] a = fa.apply(size); float[] b = fb.apply(size); boolean[] ms = fm.apply(size); ! VectorMask<Float> m = VectorMask.maskFromArray(SPECIES, ms, 0); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); FloatVector bv = FloatVector.fromArray(SPECIES, b, i); ! VectorMask<Float> mv = av.notEqual(bv); m = m.and(mv); // accumulate results, so JIT can't eliminate relevant computations } } return m;
*** 460,476 **** @Benchmark public Object lessThanEq() { float[] a = fa.apply(size); float[] b = fb.apply(size); boolean[] ms = fm.apply(size); ! Vector.Mask<Float> m = FloatVector.maskFromArray(SPECIES, ms, 0); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); FloatVector bv = FloatVector.fromArray(SPECIES, b, i); ! Vector.Mask<Float> mv = av.lessThanEq(bv); m = m.and(mv); // accumulate results, so JIT can't eliminate relevant computations } } return m; --- 461,477 ---- @Benchmark public Object lessThanEq() { float[] a = fa.apply(size); float[] b = fb.apply(size); boolean[] ms = fm.apply(size); ! VectorMask<Float> m = VectorMask.maskFromArray(SPECIES, ms, 0); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); FloatVector bv = FloatVector.fromArray(SPECIES, b, i); ! VectorMask<Float> mv = av.lessThanEq(bv); m = m.and(mv); // accumulate results, so JIT can't eliminate relevant computations } } return m;
*** 480,496 **** @Benchmark public Object greaterThanEq() { float[] a = fa.apply(size); float[] b = fb.apply(size); boolean[] ms = fm.apply(size); ! Vector.Mask<Float> m = FloatVector.maskFromArray(SPECIES, ms, 0); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); FloatVector bv = FloatVector.fromArray(SPECIES, b, i); ! Vector.Mask<Float> mv = av.greaterThanEq(bv); m = m.and(mv); // accumulate results, so JIT can't eliminate relevant computations } } return m; --- 481,497 ---- @Benchmark public Object greaterThanEq() { float[] a = fa.apply(size); float[] b = fb.apply(size); boolean[] ms = fm.apply(size); ! VectorMask<Float> m = VectorMask.maskFromArray(SPECIES, ms, 0); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); FloatVector bv = FloatVector.fromArray(SPECIES, b, i); ! VectorMask<Float> mv = av.greaterThanEq(bv); m = m.and(mv); // accumulate results, so JIT can't eliminate relevant computations } } return m;
*** 501,511 **** public void blend(Blackhole bh) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! Vector.Mask<Float> vmask = FloatVector.maskFromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); FloatVector bv = FloatVector.fromArray(SPECIES, b, i); --- 502,512 ---- public void blend(Blackhole bh) { float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! VectorMask<Float> vmask = VectorMask.fromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
*** 523,533 **** float[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); ! av.rearrange(FloatVector.shuffleFromArray(SPECIES, order, i)).intoArray(r, i); } } bh.consume(r); } --- 524,534 ---- float[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); ! av.rearrange(VectorShuffle.fromArray(SPECIES, order, i)).intoArray(r, i); } } bh.consume(r); }
*** 1027,1037 **** float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] c = fc.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! Vector.Mask<Float> vmask = FloatVector.maskFromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); FloatVector bv = FloatVector.fromArray(SPECIES, b, i); --- 1028,1038 ---- float[] a = fa.apply(SPECIES.length()); float[] b = fb.apply(SPECIES.length()); float[] c = fc.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! VectorMask<Float> vmask = VectorMask.fromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
*** 1062,1072 **** @Benchmark public void negMasked(Blackhole bh) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! Vector.Mask<Float> vmask = FloatVector.maskFromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); av.neg(vmask).intoArray(r, i); --- 1063,1073 ---- @Benchmark public void negMasked(Blackhole bh) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! VectorMask<Float> vmask = VectorMask.fromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); av.neg(vmask).intoArray(r, i);
*** 1094,1104 **** @Benchmark public void absMasked(Blackhole bh) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! Vector.Mask<Float> vmask = FloatVector.maskFromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); av.abs(vmask).intoArray(r, i); --- 1095,1105 ---- @Benchmark public void absMasked(Blackhole bh) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! VectorMask<Float> vmask = VectorMask.fromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); av.abs(vmask).intoArray(r, i);
*** 1131,1141 **** @Benchmark public void sqrtMasked(Blackhole bh) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! Vector.Mask<Float> vmask = FloatVector.maskFromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); av.sqrt(vmask).intoArray(r, i); --- 1132,1142 ---- @Benchmark public void sqrtMasked(Blackhole bh) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! VectorMask<Float> vmask = VectorMask.fromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); av.sqrt(vmask).intoArray(r, i);
< prev index next >