-
Notifications
You must be signed in to change notification settings - Fork 3
202 lines (178 loc) · 9.17 KB
/
run-tests.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
---
name: Cross-platform tests
# Do this on every push that isn't tagged
on:
push:
tags-ignore:
- '**'
branches:
- '**'
pull_request:
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
RUSTFLAGS: -C target-cpu=native
DEBIAN_FRONTEND: noninteractive
MWA_BEAM_FILE: mwa_full_embedded_element_pattern.h5
jobs:
test:
name: Test ${{matrix.os}} Rust ${{matrix.rust.ver}} ex ${{matrix.rust.examples}}
runs-on: ${{matrix.os}}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-22.04
- macos-13
- macos-14
- ubuntu-22.04-arm
rust:
- ver: nightly
examples: false
- ver: beta
examples: false
- ver: stable
examples: true
- ver: "1.80.0" # MSRV
examples: false
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: (macos) install dependencies
if: ${{ startsWith(matrix.os, 'macos') }}
run: |
brew install automake autoconf pkg-config hdf5@1.10
- name: (ubuntu) install dependencies
if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: |
sudo apt -y update
sudo apt -y install libhdf5-dev gcc pkg-config python3{,-pip,-venv} curl wget git jq
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{matrix.rust.ver}}
profile: minimal
override: true
components: rustfmt, clippy
- name: Run cargo check, fmt, clippy
run: |
cargo check --all
cargo fmt --all -- --check
cargo clippy --all -- -D warnings
- name: No GPU references in CPU-only header
run: |
! grep -i gpu include/mwa_hyperbeam.h
- name: Get the HDF5 file
run: curl http://ws.mwatelescope.org/static/mwa_full_embedded_element_pattern.h5 -o mwa_full_embedded_element_pattern.h5
# Taken from https://github.com/dtolnay/thiserror/blob/a2d1ed1ccfc2a5dbb2a8fb45d4f938175a28bc86/.github/workflows/ci.yml
- name: Enable type layout randomization
run: echo RUSTFLAGS=${RUSTFLAGS}\ -Zrandomize-layout >> $GITHUB_ENV
if: ${{ matrix.rust.ver == 'nightly' }}
- name: Run tests (dynamic)
run: cargo test
- name: Run tests (static)
run: cargo test --features=all-static
- name: Setup example environment
if: ${{ matrix.rust.examples }} # only run examples on stable
run: |
echo LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${PWD}/target/debug/ >> $GITHUB_ENV
which gcc || true
which gcc-12 || true
which gcc-13 || true
if [ "$RUNNER_OS" == "Linux" ]; then
echo CC=gcc >> $GITHUB_ENV
else
echo CC=gcc-12 >> $GITHUB_ENV
fi
- name: Run Rust example
if: ${{ matrix.rust.examples }} # only run examples on stable
run: cargo run --example fee 10
- name: Run C examples
if: ${{ matrix.rust.examples }} # only run examples on stable
run: |
cargo build
echo "*** Compiling C examples ***"
# The macOS runner has clang symlinked as gcc, and attempting to alias
# gcc as /usr/local/bin/gcc doesn't work! Why???
$CC -O3 examples/fee.c -o fee -I ./include/ -L ./target/debug/ -l mwa_hyperbeam
$CC -O3 examples/fee_parallel.c -o fee_parallel -I ./include/ -L ./target/debug/ -l mwa_hyperbeam
$CC -O3 -fopenmp examples/fee_parallel_omp.c -o fee_parallel_omp -I ./include/ -L ./target/debug/ -l mwa_hyperbeam
$CC -O3 examples/fee_get_freqs.c -o fee_get_freqs -I ./include/ -L ./target/debug/ -l mwa_hyperbeam
$CC -O3 examples/analytic.c -o analytic -I ./include/ -L ./target/debug/ -l mwa_hyperbeam
$CC -O3 examples/analytic_parallel.c -o analytic_parallel -I ./include/ -L ./target/debug/ -l mwa_hyperbeam
echo "*** Running C examples ***"
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/debug/ ./fee mwa_full_embedded_element_pattern.h5
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/debug/ ./fee_parallel mwa_full_embedded_element_pattern.h5
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/debug/ ./fee_parallel_omp mwa_full_embedded_element_pattern.h5
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/debug/ ./fee_get_freqs mwa_full_embedded_element_pattern.h5
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/debug/ ./analytic
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/debug/ ./analytic_parallel
- name: (ubuntu) Run Python tests
if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: cargo test --features=python
- name: Run Python example
if: ${{ matrix.rust.examples }} # only run examples on stable
run: |
python3 -m venv venv
. ./venv/bin/activate
pip install numpy maturin
echo "*** Compiling Python hyperbeam ***"
maturin develop -b pyo3 --features=python
echo "*** Running Python examples ***"
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/debug/ ./examples/fee.py mwa_full_embedded_element_pattern.h5
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/debug/ ./examples/analytic.py
- name: (ubuntu) install CUDA
if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: |
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb
sudo apt -y update
sudo apt -y install cuda-nvcc-12-6 --no-install-recommends
echo PATH=${PATH}:/usr/local/cuda/bin >> $GITHUB_ENV
- name: (ubuntu) CUDA smoke tests
if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: |
# Can't run the tests; there's no GPU
cargo test --all --no-run --features=cuda
cargo test --all --no-run --features=cuda,gpu-single
cargo test --all --no-run --features=python,cuda
cargo test --all --no-run --features=python,cuda,gpu-single
- name: (ubuntu) CUDA examples
if: ${{ startsWith(matrix.os, 'ubuntu') && matrix.rust.examples }}
run: |
# Examples may fail because there's no GPU
cargo build --features=cuda --example fee_cuda
./target/debug/examples/fee_cuda 10 || true
cargo build --features=cuda --example analytic_cuda
./target/debug/examples/analytic_cuda 10 || true
cargo build --features=cuda,gpu-single --example fee_cuda
./target/debug/examples/fee_cuda 10 || true
cargo build --features=cuda,gpu-single --example analytic_cuda
./target/debug/examples/analytic_cuda 10 || true
cargo build --release --features=cuda
$CC -O3 examples/fee_gpu.c -o fee_cuda -I ./include/ -L ./target/release/ -l mwa_hyperbeam
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release/ ./fee_cuda mwa_full_embedded_element_pattern.h5 || true
nvcc -O3 examples/fee_cuda_device.cu -o fee_cuda_device -I ./include/ -L ./target/release/ -l mwa_hyperbeam
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release ./fee_cuda_device mwa_full_embedded_element_pattern.h5 || true
$CC -O3 examples/analytic_gpu.c -o analytic_cuda -I ./include/ -L ./target/release/ -l mwa_hyperbeam
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release/ ./analytic_cuda || true
nvcc -O3 examples/analytic_cuda_device.cu -o analytic_cuda_device -I ./include/ -L ./target/release/ -l mwa_hyperbeam
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release ./analytic_cuda_device || true
cargo build --release --features=cuda,gpu-single
$CC -O3 -D SINGLE examples/fee_gpu.c -o fee_cuda -I ./include/ -L ./target/release/ -l mwa_hyperbeam
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release/ ./fee_cuda mwa_full_embedded_element_pattern.h5 || true
nvcc -O3 -D SINGLE examples/fee_cuda_device.cu -o fee_cuda_device -I ./include/ -L ./target/release/ -l mwa_hyperbeam
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release ./fee_cuda_device mwa_full_embedded_element_pattern.h5 || true
$CC -O3 -D SINGLE examples/analytic_gpu.c -o analytic_cuda -I ./include/ -L ./target/release/ -l mwa_hyperbeam
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release/ ./analytic_cuda || true
nvcc -O3 -D SINGLE examples/analytic_cuda_device.cu -o analytic_cuda_device -I ./include/ -L ./target/release/ -l mwa_hyperbeam
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release ./analytic_cuda_device || true
. ./venv/bin/activate
maturin develop -b pyo3 --features=python,cuda
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release/ ./examples/fee_gpu.py mwa_full_embedded_element_pattern.h5 || true
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release/ ./examples/analytic_gpu.py || true
maturin develop -b pyo3 --features=python,cuda,gpu-single
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release/ ./examples/fee_gpu.py mwa_full_embedded_element_pattern.h5 || true
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release/ ./examples/analytic_gpu.py || true