#!/bin/bash
set -e
OPERATOR_DIR="${1:?Error: operator_dir is required}"
BATCH_SIZE="${2:-128}"
NUM_CLASS="${3:-1024}"
cd "$OPERATOR_DIR"
echo "===== 步骤 1:清理旧的 msprof 输出 ====="
rm -rf OPPROF_*
echo "===== 步骤 2:编译仿真版本 ====="
bash compile_simulator.sh "$BATCH_SIZE" "$NUM_CLASS"
echo ""
echo "===== 步骤 3:执行 msprof op simulator 仿真性能采集 ====="
echo "命令:msprof op simulator --soc-version=Ascend910B1 ./run.fatbin $BATCH_SIZE $NUM_CLASS"
msprof op simulator --soc-version=Ascend910B1 ./run.fatbin "$BATCH_SIZE" "$NUM_CLASS"
echo ""
echo "===== 步骤 4:查找生成的性能数据目录 ====="
PROFILE_DIR=$(ls -d OPPROF_* 2>/dev/null | head -1)
if [ -n "$PROFILE_DIR" ]; then
echo "性能数据目录:$OPERATOR_DIR/$PROFILE_DIR"
echo "关键文件列表:"
ls "$PROFILE_DIR"/
else
echo "错误:未找到 OPPROF_* 目录,性能采集可能失败"
exit 1
fi