-
Notifications
You must be signed in to change notification settings - Fork 3
/
build-scalehls.sh
executable file
·104 lines (88 loc) · 2.22 KB
/
build-scalehls.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
# Script options.
while getopts 'j:p:' opt
do
case $opt in
j) JOBS="${OPTARG}";;
p) PYBIND="${OPTARG}";;
esac
done
# If ninja is available, use it.
CMAKE_GENERATOR="Unix Makefiles"
if which ninja &>/dev/null; then
CMAKE_GENERATOR="Ninja"
fi
# The absolute path to the directory of this script.
SCALEHLS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
# Make sure polygeist submodule is up-to-date.
git submodule sync
git submodule update --init --recursive
echo ""
echo ">>> Unified MLIR, Clang, and ScaleHLS build..."
echo ""
# Got to the build directory.
cd "${SCALEHLS_DIR}"
mkdir -p build
cd build
# Configure CMake.
if [ ! -f "CMakeCache.txt" ]; then
cmake -G "${CMAKE_GENERATOR}" \
../polygeist/llvm-project/llvm \
-DLLVM_ENABLE_PROJECTS="mlir;clang" \
-DLLVM_EXTERNAL_PROJECTS="scalehls" \
-DLLVM_EXTERNAL_SCALEHLS_SOURCE_DIR="${SCALEHLS_DIR}" \
-DLLVM_TARGETS_TO_BUILD="host" \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCMAKE_BUILD_TYPE=DEBUG \
-DMLIR_ENABLE_BINDINGS_PYTHON="${PYBIND:=OFF}" \
-DSCALEHLS_ENABLE_BINDINGS_PYTHON="${PYBIND:=OFF}" \
-DLLVM_PARALLEL_LINK_JOBS="${JOBS:=}" \
-DLLVM_USE_LINKER=lld \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++
fi
# Run building.
if [ "${CMAKE_GENERATOR}" == "Ninja" ]; then
ninja
else
make -j "$(nproc)"
fi
echo ""
echo ">>> Polygeist build..."
echo ""
# Got to the build directory.
cd "${SCALEHLS_DIR}/polygeist"
mkdir -p build
cd build
# Configure CMake.
if [ ! -f "CMakeCache.txt" ]; then
cmake -G "${CMAKE_GENERATOR}" \
.. \
-DMLIR_DIR="${SCALEHLS_DIR}/build/lib/cmake/mlir" \
-DCLANG_DIR="${SCALEHLS_DIR}/build/lib/cmake/clang" \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCMAKE_BUILD_TYPE=DEBUG \
-DLLVM_USE_LINKER=lld \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++
fi
# Run building.
if [ "${CMAKE_GENERATOR}" == "Ninja" ]; then
ninja
ninja check-cgeist
else
make -j "$(nproc)"
make -j "$(nproc)" check-cgeist
fi
echo ""
echo ">>> ScaleHLS check..."
echo ""
cd "${SCALEHLS_DIR}/build"
if [ "${CMAKE_GENERATOR}" == "Ninja" ]; then
ninja check-scalehls
else
make -j "$(nproc)" check-scalehls
fi