Merge pull request #68209 from sunyuechi/riscv-bench-crc

test/common: add RISC-V CRC32C performance benchmark to unittest_crc32c

Reviewed-by: Kefu Chai <k.chai@proxmox.com>
This commit is contained in:
Kefu Chai 2026-07-28 09:40:42 +08:00 committed by GitHub
commit 6f4345554d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 0 deletions

View File

@ -10,6 +10,8 @@
#define CEPH_COMMON_CRC32C_RISCV_H
#include <stdint.h>
#include "acconfig.h"
#include "arch/riscv.h"
#ifdef __cplusplus
extern "C" {

View File

@ -14,6 +14,7 @@
#include "common/sctp_crc32.h"
#include "common/crc32c_intel_baseline.h"
#include "common/crc32c_aarch64.h"
#include "common/crc32c_riscv.h"
TEST(Crc32c, Small) {
const char *a = "foo bar baz";
@ -94,6 +95,17 @@ TEST(Crc32c, Performance) {
std::cout << "aarch64 = " << rate << " MB/sec" << std::endl;
ASSERT_EQ(261108528u, val);
}
#endif
#if defined(__riscv) && defined(HAVE_RISCV_ZVBC)
if (ceph_arch_riscv_zbc && ceph_arch_riscv_zvbc)
{
utime_t start = ceph_clock_now();
unsigned val = ceph_crc32c_riscv(0, (unsigned char *)a, len);
utime_t end = ceph_clock_now();
float rate = (float)len / (float)(1024*1024) / (float)(end - start);
std::cout << "riscv = " << rate << " MB/sec" << std::endl;
ASSERT_EQ(261108528u, val);
}
#endif
free(a);
}