Skip to content

Commit 74debf7

Browse files
committed
Rough first pass at nvhpc ci
1 parent 2dcc513 commit 74debf7

1 file changed

Lines changed: 170 additions & 0 deletions

File tree

.github/workflows/NVHPC.yml

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
# Build using nvhpc installs of CUDA, using containers so doesn't fit in the ubuntu workflow.
2+
name: NVHPC
3+
4+
# Run on branch push events (i.e. not tag pushes) and on pull requests
5+
on:
6+
# Branch pushes that do not only modify other workflow files
7+
push:
8+
branches:
9+
- '**'
10+
paths:
11+
- "**"
12+
- "!.github/**"
13+
- ".github/workflows/NVHPC.yml"
14+
# Disabled for now. See https://github.com/FLAMEGPU/FLAMEGPU2/pull/644
15+
# pull_request:
16+
# Allow manual invocation.
17+
workflow_dispatch:
18+
19+
defaults:
20+
run:
21+
shell: bash
22+
23+
# A single job, which builds manylinux2014 wheels, which ships with GCC 10.2.1 at the time of writing. If this bumps to unpatched 10.3 we might have issues w/ cuda.
24+
jobs:
25+
build:
26+
runs-on: ubuntu-latest
27+
# Run steps inside a nvhpc container
28+
container: ${{ matrix.cudacxx.container}}
29+
strategy:
30+
fail-fast: false
31+
# Multiplicative build matrix
32+
# optional exclude: can be partial, include: must be specific
33+
matrix:
34+
cudacxx:
35+
- cuda: "12.3"
36+
cuda_arch: "50"
37+
hostcxx: nvhpc-23.11
38+
os: ubuntu-22.04
39+
container: nvcr.io/nvidia/nvhpc:23.11-devel-cuda12.3-ubuntu22.04
40+
python:
41+
- ""
42+
# - "3.12"
43+
config:
44+
- name: "Release"
45+
config: "Release"
46+
SEATBELTS: "ON"
47+
VISUALISATION:
48+
# - "ON"
49+
- "OFF"
50+
51+
# Name the job based on matrix/env options
52+
name: "build (${{ matrix.cudacxx.hostcxx }}, ${{matrix.python}}, ${{ matrix.VISUALISATION }}, ${{ matrix.config.name }}, ${{ matrix.cudacxx.os }})"
53+
54+
env:
55+
# Define constants
56+
BUILD_DIR: "build"
57+
FLAMEGPU_BUILD_TESTS: "OFF"
58+
# Conditional based on matrix via awkward almost ternary
59+
FLAMEGPU_BUILD_PYTHON: ${{ fromJSON('{true:"ON",false:"OFF"}')[matrix.python != ''] }}
60+
# Port matrix options to environment, for more portability.
61+
CUDA: ${{ matrix.cudacxx.cuda }}
62+
CUDA_ARCH: ${{ matrix.cudacxx.cuda_arch }}
63+
HOSTCXX: ${{ matrix.cudacxx.hostcxx }}
64+
OS: ${{ matrix.cudacxx.os }}
65+
CONFIG: ${{ matrix.config.config }}
66+
FLAMEGPU_SEATBELTS: ${{ matrix.config.SEATBELTS }}
67+
PYTHON: ${{ matrix.python}}
68+
VISUALISATION: ${{ matrix.VISUALISATION }}
69+
70+
steps:
71+
- uses: actions/checkout@v3
72+
73+
- name: Add custom problem matchers for annotations
74+
run: echo "::add-matcher::.github/problem-matchers.json"
75+
76+
- name: Select Python
77+
if: ${{ env.PYTHON != '' && env.FLAMEGPU_BUILD_PYTHON == 'ON' }}
78+
uses: actions/setup-python@v4
79+
with:
80+
python-version: ${{ env.PYTHON }}
81+
82+
# @todo - is some/all of this still required when using select Python?
83+
- name: Install python dependencies
84+
if: ${{ env.PYTHON != '' && env.FLAMEGPU_BUILD_PYTHON == 'ON' }}
85+
run: |
86+
sudo apt-get install python3-venv
87+
python3 -m pip install --upgrade wheel build setuptools
88+
89+
- name: Install Visualisation Dependencies
90+
if: ${{ startswith(env.OS, 'ubuntu') && env.VISUALISATION == 'ON' }}
91+
run: |
92+
# Install ubuntu-20.04 packages
93+
if [ "$OS" == 'ubuntu-22.04' ]; then
94+
sudo apt-get install -y libglew-dev libfontconfig1-dev libsdl2-dev libdevil-dev libfreetype-dev
95+
fi
96+
if [ "$OS" == 'ubuntu-20.04' ]; then
97+
sudo apt-get install -y libglew-dev libfontconfig1-dev libsdl2-dev libdevil-dev libfreetype-dev
98+
fi
99+
# Install Ubuntu 18.04 packages
100+
if [ "$OS" == 'ubuntu-18.04' ]; then
101+
sudo apt-get install -y libglew-dev libfontconfig1-dev libsdl2-dev libdevil-dev libfreetype6-dev libgl1-mesa-dev
102+
fi
103+
104+
- name: Install Swig >= 4.0.2
105+
run: |
106+
# Remove existing swig install, so CMake finds the correct swig
107+
if [ "$OS" == 'ubuntu-20.04' ]; then
108+
sudo apt-get remove -y swig swig4.0
109+
fi
110+
# Install Ubuntu 18.04 packages
111+
if [ "$OS" == 'ubuntu-18.04' ]; then
112+
sudo apt-get remove -y swig
113+
fi
114+
# Install additional apt-based dependencies required to build swig 4.0.2
115+
sudo apt-get install -y bison
116+
# Create a local directory to build swig in.
117+
mkdir -p swig-from-source && cd swig-from-source
118+
# Install SWIG building from source dependencies
119+
wget https://github.com/swig/swig/archive/refs/tags/v4.0.2.tar.gz
120+
tar -zxf v4.0.2.tar.gz
121+
cd swig-4.0.2/
122+
./autogen.sh
123+
./configure
124+
make
125+
sudo make install
126+
127+
128+
- name: Configure cmake
129+
run: >
130+
cmake . -B "${{ env.BUILD_DIR }}"
131+
-DCMAKE_BUILD_TYPE="${{ env.CONFIG }}"
132+
-Werror=dev
133+
-DCMAKE_WARN_DEPRECATED="OFF"
134+
-DFLAMEGPU_WARNINGS_AS_ERRORS="ON"
135+
-DCMAKE_CUDA_ARCHITECTURES="${{ env.CUDA_ARCH }}"
136+
-DFLAMEGPU_BUILD_TESTS="${{ env.FLAMEGPU_BUILD_TESTS }}"
137+
-DFLAMEGPU_BUILD_PYTHON="${{ env.FLAMEGPU_BUILD_PYTHON }}"
138+
-DPYTHON3_EXACT_VERSION="${{ env.PYTHON }}"
139+
-DFLAMEGPU_VISUALISATION="${{ env.VISUALISATION }}"
140+
-DFLAMEGPU_ENABLE_NVTX="ON"
141+
142+
- name: Build static library
143+
working-directory: ${{ env.BUILD_DIR }}
144+
run: cmake --build . --target flamegpu --verbose -j `nproc`
145+
146+
147+
- name: Build python wheel
148+
if: ${{ env.FLAMEGPU_BUILD_PYTHON == 'ON' }}
149+
working-directory: ${{ env.BUILD_DIR }}
150+
run: cmake --build . --target pyflamegpu --verbose -j `nproc`
151+
152+
- name: Build tests
153+
if: ${{ env.FLAMEGPU_BUILD_TESTS == 'ON' }}
154+
working-directory: ${{ env.BUILD_DIR }}
155+
run: cmake --build . --target tests --verbose -j `nproc`
156+
157+
- name: Build all remaining targets
158+
working-directory: ${{ env.BUILD_DIR }}
159+
run: cmake --build . --target all --verbose -j `nproc`
160+
161+
# Upload wheel artifacts to the job on GHA, with a short retention
162+
# Use a unique name per job matrix run, to avoid a risk of corruption according to the docs (although it should work with unique filenames)
163+
# - name: Upload Wheel Artifacts
164+
# if: ${{env.FLAMEGPU_BUILD_PYTHON == 'ON' }}
165+
# uses: actions/upload-artifact@v3
166+
# with:
167+
# name: ${{ env.ARTIFACT_NAME }}
168+
# path: ${{ env.BUILD_DIR }}/lib/${{ env.CONFIG }}/python/dist/*.whl
169+
# if-no-files-found: error
170+
# retention-days: 5

0 commit comments

Comments
 (0)