mbox series

[0/3] Add ifunc support for str{nlen, cmp, ncmp}

Message ID 20230822021118.3489949-1-dengjianbo@loongson.cn
Headers show
Series Add ifunc support for str{nlen, cmp, ncmp} | expand

Message

dengjianbo Aug. 22, 2023, 2:11 a.m. UTC
This patch add mutiple versions of strnlen, strcmp, strncmp implemented
by Loongarch basic instructions, LSX instructions, LASX instructions.
Even though this implementation experience performance degradation in
few cases, overall, the performace gains are significant.

See:
https://github.com/jiadengx/glibc_test/blob/main/bench/strnlen_compare.out
https://github.com/jiadengx/glibc_test/blob/main/bench/strcmp_compare.out
https://github.com/jiadengx/glibc_test/blob/main/bench/strncmp_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
strnlen-aligned       >10%
strnlen-lsx           50%-78%
strnlen-lasx          50%-88%
strcmp-aligned        0%-10% for aligned comparision
                      10%-20% for unaligned comparision
strcmp-lsx            0%-50%
strncmp-aligned       0%-10% for aligned comparision
                      10%-25% for unaligned comparision
strncmp-lsx           0%-50%

dengjianbo (3):
  Loongarch: Add ifunc support for strnlen{aligned, lsx, lasx}
  Loongarch: Add ifunc support for strcmp{aligned, lsx}
  Loongarch: Add ifunc support for strncmp{aligned, lsx}

 sysdeps/loongarch/lp64/multiarch/Makefile     |   7 +
 .../lp64/multiarch/ifunc-impl-list.c          |  22 ++
 .../loongarch/lp64/multiarch/ifunc-strcmp.h   |  38 +++
 .../loongarch/lp64/multiarch/ifunc-strncmp.h  |  38 +++
 .../loongarch/lp64/multiarch/ifunc-strnlen.h  |  41 ++++
 .../loongarch/lp64/multiarch/strcmp-aligned.S | 179 ++++++++++++++
 sysdeps/loongarch/lp64/multiarch/strcmp-lsx.S | 162 +++++++++++++
 sysdeps/loongarch/lp64/multiarch/strcmp.c     |  35 +++
 .../lp64/multiarch/strncmp-aligned.S          | 218 ++++++++++++++++++
 .../loongarch/lp64/multiarch/strncmp-lsx.S    | 206 +++++++++++++++++
 sysdeps/loongarch/lp64/multiarch/strncmp.c    |  35 +++
 .../lp64/multiarch/strnlen-aligned.S          | 102 ++++++++
 .../loongarch/lp64/multiarch/strnlen-lasx.S   | 100 ++++++++
 .../loongarch/lp64/multiarch/strnlen-lsx.S    |  89 +++++++
 sysdeps/loongarch/lp64/multiarch/strnlen.c    |  39 ++++
 15 files changed, 1311 insertions(+)
 create mode 100644 sysdeps/loongarch/lp64/multiarch/ifunc-strcmp.h
 create mode 100644 sysdeps/loongarch/lp64/multiarch/ifunc-strncmp.h
 create mode 100644 sysdeps/loongarch/lp64/multiarch/ifunc-strnlen.h
 create mode 100644 sysdeps/loongarch/lp64/multiarch/strcmp-aligned.S
 create mode 100644 sysdeps/loongarch/lp64/multiarch/strcmp-lsx.S
 create mode 100644 sysdeps/loongarch/lp64/multiarch/strcmp.c
 create mode 100644 sysdeps/loongarch/lp64/multiarch/strncmp-aligned.S
 create mode 100644 sysdeps/loongarch/lp64/multiarch/strncmp-lsx.S
 create mode 100644 sysdeps/loongarch/lp64/multiarch/strncmp.c
 create mode 100644 sysdeps/loongarch/lp64/multiarch/strnlen-aligned.S
 create mode 100644 sysdeps/loongarch/lp64/multiarch/strnlen-lasx.S
 create mode 100644 sysdeps/loongarch/lp64/multiarch/strnlen-lsx.S
 create mode 100644 sysdeps/loongarch/lp64/multiarch/strnlen.c