forked from Xilinx/mlir-aie
-
Notifications
You must be signed in to change notification settings - Fork 0
443 lines (354 loc) · 13.5 KB
/
mlirAIEDistro.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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
name: MLIR AIE Distro
on:
pull_request:
paths:
- '.github/workflows/mlirAIEDistro.yml'
workflow_dispatch:
inputs:
DEBUG_ENABLED:
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
type: boolean
required: false
default: false
DEBUG_OS:
description: 'which runner os to run the tmate action in (if the tmate action is run)'
type: string
default: 'windows-2019'
required: false
DEBUG_ARCH:
description: 'which runner arch to run the tmate action in (if the tmate action is run)'
type: string
default: 'x86_64'
required: false
DEBUG_DETACHED:
description: 'whether to launch tmate in detached mode (if the tmate action is run)'
type: boolean
required: false
default: true
AIE_COMMIT:
description: 'AIE commit to build'
type: string
required: false
default: ''
# this is only for debugging this same yamls
# comment it out when you're not working on these yamls
jobs:
get_aie_project_commit:
name: Get canonical AIE Project commit
runs-on: ubuntu-latest
outputs:
AIE_PROJECT_COMMIT: ${{ steps.get_aie_project_commit.outputs.AIE_PROJECT_COMMIT }}
DATETIME: ${{ steps.get_aie_project_commit.outputs.DATETIME }}
steps:
- name: Get AIE-project commit
id: get_aie_project_commit
shell: bash
run: |
if [ x"${{ inputs.AIE_COMMIT }}" == x"" ]; then
sudo apt install jq
AIE_PROJECT_COMMIT=$(curl -s https://api.github.com/repos/Xilinx/mlir-aie/commits/main | jq -r '.sha[:8]')
else
AIE_PROJECT_COMMIT="${{ inputs.AIE_COMMIT }}"
fi
echo "AIE_PROJECT_COMMIT=${AIE_PROJECT_COMMIT}" | tee -a $GITHUB_OUTPUT
DATETIME=$(date +"%Y%m%d%H")
echo "DATETIME=${DATETIME}" | tee -a $GITHUB_OUTPUT
build_distro_wheels:
needs: get_aie_project_commit
name: ${{ matrix.OS }} ${{ matrix.ARCH }} rtti=${{ matrix.ENABLE_RTTI }}
continue-on-error: true
runs-on: ${{ matrix.OS }}
outputs:
MLIR_AIE_WHEEL_VERSION: ${{ steps.get_wheel_version.outputs.MLIR_AIE_WHEEL_VERSION }}
strategy:
fail-fast: false
matrix:
include:
- OS: ubuntu-20.04
ARCH: x86_64
ENABLE_RTTI: ON
- OS: windows-2019
ARCH: AMD64
ENABLE_RTTI: ON
- OS: macos-11
ARCH: x86_64
ENABLE_RTTI: ON
- OS: macos-11
ARCH: arm64
ENABLE_RTTI: ON
- OS: ubuntu-20.04
ARCH: aarch64
ENABLE_RTTI: ON
- OS: ubuntu-20.04
ARCH: x86_64
ENABLE_RTTI: OFF
- OS: windows-2019
ARCH: AMD64
ENABLE_RTTI: OFF
- OS: macos-11
ARCH: x86_64
ENABLE_RTTI: OFF
- OS: macos-11
ARCH: arm64
ENABLE_RTTI: OFF
- OS: ubuntu-20.04
ARCH: aarch64
ENABLE_RTTI: OFF
steps:
- name: set ENV
shell: bash
run: |
PIP_FIND_LINKS_URL="https://github.com/Xilinx/mlir-aie/releases/expanded_assets/mlir-distro"
if [ x"${{ github.event_name }}" == x"pull_request" ]; then
PIP_FIND_LINKS_URL="$PIP_FIND_LINKS_URL https://github.com/Xilinx/mlir-aie/releases/expanded_assets/dev-wheels"
fi
echo "PIP_FIND_LINKS=$PIP_FIND_LINKS_URL" | tee -a $GITHUB_ENV
echo "ENABLE_RTTI=${{ matrix.ENABLE_RTTI }}" | tee -a $GITHUB_ENV
- name: Checkout actions
uses: actions/checkout@v3
with:
# checkout just the actions in order to pick and choose
# where the actual repo is checked out manually (see actions/setup_base)
sparse-checkout: .github/actions
- uses: ./.github/actions/setup_base
id: setup_base
with:
# optional
DEBUG_ENABLED: ${{ inputs.DEBUG_ENABLED }}
DEBUG_OS: ${{ inputs.DEBUG_OS }}
DEBUG_ARCH: ${{ inputs.DEBUG_ARCH }}
DEBUG_DETACHED: ${{ inputs.DEBUG_DETACHED }}
# required
MATRIX_OS: ${{ matrix.OS }}
MATRIX_ARCH: ${{ matrix.ARCH }}
- uses: ./.github/actions/setup_ccache
id: setup_ccache
with:
MATRIX_OS: ${{ matrix.OS }}
MATRIX_ARCH: ${{ matrix.ARCH }}
EXTRA_KEY: mlir-aie-distro-rtti-${{ matrix.ENABLE_RTTI }}
- name: Shift workspace root
id: workspace_root
shell: bash
working-directory: ${{ env.TEMP }}
run: |
ls "${{ steps.setup_base.outputs.WORKSPACE_ROOT }}"
if [ x"${{ matrix.OS }}" == x"windows-2019" ]; then
WORKSPACE_ROOT="${{ steps.setup_base.outputs.WORKSPACE_ROOT }}\utils\mlir_aie_wheels"
else
WORKSPACE_ROOT="${{ steps.setup_base.outputs.WORKSPACE_ROOT }}/utils/mlir_aie_wheels"
fi
echo "WORKSPACE_ROOT=$WORKSPACE_ROOT" | tee -a $GITHUB_OUTPUT
- name: Get AIE
id: get_aie
working-directory: ${{ steps.workspace_root.outputs.WORKSPACE_ROOT }}
shell: bash
run: |
curl -s https://codeload.github.com/Xilinx/mlir-aie/zip/${{ needs.get_aie_project_commit.outputs.AIE_PROJECT_COMMIT }} -o aie.zip
unzip -q aie.zip
rm -rf aie.zip
AIE_PROJECT_COMMIT=${{ needs.get_aie_project_commit.outputs.AIE_PROJECT_COMMIT }}
mv mlir-aie-$AIE_PROJECT_COMMIT mlir-aie
ls -lh mlir-aie
# build
- name: build distro wheels
if: ${{ matrix.OS != 'ubuntu-20.04' || matrix.ARCH != 'aarch64' }}
shell: bash
working-directory: ${{ steps.workspace_root.outputs.WORKSPACE_ROOT }}
run: |
export PIP_NO_BUILD_ISOLATION=false
CIBW_ARCHS=${{ matrix.ARCH }} \
CMAKE_GENERATOR=Ninja \
DATETIME=${{ needs.get_aie_project_commit.outputs.DATETIME }} \
HOST_CCACHE_DIR=${{ steps.setup_ccache.outputs.HOST_CCACHE_DIR }} \
AIE_PROJECT_COMMIT=${{ needs.get_aie_project_commit.outputs.AIE_PROJECT_COMMIT }} \
MATRIX_OS=${{ matrix.OS }} \
PARALLEL_LEVEL=2 \
cibuildwheel --output-dir wheelhouse
- name: build aarch ubuntu wheel
if: ${{ matrix.OS == 'ubuntu-20.04' && matrix.ARCH == 'aarch64' }}
working-directory: ${{ steps.workspace_root.outputs.WORKSPACE_ROOT }}
shell: bash
run: |
export PIP_NO_BUILD_ISOLATION=false
pip install -r requirements.txt
pip install importlib-metadata
CIBW_ARCHS=${{ matrix.ARCH }} MATRIX_OS=${{ matrix.OS }} ./scripts/download_mlir.sh
CIBW_ARCHS=${{ matrix.ARCH }} \
CMAKE_GENERATOR=Ninja \
DATETIME=${{ needs.get_aie_project_commit.outputs.DATETIME }} \
AIE_PROJECT_COMMIT=${{ needs.get_aie_project_commit.outputs.AIE_PROJECT_COMMIT }} \
MATRIX_OS=${{ matrix.OS }} \
PARALLEL_LEVEL=2 \
pip wheel . -v -w wheelhouse
- name: Clean
working-directory: ${{ steps.workspace_root.outputs.WORKSPACE_ROOT }}
shell: bash
run: |
rm -rf mlir-aie
rm -rf build
- name: Docker prune
if: contains(inputs.MATRIX_OS, 'ubuntu')
shell: bash
run: |
docker system prune -a -f
- name: Get wheel version
id: get_wheel_version
working-directory: ${{ steps.workspace_root.outputs.WORKSPACE_ROOT }}
shell: bash
run: |
pip install pkginfo
WHL=$(ls wheelhouse/mlir_aie*whl)
echo "MLIR_AIE_WHEEL_VERSION=$(python -c "import pkginfo; w = pkginfo.Wheel('$WHL'); print(w.version.split('+')[0] + '+' + w.version.split('+')[1].rsplit('.', 1)[-1])")" | tee -a $GITHUB_OUTPUT
- name: Download cache from container ubuntu
if: (matrix.OS == 'ubuntu-20.04' && matrix.ARCH == 'x86_64') && (success() || failure())
working-directory: ${{ steps.workspace_root.outputs.WORKSPACE_ROOT }}
shell: bash
run: |
ccache -s
HOST_CCACHE_DIR="$(ccache --get-config cache_dir)"
rm -rf $HOST_CCACHE_DIR
mv ./wheelhouse/.ccache $HOST_CCACHE_DIR
ls -la $HOST_CCACHE_DIR
ccache -s
# For whatever reason, the timestamps on all of the files that come out of the docker container
# are some amount ahead in time (maybe 12 hours?). that means if you try to rebuild at any point
# within that window ccache will not hit because the timestamps of the cached objects are ahead of
# your build time. I'm not 100% sure about this explanation/mechanism but this fixed ccache misses for me.
- name: Reset datetime ccache
working-directory: ${{ steps.workspace_root.outputs.WORKSPACE_ROOT }}
shell: bash
run: |
ccache --print-stats
HOST_CCACHE_DIR="$(ccache --get-config cache_dir)"
# Set the timestamp to the beginning of the current hour.
find $HOST_CCACHE_DIR -exec touch -a -m -t 201108231405.14 {} \;
# The important parts of the wheels (all the LLVM/MLIR archives) have nothing to do with the
# python version. With py3-none you can pip install them in any python venv. Unfortunately though this does
# mean that the python bindings themselves will confusingly not work in other envs (!=3.10)
- name: rename non-windows
if: ${{ matrix.OS == 'ubuntu-20.04' || matrix.OS == 'macos-11' }}
working-directory: ${{ steps.workspace_root.outputs.WORKSPACE_ROOT }}
shell: bash
run: |
rename 's/cp310-cp310/py3-none/' wheelhouse/mlir_aie*whl
if [ x"${{ matrix.OS }}" == x"ubuntu-20.04" ] && [ x"${{ matrix.ARCH }}" == x"aarch64" ]; then
rename 's/x86_64/aarch64/' wheelhouse/mlir_aie*whl
fi
- name: rename windows
if: ${{ matrix.OS == 'windows-2019' }}
working-directory: ${{ steps.workspace_root.outputs.WORKSPACE_ROOT }}
run: |
ls wheelhouse/mlir_aie*whl | Rename-Item -NewName {$_ -replace 'cp310-cp310', 'py3-none' }
- name: Upload distro wheels
uses: actions/upload-artifact@v3
with:
path: ${{ steps.workspace_root.outputs.WORKSPACE_ROOT }}/wheelhouse/*.whl
name: build_artifact_${{ matrix.OS }}_${{ matrix.ARCH }}_rtti_${{ matrix.ENABLE_RTTI }}
smoke_test_wheels:
name: test ${{ matrix.OS }} ${{ matrix.ARCH }} rtti=${{ matrix.ENABLE_RTTI }}
needs: build_distro_wheels
runs-on: ${{ matrix.OS }}
strategy:
fail-fast: false
matrix:
include:
- OS: ubuntu-20.04
ARCH: x86_64
ENABLE_RTTI: ON
- OS: windows-2019
ARCH: AMD64
ENABLE_RTTI: ON
- OS: macos-11
ARCH: x86_64
ENABLE_RTTI: ON
- OS: ubuntu-20.04
ARCH: x86_64
ENABLE_RTTI: OFF
- OS: windows-2019
ARCH: AMD64
ENABLE_RTTI: OFF
- OS: macos-11
ARCH: x86_64
ENABLE_RTTI: OFF
steps:
- name: Checkout reqs
uses: actions/checkout@v3
with:
sparse-checkout: python/requirements.txt
- uses: actions/download-artifact@v3
with:
name: build_artifact_${{ matrix.OS }}_${{ matrix.ARCH }}_rtti_${{ matrix.ENABLE_RTTI }}
path: dist
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: test
shell: bash
run: |
pip install -r python/requirements.txt
unzip -o -q dist/mlir_aie\*.whl
if [ x"${{ matrix.ENABLE_RTTI }}" == x"ON" ]; then
export PYTHONPATH=mlir_aie/python
else
export PYTHONPATH=mlir_aie_no_rtti/python
fi
python -c 'import aie.ir'
upload_wheels:
needs: smoke_test_wheels
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
strategy:
fail-fast: false
matrix:
include:
- OS: ubuntu-20.04
ARCH: x86_64
ENABLE_RTTI: ON
- OS: ubuntu-20.04
ARCH: aarch64
ENABLE_RTTI: ON
- OS: windows-2019
ARCH: AMD64
ENABLE_RTTI: ON
- OS: macos-11
ARCH: x86_64
ENABLE_RTTI: ON
- OS: macos-11
ARCH: arm64
ENABLE_RTTI: ON
- OS: ubuntu-20.04
ARCH: x86_64
ENABLE_RTTI: OFF
- OS: ubuntu-20.04
ARCH: aarch64
ENABLE_RTTI: OFF
- OS: windows-2019
ARCH: AMD64
ENABLE_RTTI: OFF
- OS: macos-11
ARCH: x86_64
ENABLE_RTTI: OFF
- OS: macos-11
ARCH: arm64
ENABLE_RTTI: OFF
steps:
- uses: actions/download-artifact@v3
with:
# unpacks default artifact into dist/
# if `name: artifact` is omitted, the action will create extra parent dir
name: build_artifact_${{ matrix.OS }}_${{ matrix.ARCH }}_rtti_${{ matrix.ENABLE_RTTI }}
path: dist
- name: Release current commit
uses: ncipollo/release-action@v1.12.0
with:
artifacts: "dist/*.whl,dist/*.tar.xz"
token: "${{ secrets.GITHUB_TOKEN }}"
tag: ${{ github.event_name == 'workflow_dispatch' && 'latest-wheels' || 'dev-wheels' }}
name: ${{ github.event_name == 'workflow_dispatch' && 'latest-wheels' || 'dev-wheels' }}
removeArtifacts: false
allowUpdates: true
replacesArtifacts: true
makeLatest: true