From: dengjianbo <dengjianbo@loongson.cn>
To: libc-alpha@sourceware.org
Cc: adhemerval.zanella@linaro.org, xry111@xry111.site,
caiyinyu@loongson.cn, xuchenghua@loongson.cn,
huangpei@loongson.cn, dengjianbo <dengjianbo@loongson.cn>
Subject: [PATCH v2 0/3] LoongArch: Add ifunc support for str{cp, rchr},
Date: Wed, 13 Sep 2023 15:34:58 +0800 [thread overview]
Message-ID: <20230913073501.1018239-1-dengjianbo@loongson.cn> (raw)
This patch add mutiple versions of strcpy, stpcpy, strrchr implemented
by basic LoongArch instructions, LSX instructions, LASX instructions.
Even though this implementation experience degradation in a few cases,
overall, the performance gains are significant.
See:
https://github.com/jiadengx/glibc_test/blob/main/bench/strcpy_compare_v2.out
https://github.com/jiadengx/glibc_test/blob/main/bench/stpcpy_compare_v2.out
Test results are compared with generic strcpy and stpcpy, not strlen +
memcpy in the benchmark.
Generic strrchr is implemented by strlen + memrchr, the strrchr_lasx
will be compared with generic_strrchr implemented by strlen-lasx and
memrchr-lasx, strrchr-lsx will be compared with generic_strrchr
implemented by strlen-lsx and memrchr-lsx, strrchr-aligned will be
compared with generic_strrchr implemented by strlen-aligned and
memrchr-generic.
https://github.com/jiadengx/glibc_test/blob/main/bench/strrchr_lasx_compare.out
https://github.com/jiadengx/glibc_test/blob/main/bench/strrchr_lsx_compare.out
https://github.com/jiadengx/glibc_test/blob/main/bench/strrchr_aligned_compare.out
In the data, positive values in the parentheses indicate that our
implementation took less time, indicating a performance improvement;
negative values in the parentheses mean that our implementation took
more time, indicating a decrease in performance. Following is the
summarise of the performance comparing with the generic version in the
glibc microbenchmark,
name reduce time percent
strcpy-aligned 8%-45%
strcpy-unaligned 8%-48%, comparing with the aligned version,unaligned
version experience better performance in case src and
dest cannot be both aligned with 8bytes
strcpy-lsx 20%-80%
strcpy-lasx 15%-86%
stpcpy-lasx 10%-87%
stpcpy-lsx 10%-80%
stpcpy-aligned 6%-43%
stpcpy-unaligned 8%-48%
strrchr-lasx 10%-50%
strrchr-lsx 0%-50%
strrchr-aligned 5%-50%
dengjianbo (3):
LoongArch: Add ifunc support for strcpy, stpcpy{aligned, unaligned,
lsx, lasx}
LoongArch: Add ifunc support for strrchr{aligned, lsx, lasx}
LoongArch: Change to put magic number to .rodata section
sysdeps/loongarch/lp64/multiarch/Makefile | 11 +
.../lp64/multiarch/ifunc-impl-list.c | 26 +++
.../loongarch/lp64/multiarch/ifunc-strrchr.h | 41 ++++
.../loongarch/lp64/multiarch/memmove-lsx.S | 20 +-
.../loongarch/lp64/multiarch/stpcpy-aligned.S | 27 +++
.../loongarch/lp64/multiarch/stpcpy-lasx.S | 22 ++
sysdeps/loongarch/lp64/multiarch/stpcpy-lsx.S | 22 ++
.../lp64/multiarch/stpcpy-unaligned.S | 22 ++
sysdeps/loongarch/lp64/multiarch/stpcpy.c | 42 ++++
.../loongarch/lp64/multiarch/strcpy-aligned.S | 202 ++++++++++++++++
.../loongarch/lp64/multiarch/strcpy-lasx.S | 215 ++++++++++++++++++
sysdeps/loongarch/lp64/multiarch/strcpy-lsx.S | 212 +++++++++++++++++
.../lp64/multiarch/strcpy-unaligned.S | 138 +++++++++++
sysdeps/loongarch/lp64/multiarch/strcpy.c | 35 +++
.../lp64/multiarch/strrchr-aligned.S | 170 ++++++++++++++
.../loongarch/lp64/multiarch/strrchr-lasx.S | 176 ++++++++++++++
.../loongarch/lp64/multiarch/strrchr-lsx.S | 144 ++++++++++++
sysdeps/loongarch/lp64/multiarch/strrchr.c | 36 +++
18 files changed, 1551 insertions(+), 10 deletions(-)
create mode 100644 sysdeps/loongarch/lp64/multiarch/ifunc-strrchr.h
create mode 100644 sysdeps/loongarch/lp64/multiarch/stpcpy-aligned.S
create mode 100644 sysdeps/loongarch/lp64/multiarch/stpcpy-lasx.S
create mode 100644 sysdeps/loongarch/lp64/multiarch/stpcpy-lsx.S
create mode 100644 sysdeps/loongarch/lp64/multiarch/stpcpy-unaligned.S
create mode 100644 sysdeps/loongarch/lp64/multiarch/stpcpy.c
create mode 100644 sysdeps/loongarch/lp64/multiarch/strcpy-aligned.S
create mode 100644 sysdeps/loongarch/lp64/multiarch/strcpy-lasx.S
create mode 100644 sysdeps/loongarch/lp64/multiarch/strcpy-lsx.S
create mode 100644 sysdeps/loongarch/lp64/multiarch/strcpy-unaligned.S
create mode 100644 sysdeps/loongarch/lp64/multiarch/strcpy.c
create mode 100644 sysdeps/loongarch/lp64/multiarch/strrchr-aligned.S
create mode 100644 sysdeps/loongarch/lp64/multiarch/strrchr-lasx.S
create mode 100644 sysdeps/loongarch/lp64/multiarch/strrchr-lsx.S
create mode 100644 sysdeps/loongarch/lp64/multiarch/strrchr.c
--
2.40.0
next reply other threads:[~2023-09-13 7:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-13 7:34 dengjianbo [this message]
2023-09-13 7:34 ` [PATCH v2 1/3] LoongArch: Add ifunc support for strcpy, stpcpy{aligned, unaligned, lsx, lasx} dengjianbo
2023-09-13 7:35 ` [PATCH v2 2/3] LoongArch: Add ifunc support for strrchr{aligned, " dengjianbo
2023-09-13 7:35 ` [PATCH v2 3/3] LoongArch: Change to put magic number to .rodata section dengjianbo
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=20230913073501.1018239-1-dengjianbo@loongson.cn \
--to=dengjianbo@loongson.cn \
--cc=adhemerval.zanella@linaro.org \
--cc=caiyinyu@loongson.cn \
--cc=huangpei@loongson.cn \
--cc=libc-alpha@sourceware.org \
--cc=xry111@xry111.site \
--cc=xuchenghua@loongson.cn \
/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).