Page MenuHomeFreeBSD

libc: scalar memset() in RISC-V assembly
ClosedPublic

Authored by strajabot on Jun 25 2024, 2:24 PM.
Tags
None
Referenced Files
F138009072: D45730.id140244.diff
Fri, Nov 28, 2:47 AM
Unknown Object (File)
Thu, Nov 27, 4:35 PM
Unknown Object (File)
Mon, Nov 17, 8:06 AM
Unknown Object (File)
Fri, Nov 14, 7:20 AM
Unknown Object (File)
Tue, Nov 11, 8:32 PM
Unknown Object (File)
Thu, Oct 30, 2:17 PM
Unknown Object (File)
Oct 28 2025, 11:51 PM
Unknown Object (File)
Oct 26 2025, 12:59 AM
Subscribers

Details

Summary

Adds scalar implementation of memset for RISC-V
and updates the relevant manpage

os: FreeBSD
arch: riscv
        │ ./results/memset/memset_baseline │   ./results/memset/memset_scalar    │
        │              sec/op              │   sec/op     vs base                │
40                             527.5µ ± 1%   479.4µ ± 1%   -9.12% (p=0.000 n=20)
168                            254.5µ ± 1%   216.7µ ± 1%  -14.86% (p=0.000 n=20)
2k                             169.5µ ± 1%   128.4µ ± 0%  -24.24% (p=0.000 n=20)
256k                           161.2µ ± 1%   118.6µ ± 1%  -26.42% (p=0.000 n=20)
16m                            56.58m ± 0%   53.91m ± 0%   -4.72% (p=0.000 n=20)
geomean                        730.2µ        611.2µ       -16.29%
 
        │ ./results/memset/memset_baseline │    ./results/memset/memset_scalar     │
        │               B/s                │      B/s       vs base                │
40                            452.0Mi ± 1%    497.3Mi ± 1%  +10.04% (p=0.000 n=20)
168                           936.9Mi ± 1%   1100.4Mi ± 1%  +17.45% (p=0.000 n=20)
2k                            1.373Gi ± 1%    1.813Gi ± 0%  +32.00% (p=0.000 n=20)
256k                          1.444Gi ± 1%    1.962Gi ± 1%  +35.91% (p=0.000 n=20)
16m                           269.7Mi ± 0%    283.1Mi ± 0%   +4.96% (p=0.000 n=20)
geomean                       750.1Mi         896.1Mi       +19.47%
Test Plan

Tested using the provided test suite

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Add license, reformat comments

mhorne added a subscriber: mhorne.
mhorne added inline comments.
lib/libc/riscv/string/memset.S
31–33 ↗(On Diff #140244)
This revision is now accepted and ready to land.Jun 26 2024, 3:57 PM
lib/libc/riscv/string/memset.S
31–33 ↗(On Diff #140244)

Please note this open comment.

fuz requested changes to this revision.Aug 21 2025, 5:42 PM
fuz added inline comments.
lib/libc/riscv/string/memset.S
38 ↗(On Diff #140244)

This should be an unsigned comparison as buffer lengths are unsigned. Not that you can have a real buffer that long anyway...

This revision now requires changes to proceed.Aug 21 2025, 5:42 PM
  • fixup: slti -> sltiu and comments
This revision is now accepted and ready to land.Sep 22 2025, 9:27 PM