-
Notifications
You must be signed in to change notification settings - Fork 1
167 lines (139 loc) · 4.9 KB
/
ci-cpu.yaml
File metadata and controls
167 lines (139 loc) · 4.9 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
name: CI-CPU
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
on:
pull_request:
branches:
- main
workflow_dispatch: # Allow to start this workflow manually
jobs:
# Format check job - runs first and blocks everything else if it fails
format-check:
uses: ./.github/workflows/format-check.yaml
build:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
container:
image: ghcr.io/funtides-sim/funtides/funtides-env:latest
options: --user root
needs: format-check
strategy:
matrix:
pywrap: [pywrap-on, pywrap-off]
programming_model: [vector, kokkos]
exclude:
# Exclude Vector + Python (wrappers use Kokkos)
- programming_model: vector
pywrap: pywrap-on
max-parallel: 5
continue-on-error: true # We want to run other builds even if some build fails
steps:
- name: Get PR labels
id: pr-labels
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const { data: pullRequest } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
});
const labels = pullRequest.labels.map(label => label.name);
core.setOutput('labels', labels.join(','));
core.setOutput('has-sccache-off', labels.includes('SCCACHE_OFF') ? 'true' : 'false');
- name: Checkout
id: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Set up Python
if: matrix.pywrap == 'pywrap-on'
run: |
source /opt/tpl/tpl-venv/bin/activate
pip install --upgrade pip
pip install pybind11 pytest numpy
- name: Turn off sccache
if: steps.pr-labels.outputs.has-sccache-off == 'true'
run: echo "SCCACHE_OFF=true" >> $GITHUB_ENV
- name: Run sccache-cache
if: env.SCCACHE_OFF != 'true'
uses: mozilla-actions/sccache-action@v0.0.9
- name: Configure
id: configure
env:
SCCACHE_GHA_ENABLED: "true"
run: |
export PYWRAP=${{ matrix.pywrap }}
export PROGRAMMING_MODEL=${{ matrix.programming_model }}
# Extend CMAKE_FLAGS based on selections
# Discretization (build fd + sem)
CMAKE_FLAGS="-DCOMPILE_FD=ON -DCOMPILE_SEM=ON"
# Use sccache to speed up recompilation unless disabled
if [[ "$SCCACHE_OFF" != "true" ]]; then
export CMAKE_FLAGS="$CMAKE_FLAGS -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache"
fi
# Python bindings
if [[ "$PYWRAP" == "pywrap-on" ]]; then
CMAKE_FLAGS="$CMAKE_FLAGS -DENABLE_PYWRAP=ON"
export PYWRAP_SUMMARY=on
else
CMAKE_FLAGS="$CMAKE_FLAGS -DENABLE_PYWRAP=OFF"
export PYWRAP_SUMMARY=off
fi
# Programming model
if [[ "$PROGRAMMING_MODEL" == "vector" ]]; then
CMAKE_FLAGS="$CMAKE_FLAGS -DUSE_VECTOR=ON"
elif [[ "$PROGRAMMING_MODEL" == "kokkos" ]]; then
CMAKE_FLAGS="$CMAKE_FLAGS -DUSE_KOKKOS=ON"
fi
# Activate python venv if pywrap is on
if [[ "$PYWRAP" == "pywrap-on" ]]; then
source /opt/tpl/tpl-venv/bin/activate
fi
mkdir build
cd build
echo "cmake .. ${CMAKE_FLAGS}" # For debug
CC=gcc-13 CXX=g++-13 cmake .. ${CMAKE_FLAGS} -DCMAKE_INSTALL_PREFIX=../install
- name: Build
id: build
env:
SCCACHE_GHA_ENABLED: "true"
run: |
# Activate python venv if pywrap is on
if [[ "$PYWRAP" == "pywrap-on" ]]; then
source /opt/tpl/tpl-venv/bin/activate
fi
cd build
make -j$(nproc)
- name: Test
id: test
env:
OMP_NUM_THREADS: 2
OMP_THREAD_LIMIT: 2
KOKKOS_NUM_THREADS: 2
run: |
cd build
# Run tests without benchmarks and validation tests
ctest -LE "benchmark|validation" --output-on-failure
- name: Install
id: install
run: |
# Activate python venv if pywrap is on
if [[ "$PYWRAP" == "pywrap-on" ]]; then
source /opt/tpl/tpl-venv/bin/activate
fi
cd build
make install
- name: Run pytests
if: matrix.pywrap == 'pywrap-on'
run: |
source /opt/tpl/tpl-venv/bin/activate
export INSTALL_DIR=$(realpath ./install)
export PYTHONPATH=$PYTHONPATH:$INSTALL_DIR/python
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$INSTALL_DIR/lib
python -m pytest tests/units --kokkos-num-threads=2