-
Notifications
You must be signed in to change notification settings - Fork 45
190 lines (171 loc) · 6.96 KB
/
build.yml
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
name: Cross-compile IMEX on CPUs
on:
push:
branches:
- main
- refactor
pull_request:
branches:
- main
- refactor
jobs:
build_linux:
name: Builds IMEX on Linux
runs-on: ubuntu-latest
timeout-minutes: 450
env:
LEVEL_ZERO_VER: v1.6.2
TBB_VER: 2021.5.0
TBB_URL_PREFIX: https://github.com/oneapi-src/oneTBB/releases/download/
LLVM_SHA_FILE: /home/runner/work/mlir-extensions/mlir-extensions/build_tools/llvm_version.txt
strategy:
matrix:
python: [3.9]
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- name: Setup conda
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.python }}
activate-environment: imex-devel
- name: Conda info
shell: bash -l {0}
run: conda info
- name: Install Build tools
shell: bash -l {0}
run: |
conda install cmake ninja graphviz conda-forge::lit conda-forge::doxygen
conda list
- name: Checkout repo
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Cache Vars
run: |
echo 'LLVM_SHA<<EOF' >> $GITHUB_ENV
cat $LLVM_SHA_FILE >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Cache TBB
id: cache-tbb
uses: actions/cache@v3
with:
path: |
/home/runner/work/tbb/*
key: ${{ runner.os }}-build-tbb-${{ env.TBB_VER }}
- name: Cache Level-Zero
id: cache-level-zero
uses: actions/cache@v3
with:
path: |
/home/runner/work/level-zero/**
key: ${{ runner.os }}-build-l0-${{ env.LEVEL_ZERO_VER }}
- name: Cache LLLVM-MLIR
id: cache-llvm-mlir
uses: actions/cache@v3
env:
LLVM_CACHE_NUMBER: 1 # Increase to reset cache
with:
path: |
/home/runner/work/llvm-mlir/_mlir_install/**
key: ${{ runner.os }}-build-llvm-${{ env.LLVM_CACHE_NUMBER }}-${{ env.LLVM_SHA }}
- name: Download TBB
if: steps.cache-tbb.outputs.cache-hit != 'true'
shell: bash -l {0}
run: |
cd /home/runner/work
mkdir -p tbb
pushd tbb
if [[ -f bundle_id.txt && ( "$(cat bundle_id.txt)" == "${TBB_VER}" ) ]]; then
echo "INFO: Using cached download of TBB ${TBB_VER}"
else
echo "INFO: Downloading TBB ${TBB_VER}"
rm -rf *
export TBB_FN=oneapi-tbb-${TBB_VER}-lin.tgz
wget ${TBB_URL_PREFIX}/v${TBB_VER}/${TBB_FN} || exit 1
tar xf ${TBB_FN} -C . || exit 1
cat $(find . -name tbb.pc) | grep Version: | cut -d " " -f 2 > bundle_id.txt || rm -rf bundle_id.txt
[ -f bundle_id.txt ] || exit 1
fi
popd
- name: Download and Build Level-Zero
if: steps.cache-level-zero.outputs.cache-hit != 'true'
shell: bash -l {0}
run: |
cd /home/runner/work
mkdir -p level-zero
pushd level-zero
tree
if [[ -f bundle_id.txt && ( "$(cat bundle_id.txt)" == "${LEVEL_ZERO_VER}" ) ]]; then
echo "INFO: Using cached build of Level-Zero ${LEVEL_ZERO_VER}"
else
echo "INFO: Downloading and building Level-Zero ${LEVEL_ZERO_VER}"
rm -rf *
echo ${LEVEL_ZERO_VER} > bundle_id.txt || rm -rf bundle_id.txt
cat bundle_id.txt || exit 1
[ -f bundle_id.txt ] || exit 1
git clone https://github.com/oneapi-src/level-zero.git --branch ${LEVEL_ZERO_VER} --single-branch || exit 1
pushd level-zero || exit 1
mkdir level_zero_install || exit 1
mkdir build || exit 1
cd build || exit 1
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../level_zero_install .. || exit 1
make install || exit 1
popd
fi
popd
- name: Build LLVM-MLIR
if: steps.cache-llvm-mlir.outputs.cache-hit != 'true'
shell: bash -l {0}
timeout-minutes: 420
run: |
mkdir -p /home/runner/work/llvm-mlir
pushd /home/runner/work/llvm-mlir
echo "INFO: Need to rebuild LLVM-MLIR. Previous installation for MLIR not found"
np=`nproc`
echo "INFO: nproc $np"
git clone https://github.com/llvm/llvm-project --branch main --single-branch || exit 1
cd llvm-project || exit 1
git checkout ${LLVM_SHA} || exit 1
if [ -d "/home/runner/work/mlir-extensions/mlir-extensions/build_tools/patches" ]; then git apply /home/runner/work/mlir-extensions/mlir-extensions/build_tools/patches/*.patch; fi
mkdir _build || exit 1
cd _build || exit 1
cmake ../llvm \
-GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_PROJECTS=mlir \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_ENABLE_RTTI=ON \
-DLLVM_USE_LINKER=gold \
-DLLVM_INSTALL_UTILS=ON \
-DLLVM_TARGETS_TO_BUILD=X86 \
-DLLVM_ENABLE_BINDINGS=OFF \
-DLLVM_ENABLE_ZSTD=OFF \
-DLLVM_DISTRIBUTION_COMPONENTS="llvm-headers;llvm-libraries;cmake-exports;FileCheck;count;not;mlir-headers;mlir-libraries;mlir-cmake-exports;mlir-tblgen;mlir-cpu-runner" \
-DCMAKE_INSTALL_PREFIX=/home/runner/work/llvm-mlir/_mlir_install || exit 1
ninja install-distribution-stripped || exit 1
popd
- name: Build IMEX
shell: bash -l {0}
run: |
external_lit=`which lit`
echo ${external_lit}
# make the llvm-mlir working dir
mkdir -p /home/runner/work/tmpdir
python build_tools/build_imex.py \
--working-dir /home/runner/work/tmpdir \
--llvm-install /home/runner/work/llvm-mlir/_mlir_install \
--external-lit ${external_lit}
- name: Run lit tests
shell: bash -l {0}
run: |
cd /home/runner/work/mlir-extensions/mlir-extensions/_build || exit 1
cmake --build . --target check-imex || exit 1
- name: Build doxygen docs
shell: bash -l {0}
run: |
cd /home/runner/work/mlir-extensions/mlir-extensions/_build || exit 1
cmake --build . --target doc_doxygen || exit 1