Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8200477

Integer dot product no longer autovectorised

XMLWordPrintable

    • 10
    • b11
    • x86
    • windows_10

      FULL PRODUCT VERSION :
      JDK 10, VM 10+46

      FULL OS VERSION :
      Microsoft Windows [Version 10.0.16299.309]

      A DESCRIPTION OF THE PROBLEM :
      32 bit integer dot product is no longer vectorised. This represents a performance regression.

      THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: Did not try

      THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Yes

      REGRESSION. Last worked in version 9.0.1

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the benchmark with JMH

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      There should be similar performance between the two versions:

      # JMH version: 1.19
      # VM version: JDK 9.0.1, VM 9.0.1+11
      Benchmark (size) Mode Cnt Score Error Units
      DotProduct.dotProduct 1024 thrpt 10 2.998 ± 0.028 ops/us

      # JMH version: 1.19
      # VM version: JDK 10, VM 10+46
      Benchmark (size) Mode Cnt Score Error Units
      DotProduct.dotProduct 1024 thrpt 10 1.907 ± 0.063 ops/us
      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import org.openjdk.jmh.annotations.*;

      import java.util.concurrent.ThreadLocalRandom;
      import java.util.concurrent.TimeUnit;

      @State(Scope.Thread)
      @OutputTimeUnit(TimeUnit.MICROSECONDS)
      public class DotProduct {

        private int[] left;
        private int[] right;

        @Param({"1024"})
        int size;

        @Setup(Level.Trial)
        public void init() {
          left = new int[size];
          right = new int[size];
          for (int i = 0; i < size; ++i) {
            left[i] = ThreadLocalRandom.current().nextInt();
            right[i] = ThreadLocalRandom.current().nextInt();
          }
        }

        @Benchmark
        public int dotProduct() {
          int dp = 0;
          for (int i = 0; i < left.length && i < right.length; ++i) {
            dp += left[i] * right[i ];
          }
          return dp;
        }

      }
      ---------- END SOURCE ----------

            roland Roland Westrelin
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: