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

[Vector API] Move Reduction outside loop when possible

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 21
    • hotspot

      Do same as JDK-8302652 but for Vector API.

      [~jrose] Sketched it like this:

      From
      int a = 0; for (…) { … a += v.reduceLanes(ADD) … }
      to
      vector<int> asplit = zeroes(); for (…) { ... asplit = asplit.add(v) … }; int a = asplit.reduceLanes(ADD);


      I coded up concreate int-add-reduction example (dot-product).

      ./java -Xbatch -XX:CompileCommand=printcompilation,Test::* -XX:CompileCommand=exclude,Test::test00 -XX:UseAVX=2 -XX:CompileCommand=print,Test::test11 Test.java > txt1.txt

      ./java -Xbatch -XX:CompileCommand=printcompilation,Test::* -XX:CompileCommand=exclude,Test::test00 -XX:UseAVX=2 -XX:CompileCommand=print,Test::test12 Test.java > txt1.txt

      grepping for "vector_reduction_int", we see that for test11 we have many reductions in the loop, whereas for test12 we only have 2 reductions in the whole compilation.

            epeter Emanuel Peter
            epeter Emanuel Peter
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: