commit | f72b9c97f65320e6f81ed48f2dc8c7469b5c28ff | [log] [tgz] |
---|---|---|
author | Tim Harvey <146767459+TimAtGoogle@users.noreply.github.com> | Thu May 23 18:44:42 2024 +0000 |
committer | GitHub <noreply@github.com> | Thu May 23 18:44:42 2024 +0000 |
tree | 734e6119608ce3ff04813b060bf5d5ea86ff8c9e | |
parent | 983a8d85b7a759e2ac658e2a08a54bb77b5de8f2 [diff] |
Update README.md Added explanations and csh/tcsh/fish specific instructions.
The MPACT project's main objective is to dramatically reduce the effort required to create highly optimizing HPC and ML compilers for a large class of architectures using LLVM and MLIR. We will do this by providing a declarative language-based mechanism for collecting and expressing critical aspects of a target architecture in a way that can be reasoned about and leveraged by all passes in both MLIR and LLVM.
To build and run the MPACT compiler from source (for developers), please follow the steps below.
Use the following commands to clone the MPACT compiler repository.
git clone https://github.com/MPACT-ORG/mpact-compiler.git cd mpact-compiler git submodule update --init --recursive --progress
All of the following commands assume you remain in the mpact-compiler
directory.
The following commands initialize a virtual environment.
python3.11 -m venv mpact_venv # one time set up
NOTE: every session you have in this repo requires one of the following three commands (maybe add it to your .*sh file?). (Remember to replace “<path_to_mpact_compiler>” with your specific path.)
source <path_to_mpact_compiler>/mpact_venv/bin/activate # for bash/sh/etc. source <path_to_mpact_compiler>/mpact_venv/bin/activate.csh # for csh/tcsh/etc. source <path_to_mpact_compiler>/mpact_venv/bin/activate.fish # for fish/etc.
Also make sure to set the Python paths as follows -- note that shell syntax depends on the shell you're running, and you need to replace “<path_to_mpact_compiler>” with your specific path.
# FOR bash/sh/etc. export PYTHONPATH=<path_to_mpact_compiler>/build/tools/torch-mlir/python_packages/torch_mlir: \\ <path_to_mpact_compiler>/build/tools/mpact/python_packages/mpact # FOR csh/tcsh/etc. setenv PYTHONPATH <path_to_mpact_compiler>/build/tools/torch-mlir/python_packages/torch_mlir:<path_to_mpact_compiler>/build/tools/mpact/python_packages/mpact
Note that currently we rely on torch-mlir
requirements defined in the submodule to ensure all the build requirements are consistent.
python -m pip install --upgrade pip python -m pip install -r externals/torch-mlir/requirements.txt python -m pip install -r externals/torch-mlir/torchvision-requirements.txt
The following command generates configuration files to build the MPACT compiler project completely in-tree, which means that both LLVM as well as torch-mlir are built from source.
NOTE: if using csh/tcsh/etc., run the following command:
rehash
cmake -GNinja -Bbuild \ -DCMAKE_BUILD_TYPE=Release \ -DPython3_FIND_VIRTUALENV=ONLY \ -DLLVM_ENABLE_PROJECTS=mlir \ -DLLVM_EXTERNAL_PROJECTS="torch-mlir;mpact" \ -DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR="${PWD}/externals/torch-mlir" \ -DLLVM_EXTERNAL_MPACT_SOURCE_DIR="${PWD}" \ -DLLVM_TARGETS_TO_BUILD=host \ -DMLIR_ENABLE_BINDINGS_PYTHON=ON \ externals/torch-mlir/externals/llvm-project/llvm
Run the following to ensure the MPACT compiler builds and runs correctly.
cmake --build build --target check-mpact