< prev index next >

test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/jdk/incubator/vector/Double64Vector.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.DoubleVector; 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.DoubleVector; 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 Double64Vector extends AbstractVectorBenchmark { ! static final Species<Double> SPECIES = DoubleVector.SPECIES_64; 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 Double64Vector extends AbstractVectorBenchmark { ! static final VectorSpecies<Double> SPECIES = DoubleVector.SPECIES_64; static final int INVOC_COUNT = 1; // get rid of outer loop @Param("1024") int size;
*** 106,116 **** public void addMasked(Blackhole bh) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! Vector.Mask<Double> vmask = DoubleVector.maskFromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i); --- 107,117 ---- public void addMasked(Blackhole bh) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! VectorMask<Double> vmask = VectorMask.fromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
*** 142,152 **** public void subMasked(Blackhole bh) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! Vector.Mask<Double> vmask = DoubleVector.maskFromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i); --- 143,153 ---- public void subMasked(Blackhole bh) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! VectorMask<Double> vmask = VectorMask.fromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
*** 181,191 **** public void divMasked(Blackhole bh) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! Vector.Mask<Double> vmask = DoubleVector.maskFromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i); --- 182,192 ---- public void divMasked(Blackhole bh) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! VectorMask<Double> vmask = VectorMask.fromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
*** 218,228 **** public void mulMasked(Blackhole bh) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! Vector.Mask<Double> vmask = DoubleVector.maskFromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i); --- 219,229 ---- public void mulMasked(Blackhole bh) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! VectorMask<Double> vmask = VectorMask.fromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
*** 380,396 **** @Benchmark public Object lessThan() { double[] a = fa.apply(size); double[] b = fb.apply(size); boolean[] ms = fm.apply(size); ! Vector.Mask<Double> m = DoubleVector.maskFromArray(SPECIES, ms, 0); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i); ! Vector.Mask<Double> 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() { double[] a = fa.apply(size); double[] b = fb.apply(size); boolean[] ms = fm.apply(size); ! VectorMask<Double> m = VectorMask.maskFromArray(SPECIES, ms, 0); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i); ! VectorMask<Double> 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() { double[] a = fa.apply(size); double[] b = fb.apply(size); boolean[] ms = fm.apply(size); ! Vector.Mask<Double> m = DoubleVector.maskFromArray(SPECIES, ms, 0); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i); ! Vector.Mask<Double> 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() { double[] a = fa.apply(size); double[] b = fb.apply(size); boolean[] ms = fm.apply(size); ! VectorMask<Double> m = VectorMask.maskFromArray(SPECIES, ms, 0); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i); ! VectorMask<Double> 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() { double[] a = fa.apply(size); double[] b = fb.apply(size); boolean[] ms = fm.apply(size); ! Vector.Mask<Double> m = DoubleVector.maskFromArray(SPECIES, ms, 0); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i); ! Vector.Mask<Double> 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() { double[] a = fa.apply(size); double[] b = fb.apply(size); boolean[] ms = fm.apply(size); ! VectorMask<Double> m = VectorMask.maskFromArray(SPECIES, ms, 0); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i); ! VectorMask<Double> 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() { double[] a = fa.apply(size); double[] b = fb.apply(size); boolean[] ms = fm.apply(size); ! Vector.Mask<Double> m = DoubleVector.maskFromArray(SPECIES, ms, 0); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i); ! Vector.Mask<Double> 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() { double[] a = fa.apply(size); double[] b = fb.apply(size); boolean[] ms = fm.apply(size); ! VectorMask<Double> m = VectorMask.maskFromArray(SPECIES, ms, 0); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i); ! VectorMask<Double> 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() { double[] a = fa.apply(size); double[] b = fb.apply(size); boolean[] ms = fm.apply(size); ! Vector.Mask<Double> m = DoubleVector.maskFromArray(SPECIES, ms, 0); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i); ! Vector.Mask<Double> 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() { double[] a = fa.apply(size); double[] b = fb.apply(size); boolean[] ms = fm.apply(size); ! VectorMask<Double> m = VectorMask.maskFromArray(SPECIES, ms, 0); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i); ! VectorMask<Double> 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() { double[] a = fa.apply(size); double[] b = fb.apply(size); boolean[] ms = fm.apply(size); ! Vector.Mask<Double> m = DoubleVector.maskFromArray(SPECIES, ms, 0); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i); ! Vector.Mask<Double> 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() { double[] a = fa.apply(size); double[] b = fb.apply(size); boolean[] ms = fm.apply(size); ! VectorMask<Double> m = VectorMask.maskFromArray(SPECIES, ms, 0); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i); ! VectorMask<Double> 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) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! Vector.Mask<Double> vmask = DoubleVector.maskFromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i); --- 502,512 ---- public void blend(Blackhole bh) { double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! VectorMask<Double> vmask = VectorMask.fromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
*** 523,533 **** double[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); ! av.rearrange(DoubleVector.shuffleFromArray(SPECIES, order, i)).intoArray(r, i); } } bh.consume(r); } --- 524,534 ---- double[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); ! av.rearrange(VectorShuffle.fromArray(SPECIES, order, i)).intoArray(r, i); } } bh.consume(r); }
*** 1027,1037 **** double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] c = fc.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! Vector.Mask<Double> vmask = DoubleVector.maskFromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i); --- 1028,1038 ---- double[] a = fa.apply(SPECIES.length()); double[] b = fb.apply(SPECIES.length()); double[] c = fc.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! VectorMask<Double> vmask = VectorMask.fromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
*** 1062,1072 **** @Benchmark public void negMasked(Blackhole bh) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! Vector.Mask<Double> vmask = DoubleVector.maskFromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); av.neg(vmask).intoArray(r, i); --- 1063,1073 ---- @Benchmark public void negMasked(Blackhole bh) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! VectorMask<Double> vmask = VectorMask.fromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); av.neg(vmask).intoArray(r, i);
*** 1094,1104 **** @Benchmark public void absMasked(Blackhole bh) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! Vector.Mask<Double> vmask = DoubleVector.maskFromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); av.abs(vmask).intoArray(r, i); --- 1095,1105 ---- @Benchmark public void absMasked(Blackhole bh) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! VectorMask<Double> vmask = VectorMask.fromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); av.abs(vmask).intoArray(r, i);
*** 1131,1141 **** @Benchmark public void sqrtMasked(Blackhole bh) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! Vector.Mask<Double> vmask = DoubleVector.maskFromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); av.sqrt(vmask).intoArray(r, i); --- 1132,1142 ---- @Benchmark public void sqrtMasked(Blackhole bh) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); ! VectorMask<Double> vmask = VectorMask.fromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); av.sqrt(vmask).intoArray(r, i);
< prev index next >