# buddy-mlir **Repository Path**: jayzlee147/buddy-mlir ## Basic Information - **Project Name**: buddy-mlir - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-02-10 - **Last Updated**: 2025-02-10 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # BUDDY MLIR An MLIR-based compiler framework designed for a co-design ecosystem from DSL (domain-specific languages) to DSA (domain-specific architectures). ([Project page](https://buddy-compiler.github.io/)). ## Getting Started The default build system uses LLVM/MLIR as an external library. We also provide a [one-step build strategy](#one-step) for users who only want to use our tools. Please make sure [the dependencies](https://llvm.org/docs/GettingStarted.html#requirements) are available on your machine. ### LLVM/MLIR Dependencies Before building, please make sure [the dependencies](https://llvm.org/docs/GettingStarted.html#requirements) are available on your machine. ### Clone and Initialize ``` $ git clone git@github.com:buddy-compiler/buddy-mlir.git $ cd buddy-mlir $ git submodule update --init ``` ### Build and Test LLVM/MLIR/CLANG ``` $ cd buddy-mlir $ mkdir llvm/build $ cd llvm/build $ cmake -G Ninja ../llvm \ -DLLVM_ENABLE_PROJECTS="mlir;clang" \ -DLLVM_TARGETS_TO_BUILD="host;RISCV" \ -DLLVM_ENABLE_ASSERTIONS=ON \ -DCMAKE_BUILD_TYPE=RELEASE $ ninja check-mlir check-clang ``` If your target machine includes a Nvidia GPU, you can use the following configuration: ``` $ cmake -G Ninja ../llvm \ -DLLVM_ENABLE_PROJECTS="mlir;clang" \ -DLLVM_TARGETS_TO_BUILD="host;RISCV;NVPTX" \ -DMLIR_ENABLE_CUDA_RUNNER=ON \ -DLLVM_ENABLE_ASSERTIONS=ON \ -DCMAKE_BUILD_TYPE=RELEASE ``` To enable MLIR Python bindings, please use the following configuration: ``` $ cmake -G Ninja ../llvm \ -DLLVM_ENABLE_PROJECTS="mlir;clang" \ -DLLVM_TARGETS_TO_BUILD="host;RISCV" \ -DLLVM_ENABLE_ASSERTIONS=ON \ -DCMAKE_BUILD_TYPE=RELEASE \ -DMLIR_ENABLE_BINDINGS_PYTHON=ON \ -DPython3_EXECUTABLE=$(which python3) ``` If your target machine has lld installed, you can use the following configuration: ``` $ cmake -G Ninja ../llvm \ -DLLVM_ENABLE_PROJECTS="mlir;clang" \ -DLLVM_TARGETS_TO_BUILD="host;RISCV" \ -DLLVM_USE_LINKER=lld \ -DLLVM_ENABLE_ASSERTIONS=ON \ -DCMAKE_BUILD_TYPE=RELEASE ``` ### Build buddy-mlir If you have previously built the llvm-project, you can replace the $PWD with the path to the directory where you have successfully built the llvm-project. ``` $ cd buddy-mlir $ mkdir build $ cd build $ 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 $ ninja $ ninja check-buddy ``` To utilize the Buddy Compiler Python package, please ensure that the MLIR Python bindings are enabled and use the following configuration: ``` $ 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) $ ninja $ ninja check-buddy $ export BUDDY_MLIR_BUILD_DIR=$PWD $ export LLVM_MLIR_BUILD_DIR=$PWD/../llvm/build $ export PYTHONPATH=${LLVM_MLIR_BUILD_DIR}/tools/mlir/python_packages/mlir_core:${BUDDY_MLIR_BUILD_DIR}/python_packages:${PYTHONPATH} ``` To configure the build environment for using image processing libraries, follow these steps: ``` $ 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_DIP_LIB=ON \ -DBUDDY_ENABLE_PNG=ON $ ninja $ ninja check-buddy ``` To build buddy-mlir with custom LLVM sources: ``` $ cmake -G Ninja .. \ -DMLIR_DIR=PATH/TO/LLVM/lib/cmake/mlir \ -DLLVM_DIR=PATH/TO/LLVM/lib/cmake/llvm \ -DLLVM_ENABLE_ASSERTIONS=ON \ -DCMAKE_BUILD_TYPE=RELEASE \ -DLLVM_MAIN_SRC_DIR=PATH/TO/LLVM_SOURCE ```