76 lines
3.7 KiB
Bash
76 lines
3.7 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
source /opt/artifact/pins.env
|
|
export CMAKE_BUILD_PARALLEL_LEVEL=${1:-$(env -u OMP_NUM_THREADS -u OMP_THREAD_LIMIT nproc)}
|
|
[[ "$CMAKE_BUILD_PARALLEL_LEVEL" =~ ^[1-9][0-9]*$ ]]
|
|
cd /opt/raptor
|
|
sha256sum -c /opt/artifact/models.sha256
|
|
|
|
checkout() {
|
|
local url=$1 revision=$2 destination=$3
|
|
git init "$destination"
|
|
git -C "$destination" remote add origin "$url"
|
|
git -C "$destination" fetch --depth 1 origin "$revision"
|
|
git -C "$destination" checkout --detach FETCH_HEAD
|
|
test "$(git -C "$destination" rev-parse HEAD)" = "$revision"
|
|
git -C "$destination" submodule update --init --recursive --depth 1
|
|
}
|
|
|
|
checkout https://github.com/onnx/onnx-mlir.git "$ONNX_MLIR_COMMIT" onnx-mlir
|
|
checkout https://github.com/llvm/llvm-project.git "$LLVM_COMMIT" onnx-mlir/llvm-project
|
|
checkout https://github.com/HEAPLab/PIMCOMP-NN.git "$PIMCOMP_COMMIT" third_party/PIMCOMP-NN
|
|
checkout https://github.com/HEAPLab/pimsim-nn.git "$PIMSIM_COMMIT" backend-simulators/pim/pimsim-nn
|
|
checkout https://github.com/protocolbuffers/protobuf.git "$PROTOBUF_COMMIT" /opt/protobuf
|
|
|
|
common=(-G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON
|
|
-DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=mold
|
|
-DCMAKE_SHARED_LINKER_FLAGS=-fuse-ld=mold
|
|
-DCMAKE_MODULE_LINKER_FLAGS=-fuse-ld=mold)
|
|
|
|
cmake -S /opt/protobuf -B /opt/protobuf/build "${common[@]}" \
|
|
-Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_ABSL_PROVIDER=module \
|
|
-DABSL_PROPAGATE_CXX_STD=ON -DCMAKE_CXX_STANDARD=17
|
|
cmake --build /opt/protobuf/build
|
|
cmake --install /opt/protobuf/build
|
|
ldconfig
|
|
|
|
llvm=onnx-mlir/llvm-project
|
|
cmake -S "$llvm/llvm" -B "$llvm/build_release" "${common[@]}" \
|
|
'-DLLVM_ENABLE_PROJECTS=mlir;clang' -DLLVM_ENABLE_RUNTIMES=openmp \
|
|
-DLLVM_TARGETS_TO_BUILD=host -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_ENABLE_RTTI=ON \
|
|
-DENABLE_LIBOMPTARGET=OFF -DLLVM_ENABLE_LIBEDIT=OFF \
|
|
-DLLVM_PARALLEL_LINK_JOBS="$CMAKE_BUILD_PARALLEL_LEVEL"
|
|
cmake --build "$llvm/build_release"
|
|
|
|
cmake -S . -B build_release "${common[@]}" \
|
|
-DONNX_MLIR_ACCELERATORS=PIM -DLLVM_ENABLE_ASSERTIONS=ON \
|
|
-DONNX_MLIR_ENABLE_JAVA=OFF -DONNX_MLIR_BUILD_TESTS=OFF \
|
|
-DMLIR_DIR="$PWD/$llvm/build_release/lib/cmake/mlir"
|
|
cmake --build ./build_release
|
|
|
|
cmake -S third_party/PIMCOMP-NN -B third_party/PIMCOMP-NN/build "${common[@]}"
|
|
cmake --build third_party/PIMCOMP-NN/build --target PIMCOMP-NN
|
|
sim=backend-simulators/pim/pimsim-nn
|
|
cmake -S "$sim" -B "$sim/build" "${common[@]}"
|
|
cmake --build "$sim/build"
|
|
ctest --test-dir "$sim/build" --output-on-failure
|
|
|
|
crate=backend-simulators/pim/pim-simulator
|
|
cargo build --locked --release --no-default-features --manifest-path "$crate/Cargo.toml" \
|
|
--package pim-simulator --bin pim-simulator --jobs "$CMAKE_BUILD_PARALLEL_LEVEL"
|
|
# The experiment driver uses cargo run. All dependencies must be available offline.
|
|
cargo fetch --locked --manifest-path "$crate/Cargo.toml"
|
|
mkdir -p /opt/artifact/provenance
|
|
cp /opt/artifact/pins.env /opt/artifact/source.sha256 /opt/artifact/models.sha256 /opt/artifact/provenance/
|
|
for dir in onnx-mlir "$llvm" third_party/PIMCOMP-NN "$sim" /opt/protobuf; do
|
|
printf '%s %s\n' "$dir" "$(git -C "$dir" rev-parse HEAD)"
|
|
git -C "$dir" submodule status --recursive
|
|
done > /opt/artifact/provenance/revisions.txt
|
|
dpkg-query -W > /opt/artifact/provenance/system-packages.txt
|
|
.venv/bin/python -m pip freeze > /opt/artifact/provenance/python-packages.txt
|
|
{ clang-19 --version; mold --version; cmake --version; rustc --version; } \
|
|
> /opt/artifact/provenance/toolchain.txt
|
|
# Runtime uses an arbitrary host UID. Cargo and the runners need writable caches
|
|
# and ONNX-MLIR writes temporary shims/configurations inside its source tree.
|
|
chmod -R a+rwX /opt/raptor /opt/cargo /opt/rustup
|