Page MenuHomeFreeBSD

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

Authored by strajabot on Jun 25 2024, 2:24 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Oct 30, 2:17 PM
Unknown Object (File)
Tue, Oct 28, 11:51 PM
Unknown Object (File)
Sun, Oct 26, 12:59 AM
Unknown Object (File)
Fri, Oct 24, 4:51 PM
Unknown Object (File)
Wed, Oct 22, 12:18 AM
Unknown Object (File)
Tue, Oct 14, 11:45 AM
Unknown Object (File)
Sun, Oct 12, 7:19 PM
Unknown Object (File)
Sun, Oct 12, 3: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