harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Xiao-Feng Li" <xiaofeng...@gmail.com>
Subject Re: [jira] Commented: (HARMONY-5901) replace integer multiplication or division with shift if one of multipliers or divisor is a power of 2
Date Thu, 21 Aug 2008 06:13:00 GMT
On Thu, Aug 21, 2008 at 12:30 PM, Xiaoming Gu (JIRA) <jira@apache.org> wrote:
>
>    [ https://issues.apache.org/jira/browse/HARMONY-5901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12624249#action_12624249
]
>
> Xiaoming Gu commented on HARMONY-5901:
> --------------------------------------
>
> Hi, guys. I'm working on the strength reduction for MUL & DIV these days.
>
> I found the optimization is available in simplify.cpp and multiplybyconstant.cpp but
it is not turned on. Then I turned on it by simply changing "simplify" to "latesimplify" in
.emconf files. To turn on DIV reduction, it needs to delete #ifdef __IPF__ around the related
code. I did some tests with the benchmarks by Stefan Krause (http://www.stefankrause.net/wp/?m=200807)
yesterday and following are the details.
>
> ++++++++++++Using latest version of Harmony, -Xem:opt++++++++++
> mandelbrot_long            2547(msec)
> fannkuch_long               5437
> himeno_bench2             26518
> nbody_long                   8468
> spectralnorm_long         14967
>
> As mentioned before there is an opportunity for DIV reduction in spectralnorm_long.
> ++++++++++++Manually transformed spectralnorm_long using latest version of Harmony, -Xem:opt++++++++++
> spectralnorm_long         8905(msec)
>
> Then I turned on the available MUL and DIV reduction
> ++++++++++++Using latest version of Harmony, -Xem:opt but MUL & DIV reduction turned
on++++++++++
> mandelbrot_long            2547(msec)
> fannkuch_long               5453
> himeno_bench2             26987
> nbody_long                   19342
> spectralnorm_long         8765
>
> The inputs for these tests are
> +++++++++++++Input++++++++++++++
> mandelbrot_long 4000
> fannkuch_long           11
> himeno_bench2           M (more options "-Xmx1024m -Xms1024m" needed)
> nbody_long              19900001
> spectralnorm_long       5501
>
> From the above results, spectralnorm_long is improved a lot by the available reduction
even better than the manual transformation. But fannkuch_long and himeno_bench2 are degraded
a little and nbody_long is degraded a lot. After breifly reading the reduction code, I find
the cost model for reduction is missing and the reduction is always done if it's turned on.
Maybe that's why the available reduction is turned off in all emconf files. Does anyone know
about this available reduction? Why it is turned off by default? Thanks.

Thanks for the experiments and the discovery. I think you can decide
if we want to improve the cost model or have a butter solution.
Thanks.

-xiaofeng

>
>> replace integer multiplication or division with shift if one of multipliers or divisor
is a power of 2
>> ------------------------------------------------------------------------------------------------------
>>
>>                 Key: HARMONY-5901
>>                 URL: https://issues.apache.org/jira/browse/HARMONY-5901
>>             Project: Harmony
>>          Issue Type: Improvement
>>          Components: DRLVM
>>            Reporter: Xiaoming Gu
>>         Attachments: 5901.patch, H5901-V2.patch, H5901-V3.patch, H5901-V4.patch,
H5901-V5.patch
>>
>>
>> 1. Mulitiplication replacement
>>     a. It's about integer multiplication.
>>     b. One of two multipliers is a power of 2.
>>     c. The power of 2 could be negative.
>>     For example, 23*4 is transformed to 23<<2 and 23*(-4) is transformed to
(23<<2)*(-1).
>> 2. Division replacement
>>     a. It's about integer division.
>>     b. The divisor is a power of 2.
>>     c. The power of 2 could be negative.
>>     d. Because of round-up difference between division and shift right, the following
equations from Aleksey are used.
>>               Baseline: q = a / (1 << d);
>>               Optimized: q = (a + [(1 << d) - 1] & (a >> 31)) >>
d;
>>     For example, 23/4 is transformed to  (23+((1<<2)-1)&(23>>31))>>2.
and (-23)/(-4) is transformed to ((-23+((1<<2)-1)&(-23>>31))>>2)*(-1).
>> 3. Comments for SAR and SHR swapped
>>      The comments for the two similar operations were misplaced in working_vm/vm/port/src/encoder/ia32_em64t.
>
> --
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
>
>



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

Mime
View raw message