< prev index next >

test/jdk/jdk/incubator/vector/templates/Perf-Scalar-Ternary-Masked-op.template

Print this page
rev 55606 : 8221812: Fine-tune jmh test for vector api
Summary: To compare performance of vector api and auto vectorization, vector
api and scalar test cases are updated to keep aligned.
Reviewed-by: duke
   1 
   2     @Benchmark
   3     public Object [[TEST]][[TEST_TYPE]][[OP_NAME]]() {
   4         $type$[] as = fa.apply(size);
   5         $type$[] bs = fb.apply(size);
   6         $type$[] cs = fc.apply(size);
   7         $type$[] rs = fr.apply(size);
   8         boolean[] ms = fm.apply(size);
   9 

  10         for (int i = 0; i < as.length; i++) {
  11             $type$ a = as[i];
  12             $type$ b = bs[i];
  13             $type$ c = cs[i];
  14             if (ms[i % ms.length]) {
  15                 rs[i] = ($type$)([[TEST_OP]]);
  16             } else {
  17                 rs[i] = a;
  18             }
  19         }
  20         return rs;

  21     }
   1 
   2     @Benchmark
   3     public void [[TEST]][[TEST_TYPE]][[OP_NAME]](Blackhole bh) {
   4         $type$[] as = fa.apply(size);
   5         $type$[] bs = fb.apply(size);
   6         $type$[] cs = fc.apply(size);
   7         $type$[] rs = fr.apply(size);
   8         boolean[] ms = fm.apply(size);
   9 
  10         for (int ic = 0; ic < INVOC_COUNT; ic++) {
  11             for (int i = 0; i < as.length; i++) {
  12                 $type$ a = as[i];
  13                 $type$ b = bs[i];
  14                 $type$ c = cs[i];
  15                 if (ms[i % ms.length]) {
  16                     rs[i] = ($type$)([[TEST_OP]]);
  17                 } else {
  18                     rs[i] = a;
  19                 }
  20             }
  21         }
  22         bh.consume(rs);
  23     }
< prev index next >