From: Georg Sauthoff <mail@georg.so>
To: musl@lists.openwall.com
Subject: Re: memchr() performance
Date: Mon, 19 Sep 2016 15:29:53 +0200 [thread overview]
Message-ID: <20160919132953.GA8375@dell12.lru.li> (raw)
In-Reply-To: <20160918204036.GZ1280@port70.net>
On Sun, Sep 18, 2016 at 10:40:36PM +0200, Szabolcs Nagy wrote:
Hello,
> * Georg Sauthoff <mail@georg.so> [2016-09-18 20:54:22 +0200]:
[..]
> > On recent Intel CPUs it is even slower than a naive implementation:
> >
> > https://gms.tf/stdfind-and-memchr-optimizations.html#measurements
> > https://gms.tf/sparc-and-ppc-find-benchmark-results.html
> >
> > Of course, on x86, other implementations that use SIMD instructions
> > perform even better.
> yes simd is expected to be faster.
> but that needs asm which is expensive to maintain (there is no
> portable simd language extension for c and there is the aliasing
> issue: the reinterpret_cast in your code is formally ub).
you mean because the vector-word pointer returned by reinterpret_cast is
used to access vector-words in the memory passed via a char pointer and
this is not covered by the ISO C++ strict aliasing rules?
Yes. Sure, ub means that anything can happen, but this case should be ok
with GCC - if the function is compiled in isolation in its own
translation unit.
I mean, there isn't much possibiltiy for reordering due to the
application of strict-aliasing-rules that would yield a different
result.
There are no aliased write accesses.
Btw, the current musl memchr() implementation has similar aliased
accesses - there, unsigned characters are aliased via a size_t pointer.
Best regards
Georg
next prev parent reply other threads:[~2016-09-19 13:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-18 18:54 Georg Sauthoff
2016-09-18 20:40 ` Rich Felker
2016-09-18 20:40 ` Szabolcs Nagy
2016-09-19 13:29 ` Georg Sauthoff [this message]
2016-09-19 13:37 ` Rich Felker
2016-09-19 17:58 ` Szabolcs Nagy
2016-09-20 17:57 ` Georg Sauthoff
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=20160919132953.GA8375@dell12.lru.li \
--to=mail@georg.so \
--cc=musl@lists.openwall.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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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 NNTP newsgroup(s).