Skip to content

Commit 2953c7d

Browse files
Add OMATCOPY_CT performance test with RVV optimization
- Created comprehensive performance test for omatcopy_ct function - Added RVV vectorized implementation with conditional compilation - Included build script for SG2044 server testing - Support both scalar and RVV optimized versions - Added throughput measurement and detailed performance metrics Co-authored-by: gong-flying <gongxiaofei24@iscas.ac.cn>
1 parent 2a95564 commit 2953c7d

File tree

2 files changed

+402
-0
lines changed

2 files changed

+402
-0
lines changed

build_and_test.sh

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/bin/bash
2+
3+
# OMATCOPY_CT 性能测试编译脚本
4+
# 适用于 SG2044 服务器
5+
6+
echo "=== OMATCOPY_CT 性能测试编译脚本 ==="
7+
echo "适用于 SG2044 RISC-V 服务器"
8+
echo
9+
10+
# 检查编译器
11+
if ! command -v gcc &> /dev/null; then
12+
echo "错误: 未找到 GCC 编译器"
13+
exit 1
14+
fi
15+
16+
# 显示 GCC 版本
17+
echo "GCC 版本:"
18+
gcc --version | head -1
19+
echo
20+
21+
# 编译标准版本(无RVV)
22+
echo "[1/3] 编译标准版本(标量优化)..."
23+
gcc -O3 -march=rv64gc test_omatcopy_ct.c -lm -o test_omatcopy_ct_scalar
24+
if [ $? -eq 0 ]; then
25+
echo "✓ 标准版本编译成功: test_omatcopy_ct_scalar"
26+
else
27+
echo "✗ 标准版本编译失败"
28+
exit 1
29+
fi
30+
31+
# 编译RVV版本
32+
echo "[2/3] 编译RVV优化版本..."
33+
gcc -O3 -march=rv64gcv -DUSE_RVV test_omatcopy_ct.c -lm -o test_omatcopy_ct_rvv
34+
if [ $? -eq 0 ]; then
35+
echo "✓ RVV版本编译成功: test_omatcopy_ct_rvv"
36+
else
37+
echo "⚠ RVV版本编译失败(可能不支持RVV扩展)"
38+
echo " 将只运行标量版本测试"
39+
fi
40+
41+
echo
42+
echo "[3/3] 编译完成!"
43+
echo
44+
45+
# 检查CPU信息
46+
echo "=== CPU 信息 ==="
47+
if [ -f /proc/cpuinfo ]; then
48+
echo "CPU型号:"
49+
grep "model name" /proc/cpuinfo | head -1 | cut -d: -f2 | xargs
50+
echo "CPU核心数: $(nproc)"
51+
52+
# 检查RVV支持
53+
if grep -q "v" /proc/cpuinfo; then
54+
echo "✓ 检测到向量扩展支持"
55+
else
56+
echo "⚠ 未检测到向量扩展支持"
57+
fi
58+
fi
59+
echo
60+
61+
# 运行测试
62+
echo "=== 开始性能测试 ==="
63+
echo
64+
65+
if [ -f "test_omatcopy_ct_rvv" ]; then
66+
echo "运行 RVV 优化版本测试:"
67+
echo "----------------------------------------"
68+
./test_omatcopy_ct_rvv
69+
echo
70+
fi
71+
72+
echo "运行标量版本测试:"
73+
echo "----------------------------------------"
74+
./test_omatcopy_ct_scalar
75+
76+
echo
77+
echo "=== 测试完成 ==="
78+
echo "文件说明:"
79+
echo " test_omatcopy_ct_scalar - 标量优化版本"
80+
if [ -f "test_omatcopy_ct_rvv" ]; then
81+
echo " test_omatcopy_ct_rvv - RVV向量化版本"
82+
fi
83+
echo " test_omatcopy_ct.c - 源代码文件"
84+
echo " build_and_test.sh - 本编译脚本"

0 commit comments

Comments
 (0)