public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: "Ondřej Bílka" <neleai@seznam.cz>
To: Wilco Dijkstra <wdijkstr@arm.com>
Cc: 'GNU C Library' <libc-alpha@sourceware.org>
Subject: Re: [PATCH][AArch64] Optimized memset
Date: Wed, 30 Sep 2015 12:58:00 -0000	[thread overview]
Message-ID: <20150930125811.GA16679@domone> (raw)
In-Reply-To: <004c01d0cba1$e15ac5a0$a41050e0$@com>

On Fri, Jul 31, 2015 at 04:02:12PM +0100, Wilco Dijkstra wrote:
> This is an optimized memset for AArch64. Memset is split into 4 main cases: small sets of up to 16
> bytes, medium of 16..96 bytes which are fully unrolled. Large memsets of more than 96 bytes align
> the destination and use an unrolled loop processing 64 bytes per iteration. Memsets of zero of more
> than 256 use the dc zva instruction, and there are faster versions for the common ZVA sizes 64 or
> 128. STP of Q registers is used to reduce codesize without loss of performance.
> 
> Speedup on test-memset is 1% on Cortex-A57 and 8% on Cortex-A53. On a random test with varying sizes
> and alignment the new version is 50% faster.
> 
> OK for commit?
> 
I have two comments, first is that you should try same optimizations I
did on x64.

First what surprised me is why you stop full unrolling at only 96 bytes
as you could go upto 256 bytes and code would be still relatively small.

Then you could use trick that you could handle size 32-96 bytes and
x-3*x range in general by using following which cuts number of branches.
*s = c;
*s + (size - x) / 2 = c;
*s + size -x = c;

Second is to turn sizes smaller than 16 bytes branchless by using
conditional moves to write to stack when size is smaller than constant
for example in following way.

uint64 *p8 = size >= 8 ? s : stack;
uint64 *p4 = size >= 4 ? s + (size & 8) : stack;
uint64 *p2 = size >= 2 ? s + (size & 12) : stack;
char *p1 = size ? s + size - 1 : stack;
*p8 = c;
*p4 = c;
*p2 = c;
*p1 = c;


> ChangeLog:
> 2015-07-31  Wilco Dijkstra  <wdijkstr@arm.com>
> 
> 	* sysdeps/aarch64/memset.S (__memset): 
> 	Rewrite of optimized memset.
> 

> ---
>  sysdeps/aarch64/memset.S | 361 +++++++++++++++++++++--------------------------
>  1 file changed, 162 insertions(+), 199 deletions(-)
> 
> diff --git a/sysdeps/aarch64/memset.S b/sysdeps/aarch64/memset.S
> index 816640a..bdd670d 100644
> --- a/sysdeps/aarch64/memset.S
> +++ b/sysdeps/aarch64/memset.S
> @@ -9,220 +9,183 @@
>  
>     The GNU C Library is distributed in the hope that it will be useful,
>     but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
>     Lesser General Public License for more details.
>  
again substitution gone awry.

  parent reply	other threads:[~2015-09-30 12:58 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-31 15:02 Wilco Dijkstra
2015-08-11 12:23 ` Ondřej Bílka
2015-08-11 13:02   ` Wilco Dijkstra
2015-08-11 13:43     ` Ondřej Bílka
2015-09-25 14:55 ` Marcus Shawcroft
2015-09-30 12:58 ` Ondřej Bílka [this message]
2015-10-01 14:38   ` Wilco Dijkstra
2015-09-25 13:24 Wilco Dijkstra
2015-12-15 16:39 Wilco Dijkstra
2016-04-15 12:40 ` Wilco Dijkstra
2016-04-20 21:10 ` Adhemerval Zanella
2016-05-12 13:58 ` Wilco Dijkstra
2016-05-12 15:32   ` Marcus Shawcroft

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=20150930125811.GA16679@domone \
    --to=neleai@seznam.cz \
    --cc=libc-alpha@sourceware.org \
    --cc=wdijkstr@arm.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).