-
Notifications
You must be signed in to change notification settings - Fork 262
353 lines (305 loc) · 12.7 KB
/
root-cmakelists.yaml
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
# Build SuiteSparse using the root CMakeLists.txt
name: root-cmakelists
on:
workflow_dispatch:
push:
branches-ignore:
- '**/dev2'
pull_request:
concurrency: ci-root-cmakelists-${{ github.ref }}
jobs:
ubuntu:
# For available GitHub-hosted runners, see:
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners
runs-on: ubuntu-latest
name: ubuntu (${{ matrix.compiler }} ${{ matrix.cuda }} CUDA)
strategy:
# Allow other runners in the matrix to continue if some fail
fail-fast: false
matrix:
compiler: [gcc, clang]
cuda: [with, without]
include:
- compiler: gcc
compiler-pkgs: "g++ gcc"
cc: "gcc"
cxx: "g++"
- compiler: clang
compiler-pkgs: "clang libomp-dev"
cc: "clang"
cxx: "clang++"
# Clang seems to generally require less cache size (smaller object files?).
- compiler: gcc
ccache-max: 600M
- compiler: clang
ccache-max: 500M
- cuda: with
cuda-pkgs: "nvidia-cuda-dev nvidia-cuda-toolkit"
cuda-cmake-flags:
-DENABLE_CUDA=ON
-DCUDAToolkit_INCLUDE_DIR="/usr/include"
-DCMAKE_CUDA_COMPILER_LAUNCHER="ccache"
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
steps:
- name: checkout repository
uses: actions/checkout@v3
- name: install dependencies
env:
COMPILER_PKGS: ${{ matrix.compiler-pkgs }}
CUDA_PKGS: ${{ matrix.cuda-pkgs }}
run: |
sudo apt -qq update
sudo apt install -y ${COMPILER_PKGS} autoconf automake ccache cmake \
dvipng gfortran libgmp-dev liblapack-dev libmpfr-dev \
libopenblas-dev ${CUDA_PKGS}
- name: prepare ccache
# create key with human readable timestamp
# used in action/cache/restore and action/cache/save steps
id: ccache-prepare
run: |
echo "key=ccache:ubuntu:root:${{ matrix.compiler }}:${{ matrix.cuda }}:${{ github.ref }}:$(date +"%Y-%m-%d_%H-%M-%S"):${{ github.sha }}" >> $GITHUB_OUTPUT
- name: restore ccache
# setup the GitHub cache used to maintain the ccache from one job to the next
uses: actions/cache/restore@v3
with:
path: ~/.ccache
key: ${{ steps.ccache-prepare.outputs.key }}
# Prefer caches from the same branch. Fall back to caches from the dev branch.
restore-keys: |
ccache:ubuntu:root:${{ matrix.compiler }}:${{ matrix.cuda }}:${{ github.ref }}
ccache:ubuntu:root:${{ matrix.compiler }}:${{ matrix.cuda }}
- name: create empty libraries
# This is to work around a bug in nvlink.
# See: https://forums.developer.nvidia.com/t/nvlink-fatal-could-not-open-input-file-when-linking-with-empty-static-library/208517
if: matrix.cuda == 'with'
run: |
touch empty.c
gcc -fPIC -c empty.c -oempty.o
ar rcsv libdl.a empty.o
ar rcsv librt.a empty.o
ar rcsv libpthread.a empty.o
# overwrite system libraries with "valid" empty libraries
sudo mv ./libdl.a /usr/lib/x86_64-linux-gnu/libdl.a
sudo mv ./librt.a /usr/lib/x86_64-linux-gnu/librt.a
sudo mv ./libpthread.a /usr/lib/x86_64-linux-gnu/libpthread.a
- name: configure ccache
env:
CCACHE_MAX: ${{ matrix.ccache-max }}
run: |
test -d ~/.ccache || mkdir ~/.ccache
echo "max_size = $CCACHE_MAX" >> ~/.ccache/ccache.conf
echo "compression = true" >> ~/.ccache/ccache.conf
ccache -s
echo "/usr/lib/ccache" >> $GITHUB_PATH
- name: build libraries
run: |
printf "::group:: \033[0;32m==>\033[0m Configuring\n"
mkdir -p ${GITHUB_WORKSPACE}/build && cd ${GITHUB_WORKSPACE}/build
cmake -DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_INSTALL_PREFIX=".." \
-DCMAKE_C_COMPILER_LAUNCHER="ccache" \
-DCMAKE_CXX_COMPILER_LAUNCHER="ccache" \
-DCMAKE_Fortran_COMPILER_LAUNCHER="ccache" \
-DBLA_VENDOR="OpenBLAS" \
${{ matrix.cuda-cmake-flags }} \
..
echo "::endgroup::"
printf "::group:: \033[0;32m==>\033[0m Building\n"
cmake --build .
echo "::endgroup::"
- name: build demos
run: |
printf "::group:: \033[0;32m==>\033[0m Configuring for demos\n"
cd ${GITHUB_WORKSPACE}/build
cmake -DDEMO=ON ..
echo "::endgroup::"
printf "::group:: \033[0;32m==>\033[0m Building demos\n"
cd ${GITHUB_WORKSPACE}/build
cmake --build .
echo "::endgroup::"
# FIXME: How to run the demos without Makefile?
- name: ccache status
continue-on-error: true
run: ccache -s
- name: save ccache
# Save the cache after we are done (successfully) building.
# This helps to retain the ccache even if the subsequent steps are failing.
uses: actions/cache/save@v3
with:
path: ~/.ccache
key: ${{ steps.ccache-prepare.outputs.key }}
- name: install
run: |
printf "\033[0;32m==>\033[0m Installing libraries\n"
cd ${GITHUB_WORKSPACE}/build
cmake --install .
- name: build example
run: |
cd ${GITHUB_WORKSPACE}/Example/build
printf "::group::\033[0;32m==>\033[0m Configuring example\n"
cmake \
-DCMAKE_PREFIX_PATH="${GITHUB_WORKSPACE}/lib/cmake" \
-DBLA_VENDOR="OpenBLAS" \
${{ matrix.cuda-cmake-flags }} \
..
echo "::endgroup::"
printf "::group::\033[0;32m==>\033[0m Building example\n"
cmake --build .
echo "::endgroup::"
printf "::group::\033[0;32m==>\033[0m Executing example\n"
LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/lib ./my_demo
echo "::endgroup::"
msvc:
# For available GitHub-hosted runners, see:
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners
runs-on: windows-latest
name: msvc (${{ matrix.openmp }} OpenMP)
defaults:
run:
# Use bash as default shell
shell: bash -el {0}
strategy:
# Allow other runners in the matrix to continue if some fail
fail-fast: false
env:
CHERE_INVOKING: 1
steps:
- name: get CPU name
shell: pwsh
run : |
Get-CIMInstance -Class Win32_Processor | Select-Object -Property Name
- name: checkout repository
uses: actions/checkout@v3
- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
- name: cache conda packages
id: conda-cache
uses: actions/cache/restore@v3
with:
path: C:/Miniconda/envs/test
key: conda:msvc
- name: install packages with conda
if: ${{ steps.conda-cache.outputs.cache-hit != 'true' }}
run: |
echo ${{ steps.conda-cache.outputs.cache-hit }}
conda info
conda list
conda install -y -c intel mkl-devel
conda install -y -c conda-forge --override-channels ccache
- name: save conda cache
if: ${{ steps.conda-cache.outputs.cache-hit != 'true' }}
uses: actions/cache/save@v3
with:
path: C:/Miniconda/envs/test
key: ${{ steps.conda-cache.outputs.cache-primary-key }}
- name: install libraries from MSYS2
uses: msys2/setup-msys2@v2
with:
update: true
# Use pre-installed version to save disc space on partition with source.
release: false
install: >-
mingw-w64-ucrt-x86_64-gmp
mingw-w64-ucrt-x86_64-mpfr
msystem: UCRT64
- name: setup build environment
# get packages from MSYS2
# Copy only relevant parts to avoid picking up headers and libraries
# that are thought for MinGW only.
run: |
mkdir -p ./dependencies/{bin,lib,include}
# GMP
cp C:/msys64/ucrt64/bin/libgmp*.dll ./dependencies/bin/
cp C:/msys64/ucrt64/include/gmp.h ./dependencies/include/
cp C:/msys64/ucrt64/lib/libgmp.dll.a ./dependencies/lib/gmp.lib
# MPFR
cp C:/msys64/ucrt64/bin/libmpfr*.dll ./dependencies/bin/
cp C:/msys64/ucrt64/include/mpf2mpfr.h ./dependencies/include/
cp C:/msys64/ucrt64/include/mpfr.h ./dependencies/include/
cp C:/msys64/ucrt64/lib/libmpfr.dll.a ./dependencies/lib/mpfr.lib
# run-time dependencies
cp C:/msys64/ucrt64/bin/libgcc_s_seh*.dll ./dependencies/bin/
cp C:/msys64/ucrt64/bin/libwinpthread*.dll ./dependencies/bin/
# create environment variable for easier access
echo "CCACHE=C:/Miniconda/envs/test/Library/bin/ccache.exe" >> ${GITHUB_ENV}
- name: prepare ccache
# create key with human readable timestamp
# used in action/cache/restore and action/cache/save steps
id: ccache-prepare
shell: msys2 {0}
run: |
echo "ccachedir=$(cygpath -m $(${CCACHE} -k cache_dir))" >> $GITHUB_OUTPUT
echo "key=ccache:msvc:root:${{ github.ref }}:$(date +"%Y-%m-%d_%H-%M-%S"):${{ github.sha }}" >> $GITHUB_OUTPUT
- name: restore ccache
# Setup the GitHub cache used to maintain the ccache from one job to the next
uses: actions/cache/restore@v3
with:
path: ${{ steps.ccache-prepare.outputs.ccachedir }}
key: ${{ steps.ccache-prepare.outputs.key }}
# Prefer caches from the same branch. Fall back to caches from the dev branch.
restore-keys: |
ccache:msvc:root:${{ github.ref }}
ccache:msvc:root:
- name: configure ccache
# Limit the maximum size and switch on compression to avoid exceeding the total disk or cache quota.
run: |
test -d ${{ steps.ccache-prepare.outputs.ccachedir }} || mkdir -p ${{ steps.ccache-prepare.outputs.ccachedir }}
echo "max_size = 250M" > ${{ steps.ccache-prepare.outputs.ccachedir }}/ccache.conf
echo "compression = true" >> ${{ steps.ccache-prepare.outputs.ccachedir }}/ccache.conf
${CCACHE} -p
${CCACHE} -s
- name: setup MSVC toolchain
uses: ilammy/msvc-dev-cmd@v1
- name: build libraries
run: |
printf "::group:: \033[0;32m==>\033[0m Configuring\n"
mkdir -p ${GITHUB_WORKSPACE}/build && cd ${GITHUB_WORKSPACE}/build
cmake -G"Ninja Multi-Config" \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_INSTALL_PREFIX=".." \
-DCMAKE_PREFIX_PATH="C:/Miniconda/envs/test/Library;${GITHUB_WORKSPACE}/dependencies" \
-DCMAKE_C_COMPILER_LAUNCHER="ccache" \
-DCMAKE_CXX_COMPILER_LAUNCHER="ccache" \
-DCMAKE_Fortran_COMPILER_LAUNCHER="ccache" \
-DNFORTRAN=ON \
-DBLA_VENDOR="All" \
..
echo "::endgroup::"
printf "::group:: \033[0;32m==>\033[0m Building\n"
cmake --build . --config Release
echo "::endgroup::"
# FIXME: Build and run tests and demos
- name: ccache status
continue-on-error: true
run: ${CCACHE} -s
- name: save ccache
# Save the cache after we are done (successfully) building
# This helps to retain the ccache even if the subsequent steps are failing.
uses: actions/cache/save@v3
with:
path: ${{ steps.ccache-prepare.outputs.ccachedir }}
key: ${{ steps.ccache-prepare.outputs.key }}
- name: install
run: |
printf "\033[0;32m==>\033[0m Installing libraries\n"
cd ${GITHUB_WORKSPACE}/build
cmake --install .
- name: build example
run: |
cd ${GITHUB_WORKSPACE}/Example/build
printf "::group::\033[0;32m==>\033[0m Configuring example\n"
cmake \
-DCMAKE_PREFIX_PATH="${GITHUB_WORKSPACE}/lib/cmake;C:/Miniconda/envs/test/Library;${GITHUB_WORKSPACE}/dependencies" \
-DBLA_VENDOR="All" \
${{ matrix.openmp-cmake-flags }} \
..
echo "::endgroup::"
printf "::group::\033[0;32m==>\033[0m Building example\n"
cmake --build . --config Release
echo "::endgroup::"
printf "::group::\033[0;32m==>\033[0m Executing example\n"
PATH="${GITHUB_WORKSPACE}/bin;${GITHUB_WORKSPACE}/dependencies/bin;${PATH}" ./Release/my_demo
echo "::endgroup::"