RFR[S]:8241874 [PPC64] Improve performance of Long.reverseBytes() and Integer.reverseBytes() on Power9

Michihiro Horie HORIE at jp.ibm.com
Fri Apr 10 08:47:42 UTC 2020


Hi Corey,

Thank you for sharing your benchmarks. I confirmed your change reduced the
elapsed time of the benchmarks by more than 30% on my P9 node. Also, I
checked JTREG results, which look no problem.

BTW, I cannot find further points of improvement in your change.

Best regards,
Michihiro


 ----- Original message -----
 From: "Corey Ashford" <cjashfor at linux.ibm.com>
 To: Michihiro Horie/Japan/IBM at IBMJP
 Cc: hotspot-compiler-dev at openjdk.java.net,
 ppc-aix-port-dev at openjdk.java.net, "Gustavo Romero"
 <gromero at linux.vnet.ibm.com>
 Subject: Re: RFR[S]:8241874 [PPC64] Improve performance of
 Long.reverseBytes() and Integer.reverseBytes() on Power9
 Date: Fri, Apr 3, 2020 8:07 AM

 On 4/2/20 7:27 AM, Michihiro Horie wrote:
 > Hi Corey,
 >
 > I’m not a reviewer, but I can run your benchmark in my local P9 node if
 > you share it.
 >
 > Best regards,
 > Michihiro

 The tests are somewhat hokey; I added the shifts to keep the compiler
 from hoisting the code that it could predetermine the result.

 Here's the one for Long.reverseBytes():

 import java.lang.*;

 class ReverseLong
 {
      public static void main(String args[])
      {
          long reversed, re_reversed;
 long accum = 0;
 long orig = 0x1122334455667788L;
 long start = System.currentTimeMillis();
 for (int i = 0; i < 1_000_000_000; i++) {
 // Try to keep java from figuring out stuff in advance
 reversed = Long.reverseBytes(orig);
 re_reversed = Long.reverseBytes(reversed);
 if (re_reversed != orig) {
          System.out.println("Orig: " + String.format("%16x", orig) +
 "  Re-reversed: " + String.format("%16x", re_reversed));
 }
 accum += orig;
 orig = Long.rotateRight(orig, 3);
 }
 System.out.println("Elapsed time: " +
 Long.toString(System.currentTimeMillis() - start));
 System.out.println("accum: " + Long.toString(accum));
      }
 }


 And the one for Integer.reverseBytes():

 import java.lang.*;

 class ReverseInt
 {
      public static void main(String args[])
      {
          int reversed, re_reversed;
 int orig = 0x11223344;
 int accum = 0;
 long start = System.currentTimeMillis();
 for (int i = 0; i < 1_000_000_000; i++) {
 // Try to keep java from figuring out stuff in advance
 reversed = Integer.reverseBytes(orig);
 re_reversed = Integer.reverseBytes(reversed);
 if (re_reversed != orig) {
          System.out.println("Orig: " + String.format("%08x", orig) +
 "  Re-reversed: " + String.format("%08x", re_reversed));
 }
 accum += orig;
 orig = Integer.rotateRight(orig, 3);
 }
 System.out.println("Elapsed time: " +
 Long.toString(System.currentTimeMillis() - start));
 System.out.println("accum: " + Integer.toString(accum));
      }
 }



More information about the hotspot-compiler-dev mailing list