From 5c93a5dd61d3b1b3368149d64bcb4c0634d69fdd Mon Sep 17 00:00:00 2001 From: Daniel Peter Date: Thu, 14 Nov 2024 08:34:25 +0100 Subject: [PATCH] updates github actions --- .github/scripts/run_build.sh | 19 ++++++++- .github/scripts/run_tests.sh | 75 +++++++++++++++++++++++------------- .github/workflows/CI.yml | 8 ++-- 3 files changed, 70 insertions(+), 32 deletions(-) diff --git a/.github/scripts/run_build.sh b/.github/scripts/run_build.sh index 74b6ac863..8a72459c7 100755 --- a/.github/scripts/run_build.sh +++ b/.github/scripts/run_build.sh @@ -40,13 +40,24 @@ else adios=() fi +## HIP +if [ "${HIP}" == "true" ]; then + echo + echo "enabling HIP" + echo + hip=(--with-hip HIPCC=g++ HIP_FLAGS="-O2 -g -std=c++17" HIP_PLATFORM=cpu HIP_INC=./external_libs/ROCm-HIP-CPU/include HIP_LIBS="-ltbb -lpthread -lstdc++") +else + hip=() +fi + # configuration echo echo "configuration:" echo ./configure \ -${adios[@]} \ +"${adios[@]}" \ +"${hip[@]}" \ FC=gfortran MPIFC=mpif90 CC=gcc ${TESTFLAGS} # checks @@ -61,9 +72,13 @@ fi sed -i "s:IMAIN .*:IMAIN = ISTANDARD_OUTPUT:" setup/constants.h # compilation +echo +echo "clean:" +make clean + echo echo "compilation:" -make clean; make -j2 all +make -j4 all # checks if [[ $? -ne 0 ]]; then exit 1; fi diff --git a/.github/scripts/run_tests.sh b/.github/scripts/run_tests.sh index fa54a6dd3..837f6303b 100755 --- a/.github/scripts/run_tests.sh +++ b/.github/scripts/run_tests.sh @@ -30,6 +30,45 @@ my_test(){ if [[ $? -ne 0 ]]; then exit 1; fi } +my_kernel_test(){ + # kernel values + # get expect input arguments + RHO="$1" + KAPPA="$2" + MU="$3" + # Check if arguments are not empty + if [[ -z "$RHO" || -z "$KAPPA" || -z "$MU" ]]; then + echo "Error: All three arguments are required, got RHO=$RHO KAPPA=$KAPPA MU=$MU" + exit 1 + fi + # final test result + PASSED=0 + # checks rho kernel value + VAL=`fgrep 'maximum value of rho kernel' OUTPUT_FILES/output_solver.txt | cut -d = -f 2 | tr -d ' '` + echo "kernel rho : $VAL" + echo "" | awk '{diff=ex-val;diff_abs=(diff >= 0)? diff:-diff;diff_rel=diff_abs/ex;print " value: expected = "ex" gotten = "val" - difference absolute = "diff_abs" relative = "diff_rel; if (diff_rel>0.0001){print "failed"; exit 1;}else{print "good"; exit 0;} }' ex=$RHO val=$VAL + if [[ $? -ne 0 ]]; then PASSED=1; fi + + # checks kappa kernel value + VAL=`fgrep 'maximum value of kappa kernel' OUTPUT_FILES/output_solver.txt | cut -d = -f 2 | tr -d ' '` + echo "kernel kappa : $VAL" + echo "" | awk '{diff=ex-val;diff_abs=(diff >= 0)? diff:-diff;diff_rel=diff_abs/ex;print " value: expected = "ex" gotten = "val" - difference absolute = "diff_abs" relative = "diff_rel; if (diff_rel>0.0001){print "failed"; exit 1;}else{print "good"; exit 0;} }' ex=$KAPPA val=$VAL + if [[ $? -ne 0 ]]; then PASSED=1; fi + + # checks mu kernel value + VAL=`fgrep 'maximum value of mu kernel' OUTPUT_FILES/output_solver.txt | cut -d = -f 2 | tr -d ' '` + echo "kernel mu : $VAL" + echo "" | awk '{diff=ex-val;diff_abs=(diff >= 0)? diff:-diff;diff_rel=diff_abs/ex;print " value: expected = "ex" gotten = "val" - difference absolute = "diff_abs" relative = "diff_rel; if (diff_rel>0.0001){print "failed"; exit 1;}else{print "good"; exit 0;} }' ex=$MU val=$VAL + if [[ $? -ne 0 ]]; then PASSED=1; fi + + # overall pass + if [[ $PASSED -ne 0 ]]; then + echo "testing kernel values: failed"; exit 1; + else + echo "testing kernel values: all good" + fi +} + # test example cd $dir @@ -132,7 +171,7 @@ fi # use kernel script if [ "${RUN_KERNEL}" == "true" ]; then # use kernel script - ./run_this_example.kernel.sh + ./run_this_example_kernel.sh else # default script ./run_this_example.sh @@ -153,44 +192,26 @@ if [ "${DEBUG}" == "true" ] || [ "${RUN_KERNEL}" == "true" ]; then else my_test fi +# checks exit code +if [[ $? -ne 0 ]]; then exit 1; fi # kernel test if [ "${RUN_KERNEL}" == "true" ]; then # homogeneous halfspace if [ "$TESTDIR" == "EXAMPLES/applications/homogeneous_halfspace/" ]; then - PASSED=0 - # checks rho kernel value + # checks rho/kappa/mu kernel value outputs RHO=3.18576676E-09 - VAL=`fgrep 'maximum value of rho kernel' OUTPUT_FILES/output_solver.txt | cut -d = -f 2 | tr -d ' '` - echo "kernel rho : $VAL" - echo "" | awk '{diff=ex-val;diff_abs=(diff >= 0)? diff:-diff;diff_rel=diff_abs/ex;print " value: expected = "ex" gotten = "val" - difference absolute = "diff_abs" relative = "diff_rel; if (diff_rel>0.0001){print "failed"; exit 1;}else{print "good"; exit 0;} }' ex=$RHO val=$VAL - if [[ $? -ne 0 ]]; then PASSED=1; fi - - # checks kappa kernel value KAPPA=9.48281809E-09 - VAL=`fgrep 'maximum value of kappa kernel' OUTPUT_FILES/output_solver.txt | cut -d = -f 2 | tr -d ' '` - echo "kernel kappa : $VAL" - echo "" | awk '{diff=ex-val;diff_abs=(diff >= 0)? diff:-diff;diff_rel=diff_abs/ex;print " value: expected = "ex" gotten = "val" - difference absolute = "diff_abs" relative = "diff_rel; if (diff_rel>0.0001){print "failed"; exit 1;}else{print "good"; exit 0;} }' ex=$KAPPA val=$VAL - if [[ $? -ne 0 ]]; then PASSED=1; fi - - # checks mu kernel value MU=3.89545782E-08 - VAL=`fgrep 'maximum value of mu kernel' OUTPUT_FILES/output_solver.txt | cut -d = -f 2 | tr -d ' '` - echo "kernel mu : $VAL" - echo "" | awk '{diff=ex-val;diff_abs=(diff >= 0)? diff:-diff;diff_rel=diff_abs/ex;print " value: expected = "ex" gotten = "val" - difference absolute = "diff_abs" relative = "diff_rel; if (diff_rel>0.0001){print "failed"; exit 1;}else{print "good"; exit 0;} }' ex=$MU val=$VAL - if [[ $? -ne 0 ]]; then PASSED=1; fi - - # overall pass - if [[ $PASSED -ne 0 ]]; then - echo "kernel tests: failed"; exit 1; - else - echo "kernel tests: good" - fi + my_kernel_test $RHO $KAPPA $MU fi fi +# checks exit code +if [[ $? -ne 0 ]]; then exit 1; fi # cleanup -rm -rf OUTPUT_FILES/ DATABASES_MPI/ +rm -rf OUTPUT_FILES/ +if [ -e DATABASES_MPI ]; then rm -rf DATABASES_MPI/; fi echo echo "all good" diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 2d24a266e..5cd3cea00 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -160,7 +160,7 @@ jobs: run: ./configure - name: make - run: make -j2 all + run: make -j4 all linuxCheck-Intel: @@ -331,7 +331,7 @@ jobs: - name: Run build env: - TESTFLAGS: --with-mpi # --enable-vectorization + TESTFLAGS: --with-mpi run: ./.github/scripts/run_build.sh shell: bash @@ -794,6 +794,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + submodules: true # needs submodule content in folder external_libs/ROCm-HIP-CPU/ - name: Install packages env: @@ -803,7 +805,7 @@ jobs: - name: Run build env: - TESTFLAGS: --with-hip HIPCC=g++ HIP_FLAGS="-O2 -g -std=c++17" HIP_PLATFORM=cpu HIP_INC=./external_libs/ROCm-HIP-CPU/include HIP_LIBS="-ltbb -lpthread -lstdc++" + HIP: true run: ./.github/scripts/run_build.sh shell: bash