]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test/common: add RISC-V CRC32C performance benchmark to unittest_crc32c 68209/head
authorSun Yuechi <sunyuechi@iscas.ac.cn>
Sat, 4 Apr 2026 02:39:19 +0000 (10:39 +0800)
committerSun Yuechi <sunyuechi@iscas.ac.cn>
Wed, 1 Jul 2026 13:38:27 +0000 (21:38 +0800)
Signed-off-by: Yuechi Sun <sunyuechi@gmail.com>
src/common/crc32c_riscv.h
src/test/common/test_crc32c.cc

index a4e506ef5dca136bb40ae3bd262cd9dc62ad4368..6f8864761d5a07ea7f342005b81e8c2cb083d69d 100644 (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" {
index 08a934fc19e4b756db0dac62cfa65896533fb0f7..92882deb3c2ef3f50efb12ce6fd2f0073bb5bd9b 100644 (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);
 }