From: Pincheng Wang <pincheng.plct@isrc.iscas.ac.cn>
To: musl@lists.openwall.com
Cc: pincheng.plct@isrc.iscas.ac.cn
Subject: [musl] [PATCH 0/1] riscv64: Add RVV optimized memset implementation
Date: Thu, 25 Sep 2025 21:15:56 +0800 [thread overview]
Message-ID: <20250925131557.8907-1-pincheng.plct@isrc.iscas.ac.cn> (raw)
Hi all,
This patch introduces a RISC-V Vector (RVV) optimized implementation of
memset.
Key points:
- Use RVV instructions to fill memory in bulk, with a small-size
head-tail fast path to reduce vsetvli overhead.
- Fall back to a scalar head-tail implementation (like generic C
implementation) when RVV is not available.
- Reduce both instruction count and code size: memset.o shrinks by about
16.5% compared to the generic C build.
Performance results on RVV-capable hardware show clear improvements:
- On Spacemit X60: up to ~3.1x faster (256B), with consistent gains
across medium and large sizes.
- On XuanTie C908: up to ~2.1x faster (128B), with modest gains for
larger sizes.
For very small sizes (<8 Bytes), there can be regressions compared to
the generic C version. A more aggresive fast path could remove these
regressions, but at the cost of added code complexity. Feedback on this
trade-off is welcome.
The implementation was tested under QEMU with RVV enabled and on real
hardware. Functional behavior matches the generic memset, with no
changes to the public interface.
Thanks,
Pincheng Wang
Pincheng Wang (1):
riscv64: optimize memset implementation with vector extension
src/string/riscv64/memset.S | 101 ++++++++++++++++++++++++++++++++++++
1 file changed, 101 insertions(+)
create mode 100644 src/string/riscv64/memset.S
--
2.39.5
next reply other threads:[~2025-09-25 13:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-25 13:15 Pincheng Wang [this message]
2025-09-25 13:15 ` [musl] [PATCH 1/1] riscv64: optimize memset implementation with vector extension Pincheng Wang
2025-09-25 15:30 ` Yao Zi
2025-09-26 0:31 ` Pincheng Wang
2025-09-26 3:37 ` Markus Wichmann
2025-09-26 11:21 ` Pincheng Wang
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=20250925131557.8907-1-pincheng.plct@isrc.iscas.ac.cn \
--to=pincheng.plct@isrc.iscas.ac.cn \
--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).