iobuf: add RISC-V Vector (RVV) optimized memcpy for cp()#3375
Open
Felix-Gong wants to merge 1 commit into
Open
iobuf: add RISC-V Vector (RVV) optimized memcpy for cp()#3375Felix-Gong wants to merge 1 commit into
Felix-Gong wants to merge 1 commit into
Conversation
Add a RVV-accelerated cp() path for RISC-V 64-bit systems with the Vector (RVV) extension. Uses VL-agnostic intrinsics with LMUL=8 (e8m8) for maximum vector width. Key design: - Falls back to memcpy for < 64 bytes (RVV overhead threshold) - VL-agnostic: works with any VLEN (128/256/512/1024+) - Uses __has_include for compiler compatibility - Guarded by __riscv && __riscv_vector && header availability On SG2044 (rv64gcv, VLEN=128): vectorized copy processes 128 bytes per iteration with e8m8 LMUL. Other platforms and compilers without riscv_vector.h fall back to the existing memcpy path. Signed-off-by: Xiaofei Gong <gongxiaofei24@iscas.ac.cn> Signed-off-by: YuanSheng <yuansheng@isrc.iscas.ac.cn>
Contributor
Author
Benchmark Results — SG2044 (rv64gcv, VLEN=128, Clang 17, -O2 -march=rv64gcv)Measured on SOPHGO SG2044 RISC-V 64-bit hardware with PR #3375 changes compiled using Clang 17 + glibc 2.38. Each data point is the median of 5 runs with 64-byte aligned buffers.
Analysis
Compiler CompatibilityThe implementation uses |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add a RVV-accelerated
cp()path for RISC-V 64-bit systems with the Vector (RVV) extension.The
cp()function is the internal memcpy wrapper used throughout IOBuf for all buffer copy operations — optimizing it benefits append, cut, push_back, and all other IOBuf data movement.Implementation
__has_include(<riscv_vector.h>)for broad compiler compatibility__riscvand__riscv_vectorVerification
vsetvli,vle8.v,vse8.vin the object file