public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: Raphael M Zinsly <rzinsly@linux.ibm.com>, libc-alpha@sourceware.org
Subject: Re: [PATCH v3 2/2] powerpc: Add optimized stpncpy for POWER9
Date: Wed, 30 Sep 2020 11:46:30 -0300	[thread overview]
Message-ID: <b9c715b3-cd8b-383b-3ca5-d09e38b51195@linaro.org> (raw)
In-Reply-To: <8c436fe7-cdf4-a1fa-6777-f641f3b8a59c@linux.ibm.com>



On 30/09/2020 11:21, Raphael M Zinsly wrote:
> Hi Adhemerval,
> 
> On 30/09/2020 10:42, Adhemerval Zanella wrote:
>>
>>
>> On 29/09/2020 12:21, Raphael Moreira Zinsly via Libc-alpha wrote:
>>> Add stpncpy support into the POWER9 strncpy.
>>
>> The benchmark numbers you provided [1] seems to show it is slight worse than
>> the generic_strncpy which uses the same strategy as string/strncpy.c
>> (which would use VSX instruction through memset/memcpy).
> 
> My implementation is always better than the generic_strncpy, almost three times better in average. And it calls memset as well.
> 
> Are you talking about __strncpy_ppc? For some reason it is using strnlen_ppc instead of the strnlen_power8, but I didn't touch it.
> 
>> Did you compare this
>> optimization against an implementation that just call power8/9 memset/memcpy
>> instead?
>>
> 
> Not sure if I understand, isn't that generic_strncpy and strncpy_ppc?


Right, I misread the benchmark.  And I tested my own suggestion on the power9
from gcc farm and it seems that although it is slight faster than power7
variant it does not really beat power8 (as expected since it calls strnlen and
then memcpy/memset and access the input twice).

I do not really oppose it and it is up to the arch maintainer, but I still think
these micro-optimizations tends to just add extra maintainability and icache
pressure where the microbenchmark does not really catch.

> 
> 
>> It should resulting a smaller implementation which reduces i-cache size and
>> the code is much more simpler and maintainable.  The same applies for stpncpy.
>>
>> I tried to dissuade Intel developers that such micro-optimization are not
>> really a real gain and instead we should optimize only a handful of string
>> operations (memcpy/memset/etc.) and use composable implementation instead
>> (as generic strncpy).  It still resulted on 1a153e47fcc, but I think we
>> might do better for powerpc.
>>
>> [1] https://sourceware.org/pipermail/libc-alpha/2020-September/118049.html
>>
> 
> Best Regards,

  reply	other threads:[~2020-09-30 14:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-29 15:21 [PATCH v3 1/2] powerpc: Add optimized strncpy " Raphael Moreira Zinsly
2020-09-29 15:21 ` [PATCH v3 2/2] powerpc: Add optimized stpncpy " Raphael Moreira Zinsly
2020-09-29 15:23   ` Raphael M Zinsly
2020-09-30 13:42   ` Adhemerval Zanella
2020-09-30 14:21     ` Raphael M Zinsly
2020-09-30 14:46       ` Adhemerval Zanella [this message]
2020-11-12 17:12   ` Tulio Magno Quites Machado Filho
2020-09-29 15:22 ` [PATCH v3 1/2] powerpc: Add optimized strncpy " Raphael M Zinsly
2020-10-15 15:20 ` Lucas A. M. Magalhaes
2020-11-12 17:09 ` Tulio Magno Quites Machado Filho

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=b9c715b3-cd8b-383b-3ca5-d09e38b51195@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=libc-alpha@sourceware.org \
    --cc=rzinsly@linux.ibm.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).