Skip to content

update benchmark and errors #172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions test/test_script_audioprocessing.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash

export BUDDY_MLIR_BUILD_DIR=/home/buddy-complier-workspace/buddy-mlir/build
export LLVM_MLIR_BUILD_DIR=/home/buddy-complier-workspace/buddy-mlir/llvm/build
cd /home/buddy-complier-workspace/buddy-benchmark
mkdir -p build && cd build
cmake -G Ninja .. \
-DCMAKE_BUILD_TYPE=RELEASE \
-DAUDIO_PROCESSING_BENCHMARKS=ON \
-DCMAKE_CXX_COMPILER=${LLVM_MLIR_BUILD_DIR}/bin/clang++ \
-DKFR_DIR=/home/buddy-complier-workspace/buddy-benchmark/thirdparty/kfr \
-DBUDDY_MLIR_BUILD_DIR=${BUDDY_MLIR_BUILD_DIR}
ninja dap-op-iir-benchmark
cd bin
./dap-op-iir-benchmark



cmake -G Ninja .. \
-DCMAKE_BUILD_TYPE=RELEASE \
-DAUDIO_PROCESSING_BENCHMARKS=ON \
-DCMAKE_CXX_COMPILER=${LLVM_MLIR_BUILD_DIR}/bin/clang++ \
-DKFR_DIR=/home/buddy-complier-workspace/buddy-benchmark/thirdparty/kfr \
-DBUDDY_MLIR_BUILD_DIR=${BUDDY_MLIR_BUILD_DIR} \
-DPYTHON_BINARY_DIR="$(dirname "$(which python3)")"

ninja audio-plot
cd bin
./audio-plot ../../benchmarks/AudioProcessing/Audios/NASA_Mars.wav ResultKFRIir.wav
# "
# root@4f445bb41579:/home/buddy-complier-workspace/buddy-benchmark/build/bin# ./audio-plot ../../benchmarks/AudioProcessing/Audios/NASA_Mars.wav ResultKFRIir.wav
# Plotting now...
# Traceback (most recent call last):
# File "/home/buddy-complier-workspace/buddy-benchmark/utils/plots/python/plot.py", line 71, in <module>
# compare_wave(args.file1, args.file2, part=args.part,
# File "/home/buddy-complier-workspace/buddy-benchmark/utils/plots/python/plotools/compare.py", line 120, in compare_wave
# after, time2 = get_time_domain(file2)
# File "/home/buddy-complier-workspace/buddy-benchmark/utils/plots/python/plotools/compare.py", line 60, in get_time_domain
# info, samples = get_info_and_samples(file)
# File "/home/buddy-complier-workspace/buddy-benchmark/utils/plots/python/plotools/compare.py", line 38, in get_info_and_samples
# with wave.open(file, 'rb') as audio:
# File "/usr/lib/python3.10/wave.py", line 509, in open
# return Wave_read(f)
# File "/usr/lib/python3.10/wave.py", line 159, in __init__
# f = builtins.open(f, 'rb')
# FileNotFoundError: [Errno 2] No such file or directory: 'ResultKFRIir.wav'
# "
221 changes: 221 additions & 0 deletions test/test_script_deeplearning.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
#!/usr/bin/env bash

################################################################################
# 0. Script Setup
################################################################################
# We disable "exit on error" so that if one benchmark fails to build or run,
# we can continue with the rest.
set +e

################################################################################
# 1. (Optional) Activate Python/Conda Environment
################################################################################
# Uncomment or adjust if you use Anaconda/Miniconda:
# conda activate <YOUR-CONDA-ENV-NAME>


################################################################################
# 2. Build Each Benchmark (Continue Even If One Fails)
################################################################################
BENCHMARK_TARGETS=(
# ------------------
# Model-Level
# ------------------
"dl-model-tinyllama-benchmark"
"dl-model-mobilenetv3-benchmark"
"dl-model-lenet-benchmark"
"dl-model-bert-benchmark"
"dl-model-whisper-benchmark"
"dl-model-resnet18-benchmark"

# ------------------
# Layer-Level
# ------------------
"dl-layer-ffn-benchmark"
"dl-layer-selfattention-benchmark"
"dl-layer-rmsnorm-benchmark"

# ------------------
# Operation-Level
# ------------------
"dl-op-linalg-matmul-benchmark"
"dl-op-linalg-conv2d-nchw-fchw-benchmark"
"dl-op-linalg-conv2d-nhwc-hwcf-benchmark"
"dl-op-linalg-conv2d-nhwc-fhwc-benchmark"
"dl-op-linalg-depthwise-conv-2d-nhwc-hwc-benchmark"
"dl-op-linalg-pooling-nhwc-sum-benchmark"
"dl-op-linalg-batch-matmul-benchmark"
"dl-op-linalg-arithaddf-benchmark"
"dl-op-linalg-arithdivf-benchmark"
"dl-op-linalg-arithmulf-benchmark"
"dl-op-linalg-arithnegf-benchmark"
"dl-op-linalg-arithsubf-benchmark"
"dl-op-linalg-mathfpow-benchmark"
"dl-op-linalg-mathrsqrt-benchmark"
"dl-op-linalg-mathexp-benchmark"
"dl-op-linalg-reduceaddf-benchmark"
"dl-op-linalg-reducemaxf-benchmark"
"dl-op-linalg-softmax-exp-sum-div-benchmark"
"dl-op-tosa-transpose-benchmark"
"dl-op-matmul-transpose-b-benchmark"
)


################################################################################
# 3. Set Environment Variables for Buddy MLIR/LLVM
################################################################################
# Adjust these paths according to your local setup:
BUDDY_MLIR_DIR="/home/buddy-complier-workspace/buddy-mlir" # The root directory of buddy-mlir
LLVM_BUILD_DIR="$BUDDY_MLIR_DIR/llvm/build" # The build dir for LLVM
BUDDY_BUILD_DIR="$BUDDY_MLIR_DIR/build" # The build dir for buddy-mlir

# Export environment variables:
export BUDDY_MLIR_BUILD_DIR="$BUDDY_BUILD_DIR"
export LLVM_MLIR_BUILD_DIR="$LLVM_BUILD_DIR"
export PYTHONPATH="${LLVM_BUILD_DIR}/tools/mlir/python_packages/mlir_core:${BUDDY_BUILD_DIR}/python_packages:${PYTHONPATH}"
export BENCHMARK_PATH="${BUDDY_MLIR_DIR}/../buddy-benchmark"
echo "[Info] BUDDY_MLIR_BUILD_DIR = ${BUDDY_MLIR_BUILD_DIR}"
echo "[Info] LLVM_MLIR_BUILD_DIR = ${LLVM_MLIR_BUILD_DIR}"
echo "[Info] PYTHONPATH = ${PYTHONPATH}"

################################################################################
# 3. Prepare Build Folder and Run CMake
################################################################################
cd "${BUDDY_MLIR_DIR}/../buddy-benchmark" || exit 1
mkdir -p build
cd build || exit 1

echo "[Info] Running CMake configuration..."
cmake -G Ninja .. \
-DDEEP_LEARNING_BENCHMARKS=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DBUDDY_MLIR_BUILD_DIR="${BUDDY_MLIR_BUILD_DIR}" \
-DCMAKE_CXX_COMPILER="${LLVM_MLIR_BUILD_DIR}/bin/clang++" \
-DCMAKE_C_COMPILER="${LLVM_MLIR_BUILD_DIR}/bin/clang" \
-DCMAKE_CXX_FLAGS="-march=native" \
-DCMAKE_C_FLAGS="-march=native"


################################################################################
# 4. Prepare Build Folder and Run CMake
################################################################################

mkdir -p $BENCHMARK_PATH/test_result
mkdir -p $BENCHMARK_PATH/test_result/deeplearning
BUILD_LOG="${BENCHMARK_PATH}/test_result/deeplearning/build_results_summary.log"
> "${BUILD_LOG}" # Clear/create the file

echo "[Info] Building all benchmarks with Ninja..."
for target in "${BENCHMARK_TARGETS[@]}"; do
echo "==> ninja ${target}"
if ninja "${target}"; then
echo "[Success] Build of '${target}'" | tee -a "${BUILD_LOG}"
else
echo "[Failed] Build of '${target}'" | tee -a "${BUILD_LOG}"
fi
done

################################################################################
# 5. Run Each Benchmark & Redirect Output (Continue Even If One Fails)
################################################################################
cd bin || exit 1

RUN_LOG="${BENCHMARK_PATH}/test_result/deeplearning/run_results_summary.log"
> "${RUN_LOG}" # Clear/create the file

echo "[Info] Running all benchmarks in ./bin..."
for target in "${BENCHMARK_TARGETS[@]}"; do
if [ -f "${target}" ]; then
echo "==> Running ${target}"
if "./${target}" > "${BENCHMARK_PATH}/test_result/deeplearning/${target}.log" 2>&1; then
echo "[Success] Run of '${target}'" | tee -a "${RUN_LOG}"
echo " Output saved to test_result/deeplearning/${target}.log"
else
echo "[Failed] Run of '${target}'" | tee -a "${RUN_LOG}"
echo " Output saved to test_result/deeplearning/${target}.log (May contain error info)"
fi
else
echo "[Missing] Executable not found for '${target}'" | tee -a "${RUN_LOG}"
fi
done


################################################################################
# 6. Set Environment Variables for Buddy MLIR/LLVM for cross-compile
################################################################################
# Adjust these paths according to your local setup:
BUDDY_MLIR_DIR="/home/buddy-complier-workspace/buddy-mlir" # The root directory of buddy-mlir
LLVM_BUILD_DIR="$BUDDY_MLIR_DIR/llvm/build" # The build dir for LLVM
BUDDY_BUILD_DIR="$BUDDY_MLIR_DIR/build" # The build dir for buddy-mlir

# Export environment variables:
export BUDDY_MLIR_BUILD_DIR="$BUDDY_BUILD_DIR"
export LLVM_MLIR_BUILD_DIR="$LLVM_BUILD_DIR"
export PYTHONPATH="${LLVM_BUILD_DIR}/tools/mlir/python_packages/mlir_core:${BUDDY_BUILD_DIR}/python_packages:${PYTHONPATH}"
export BUDDY_MLIR_BUILD_CROSS_DIR=${BUDDY_MLIR_BUILD_DIR}/../build
export RISCV_GNU_TOOLCHAIN=${BUDDY_MLIR_BUILD_DIR}/../thirdparty/riscv-gnu-toolchain
export RISCV_OMP_SHARED=${LLVM_MLIR_BUILD_DIR}/../build/lib/libomp.so
export BENCHMARK_PATH="${BUDDY_MLIR_DIR}/../buddy-benchmark"

echo "[Info] BUDDY_MLIR_BUILD_DIR = ${BUDDY_MLIR_BUILD_DIR}"
echo "[Info] LLVM_MLIR_BUILD_DIR = ${LLVM_MLIR_BUILD_DIR}"
echo "[Info] PYTHONPATH = ${PYTHONPATH}"

################################################################################
# 7. Prepare Build Folder and Run CMake
################################################################################
cd "${BUDDY_MLIR_DIR}/../buddy-benchmark" || exit 1
mkdir -p build
cd build || exit 1

echo "[Info] Running CMake configuration..."
cmake -G Ninja .. \
-DDEEP_LEARNING_BENCHMARKS=ON \
-DCMAKE_BUILD_TYPE=RELEASE \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCROSS_COMPILE_RVV=ON \
-DCMAKE_SYSTEM_NAME=Linux \
-DCMAKE_SYSTEM_PROCESSOR=riscv \
-DCMAKE_C_COMPILER=${LLVM_MLIR_BUILD_DIR}/bin/clang \
-DRISCV_GNU_TOOLCHAIN=${RISCV_GNU_TOOLCHAIN} \
-DCMAKE_CXX_COMPILER=${LLVM_MLIR_BUILD_DIR}/bin/clang++ \
-DCMAKE_C_FLAGS="-march=rv64gcv --target=riscv64-unknown-linux-gnu --sysroot=${RISCV_GNU_TOOLCHAIN}/sysroot --gcc-toolchain=${RISCV_GNU_TOOLCHAIN} -fPIC" \
-DCMAKE_CXX_FLAGS="-march=rv64gcv --target=riscv64-unknown-linux-gnu --sysroot=${RISCV_GNU_TOOLCHAIN}/sysroot --gcc-toolchain=${RISCV_GNU_TOOLCHAIN} -fPIC" \
-DRISCV_OMP_SHARED=${RISCV_OMP_SHARED} \
-DBUDDY_MLIR_BUILD_DIR=${BUDDY_MLIR_BUILD_DIR} \
-DBUDDY_MLIR_BUILD_CROSS_DIR=${BUDDY_MLIR_BUILD_CROSS_DIR} \
-DBUDDY_MLIR_CROSS_LIB_DIR=${BUDDY_MLIR_BUILD_CROSS_DIR}/lib

################################################################################
# 8. Prepare Build Folder and Run CMake for cross-compile
################################################################################

mkdir -p $BENCHMARK_PATH/test_result
BUILD_LOG="${BENCHMARK_PATH}/test_result/deeplearning/build_results_crosscompile_summary.log"
> "${BUILD_LOG}" # Clear/create the file

echo "[Info] Building all benchmarks with Ninja..."
for target in "${BENCHMARK_TARGETS[@]}"; do
echo "==> ninja ${target}"
if ninja "${target}"; then
echo "[Success] Build of '${target}'" | tee -a "${BUILD_LOG}"
else
echo "[Failed] Build of '${target}'" | tee -a "${BUILD_LOG}"
fi
done


echo
echo "[Info] All build/run steps completed (script did not stop on failures)."
echo "[Info] Build summary: ${BUILD_LOG}"
echo "[Info] Run summary: ${RUN_LOG}"


cmake -G Ninja .. \
-DMLIR_DIR=$PWD/../llvm/build/lib/cmake/mlir \
-DLLVM_DIR=$PWD/../llvm/build/lib/cmake/llvm \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCMAKE_BUILD_TYPE=RELEASE \
-DBUDDY_MLIR_ENABLE_PYTHON_PACKAGES=ON \
-DPython3_EXECUTABLE=$(which python3)
97 changes: 97 additions & 0 deletions test/test_script_geminiprocessing.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/usr/bin/env bash

export BUDDY_MLIR_BUILD_DIR=/home/buddy-complier-workspace/buddy-mlir/build
export LLVM_MLIR_BUILD_DIR=/home/buddy-complier-workspace/buddy-mlir/llvm/build
export CHIPYARD_DIR=/home/buddy-complier-workspace/chipyard
export BUDDY_BENCHMARK_DIR=/home/buddy-complier-workspace/buddy-benchmark

cd "${CHIPYARD_DIR}"
git config --global --add safe.directory /home/buddy-complier-workspace/chipyard
git checkout 1.8.1

# Initialize and update the 'generators/gemmini' submodule and any submodules inside it.
git config --global --add safe.directory /home/buddy-complier-workspace/chipyard/generators/gemmini
git submodule update --init --recursive generators/gemmini

#############################################
# 1. Initialize Conda for the current shell
#############################################
conda init bash # or "conda init" if you’re already in a bash shell

#############################################
# 2. Check if 'chipyard' environment exists
#############################################
if conda env list | grep -qE '^[^ ]*\s+chipyard\s'; then
echo "[INFO] Found existing 'chipyard' environment. Activating it."
else
echo "[INFO] 'chipyard' environment not found. Creating it..."
# Example creation command - adjust packages as needed
conda create -y -n chipyard python=3.10 \
cmake ninja \
# plus any other dependencies needed...
fi

conda activate chipyard

#############################################
# 3. Source build-setup and env.sh
#############################################
# If your script uses conda-lock or has pinned requirements,
# you might need to call build-setup.sh so it *creates* the
# .conda-env environment. But be sure it doesn’t conflict
# with your newly created 'chipyard' environment.
source build-setup.sh esp-tools
source env.sh

#############################################
# 4. Proceed with your build
#############################################
cd "${BUDDY_BENCHMARK_DIR}"
rm -rf build
# Remove any existing build directory and create a fresh one.
mkdir -p build && cd build

RESULT_DIR="${BUDDY_BENCHMARK_DIR}/test_result/geminiprocessing"
mkdir -p "${RESULT_DIR}"

export C_PATH=$(which riscv64-unknown-linux-gnu-gcc)
export CXX_PATH=$(which riscv64-unknown-linux-gnu-g++)
export CLinker_PATH=$(which riscv64-unknown-linux-gnu-ld)

# Print Address here
echo "[Info] C_COMPILER_PATH = ${C_PATH}"
echo "[Info] CXX_COMPILER_PATH = ${CXX_PATH}"
echo "[Info] C_LINKER_PATH = ${CLinker_PATH}"
echo "[Info] BUDDY_MLIR_BUILD_DIR = ${BUDDY_MLIR_BUILD_DIR}"
echo "[Info] LLVM_MLIR_BUILD_DIR = ${LLVM_MLIR_BUILD_DIR}"
echo "[Info] CHIPYARD_DIR = ${CHIPYARD_DIR}"
echo "[Info] BUDDY_BENCHMARK_DIR = ${BUDDY_BENCHMARK_DIR}"
echo "[Info] RESULT_DIR = ${RESULT_DIR}"

echo "[Info] Running CMake configuration..."
cmake -G Ninja .. \
-DCMAKE_C_COMPILER=${C_PATH} \
-DCMAKE_CXX_COMPILER=${CXX_PATH} \
-DCMAKE_LINKER=${CLinker_PATH} \
-DCMAKE_BUILD_TYPE=RELEASE \
-DBUDDY_MLIR_BUILD_DIR=${BUDDY_MLIR_BUILD_DIR} \
-DGEMMINI_INCLUDE_DIR=${CHIPYARD_DIR}/generators/gemmini/software/gemmini-rocc-tests/include/ \
-DGEMMINI_BENCHMARKS=ON \
2>&1 | tee "${RESULT_DIR}/cmake_configure.log"

ninja 2>&1 | tee "${RESULT_DIR}/build.log"

# ```[1/21] Creating directories for 'project_googlebenchmark'
# [2/21] Building C object benchmarks/Gemmini/Ops/MatMulOp/CMakeFiles/ExoMatMul.dir/ExoMatmul.c.o
# FAILED: benchmarks/Gemmini/Ops/MatMulOp/CMakeFiles/ExoMatMul.dir/ExoMatmul.c.o
# riscv64-unknown-linux-gnu-gcc -I/home/buddy-complier-workspace/buddy-mlir/build/cmake/../../frontend/Interfaces -I/home/buddy-complier-workspace/buddy-mlir/build/cmake/../../thirdparty/include -I/home/buddy-complier-workspace/buddy-benchmark/benchmarks -I/home/buddy-complier-workspace/chipyard/generators/gemmini/software/gemmini-rocc-tests/include -I/home/buddy-complier-workspace/chipyard/generators/gemmini/software/gemmini-rocc-tests/include/.. -I/home/xychen/buddy-mlir/frontend/Interfaces -O3 -DNDEBUG -MD -MT benchmarks/Gemmini/Ops/MatMulOp/CMakeFiles/ExoMatMul.dir/ExoMatmul.c.o -MF benchmarks/Gemmini/Ops/MatMulOp/CMakeFiles/ExoMatMul.dir/ExoMatmul.c.o.d -o benchmarks/Gemmini/Ops/MatMulOp/CMakeFiles/ExoMatMul.dir/ExoMatmul.c.o -c /home/buddy-complier-workspace/buddy-benchmark/benchmarks/Gemmini/Ops/MatMulOp/ExoMatmul.c
# /home/buddy-complier-workspace/buddy-benchmark/benchmarks/Gemmini/Ops/MatMulOp/ExoMatmul.c: In function '_exo_matmul_4':
# /home/buddy-complier-workspace/buddy-benchmark/benchmarks/Gemmini/Ops/MatMulOp/ExoMatmul.c:28:47: error: macro "gemmini_extended_config_ex" requires 7 arguments, but only 6 given
# 28 | gemmini_extended_config_ex(WS, 0, 0, 1, 0, 0);
# | ^
# In file included from /home/buddy-complier-workspace/buddy-benchmark/benchmarks/Gemmini/Ops/MatMulOp/ExoMatmul.c:23:```

# cd bin
# ./vectorization-matrix-benchmark 2>&1 | tee "${RESULT_DIR}/run.log"

echo "[Info] CMake, build, and run logs are stored in ${RESULT_DIR}"
Loading