From: "Vladimir 'φ-coder/phcoder' Serbinenko" <phcoder@gmail.com>
To: grub-devel@gnu.org
Subject: Re: Image scaling performance
Date: Wed, 25 Feb 2015 19:56:55 +0100 [thread overview]
Message-ID: <54EE1AF7.50305@gmail.com> (raw)
In-Reply-To: <CAN9vWDJxY5qgvBrtHXkT5jdYNGO9nsjp7Ud2axku=1yndWUOpA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2390 bytes --]
On 25.02.2015 19:46, Michael Zimmermann wrote:
> oh ok so linux's div/mod/... assembler is as slow/fast as grub's code?
> Linux uses armv5>= ifdefs. Maybe we could optimized things a little :)
> About scale_nn,
> amarullz(https://plus.google.com/u/0/+AhmadAmarullah/about) wrote a
> optimized version without divs:
> loops: http://pastebin.com/MaZqWSA9
> memcpy: http://pastebin.com/iNq0V5Tw
>
Please try my patch (reattached here after minor fixes). The patch by
anonymous source, sent by third-party through pastebin isn't acceptable
from legal perspective
> this code works a little faster. I'm still questioning the efficiency
> math operations because on slow devices there are other bottlenecks of
> the same kind(like de/compression).
>
> On Wed, Feb 25, 2015 at 7:41 PM, Vladimir 'phcoder' Serbinenko
> <phcoder@gmail.com> wrote:
>> ARMv7 doesn't mandate div instructions. It's a separate flag in features.
>> GRUB supports earlier CPUs as well and we use them for testing. My only test
>> machine is armv6
>>
>> Le 2015-02-25 19:38, "Michael Zimmermann" <sigmaepsilon92@gmail.com> a écrit
>> :
>>
>>> Why u think the native div code would crash on most devices? I support
>>> ARMv7+ only anyway.
>>>
>>> On Wed, Feb 25, 2015 at 5:23 PM, Leif Lindholm <leif.lindholm@linaro.org>
>>> wrote:
>>>> On Wed, Feb 25, 2015 at 03:45:40PM +0000, Leif Lindholm wrote:
>>>>>>>> Some technical info:
>>>>>>>> ARMv7
>>>>>>>> Linaro GCC 4.9
>>>>>
>>>>> I don't see any calls to any of the __aeabi helpers generated for this
>>>>> file with current head. Which specific Linaro toolchain are you using?
>>>>> (mine is"Linaro GCC 4.9-2014.09").
>>>>
>>>> Scratch that, I do see them. Just failing to drive the tools properly.
>>>>
>>>> /
>>>> Leif
>>>>
>>>> _______________________________________________
>>>> Grub-devel mailing list
>>>> Grub-devel@gnu.org
>>>> https://lists.gnu.org/mailman/listinfo/grub-devel
>>>
>>> _______________________________________________
>>> Grub-devel mailing list
>>> Grub-devel@gnu.org
>>> https://lists.gnu.org/mailman/listinfo/grub-devel
>>
>>
>> _______________________________________________
>> Grub-devel mailing list
>> Grub-devel@gnu.org
>> https://lists.gnu.org/mailman/listinfo/grub-devel
>>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>
[-- Attachment #2: scale.diff --]
[-- Type: text/x-diff, Size: 1442 bytes --]
diff --git a/grub-core/video/bitmap_scale.c b/grub-core/video/bitmap_scale.c
index 0b93d02..64bacbf 100644
--- a/grub-core/video/bitmap_scale.c
+++ b/grub-core/video/bitmap_scale.c
@@ -366,22 +366,31 @@ scale_nn (struct grub_video_bitmap *dst, struct grub_video_bitmap *src)
/* bytes_per_pixel is the same for both src and dst. */
unsigned bytes_per_pixel = dst->mode_info.bytes_per_pixel;
- unsigned dy;
- for (dy = 0; dy < dh; dy++)
+ unsigned dy, sy, ystep, yfrac, yover;
+ unsigned dx, sx, xstep, xfrac, xover;
+ ystep = sw / dw;
+ yover = sw % dw;
+ xstep = sh / dh;
+ xover = sh % dh;
+
+ for (dy = 0, sy = 0, yfrac = 0; dy < dh; dy++, sy += ystep, yfrac += yover)
{
- unsigned dx;
- for (dx = 0; dx < dw; dx++)
+ if (yfrac > dw)
+ {
+ yfrac -= dw;
+ sy++;
+ }
+ for (dx = 0, sx = 0, xfrac = 0; dx < dw; dx++, sx += xstep, xfrac += xover)
{
grub_uint8_t *dptr;
grub_uint8_t *sptr;
- unsigned sx;
- unsigned sy;
unsigned comp;
- /* Compute the source coordinate that the destination coordinate
- maps to. Note: sx/sw = dx/dw => sx = sw*dx/dw. */
- sx = sw * dx / dw;
- sy = sh * dy / dh;
+ if (xfrac > dh)
+ {
+ xfrac -= dh;
+ sx++;
+ }
/* Get the address of the pixels in src and dst. */
dptr = ddata + dy * dstride + dx * bytes_per_pixel;
next prev parent reply other threads:[~2015-02-25 18:57 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-24 9:39 Image scaling performance Michael Zimmermann
2015-02-24 9:51 ` Vladimir 'phcoder' Serbinenko
2015-02-24 10:00 ` Michael Zimmermann
2015-02-24 11:27 ` Vladimir 'phcoder' Serbinenko
2015-02-24 11:47 ` Michael Zimmermann
2015-02-24 12:39 ` Vladimir 'phcoder' Serbinenko
2015-02-24 18:01 ` Michael Zimmermann
2015-02-24 18:22 ` Andrei Borzenkov
2015-02-25 16:20 ` Leif Lindholm
2015-02-25 15:45 ` Leif Lindholm
2015-02-25 16:23 ` Leif Lindholm
2015-02-25 18:38 ` Michael Zimmermann
2015-02-25 18:41 ` Vladimir 'phcoder' Serbinenko
2015-02-25 18:46 ` Michael Zimmermann
2015-02-25 18:56 ` Vladimir 'φ-coder/phcoder' Serbinenko [this message]
2015-02-25 19:28 ` Michael Zimmermann
2015-02-25 20:39 ` Vladimir 'φ-coder/phcoder' Serbinenko
2015-02-25 20:48 ` Vladimir 'φ-coder/phcoder' Serbinenko
2015-02-25 20:54 ` Michael Zimmermann
2015-02-26 16:44 ` Vladimir 'φ-coder/phcoder' Serbinenko
2015-02-26 17:10 ` Michael Zimmermann
2015-02-26 17:16 ` Vladimir 'φ-coder/phcoder' Serbinenko
2015-02-26 20:27 ` Michael Zimmermann
2015-02-26 20:35 ` Vladimir 'φ-coder/phcoder' Serbinenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54EE1AF7.50305@gmail.com \
--to=phcoder@gmail.com \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.