Use validation files for CI #716
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: C/C++ CI for ls1 | |
on: | |
push: | |
# pushes to master | |
branches: [ master ] | |
pull_request: | |
# PRs to master | |
branches: [ master ] | |
# abort old runs if a new one is started | |
concurrency: | |
group: ${{ github.head_ref }}-tests | |
cancel-in-progress: true | |
jobs: | |
ci-matrix: | |
runs-on: ubuntu-latest | |
strategy: | |
# do not cancel all other workflow runs if one fails | |
fail-fast: false | |
matrix: | |
vector: ['SSE', 'NONE', 'AVX', 'AVX2'] | |
target: ['Debug', 'Release'] | |
parall: ['SEQ', 'PAR'] | |
cc: ['gcc', 'clang'] | |
cxx: ['g++', 'clang++'] | |
autopas: ['ON', 'OFF'] | |
procs: ['1', '4', '8'] #TODO: >= 27 ranks case, to have non-border rank | |
openmp: ['ON', 'OFF'] | |
exclude: | |
# exclude incompatible compiler pairs | |
- cc: 'gcc' | |
cxx: 'clang++' | |
- cc: 'clang' | |
cxx: 'g++' | |
# exclude legacy configurations | |
- vector: 'SSE' | |
- vector: 'AVX' | |
- openmp: 'OFF' | |
# exclude SEQ & np > 1, exclude PAR & np = 1 | |
- parall: 'PAR' | |
procs: '1' | |
- parall: 'SEQ' | |
procs: '4' | |
- parall: 'SEQ' | |
procs: '8' | |
env: | |
JOBNAME: ${{ join(matrix.*, '-') }} | |
name: ${{ matrix.vector }}-${{ matrix.target }}-${{ matrix.parall }}-${{ matrix.cc }}-AutoPas=${{ matrix.autopas }}-Ranks=${{ matrix.procs }}-OMP=${{ matrix.openmp }} | |
steps: | |
# setup github actions runner node | |
- uses: actions/checkout@v4 | |
- name: Setup | |
run: | | |
sudo apt-get update | |
# MPICH 4.0.3 seems to have a bug that triggers a FP exception in our collective communication when doing 0+0. | |
sudo apt-get install -y \ | |
uuid-dev \ | |
libcppunit-dev \ | |
libopenmpi-dev \ | |
libomp-dev \ | |
libxerces-c-dev \ | |
python3-numpy | |
echo "Running ${JOBNAME}" | |
git status | |
mkdir build_${JOBNAME} | |
# build testing & unit testing | |
- name: Build and Unit Test | |
run: | | |
cd build_${JOBNAME} | |
#translate matrix to ON/OFF for certain entries | |
if [[ ${{ matrix.parall }} == 'PAR' ]] | |
then | |
mpi_enabled='ON' | |
else | |
mpi_enabled='OFF' | |
fi | |
if [[ ${{ matrix.parall }} == 'PAR' ]] && [[ ${{ matrix.autopas }} == 'ON' ]] | |
then | |
alllbl_enabled='ON' | |
else | |
alllbl_enabled='OFF' | |
fi | |
cmake -DVECTOR_INSTRUCTIONS=${{ matrix.vector }} \ | |
-DCMAKE_BUILD_TYPE=${{ matrix.target }} \ | |
-DENABLE_AUTOPAS=${{ matrix.autopas }} \ | |
-DAUTOPAS_ENABLE_RULES_BASED_AND_FUZZY_TUNING=ON \ | |
-DENABLE_ALLLBL=$alllbl_enabled \ | |
-DOPENMP=${{ matrix.openmp }} \ | |
-DENABLE_MPI=$mpi_enabled \ | |
-DENABLE_UNIT_TESTS=ON \ | |
-DENABLE_VTK=ON \ | |
.. | |
cmake --build . --parallel 1 | |
cd .. | |
if [[ ${{ matrix.parall }} == 'PAR' ]] | |
then | |
# when using OpenMPI --oversubscribe is needed. Remove it if you switch to MPICH. | |
mpirun --oversubscribe -np ${{ matrix.procs }} ./build_${JOBNAME}/src/MarDyn -t -d ./test_input/ | |
else | |
./build_${JOBNAME}/src/MarDyn -t -d ./test_input/ | |
fi | |
env: | |
CC: ${{ matrix.cc }} | |
CXX: ${{ matrix.cxx }} | |
OMP_NUM_THREADS: 2 | |
# validation testing | |
- if: ${{ matrix.parall == 'PAR' }} | |
name: Validation | |
run: | | |
#save absolute path to root of ls1 directory | |
repoPath=$PWD | |
#example list of new version is used | |
examplesFile="branchExamples_${JOBNAME}.txt" | |
# choose and save examples (so that the same file name could be used regardless of AutoPas is on or off) | |
if [[ ${{ matrix.autopas }} == 'ON' ]] | |
then | |
cp ./examples/example-list_autopas.txt "${examplesFile}" | |
else | |
cp ./examples/example-list.txt "${examplesFile}" | |
fi | |
#translate matrix to ON/OFF for certain entries | |
if [[ ${{ matrix.parall }} == 'PAR' ]] | |
then | |
mpi_enabled='ON' | |
else | |
mpi_enabled='OFF' | |
fi | |
if [[ ${{ matrix.parall }} == 'PAR' ]] && [[ ${{ matrix.autopas }} == 'ON' ]] | |
then | |
alllbl_enabled='ON' | |
else | |
alllbl_enabled='OFF' | |
fi | |
#set strict pipefail option | |
set -eo pipefail | |
# execute all examples. These calls create artifacts which we will then compare to the validation JSON file | |
IFS=$'\n' | |
for i in $(cat "${repoPath}/${examplesFile}" ) | |
do | |
# skip if comment or empty line | |
if [[ $i == \#* || -z "$i" ]] | |
then | |
continue | |
fi | |
cd $repoPath/examples/$(dirname $i) | |
# patch input files according to current conf | |
cp $(basename $i) input_patched.xml | |
# if AutoPas is enabled, replace all occurrences of LinkedCell in the examples' config files with AutoPas | |
if [[ ${{ matrix.autopas }} == 'ON' ]] | |
then | |
sed --in-place 's/LinkedCells/AutoPas/g' input_patched.xml | |
fi | |
# if AutoPas is enabled and no vectorization is used, the AVX functor of Autopas has to be disabled | |
if [[ ${{ matrix.vector }} == 'NONE' ]] | |
then | |
sed --in-place 's|AutoPas">|AutoPas">\n\t<functor>autoVec</functor>|g' input_patched.xml | |
fi | |
# run the example with the new exe | |
printf " Running example: $i" | |
EXE=$repoPath/build_${JOBNAME}/src/MarDyn | |
# when using OpenMPI --oversubscribe is needed. Remove it if you switch to MPICH. | |
mpirun --oversubscribe -np ${{ matrix.procs }} ${EXE} input_patched.xml --steps=20 \ | |
| tee "output_${{ join(matrix.*, '-') }}" \ | |
| awk '/Simstep = /{ print $7 " " $10 " " $13 " " $16 }' > ${repoPath}/output_${VERSION} \ | |
|| (exitCode=$?; cat "output_${{ join(matrix.*, '-') }}"; (exit $exitCode)) | |
printf "Done\n" | |
# compare the output of the run to the validation file | |
# validation files are named after the respective config xml but without the file extension (::-4) | |
python3 ${repoPath}/checks/validation_compare_files.py \ | |
--validation-file "validation_$(basename ${i::-4}).json" \ | |
--logfile "output_${{ join(matrix.*, '-') }}" | |
done | |
env: | |
CC: ${{ matrix.cc }} | |
CXX: ${{ matrix.cxx }} | |
OMP_NUM_THREADS: 2 |