< prev index next >

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

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

@@ -22,12 +22,13 @@
  */
 
 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.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,11 +41,11 @@
 @State(Scope.Benchmark)
 @Warmup(iterations = 3, time = 1)
 @Measurement(iterations = 5, time = 1)
 @Fork(value = 1, jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"})
 public class FloatMaxVector extends AbstractVectorBenchmark {
-    static final Species<Float> SPECIES = FloatVector.SPECIES_MAX;
+    static final VectorSpecies<Float> SPECIES = FloatVector.SPECIES_MAX;
 
     static final int INVOC_COUNT = 1; // get rid of outer loop
 
     @Param("1024")
     int size;

@@ -106,11 +107,11 @@
     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);
+        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,11 +143,11 @@
     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);
+        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,11 +182,11 @@
     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);
+        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,11 +219,11 @@
     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);
+        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,17 +381,17 @@
     @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);
+        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);
-                Vector.Mask<Float> mv = av.lessThan(bv);
+                VectorMask<Float> mv = av.lessThan(bv);
 
                 m = m.and(mv); // accumulate results, so JIT can't eliminate relevant computations
             }
         }
         return m;

@@ -400,17 +401,17 @@
     @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);
+        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);
-                Vector.Mask<Float> mv = av.greaterThan(bv);
+                VectorMask<Float> mv = av.greaterThan(bv);
 
                 m = m.and(mv); // accumulate results, so JIT can't eliminate relevant computations
             }
         }
         return m;

@@ -420,17 +421,17 @@
     @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);
+        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);
-                Vector.Mask<Float> mv = av.equal(bv);
+                VectorMask<Float> mv = av.equal(bv);
 
                 m = m.and(mv); // accumulate results, so JIT can't eliminate relevant computations
             }
         }
         return m;

@@ -440,17 +441,17 @@
     @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);
+        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);
-                Vector.Mask<Float> mv = av.notEqual(bv);
+                VectorMask<Float> mv = av.notEqual(bv);
 
                 m = m.and(mv); // accumulate results, so JIT can't eliminate relevant computations
             }
         }
         return m;

@@ -460,17 +461,17 @@
     @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);
+        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);
-                Vector.Mask<Float> mv = av.lessThanEq(bv);
+                VectorMask<Float> mv = av.lessThanEq(bv);
 
                 m = m.and(mv); // accumulate results, so JIT can't eliminate relevant computations
             }
         }
         return m;

@@ -480,17 +481,17 @@
     @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);
+        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);
-                Vector.Mask<Float> mv = av.greaterThanEq(bv);
+                VectorMask<Float> mv = av.greaterThanEq(bv);
 
                 m = m.and(mv); // accumulate results, so JIT can't eliminate relevant computations
             }
         }
         return m;

@@ -501,11 +502,11 @@
     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);
+        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,11 +524,11 @@
         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);
+                av.rearrange(VectorShuffle.fromArray(SPECIES, order, i)).intoArray(r, i);
             }
         }
 
         bh.consume(r);
     }

@@ -1027,11 +1028,11 @@
         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);
+        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,11 +1063,11 @@
     @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);
+        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,11 +1095,11 @@
     @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);
+        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,11 +1132,11 @@
     @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);
+        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 >