< prev index next >

test/jdk/jdk/incubator/vector/templates/Perf-Scalar-Gather-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     @Benchmark
   2     public Object gatherBase0() {
   3         $type$[] as = fa.apply(size);
   4         int[] is    = fs.apply(size);
   5         $type$[] rs = fr.apply(size);
   6 

   7         for (int i = 0; i < as.length; i++) {
   8             int ix = 0 + is[i];
   9             rs[i] = as[ix];
  10         }

  11 
  12         return rs;
  13     }
  14 
  15 
  16     Object gather(int window) {
  17         $type$[] as = fa.apply(size);
  18         int[] is    = fs.apply(size);
  19         $type$[] rs = fr.apply(size);
  20 

  21         for (int i = 0; i < as.length; i += window) {
  22             for (int j = 0; j < window; j++) {
  23                 int ix = i + is[i + j];
  24                 rs[i + j] = as[ix];
  25             }
  26         }

  27 
  28         return rs;
  29     }
  30 
  31     @Benchmark
  32     public Object gather064() {
  33         int window = 64 / $Wideboxtype$.SIZE;
  34         return gather(window);
  35     }
  36 
  37     @Benchmark
  38     public Object gather128() {
  39         int window = 128 / $Wideboxtype$.SIZE;
  40         return gather(window);
  41     }
  42 
  43     @Benchmark
  44     public Object gather256() {
  45         int window = 256 / $Wideboxtype$.SIZE;
  46         return gather(window);
  47     }
  48 
  49     @Benchmark
  50     public Object gather512() {
  51         int window = 512 / $Wideboxtype$.SIZE;
  52         return gather(window);
  53     }
   1     @Benchmark
   2     public void gatherBase0(Blackhole bh) {
   3         $type$[] as = fa.apply(size);
   4         int[] is    = fs.apply(size);
   5         $type$[] rs = fr.apply(size);
   6 
   7         for (int ic = 0; ic < INVOC_COUNT; ic++) {
   8             for (int i = 0; i < as.length; i++) {
   9                 int ix = 0 + is[i];
  10                 rs[i] = as[ix];
  11             }
  12         }
  13 
  14         bh.consume(rs);
  15     }
  16 
  17 
  18     void gather(int window, Blackhole bh) {
  19         $type$[] as = fa.apply(size);
  20         int[] is    = fs.apply(size);
  21         $type$[] rs = fr.apply(size);
  22 
  23         for (int ic = 0; ic < INVOC_COUNT; ic++) {
  24             for (int i = 0; i < as.length; i += window) {
  25                 for (int j = 0; j < window; j++) {
  26                     int ix = i + is[i + j];
  27                     rs[i + j] = as[ix];
  28                 }
  29             }
  30         }
  31 
  32         bh.consume(rs);
  33     }
  34 
  35     @Benchmark
  36     public void gather064(Blackhole bh) {
  37         int window = 64 / $Wideboxtype$.SIZE;
  38         gather(window, bh);
  39     }
  40 
  41     @Benchmark
  42     public void gather128(Blackhole bh) {
  43         int window = 128 / $Wideboxtype$.SIZE;
  44         gather(window, bh);
  45     }
  46 
  47     @Benchmark
  48     public void gather256(Blackhole bh) {
  49         int window = 256 / $Wideboxtype$.SIZE;
  50         gather(window, bh);
  51     }
  52 
  53     @Benchmark
  54     public void gather512(Blackhole bh) {
  55         int window = 512 / $Wideboxtype$.SIZE;
  56         gather(window, bh);
  57     }
< prev index next >