Skip to content

Improve the performance of RISC-V vector unit-stride/whole register ld/st instructions

Max Chou qemu-devel qemu-riscv 6 versions – Applied

Status from this message: Applied to riscv-to-apply.next

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest7 patches 10 repliesApplied
  2. v5 RFC5 patches 6 repliesSuperseded
  3. v4 RFC5 patches 9 repliesApplied
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v3 RFC5 patches1 replySuperseded
v2 RFC6 patches3 repliesSuperseded
v1 RFC6 patches12 repliesSuperseded

Changes in v6 from the cover letter · 17 lines

- patch 2
- Replace the VSTART_CHECK_EARLY_EXIT function by checking the correct evl in vext_ldst_us.
- patch 3
- Unroll the memory load/store loop
- Fix the bound checking issue in cross page elements
- Fix the endian issue in GEN_VEXT_LD_ELEM/GEN_VEXT_ST_ELEM
- Pass in mmu_index for vext_page_ldst_us
- Reduce the flag & host checking
- patch 4
- Unroll the memory load/store loop
- Fix the bound checking issue in cross page elements
- patch 5
- Extend optimizations to unmasked vector fault-only-first load instruction
- patch 6
- Switch to memcpy only when doing byte load/store
- patch 7
- Inline the vext_page_ldst_us function

Patches in v6 Applied

#Subject and filesSizeRepliesApplied
1/7target/riscv: Set vdata.vm field for vector load/store whole register instructionstarget/riscv/insn_trans/trans_rvv.c.inc+3 -02 replies
2/7target/riscv: rvv: Replace VSTART_CHECK_EARLY_EXIT in vext_ldst_ustarget/riscv/vector_helper.c+4 -11 reply
3/7target/riscv: rvv: Provide a fast path using direct access to host ram for unmasked unit-stride load/storetarget/riscv/vector_helper.c+224 -1391 reply
4/7target/riscv: rvv: Provide a fast path using direct access to host ram for unit-stride whole register load/storetarget/riscv/vector_helper.c+70 -591 reply
5/7target/riscv: rvv: Provide a fast path using direct access to host ram for unit-stride load-only-first load instructionstarget/riscv/vector_helper.c+71 -271 reply
6/7target/riscv: rvv: Provide group continuous ld/st flow for unit-stride ld/st instructionstarget/riscv/vector_helper.c+63 -141 reply
7/7target/riscv: Inline unit-stride ld/st and corresponding functions for performancetarget/riscv/vector_helper.c+11 -71 reply

Reviews trailers per patch

All 7 patches have a Reviewed-by or Acked-by.

PatchRichard HendersonDaniel Henrique Barboza
1/7R-b
2/7R-b
3/7R-b
4/7R-b
5/7R-b
6/7R-b
7/7R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v6 thread

Cover letter [PATCH v6 0/7] Improve the performance of RISC-V vector unit-stride/whole register ld/st instructions

Hi,

This version fixes several issues in v5
- The cross page bound checking issue
- The mismatch vl comparison in the early exit checking of vext_ldst_us
- The endian issue when host is big endian

Thank for Richard Henderson's suggestions that this version unrolled the loop in helper functions of unmasked vector unit-stride load/store instructions, etc.

And this version also extends the optimizations to the unmasked vector fault-only-first load instruction.

Some performance result of this version
1. Test case provided in
https://gitlab.com/qemu-project/qemu/-/issues/2137#note_1757501369
- QEMU user mode (vlen=128):
- Original: ~11.8 sec
- v5: ~1.3 sec
- v6: ~1.2 sec
- QEMU system mode (vlen=128):
- Original: ~29.4 sec
- v5: ~1.6 sec
- v6: ~1.6 sec
2. SPEC CPU2006 INT (test input)
- QEMU user mode (vlen=128)
- Original: ~459.1 sec
- v5: ~300.0 sec
- v6: ~280.6 sec
3. SPEC CPU2017 intspeed (test input)
- QEMU user mode (vlen=128)
- Original: ~2475.9 sec
- v5: ~1702.6 sec
- v6: ~1663.4 sec

This version is based on the riscv-to-apply.next branch(commit 90d5d3c).

Changes from v5:
- patch 2
- Replace the VSTART_CHECK_EARLY_EXIT function by checking the correct evl in vext_ldst_us.
- patch 3
- Unroll the memory load/store loop
- Fix the bound checking issue in cross page elements
- Fix the endian issue in GEN_VEXT_LD_ELEM/GEN_VEXT_ST_ELEM
- Pass in mmu_index for vext_page_ldst_us
- Reduce the flag & host checking
- patch 4
- Unroll the memory load/store loop
- Fix the bound checking issue in cross page elements
- patch 5
- Extend optimizations to unmasked vector fault-only-first load instruction
- patch 6
- Switch to memcpy only when doing byte load/store
- patch 7
- Inline the vext_page_ldst_us function

Previous versions:
- v1: https://lore.kernel.org/all/[email protected]/
- v2: https://lore.kernel.org/all/[email protected]/
- v3: https://lore.kernel.org/all/[email protected]/
- v4: https://lore.kernel.org/all/[email protected]/
- v5: https://lore.kernel.org/all/[email protected]/

Max Chou (7):
target/riscv: Set vdata.vm field for vector load/store whole register
instructions
target/riscv: rvv: Replace VSTART_CHECK_EARLY_EXIT in vext_ldst_us target/riscv: rvv: Provide a fast path using direct access to host ram
for unmasked unit-stride load/store
target/riscv: rvv: Provide a fast path using direct access to host ram
for unit-stride whole register load/store
target/riscv: rvv: Provide a fast path using direct access to host ram
for unit-stride load-only-first load instructions
target/riscv: rvv: Provide group continuous ld/st flow for unit-stride
ld/st instructions
target/riscv: Inline unit-stride ld/st and corresponding functions for
performance

 target/riscv/insn_trans/trans_rvv.c.inc |   3 +
 target/riscv/vector_helper.c            | 598 ++++++++++++++++--------
 2 files changed, 400 insertions(+), 201 deletions(-)
Signature · 1 line
2.34.1