Skip to content

Commit 763fe6b

Browse files
committed
adding tests in CI
1 parent 3350bde commit 763fe6b

File tree

4 files changed

+36
-8
lines changed

4 files changed

+36
-8
lines changed

.github/workflows/build_cuda.yml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#TODO: Fix and then move this as matrix arch into build.yml and
2+
13
name: Install and test Firedrake (CUDA)
24

35
on:
@@ -24,11 +26,18 @@ jobs:
2426
arch: [default]
2527
runs-on: [self-hosted, Linux]
2628
container:
27-
image: firedrakeproject/firedrake-env:latest
29+
image: nvidia/cuda:12.8.1-cudnn-devel-ubuntu24.04
30+
options: --gpus all
2831
env:
2932
FIREDRAKE_CI: 1
3033
OMP_NUM_THREADS: 1
3134
steps:
35+
- name: Fix HOME
36+
# For unknown reasons GitHub actions overwrite HOME to /github/home
37+
# which will break everything unless fixed
38+
# (https://github.com/actions/runner/issues/863)
39+
run: echo "HOME=/root" >> "$GITHUB_ENV"
40+
3241
- name: Pre-run cleanup
3342
# Make sure the current directory is empty
3443
run: find . -delete
@@ -39,8 +48,12 @@ jobs:
3948

4049
- name: Install system dependencies
4150
run: |
42-
sudo apt-get update
43-
sudo apt-get -y install \
51+
apt-get update
52+
apt-get install -y curl
53+
apt-get install -y git
54+
apt-get install -y python3
55+
apt install -y python3.12-venv
56+
apt-get -y install \
4457
$(python3 ./firedrake-repo/scripts/firedrake-configure --arch ${{ matrix.arch }} --show-system-packages)
4558
4659
- name: Install PETSc
@@ -49,16 +62,16 @@ jobs:
4962
cd petsc
5063
# TODO update configure file
5164
./configure --with-make-np=12 --with-c2html=0 --with-debugging=0 --with-fortran-bindings=0 --with-shared-libraries=1 --with-strict-petscerrorcode PETSC_ARCH=arch-firedrake-default --COPTFLAGS=-O3 -march=native -mtune=native --CXXOPTFLAGS=-O3 -march=native -mtune=native --FOPTFLAGS=-O3 -march=native -mtune=native --download-bison --download-fftw --download-hdf5 --download-hwloc --download-metis --download-mumps --download-netcdf --download-pnetcdf --download-ptscotch --download-scalapack --download-suitesparse --download-superlu_dist --download-zlib --download-hypre --with-cuda --with-cuda-dir=/usr/local/cuda CUDAPPFLAGS=-Wno-deprecated-gpu-targets --download-openmpi
52-
make
65+
make PETSC_DIR=/__w/firedrake/firedrake/petsc PETSC_ARCH=arch-firedrake-default all
5366
# TODO: This fails for some reason
54-
# make check
67+
make PETSC_DIR=/__w/firedrake/firedrake/petsc PETSC_ARCH=arch-firedrake-default check MPIEXEC="mpiexec --allow-run-as-root"
5568
5669
- name: Install Firedrake
5770
id: install
5871
run: |
5972
# TODO update configure file for the exports
6073
# export $(python3 ./firedrake-repo/scripts/firedrake-configure --arch ${{ matrix.arch }} --show-env)
61-
export PETSC_DIR=./petsc
74+
export PETSC_DIR=/__w/firedrake/firedrake/petsc
6275
export PETSC_ARCH=arch-firedrake-default
6376
export MPI_HOME=$PETSC_DIR/$PETSC_ARCH
6477
export CC=$PETSC_DIR/$PETSC_ARCH/bin/mpicc

tests/firedrake/conftest.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
os.environ["FIREDRAKE_DISABLE_OPTIONS_LEFT"] = "1"
88

99
import pytest
10-
from firedrake.petsc import PETSc, get_external_packages
10+
from firedrake.petsc import PETSc, get_external_packages, get_petsc_variables
1111

1212

1313
def _skip_test_dependency(dependency):
@@ -145,11 +145,21 @@ def pytest_configure(config):
145145
"markers",
146146
"skipnetgen: mark as skipped if netgen and ngsPETSc is not installed"
147147
)
148+
config.addinivalue_line(
149+
"markers",
150+
"skipcuda: mark as skipped if CUDA is not available"
151+
)
148152

149153

150154
def pytest_collection_modifyitems(session, config, items):
151155
from firedrake.utils import complex_mode, SLATE_SUPPORTS_COMPLEX
152156

157+
try:
158+
get_petsc_variables()["CUDA_VERSION"]
159+
cuda_unavailable = False
160+
except:
161+
cuda_unavailable = True
162+
153163
for item in items:
154164
if complex_mode:
155165
if item.get_closest_marker("skipcomplex") is not None:
@@ -160,6 +170,10 @@ def pytest_collection_modifyitems(session, config, items):
160170
if item.get_closest_marker("skipreal") is not None:
161171
item.add_marker(pytest.mark.skip(reason="Test makes no sense unless in complex mode"))
162172

173+
if cuda_unavailable:
174+
if item.get_closest_marker("skipcuda") is not None:
175+
item.add_marker(pytest.mark.skip(reason="CUDA not available"))
176+
163177
for dep, marker, reason in dependency_skip_markers_and_reasons:
164178
if _skip_test_dependency(dep) and item.get_closest_marker(marker) is not None:
165179
item.add_marker(pytest.mark.skip(reason))

tests/firedrake/cuda/test_poisson_offloading_pc.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import pytest
44

55
# TODO: add marker for cuda pytests and something to check if cuda memory was really used
6+
@pytest.mark.skipcuda
67
@pytest.mark.parametrize("ksp_type, pc_type", [("cg", "sor"), ("cg", "gamg"), ("preonly", "lu")])
78
def test_poisson_on_cuda(ksp_type, pc_type):
89

tests/firedrake/cuda/test_wave_equation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import pytest
77

88

9-
# TODO: add marker for cuda pytestss
9+
@pytest.mark.skipcuda
1010
def test_kmv_wave_propagation_cuda():
1111
nested_parameters = {
1212
"ksp_type": "preonly",

0 commit comments

Comments
 (0)