You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by xiaoming gu <xi...@gmail.com> on 2008/08/05 06:03:56 UTC

patch for HARMONY-5901 is ready

Hi, guys. The patch for harmony-5901 is ready.

I compared the performance for all the 5 benchmarks in "Java vs. C
benchmark" by Stefan Krause on my desktop
workstation (Intel Core 2 Quad Q9550@2.83GHz, 3.23G RAM, Windows XP SP2).
With MUL/DIV replaced by shift,
spectralnorm is improved more than 29% (from 450258 msec to 319578 msec) and
no noticeable change in other
4 benchmarks.

In the webpage http://www.stefankrause.net/wp/?p=9#more-9 you may see
spectralnorm is the one which drags
the total score of Harmony most. Attachments are the detailed experiment
inputs and results.

With further thoughts, I found we'd better do more for this "numerical
strength reduction" optimization. In
Integer.parseInt() method, there is a hot *10 operation if the code is
inlined. Actually gcc does this optimization for
multiplications if one of multipliers is constant and not too large. I'm
going to take care of the generalized work these
days.

Thanks.

Xiaoming

Re: patch for HARMONY-5901 is ready

Posted by Xiao-Feng Li <xi...@gmail.com>.
There are more situations that strength reduction can be applicable.
Do we want to make the optimization a general solution or just keep it
case by case?

Thanks,
xiaofeng

On Tue, Aug 5, 2008 at 3:11 PM, Aleksey Shipilev
<al...@gmail.com> wrote:
> On Tue, Aug 5, 2008 at 8:03 AM, xiaoming gu <xi...@gmail.com> wrote:
>> Hi, guys. The patch for harmony-5901 is ready.
> At last! Thanks, Xioaming!
>
>> I compared the performance for all the 5 benchmarks in "Java vs. C
>> benchmark" by Stefan Krause on my desktop
>> workstation (Intel Core 2 Quad Q9550@2.83GHz, 3.23G RAM, Windows XP SP2).
>> With MUL/DIV replaced by shift,
>> spectralnorm is improved more than 29% (from 450258 msec to 319578 msec)
> Can you spend some time and measure how much boost there is, in case
> your _manual_ change of MUL/DIV operations to shifts? I had measured
> +60% boost, so it would be great to conclude whether yours +30% is
> connected with patch overheads (handling negative operands, I guess)
> or your environment.
>
> Thanks,
> Aleksey.
>



-- 
http://xiao-feng.blogspot.com

Re: patch for HARMONY-5901 is ready

Posted by xiaoming gu <xi...@gmail.com>.
Aleksey, you are right. I did the transformation manually and tested again.
The result is
259936 msec, which is improved more than 42%. Following are about the manual

transformation.

Original:               return 1.0/((i+j)*(i+j+1)/2 +i+1);
Transformed:        return 1.0/((((i+j)*(i+j+1)+(1&(((i+j)*(i+j+1))>>31)))
>> 1) +i+1);

In my opinion, the replacement does the same thing in JIT. I'll check about
the cause of the
difference. Thanks for your suggestions.

Xiaoming

On Tue, Aug 5, 2008 at 3:11 PM, Aleksey Shipilev <aleksey.shipilev@gmail.com
> wrote:

> On Tue, Aug 5, 2008 at 8:03 AM, xiaoming gu <xi...@gmail.com> wrote:
> > Hi, guys. The patch for harmony-5901 is ready.
> At last! Thanks, Xioaming!
>
> > I compared the performance for all the 5 benchmarks in "Java vs. C
> > benchmark" by Stefan Krause on my desktop
> > workstation (Intel Core 2 Quad Q9550@2.83GHz, 3.23G RAM, Windows XP
> SP2).
> > With MUL/DIV replaced by shift,
> > spectralnorm is improved more than 29% (from 450258 msec to 319578 msec)
> Can you spend some time and measure how much boost there is, in case
> your _manual_ change of MUL/DIV operations to shifts? I had measured
> +60% boost, so it would be great to conclude whether yours +30% is
> connected with patch overheads (handling negative operands, I guess)
> or your environment.
>
> Thanks,
> Aleksey.
>

Re: patch for HARMONY-5901 is ready

Posted by Aleksey Shipilev <al...@gmail.com>.
On Tue, Aug 5, 2008 at 8:03 AM, xiaoming gu <xi...@gmail.com> wrote:
> Hi, guys. The patch for harmony-5901 is ready.
At last! Thanks, Xioaming!

> I compared the performance for all the 5 benchmarks in "Java vs. C
> benchmark" by Stefan Krause on my desktop
> workstation (Intel Core 2 Quad Q9550@2.83GHz, 3.23G RAM, Windows XP SP2).
> With MUL/DIV replaced by shift,
> spectralnorm is improved more than 29% (from 450258 msec to 319578 msec)
Can you spend some time and measure how much boost there is, in case
your _manual_ change of MUL/DIV operations to shifts? I had measured
+60% boost, so it would be great to conclude whether yours +30% is
connected with patch overheads (handling negative operands, I guess)
or your environment.

Thanks,
Aleksey.