Skip to content

Commit fc4c8db

Browse files
authored
Merge pull request #2055 from DLR-AMR/ft_github_clang
Improvement: Introduce github workflow using Clang and OpenMPI
2 parents 2922765 + c8263b5 commit fc4c8db

2 files changed

Lines changed: 186 additions & 0 deletions

File tree

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
name: CMake tests t8code with Clang compiler and OpenMPI
2+
3+
4+
# This file is part of t8code.
5+
# t8code is a C library to manage a collection (a forest) of multiple
6+
# connected adaptive space-trees of general element types in parallel.
7+
#
8+
# Copyright (C) 2026 the developers
9+
#
10+
# t8code is free software; you can redistribute it and/or modify
11+
# it under the terms of the GNU General Public License as published by
12+
# the Free Software Foundation; either version 2 of the License, or
13+
# (at your option) any later version.
14+
#
15+
# t8code is distributed in the hope that it will be useful,
16+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
# GNU General Public License for more details.
19+
#
20+
# You should have received a copy of the GNU General Public License
21+
# along with t8code; if not, write to the Free Software Foundation, Inc.,
22+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23+
24+
# This workflow checks whether building and testing works with the Clang compiler
25+
# and openmpi. It was added because all of t8code's remaining CI workflows rely
26+
# on gcc and mpich, hence missing Clang- or openmpi-specific issues.
27+
# To reduce runtime, (for now) only one configuration is run, that is, Debug mode
28+
# with MPI and all external libraries (VTK, OpenCASCADE, NetCDF).
29+
30+
env:
31+
DEBUG_CONFIG: "-O1"
32+
33+
on:
34+
workflow_call:
35+
# Note: To simplify adding more configurations of this workflow later, the MPI mode and the BUILD_TYPE
36+
# are passed as input, although currently only MPI on and Debug mode are tested.
37+
inputs:
38+
MAKEFLAGS:
39+
required: true
40+
type: string
41+
description: 'Make flags to use for compilation (like -j4)'
42+
MPI:
43+
required: true
44+
type: string
45+
description: 'Use MPI for compilation (ON/OFF)'
46+
BUILD_TYPE:
47+
required: true
48+
type: string
49+
description: 'Build type (Release/Debug)'
50+
TEST_LEVEL:
51+
required: true
52+
type: string
53+
description: 'Test level used for configuring (T8_TEST_LEVEL_FULL, T8_TEST_LEVEL_MEDIUM, or T8_TEST_LEVEL_BASIC)'
54+
default: 'T8_TEST_LEVEL_FULL'
55+
56+
jobs:
57+
t8code_cmake_tests:
58+
#
59+
# Container setup: To avoid unwanted side effects of gcc or mpich, an own Clang version of the
60+
# t8-dependencies Docker image is used. Aside from some basic packages, it contains a manually built
61+
# Clang version of OpenMPI.
62+
timeout-minutes: 60
63+
runs-on: ubuntu-latest
64+
container: dlramr/t8code-ubuntu:t8-clang-dependencies
65+
steps:
66+
#
67+
# Part 1: Preparation and sanity checks
68+
# -------------------------------------
69+
- uses: actions/checkout@v6
70+
with:
71+
fetch-depth: 0
72+
- name: Update packages
73+
run: apt-get update && apt-get upgrade -y
74+
- name: Show Clang version
75+
run: clang --version
76+
- name: Make sure MPI was built with CLANG
77+
# Note: If "clang" is not found (or "gcc" is), the workflow is exited due to fail-early mode
78+
run: |
79+
mpicc --version > mpi_version_output
80+
cat mpi_version_output
81+
grep -i "clang" mpi_version_output
82+
! grep -i "gcc" mpi_version_output
83+
rm mpi_version_output
84+
echo "CHECKED: MPI was built with Clang."
85+
- name: Assert correct MPI paths
86+
run: |
87+
mpicc --showme:compile | grep "${OMPI_INSTALL_PATH}"
88+
mpicc --showme:link | grep "${OMPI_INSTALL_PATH}"
89+
mpicxx --showme:compile | grep "${OMPI_INSTALL_PATH}"
90+
mpicxx --showme:link | grep "${OMPI_INSTALL_PATH}"
91+
echo "CHECKED: mpicc and mpicxx point to correct path"
92+
# This seems to be necessary because of the docker container
93+
- name: disable ownership checks
94+
run: git config --global --add safe.directory '*'
95+
- name: init submodules
96+
run: git submodule init
97+
- name: update submodules
98+
run: git submodule update
99+
- name: Get input vars
100+
run: export MAKEFLAGS="${{ inputs.MAKEFLAGS }}"
101+
&& export MPI="${{ inputs.MPI }}"
102+
&& export BUILD_TYPE="${{ inputs.BUILD_TYPE }}"
103+
&& echo MAKEFLAGS="$MAKEFLAGS" >> $GITHUB_ENV
104+
&& echo MPI="$MPI" >> $GITHUB_ENV
105+
&& echo BUILD_TYPE="$BUILD_TYPE" >> $GITHUB_ENV
106+
#
107+
# Part 2: Build t8code
108+
# --------------------
109+
# Define build config
110+
- name: Set test level
111+
run: export TEST_LEVEL_FLAG="-DT8CODE_TEST_LEVEL=${{ inputs.TEST_LEVEL }}"
112+
&& echo TEST_LEVEL_FLAG="$TEST_LEVEL_FLAG" >> $GITHUB_ENV
113+
- name: build config variables
114+
run: |
115+
export CONFIG_OPTIONS="-DCMAKE_C_COMPILER=mpicc -DCMAKE_CXX_COMPILER=mpicxx -DCMAKE_Fortran_COMPILER=mpifort -GNinja \
116+
-DT8CODE_ENABLE_MPI=$MPI -DCMAKE_BUILD_TYPE=$BUILD_TYPE ${TEST_LEVEL_FLAG} -DCMAKE_C_FLAGS_DEBUG=${DEBUG_CONFIG} -DCMAKE_CXX_FLAGS_DEBUG=${DEBUG_CONFIG} \
117+
-DT8CODE_BUILD_PEDANTIC=ON -DT8CODE_BUILD_WALL=ON -DT8CODE_BUILD_WERROR=ON -DT8CODE_BUILD_WEXTRA=ON \
118+
-DT8CODE_BUILD_FORTRAN_INTERFACE=ON -DT8CODE_BUILD_MESH_HANDLE=ON \
119+
-DT8CODE_ENABLE_NETCDF=ON -DT8CODE_ENABLE_OCC=ON -DT8CODE_ENABLE_VTK=ON -DVTK_DIR=$VTK_INSTALL_PATH/lib/cmake/vtk-9.1"
120+
echo CONFIG_OPTIONS="$CONFIG_OPTIONS" >> $GITHUB_ENV
121+
# Run cmake
122+
- name: echo cmake line
123+
run: echo cmake ../ $CONFIG_OPTIONS
124+
- name: cmake
125+
run: mkdir build && cd build && cmake ../ $CONFIG_OPTIONS
126+
# On failure, upload logs
127+
- name: OnFailUploadLog
128+
if: failure()
129+
uses: actions/upload-artifact@v5
130+
with:
131+
name: cmake_w_clang_and_ompi_${{ inputs.BUILD_TYPE }}_MPI_${{ inputs.MPI }}.log
132+
path: build/CMakeFiles/CMakeOutput.log
133+
# Build with ninja
134+
- name: ninja
135+
run: cd build && ninja $MAKEFLAGS
136+
- name: ninja install
137+
run: cd build && ninja install $MAKEFLAGS
138+
#
139+
# Part 3: Run t8code tests
140+
# ------------------------
141+
- name: serial tests (if MPI is enabled)
142+
run: cd build && ctest $MAKEFLAGS -R _serial
143+
if: ${{ inputs.MPI == 'ON' }}
144+
- name: parallel tests (if MPI is enabled)
145+
run: cd build && ctest -R _parallel
146+
env:
147+
# Note: These openmpi options are required to ensure stable runs in github workflows and avoid stalling.
148+
# In particular, they activate oversubscription and define the communication channels, here tcp (and self).
149+
OMPI_ALLOW_RUN_AS_ROOT: 1
150+
OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: 1
151+
OMPI_MCA_rmaps_base_oversubscribe: 1
152+
OMPI_MCA_btl: self,tcp
153+
OMPI_MCA_pml: ob1
154+
if: ${{ inputs.MPI == 'ON' }}
155+
- name: tests (if MPI is disabled)
156+
run: cd build && ctest $MAKEFLAGS
157+
if: ${{ inputs.MPI == 'OFF' }}
158+
# On failure, upload logs
159+
- name: OnFailUploadLog
160+
if: failure()
161+
uses: actions/upload-artifact@v5
162+
with:
163+
name: test-suite_w_clang_and_ompi_${{ inputs.BUILD_TYPE }}_MPI_${{ inputs.MPI }}.log
164+
path: build/Testing/Temporary/LastTest.log

.github/workflows/testsuite.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,28 @@ jobs:
221221
BUILD_TYPE: Debug
222222
TEST_LEVEL: ${{ github.event_name == 'pull_request' && 'T8_TEST_LEVEL_MEDIUM' || 'T8_TEST_LEVEL_FULL' }} # Set TEST_LEVEL to medium if the event is a PR, otherwise full.
223223

224+
# Check t8code building and testing with the Clang compiler and openmpi.
225+
# Note: This workflow is meant to detect Clang- or openmpi-specific issues missed by the remaining (gcc- and mpich-based) workflows.
226+
# To reduce its runtime, it currently only uses one run in Debug mode with MPI activated and all external libraries like VTK or OpenCASCADE.
227+
t8code_w_clang_and_ompi_tests:
228+
needs: fine_grained_trigger
229+
secrets: inherit
230+
if: ${{ needs.fine_grained_trigger.outputs.run_ci == 'true' }}
231+
uses: ./.github/workflows/test_t8code_w_clang_and_ompi.yml
232+
strategy:
233+
fail-fast: false
234+
matrix:
235+
MPI: [ON]
236+
BUILD_TYPE: [Debug]
237+
include:
238+
- MAKEFLAGS: -j4
239+
with:
240+
MAKEFLAGS: ${{ matrix.MAKEFLAGS }}
241+
MPI: ${{ matrix.MPI }}
242+
BUILD_TYPE: ${{ matrix.BUILD_TYPE }}
243+
TEST_LEVEL: ${{ github.event_name == 'pull_request' && 'T8_TEST_LEVEL_MEDIUM' || 'T8_TEST_LEVEL_FULL' }} # Set TEST_LEVEL to medium if the event is a PR, otherwise full.
244+
245+
# Build doxygen documentation and check for errors / warnings.
224246
t8code_doxygen_check:
225247
uses: ./.github/workflows/check_doxygen.yml
226248

0 commit comments

Comments
 (0)