Uploaded image for project: 'Harmony'
  1. Harmony
  2. HARMONY-6517

New optimization and interface for either automatically or manually vectorizing Java programs with SSE instructions

Details

    • New Feature
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • DRLVM
    • OS: Linux or Windows
      Hardware: X86 or X86_64 with SSE4.2
    • Patch Available

    Description

      The patch file "javavect.patch" for DRLVM provides new features for vectorizing Java programs either automatically or manually. The work consists of four parts:

      1) IR extension for vector types and operators (middle-end);
      2) vector instruction (SSE) description and code generation (back-end);
      3) optimization pass of automatic vectorization for loops (middle-end);
      4) Java vector interface (JVI, see below) translator for manually writing vectorized Java programs with JVI (front-end).

      Parts 1) and 2) provides the basic facility for internally representing vectorized code and generating SSE instructions. Based on that, part 3) provides an automatic approach and part 4) provides a manual approach for vectorizing Java programs.

      The patch file "jvi.patch" for vmmagic provides a Java class library for programmers to write vectorized Java program explicitly. It contains 6 classes representing the types of vectors of 8-, 16-, 32- and 64-bit integers, and 32- and 64-bit floating point numbers. Each class contains appropriate methods representing supported vector operators on that type. The JVI class references and method callings in a Java program are translated into appropriate internal vector IR by the extended front-end, i.e. the work of part 4).

      The Java source file "jvi_basic.java" provides a simple test suite for JVI, covering all implemented JVI operations. It can also be used as examples of the usage of JVI.

            • Hardware requirement ****

      X86 or X86_64 with SSE4.2 instruction set

            • Usage of automatic vectorization ****

      The patch file contains two new configuration files: server_autovect.emconf and server_static_autovect.emconf, which are copied from server.emconf and servre_static.emconf, and inserted "autovect" optimization pass into their optimization paths. To try automatic vectorization, only need to add one of the following arguments: "-Xem:server_autovect" or "-Xem:server_static_autovect" to run the VM.

            • Usage of JVI ****

      Write programs with JVI (see jvi_basic.java), compile them and run them with the argument "-Xem:server_static" (This is must because the JVI code cannot be executed without being translated into the vector IR by Jitrino's optimizing compiler).

            • Performance improvement ****

      The performance of two computation intensive workloads (LU and FFT) is improved by 30% to 100%.

            • Testing of the patch based on the Harmony revision 935818 (2010-04-20) ****

      Automatic vectorization testing with SPECjvm2008:

      • Argument: -Xem:server_static_autovect
      • On 64-bit linux machine: All workloads except crypto.aes, derby and xml.transform have passed.
      • On 32-bit linux machine: All workloads except derby have passed.
      • All the above failed workloads also fail when autovect is disabled (-Xem:server_static), meaning that the failures are caused by bugs of the original code base.
      • Argument: -Xem:server_autovect
      • On both 64-bit and 32-bit linux machines: All workloads except xml.transform and serial have passed.
      • All the above failed workloads also fail when autovect is disabled (-Xem:server), meaning that the failures are caused by bugs of the original code base.

      JVI-based vectorization testing with jvi_basic.java:

      • Argument: -Xem:server_static
      • On both 64-bit and 32-bit linux machines: all test cases have passed.

      Attachments

        1. jvi.patch
          20 kB
          Jiutao Nie
        2. jvi_basic.java
          104 kB
          Jiutao Nie
        3. javavect.patch
          367 kB
          Jiutao Nie

        Activity

          niejiutao Jiutao Nie added a comment -

          The author information in vm/jitrino/src/shared/SIMD.h is irrelevant
          to this contribution. The comments may be copied from other file
          together with the copyright header incautiously. The other author
          Buqi Cheng appearing in vm/jitrino/src/shared/SIMD.cpp did some early
          work for this contribution (including an early version of JVI though
          it has been changed a lot, and most instruction patterns of SSE
          instructions). For simplicity, he has granted me the ownership of all
          those material before the submission of this work.

          I've removed the inappropriate author information form the two files
          and updated the patch file. Do you think I still need to complete a
          bulk contribution checklist? If so, which kind of written agreement
          in Part III c) should Buqi and I sign? The CC recipient is Buqi Cheng
          registered on the ASF JIRA website.

          niejiutao Jiutao Nie added a comment - The author information in vm/jitrino/src/shared/SIMD.h is irrelevant to this contribution. The comments may be copied from other file together with the copyright header incautiously. The other author Buqi Cheng appearing in vm/jitrino/src/shared/SIMD.cpp did some early work for this contribution (including an early version of JVI though it has been changed a lot, and most instruction patterns of SSE instructions). For simplicity, he has granted me the ownership of all those material before the submission of this work. I've removed the inappropriate author information form the two files and updated the patch file. Do you think I still need to complete a bulk contribution checklist? If so, which kind of written agreement in Part III c) should Buqi and I sign? The CC recipient is Buqi Cheng registered on the ASF JIRA website.
          niejiutao Jiutao Nie added a comment -

          Removed inappropriate author information from SIMD.h and SIMD.cpp.

          niejiutao Jiutao Nie added a comment - Removed inappropriate author information from SIMD.h and SIMD.cpp.
          hudson Hudson added a comment -

          Integrated in Harmony-1.5-head-linux-x86_64 #824 (See http://hudson.zones.apache.org/hudson/job/Harmony-1.5-head-linux-x86_64/824/)
          Reverting commit r952017 of the javavect.patch from "HARMONY-6517 New
          optimization and interface for either automatically or manually
          vectorizing Java programs with SSE instructions".

          Will apply again once I've clarified the authorship of:

          drlvm/vm/jitrino/src/shared/SIMD.*

          hudson Hudson added a comment - Integrated in Harmony-1.5-head-linux-x86_64 #824 (See http://hudson.zones.apache.org/hudson/job/Harmony-1.5-head-linux-x86_64/824/ ) Reverting commit r952017 of the javavect.patch from " HARMONY-6517 New optimization and interface for either automatically or manually vectorizing Java programs with SSE instructions". Will apply again once I've clarified the authorship of: drlvm/vm/jitrino/src/shared/SIMD.*
          hudson Hudson added a comment -

          Integrated in Harmony-select-1.5-head-linux-x86_64 #16 (See http://hudson.zones.apache.org/hudson/job/Harmony-select-1.5-head-linux-x86_64/16/)
          Reverting commit r952017 of the javavect.patch from "HARMONY-6517 New
          optimization and interface for either automatically or manually
          vectorizing Java programs with SSE instructions".

          Will apply again once I've clarified the authorship of:

          drlvm/vm/jitrino/src/shared/SIMD.*

          hudson Hudson added a comment - Integrated in Harmony-select-1.5-head-linux-x86_64 #16 (See http://hudson.zones.apache.org/hudson/job/Harmony-select-1.5-head-linux-x86_64/16/ ) Reverting commit r952017 of the javavect.patch from " HARMONY-6517 New optimization and interface for either automatically or manually vectorizing Java programs with SSE instructions". Will apply again once I've clarified the authorship of: drlvm/vm/jitrino/src/shared/SIMD.*
          hindessm Mark Hindess added a comment -

          I've reverted the commit (at r952128) because I'd like clarification of the authorship of the contribution. Earlier you stated:

          I am responsible for this whole contribution

          but these two files:

          vm/jitrino/src/shared/SIMD.h
          vm/jitrino/src/shared/SIMD.cpp

          have Author comments that appear to contradict this statement. Both of the authors have previously contributed to Harmony so we have ACQs on file from them so I am not greatly concerned but I think it makes sense to clarify this.

          From my perspective, the simplest way to clarify this would be to treat this as a bulk contribution and for you to complete the appropriate checklist:

          http://harmony.apache.org/bulk_contribution_checklist.html

          hindessm Mark Hindess added a comment - I've reverted the commit (at r952128) because I'd like clarification of the authorship of the contribution. Earlier you stated: I am responsible for this whole contribution but these two files: vm/jitrino/src/shared/SIMD.h vm/jitrino/src/shared/SIMD.cpp have Author comments that appear to contradict this statement. Both of the authors have previously contributed to Harmony so we have ACQs on file from them so I am not greatly concerned but I think it makes sense to clarify this. From my perspective, the simplest way to clarify this would be to treat this as a bulk contribution and for you to complete the appropriate checklist: http://harmony.apache.org/bulk_contribution_checklist.html
          hudson Hudson added a comment -

          Integrated in Harmony-select-1.5-head-linux-x86_64 #15 (See http://hudson.zones.apache.org/hudson/job/Harmony-select-1.5-head-linux-x86_64/15/)
          Applying the most recent javavect.patch from "HARMONY-6517 New
          optimization and interface for either automatically or manually
          vectorizing Java programs with SSE instructions".

          I'll apply the other patches when I can figure out how best to integrate
          them.

          hudson Hudson added a comment - Integrated in Harmony-select-1.5-head-linux-x86_64 #15 (See http://hudson.zones.apache.org/hudson/job/Harmony-select-1.5-head-linux-x86_64/15/ ) Applying the most recent javavect.patch from " HARMONY-6517 New optimization and interface for either automatically or manually vectorizing Java programs with SSE instructions". I'll apply the other patches when I can figure out how best to integrate them.
          hudson Hudson added a comment -

          Integrated in Harmony-1.5-head-linux-x86_64 #823 (See http://hudson.zones.apache.org/hudson/job/Harmony-1.5-head-linux-x86_64/823/)
          Applying the most recent javavect.patch from "HARMONY-6517 New
          optimization and interface for either automatically or manually
          vectorizing Java programs with SSE instructions".

          I'll apply the other patches when I can figure out how best to integrate
          them.

          hudson Hudson added a comment - Integrated in Harmony-1.5-head-linux-x86_64 #823 (See http://hudson.zones.apache.org/hudson/job/Harmony-1.5-head-linux-x86_64/823/ ) Applying the most recent javavect.patch from " HARMONY-6517 New optimization and interface for either automatically or manually vectorizing Java programs with SSE instructions". I'll apply the other patches when I can figure out how best to integrate them.
          hindessm Mark Hindess added a comment -

          I've applied the javavect.patch at r952017. I'll apply the other two patches when I figure out how best to integrate them.

          Thanks,
          Mark.

          hindessm Mark Hindess added a comment - I've applied the javavect.patch at r952017. I'll apply the other two patches when I figure out how best to integrate them. Thanks, Mark.
          niejiutao Jiutao Nie added a comment -

          Yes, this will be better. I've updated the javavect.patch. Now the
          code becomes:

          + if (Log::isEnabled () && num_to_be_vectorized)
          +

          { + ir_manager.getMethodDesc().printFullName (Log::out ()); + Log::out() << ": " << num_to_be_vectorized + << " loop(s) to be vectorized" + << std::endl; + }

          Yes, this patch also includes several bug fixes relating to encoding
          longer instructions, which are found during the vectorization work,
          but not specific to it. I'll keep your advice in mind in future.

          2010/5/25 Mark Hindess (JIRA) <jira@apache.org>:

          niejiutao Jiutao Nie added a comment - Yes, this will be better. I've updated the javavect.patch. Now the code becomes: + if (Log::isEnabled () && num_to_be_vectorized) + { + ir_manager.getMethodDesc().printFullName (Log::out ()); + Log::out() << ": " << num_to_be_vectorized + << " loop(s) to be vectorized" + << std::endl; + } Yes, this patch also includes several bug fixes relating to encoding longer instructions, which are found during the vectorization work, but not specific to it. I'll keep your advice in mind in future. 2010/5/25 Mark Hindess (JIRA) <jira@apache.org>:
          hindessm Mark Hindess added a comment -

          Documents received. Thanks.

          Now I just need to find a machine that has SSE4.2.

          FYI: I think:

          + if (num_to_be_vectorized)
          +

          { + ir_manager.getMethodDesc().printFullName (std::cout); + std::cout << ": " << num_to_be_vectorized + << " loops to be vectorized" + << std::endl; + }

          needs:

          if (Log::isEnabled ())

          { ... }

          around it.

          I also notice that some of the changes don't seem to be specific to your improvements. For future reference, it would be better to receive those as separate jira/patches.

          hindessm Mark Hindess added a comment - Documents received. Thanks. Now I just need to find a machine that has SSE4.2. FYI: I think: + if (num_to_be_vectorized) + { + ir_manager.getMethodDesc().printFullName (std::cout); + std::cout << ": " << num_to_be_vectorized + << " loops to be vectorized" + << std::endl; + } needs: if (Log::isEnabled ()) { ... } around it. I also notice that some of the changes don't seem to be specific to your improvements. For future reference, it would be better to receive those as separate jira/patches.
          niejiutao Jiutao Nie added a comment -

          I've just sent the documents to the list again. Can you receive it?

          niejiutao Jiutao Nie added a comment - I've just sent the documents to the list again. Can you receive it?
          hindessm Mark Hindess added a comment -

          Thanks. I'm on that list but I've not seen the mail yet. Probably they are waiting to be moderated through to the list. I'll chase this up today (and get myself added as moderator for the future).

          hindessm Mark Hindess added a comment - Thanks. I'm on that list but I've not seen the mail yet. Probably they are waiting to be moderated through to the list. I'll chase this up today (and get myself added as moderator for the future).
          niejiutao Jiutao Nie added a comment -

          I have submitted the signed and scanned ICLA and ACQ to private@harmony.apache.org on last Friday. The subject of the email was "ICLA and ACQ", and it mentioned this JIRA entry in its body. I am responsible for this whole contribution, so it doesn't require any other people's legal documents further.

          Thanks,
          Jiutao

          niejiutao Jiutao Nie added a comment - I have submitted the signed and scanned ICLA and ACQ to private@harmony.apache.org on last Friday. The subject of the email was "ICLA and ACQ", and it mentioned this JIRA entry in its body. I am responsible for this whole contribution, so it doesn't require any other people's legal documents further. Thanks, Jiutao
          hindessm Mark Hindess added a comment -

          Thanks for this contribution. Could you (and any other contributors) please complete ICLAs and ACQs as mentioned at:

          http://harmony.apache.org/contribution_policy.html

          Sign them, scan them and email them to private@harmony.apache.org.

          Thanks,
          Mark.

          hindessm Mark Hindess added a comment - Thanks for this contribution. Could you (and any other contributors) please complete ICLAs and ACQs as mentioned at: http://harmony.apache.org/contribution_policy.html Sign them, scan them and email them to private@harmony.apache.org. Thanks, Mark.

          People

            hindessm Mark Hindess
            niejiutao Jiutao Nie
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: