Skip to content

Commit

Permalink
Rough first pass at nvhpc ci
Browse files Browse the repository at this point in the history
  • Loading branch information
ptheywood committed Jan 8, 2024
1 parent 2dcc513 commit 74debf7
Showing 1 changed file with 170 additions and 0 deletions.
170 changes: 170 additions & 0 deletions .github/workflows/NVHPC.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
# Build using nvhpc installs of CUDA, using containers so doesn't fit in the ubuntu workflow.
name: NVHPC

# Run on branch push events (i.e. not tag pushes) and on pull requests
on:
# Branch pushes that do not only modify other workflow files
push:
branches:
- '**'
paths:
- "**"
- "!.github/**"
- ".github/workflows/NVHPC.yml"
# Disabled for now. See https://github.com/FLAMEGPU/FLAMEGPU2/pull/644
# pull_request:
# Allow manual invocation.
workflow_dispatch:

defaults:
run:
shell: bash

# 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.
jobs:
build:
runs-on: ubuntu-latest
# Run steps inside a nvhpc container
container: ${{ matrix.cudacxx.container}}
strategy:
fail-fast: false
# Multiplicative build matrix
# optional exclude: can be partial, include: must be specific
matrix:
cudacxx:
- cuda: "12.3"
cuda_arch: "50"
hostcxx: nvhpc-23.11
os: ubuntu-22.04
container: nvcr.io/nvidia/nvhpc:23.11-devel-cuda12.3-ubuntu22.04
python:
- ""
# - "3.12"
config:
- name: "Release"
config: "Release"
SEATBELTS: "ON"
VISUALISATION:
# - "ON"
- "OFF"

# Name the job based on matrix/env options
name: "build (${{ matrix.cudacxx.hostcxx }}, ${{matrix.python}}, ${{ matrix.VISUALISATION }}, ${{ matrix.config.name }}, ${{ matrix.cudacxx.os }})"

env:
# Define constants
BUILD_DIR: "build"
FLAMEGPU_BUILD_TESTS: "OFF"
# Conditional based on matrix via awkward almost ternary
FLAMEGPU_BUILD_PYTHON: ${{ fromJSON('{true:"ON",false:"OFF"}')[matrix.python != ''] }}
# Port matrix options to environment, for more portability.
CUDA: ${{ matrix.cudacxx.cuda }}
CUDA_ARCH: ${{ matrix.cudacxx.cuda_arch }}
HOSTCXX: ${{ matrix.cudacxx.hostcxx }}
OS: ${{ matrix.cudacxx.os }}
CONFIG: ${{ matrix.config.config }}
FLAMEGPU_SEATBELTS: ${{ matrix.config.SEATBELTS }}
PYTHON: ${{ matrix.python}}
VISUALISATION: ${{ matrix.VISUALISATION }}

steps:
- uses: actions/checkout@v3

- name: Add custom problem matchers for annotations
run: echo "::add-matcher::.github/problem-matchers.json"

- name: Select Python
if: ${{ env.PYTHON != '' && env.FLAMEGPU_BUILD_PYTHON == 'ON' }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON }}

# @todo - is some/all of this still required when using select Python?
- name: Install python dependencies
if: ${{ env.PYTHON != '' && env.FLAMEGPU_BUILD_PYTHON == 'ON' }}
run: |
sudo apt-get install python3-venv
python3 -m pip install --upgrade wheel build setuptools
- name: Install Visualisation Dependencies
if: ${{ startswith(env.OS, 'ubuntu') && env.VISUALISATION == 'ON' }}
run: |
# Install ubuntu-20.04 packages
if [ "$OS" == 'ubuntu-22.04' ]; then
sudo apt-get install -y libglew-dev libfontconfig1-dev libsdl2-dev libdevil-dev libfreetype-dev
fi
if [ "$OS" == 'ubuntu-20.04' ]; then
sudo apt-get install -y libglew-dev libfontconfig1-dev libsdl2-dev libdevil-dev libfreetype-dev
fi
# Install Ubuntu 18.04 packages
if [ "$OS" == 'ubuntu-18.04' ]; then
sudo apt-get install -y libglew-dev libfontconfig1-dev libsdl2-dev libdevil-dev libfreetype6-dev libgl1-mesa-dev
fi
- name: Install Swig >= 4.0.2
run: |
# Remove existing swig install, so CMake finds the correct swig
if [ "$OS" == 'ubuntu-20.04' ]; then
sudo apt-get remove -y swig swig4.0
fi
# Install Ubuntu 18.04 packages
if [ "$OS" == 'ubuntu-18.04' ]; then
sudo apt-get remove -y swig
fi
# Install additional apt-based dependencies required to build swig 4.0.2
sudo apt-get install -y bison
# Create a local directory to build swig in.
mkdir -p swig-from-source && cd swig-from-source
# Install SWIG building from source dependencies
wget https://github.com/swig/swig/archive/refs/tags/v4.0.2.tar.gz
tar -zxf v4.0.2.tar.gz
cd swig-4.0.2/
./autogen.sh
./configure
make
sudo make install
- name: Configure cmake
run: >
cmake . -B "${{ env.BUILD_DIR }}"
-DCMAKE_BUILD_TYPE="${{ env.CONFIG }}"
-Werror=dev
-DCMAKE_WARN_DEPRECATED="OFF"
-DFLAMEGPU_WARNINGS_AS_ERRORS="ON"
-DCMAKE_CUDA_ARCHITECTURES="${{ env.CUDA_ARCH }}"
-DFLAMEGPU_BUILD_TESTS="${{ env.FLAMEGPU_BUILD_TESTS }}"
-DFLAMEGPU_BUILD_PYTHON="${{ env.FLAMEGPU_BUILD_PYTHON }}"
-DPYTHON3_EXACT_VERSION="${{ env.PYTHON }}"
-DFLAMEGPU_VISUALISATION="${{ env.VISUALISATION }}"
-DFLAMEGPU_ENABLE_NVTX="ON"
- name: Build static library
working-directory: ${{ env.BUILD_DIR }}
run: cmake --build . --target flamegpu --verbose -j `nproc`


- name: Build python wheel
if: ${{ env.FLAMEGPU_BUILD_PYTHON == 'ON' }}
working-directory: ${{ env.BUILD_DIR }}
run: cmake --build . --target pyflamegpu --verbose -j `nproc`

- name: Build tests
if: ${{ env.FLAMEGPU_BUILD_TESTS == 'ON' }}
working-directory: ${{ env.BUILD_DIR }}
run: cmake --build . --target tests --verbose -j `nproc`

- name: Build all remaining targets
working-directory: ${{ env.BUILD_DIR }}
run: cmake --build . --target all --verbose -j `nproc`

# Upload wheel artifacts to the job on GHA, with a short retention
# 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)
# - name: Upload Wheel Artifacts
# if: ${{env.FLAMEGPU_BUILD_PYTHON == 'ON' }}
# uses: actions/upload-artifact@v3
# with:
# name: ${{ env.ARTIFACT_NAME }}
# path: ${{ env.BUILD_DIR }}/lib/${{ env.CONFIG }}/python/dist/*.whl
# if-no-files-found: error
# retention-days: 5

0 comments on commit 74debf7

Please sign in to comment.