You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nudt-compiler-cpp/count_asm.sh

61 lines
2.1 KiB

#!/bin/bash
cd /home/vega/compile/compiler/nudt-compiler-cpp
COMPILER=./build/bin/compiler
TESTS=(
"huffman-01" "huffman-02" "huffman-03"
"many_mat_cal-1" "many_mat_cal-2" "many_mat_cal-3"
"h-1-01" "h-1-02" "h-1-03"
"fft0" "fft1" "fft2"
"matmul1" "matmul2" "matmul3"
"conv2d-1" "conv2d-2" "conv2d-3"
"shuffle0" "shuffle1" "shuffle2"
"sl1" "sl2" "sl3"
"crypto-1" "crypto-2" "crypto-3"
"crc1" "crc2" "crc3"
"h-4-01" "h-4-02" "h-4-03"
"h-5-01" "h-5-02" "h-5-03"
"h-8-01" "h-8-02" "h-8-03"
"h-9-01" "h-9-02" "h-9-03"
"h-10-01" "h-10-02" "h-10-03"
"knapsack_naive-1" "knapsack_naive-2" "knapsack_naive-3"
"optimization_scheduling1" "optimization_scheduling2" "optimization_scheduling3"
"transpose0" "transpose1" "transpose2"
"03_sort1" "03_sort2" "03_sort3"
"01_mm1" "01_mm2" "01_mm3"
)
BASELINE_FILE="./指令数基线.md"
UPDATED=0
echo "=== 指令数测试 ==="
for t in "${TESTS[@]}"; do
$COMPILER -S -O -o /tmp/count_tmp.s 2026test/performance/${t}.sy 2>/dev/null
lines=$(wc -l < /tmp/count_tmp.s 2>/dev/null)
lines=${lines:-0}
# 读取基线值
baseline=$(grep "performance/${t}" "$BASELINE_FILE" 2>/dev/null | grep -oP '\|\s*\d+\s*\|' | head -1 | grep -oP '\d+')
if [[ -n "$baseline" ]] && [[ "$baseline" =~ ^[0-9]+$ ]]; then
if [[ "$lines" -lt "$baseline" ]]; then
diff=$((baseline - lines))
echo "performance/${t}: ${lines} (基线:${baseline} 减少${diff}行) ← 更新基线"
# 更新基线文件中的"当前"列(匹配任意当前值)
sed -i "s/| performance\/${t} | ${baseline} | [0-9]* |/| performance\/${t} | ${baseline} | ${lines} | 比源基线少${diff}行 |/" "$BASELINE_FILE"
UPDATED=$((UPDATED + 1))
elif [[ "$lines" -gt "$baseline" ]]; then
diff=$((lines - baseline))
echo "performance/${t}: ${lines} (基线:${baseline} 增加${diff}行)"
else
echo "performance/${t}: ${lines} (基线:${baseline} 持平)"
fi
else
echo "performance/${t}: ${lines}"
fi
done
rm -f /tmp/count_tmp.s
if [[ $UPDATED -gt 0 ]]; then
echo ""
echo "已更新 ${UPDATED} 个测试集的指令数基线"
fi