< prev index next >

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

Print this page
rev 55594 : tests and benchmark changes


   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have
  21  * questions.
  22  */
  23 
  24 package benchmark.jdk.incubator.vector;
  25 
  26 import jdk.incubator.vector.Vector;
  27 import jdk.incubator.vector.Vector.Shape;

  28 import jdk.incubator.vector.FloatVector;
  29 
  30 import java.util.concurrent.TimeUnit;
  31 import java.util.function.BiFunction;
  32 import java.util.function.IntFunction;
  33 
  34 import org.openjdk.jmh.annotations.*;
  35 import org.openjdk.jmh.infra.Blackhole;
  36 
  37 @BenchmarkMode(Mode.Throughput)
  38 @OutputTimeUnit(TimeUnit.MILLISECONDS)
  39 @State(Scope.Benchmark)
  40 @Warmup(iterations = 3, time = 1)
  41 @Measurement(iterations = 5, time = 1)
  42 @Fork(value = 1, jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"})
  43 public class FloatMaxVector extends AbstractVectorBenchmark {
  44     static final FloatVector.FloatSpecies SPECIES = FloatVector.species(Shape.S_Max_BIT);
  45 
  46     static final int INVOC_COUNT = 1; // get rid of outer loop
  47 
  48     @Param("1024")
  49     int size;
  50 
  51     float[] fill(IntFunction<Float> f) {
  52         float[] array = new float[size];
  53         for (int i = 0; i < array.length; i++) {
  54             array[i] = f.apply(i);
  55         }
  56         return array;
  57     }
  58 
  59     float[] a, b, c, r;
  60     boolean[] m, rm;
  61     int[] s;
  62 
  63     @Setup
  64     public void init() {




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have
  21  * questions.
  22  */
  23 
  24 package benchmark.jdk.incubator.vector;
  25 
  26 import jdk.incubator.vector.Vector;
  27 import jdk.incubator.vector.Vector.Shape;
  28 import jdk.incubator.vector.Vector.Species;
  29 import jdk.incubator.vector.FloatVector;
  30 
  31 import java.util.concurrent.TimeUnit;
  32 import java.util.function.BiFunction;
  33 import java.util.function.IntFunction;
  34 
  35 import org.openjdk.jmh.annotations.*;
  36 import org.openjdk.jmh.infra.Blackhole;
  37 
  38 @BenchmarkMode(Mode.Throughput)
  39 @OutputTimeUnit(TimeUnit.MILLISECONDS)
  40 @State(Scope.Benchmark)
  41 @Warmup(iterations = 3, time = 1)
  42 @Measurement(iterations = 5, time = 1)
  43 @Fork(value = 1, jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"})
  44 public class FloatMaxVector extends AbstractVectorBenchmark {
  45     static final Species<Float> SPECIES = FloatVector.SPECIES_MAX;
  46 
  47     static final int INVOC_COUNT = 1; // get rid of outer loop
  48 
  49     @Param("1024")
  50     int size;
  51 
  52     float[] fill(IntFunction<Float> f) {
  53         float[] array = new float[size];
  54         for (int i = 0; i < array.length; i++) {
  55             array[i] = f.apply(i);
  56         }
  57         return array;
  58     }
  59 
  60     float[] a, b, c, r;
  61     boolean[] m, rm;
  62     int[] s;
  63 
  64     @Setup
  65     public void init() {


< prev index next >