forked from QuEST-Kit/QuEST
-
Notifications
You must be signed in to change notification settings - Fork 0
285 lines (251 loc) · 9.68 KB
/
Copy pathcompile.yml
File metadata and controls
285 lines (251 loc) · 9.68 KB
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
# Tests for successful compilation of the source
# code with (attemptedly) all possible configurations
# of operating system, precision, multithreading,
# distribution, GPU-acceleration (via CUDA or HIP),
# and cuQuantum (else custom kernels). Compilation
# includes the v4 unit and integration tests, the
# deprecated v3 tests (when possible), and all the
# example programs. All 'isolated' example executables
# are then run (both C and C++ versions) to ensure the
# build was successful and does not cause link-time
# errors. Then, all 'automated' examples are run which
# permits contributors to demo or test their changes
# across all operation systems and compilers.
#
# Note:
# - This workflow currently wastefully re-downloads and
# installs all needed compilers (like libomp, CUDA, ROCm)
# - ARM compilation is not tested here, though it is used
# by the paid multithreaded CI tests.
#
# @author Tyson Jones
name: compile
on:
push:
branches:
- main
- devel
pull_request:
branches:
- main
- devel
jobs:
# test only compilation succeeds (no execution)
build-test:
name: >
${{ matrix.os == 'ubuntu-latest' && 'Linux' || matrix.os == 'macos-latest' && 'MacOS' || 'Windows' }}
[${{ matrix.precision }}]
${{ matrix.omp == 'ON' && 'OMP' || '' }}
${{ matrix.mpi == 'ON' && 'MPI' || '' }}
${{ matrix.mpi == 'ON' && format('({0})',matrix.mpilib) || '' }}
${{ matrix.cuda == 'ON' && 'CUDA' || '' }}
${{ matrix.hip == 'ON' && 'HIP' || '' }}
${{ matrix.cuquantum == 'ON' && 'CUQ' || '' }}
runs-on: ${{ matrix.os }}
strategy:
# continue other jobs if any fail
fail-fast: false
# limit concurrent jobs to avoid running out of disk
# (causes CUDA and MPI installation to fail on Windows)
max-parallel: 8
# compile QuEST with all combinations of below flags
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
precision: [1, 2, 4]
omp: [ON, OFF]
mpi: [ON, OFF]
cuda: [ON, OFF]
hip: [ON, OFF]
cuquantum: [ON, OFF]
mpilib: ['', 'mpich', 'ompi', 'impi', 'msmpi']
# disable deprecated API on MSVC, and assign unique compilers,
# so that we can concisely consult e.g. matrix.compiler=='cl'
# instead of hardcoding the operating system label. Note that
# ultimately env.compiler, not matrix.compiler, will be set/used
include:
- os: ubuntu-latest
compiler: g++
deprecated: ON
- os: macos-latest
compiler: clang++
deprecated: ON
- os: windows-latest
compiler: cl
deprecated: OFF
exclude:
# cannot simultaneously use CUDA and HIP
- cuda: ON
hip: ON
# cannot use GPU with quad-precision
- cuda: ON
precision: 4
- hip: ON
precision: 4
# cannot use cuquantum without CUDA
- cuda: OFF
cuquantum: ON
# cannot use GPU on MacOS
- cuda: ON
os: macos-latest
- hip: ON
os: macos-latest
# cannot use cuquantum on Windows or MacOS
- cuquantum: ON
os: windows-latest
- cuquantum: ON
os: macos-latest
# don't enumerate MPI libraries when not using MPI
- mpi: OFF
mpilib: 'mpich' # MPICH
- mpi: OFF
mpilib: 'ompi' # OpenMPI
- mpi: OFF
mpilib: 'impi' # Intel MPI
- mpi: OFF
mpilib: 'msmpi' # Microsoft MPI
- mpi: ON
mpilib: '' # must pick lib when using MPI
# exclude OS-incompatible MPI libraries
- os: ubuntu-latest
mpilib: 'msmpi' # Linux: [MPICH, OpenMPI, Intel MPI]
- os: macos-latest
mpilib: 'msmpi' # MacOS: [MPICH, OpenMPI]
- os: macos-latest
mpilib: 'impi'
- os: windows-latest
mpilib: 'mpich' # Windows: [Intel MPI, MS MPI]
- os: windows-latest
mpilib: 'ompi'
# cannot presently install HIP on Windows CI (times out)
- hip: ON
os: windows-latest
# cannot presently compile HIP + MPI; the linker fails with
# "undefined reference to 'vtable for thrust::system::system_error'
# (see failed attempted solutions in PR #554)
- hip: ON
mpi: ON
# constants
env:
cuda_arch: 70
hip_arch: gfx801
rocm_path: /opt/rocm/bin
build_dir: build
isolated_dir: build/examples/isolated
automated_dir: build/examples/automated
# perform the job
steps:
# free space for big-chungus ROCm compiler
- name: Free disk space
if: ${{ matrix.hip == 'ON' }}
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
# download QuEST
- name: Get QuEST
uses: actions/checkout@main
# obtain OMP for Clang multithreading
- name: Setup libomp
if: ${{ matrix.compiler == 'clang++' && matrix.omp == 'ON' }}
run: >
brew install libomp;
echo "OpenMP_ROOT=$(brew --prefix)/opt/libomp" >> $GITHUB_ENV
# obtain MPI for distribution
- name: Setup MPI
if: ${{ matrix.mpi == 'ON' }}
uses: mpi4py/setup-mpi@v1
with:
mpi: ${{ matrix.mpilib }}
# obtain CUDA for GPU acceleration (cuQuantum needs cuBLAS)
- name: Setup CUDA (non-MSVC)
if: ${{ matrix.cuda == 'ON' && matrix.compiler != 'cl' }}
uses: Jimver/cuda-toolkit@v0.2.21
with:
method: network
sub-packages: '["nvcc", "cudart", "thrust"]'
non-cuda-sub-packages: ${{ matrix.cuquantum == 'ON' && '["libcublas"]' || '[]' }}
# bug in Nsight for MSVC breaks above action for windows-2022, so we revert to script
- name: Setup CUDA (MSVC)
if: ${{ matrix.cuda == 'ON' && matrix.compiler == 'cl' }}
shell: pwsh
run: .github/scripts/setup_cuda.ps1
env:
INPUT_CUDA_VERSION: 12.5.0
# obtain cuQuantum on linux
- name: Setup cuQuantum
if: ${{ matrix.cuquantum == 'ON' }}
run: >
wget https://developer.download.nvidia.com/compute/cuquantum/redist/cuquantum/linux-x86_64/cuquantum-linux-x86_64-24.08.0.5_cuda12-archive.tar.xz;
tar -xvf cuquantum-linux-x86_64-24.08.0.5_cuda12-archive.tar.xz;
echo "CUQUANTUM_ROOT=cuquantum-linux-x86_64-24.08.0.5_cuda12-archive" >> $GITHUB_ENV
# obtain ROCm for HIP acceleration on Linux
- name: Install ROCm
if: ${{ matrix.hip == 'ON' }}
run: |
sudo apt install "linux-headers-$(uname -r)" "linux-modules-extra-$(uname -r)"
sudo apt install python3-setuptools python3-wheel
sudo usermod -a -G render,video $USER
wget https://repo.radeon.com/amdgpu-install/6.3.3/ubuntu/noble/amdgpu-install_6.3.60303-1_all.deb
sudo apt install ./amdgpu-install_6.3.60303-1_all.deb
sudo apt update
sudo apt install amdgpu-dkms rocm
echo "${{ env.rocm_path }}" >> $GITHUB_PATH
# invoke cmake, disabling LTO (it duplicates symbols with CUDA + MPI)
- name: Configure CMake
run: >
cmake -B ${{ env.build_dir }}
-DBUILD_EXAMPLES=ON
-DENABLE_TESTING=ON
-DFLOAT_PRECISION=${{ matrix.precision }}
-DENABLE_DEPRECATED_API=${{ matrix.deprecated }}
-DDISABLE_DEPRECATION_WARNINGS=${{ matrix.deprecated }}
-DENABLE_MULTITHREADING=${{ matrix.omp }}
-DENABLE_DISTRIBUTION=${{ matrix.mpi }}
-DENABLE_CUDA=${{ matrix.cuda }}
-DENABLE_HIP=${{ matrix.hip }}
-DENABLE_CUQUANTUM=${{ matrix.cuquantum }}
-DCMAKE_CUDA_ARCHITECTURES=${{ env.cuda_arch }}
-DCMAKE_HIP_ARCHITECTURES=${{ env.hip_arch }}
-DCMAKE_CXX_COMPILER=${{ matrix.compiler }}
-DCMAKE_CXX_FLAGS=${{ matrix.mpi == 'ON' && matrix.cuda == 'ON' && '-fno-lto' || '' }}
# force 'Release' build (needed by MSVC to enable optimisations)
- name: Compile
run: cmake --build ${{ env.build_dir }} --config Release --parallel
# run all compiled isolated examples to test for link-time errors,
# continuing if any fail (since some deliberately fail)
- name: Run isolated examples (Windows)
if: ${{ matrix.os == 'windows-latest' }}
working-directory: ${{ env.isolated_dir }}/Release/
shell: pwsh
run: |
Get-ChildItem -Filter '*.exe' -File |
ForEach-Object {
Write-Host "`r`n[[[ $($_.Name) ]]]`r`n"
& $_.FullName
}
- name: Run isolated examples (Unix)
if: ${{ matrix.os != 'windows-latest' }}
working-directory: ${{ env.isolated_dir }}
run: |
for fn in *_c *_cpp; do
printf "\n[[[ $fn ]]]\n"
./$fn || true
done
# run all compiled 'automated' examples
- name: Run automated examples (Windows)
if: ${{ matrix.os == 'windows-latest' }}
working-directory: ${{ env.automated_dir }}/Release/
shell: pwsh
run: |
Get-ChildItem -Filter '*.exe' -File |
ForEach-Object {
Write-Host "`r`n[[[ $($_.Name) ]]]`r`n"
& $_.FullName
}
- name: Run automated examples (Unix)
if: ${{ matrix.os != 'windows-latest' }}
working-directory: ${{ env.automated_dir }}
run: |
for fn in *_c *_cpp; do
printf "\n[[[ $fn ]]]\n"
./$fn || true
done