From eecf3447ab5a29437ae9e9aa7240733e9041e6bd Mon Sep 17 00:00:00 2001 From: Gaurav Dhingra Date: Tue, 18 Mar 2025 16:20:34 +0530 Subject: [PATCH 1/4] CI: run tests at CI --- .github/workflows/CI.yml | 6 ++++++ tests/run_tests.sh | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100755 tests/run_tests.sh diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 3bca275..1f4108b 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -41,6 +41,12 @@ jobs: cd tests/pot3d FC="gfortran" ./build_and_run_gfortran.sh + - name: Run standalone tests with GFortran + shell: bash -e -x -l {0} + run: | + cd tests + FC="gfortran" ./run_tests.sh + Compile_POT3D_with_LFortran: name: "Build POT3D and validate with LFortran" runs-on: ${{ matrix.os }} diff --git a/tests/run_tests.sh b/tests/run_tests.sh new file mode 100755 index 0000000..7a8740e --- /dev/null +++ b/tests/run_tests.sh @@ -0,0 +1,23 @@ +set -ex + +MPIEXEC=${CONDA_PREFIX}/bin/mpiexec + +if [[ "$(uname)" == "Linux" ]]; then + CC=gcc +else + CC=clang +fi + +$CC -I$CONDA_PREFIX/include -c ../src/mpi_wrapper.c +$FC -c ../src/mpi_c_bindings.f90 +$FC -c ../src/mpi.f90 +$FC -c -cpp cart_sub.f90 +$FC mpi_wrapper.o mpi_c_bindings.o mpi.o cart_sub.o -o cart_sub -L$CONDA_PREFIX/lib -lmpi -Wl,-rpath,$CONDA_PREFIX/lib + +echo "Running cart_sub with 1 MPI rank..." +${MPIEXEC} -np 1 cart_sub +echo "Done!" + +echo "Running cart_sub with 2 MPI rank..." +${MPIEXEC} -np 2 cart_sub +echo "Done!" From 6676e62aed9d6ef01301463b01c96812df208414 Mon Sep 17 00:00:00 2001 From: Gaurav Dhingra Date: Tue, 18 Mar 2025 16:26:41 +0530 Subject: [PATCH 2/4] create a separate CI job for running standalone tests with GFortran --- .github/workflows/CI.yml | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 1f4108b..6635ae3 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -12,6 +12,28 @@ env: MACOSX_DEPLOYMENT_TARGET: 14.0 jobs: + Run_standalone_tests_with_GFortran: + name: "Run standalone tests with GFortran" + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: ["macos-latest", "ubuntu-20.04"] + steps: + - uses: actions/checkout@v4 + + - name: Setup Micromamba + uses: mamba-org/setup-micromamba@v2.0.2 + with: + micromamba-version: '2.0.4-0' + environment-file: ci/environment_gfortran.yml + + - name: Run standalone tests with GFortran with and without optimization + shell: bash -e -x -l {0} + run: | + cd tests + FC="gfortran" ./run_tests.sh + FC="gfortran -O3 -march=native" ./run_tests.sh + Compile_POT3D_with_GFortran: name: "Build POT3D and validate with GFortran" runs-on: ${{ matrix.os }} @@ -41,12 +63,6 @@ jobs: cd tests/pot3d FC="gfortran" ./build_and_run_gfortran.sh - - name: Run standalone tests with GFortran - shell: bash -e -x -l {0} - run: | - cd tests - FC="gfortran" ./run_tests.sh - Compile_POT3D_with_LFortran: name: "Build POT3D and validate with LFortran" runs-on: ${{ matrix.os }} From 31b3e36e3f2693505f3d80a918b63426e35fc52a Mon Sep 17 00:00:00 2001 From: Gaurav Dhingra Date: Tue, 18 Mar 2025 16:56:04 +0530 Subject: [PATCH 3/4] CI: run standalone tests with LFortran --- .github/workflows/CI.yml | 22 ++++++++++++++++++++++ tests/run_tests.sh | 25 +++++++++++++++++-------- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 6635ae3..578b166 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -34,6 +34,28 @@ jobs: FC="gfortran" ./run_tests.sh FC="gfortran -O3 -march=native" ./run_tests.sh + Run_standalone_tests_with_LFortran: + name: "Run standalone tests with LFortran" + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: ["macos-latest", "ubuntu-20.04"] + steps: + - uses: actions/checkout@v4 + + - name: Setup Micromamba + uses: mamba-org/setup-micromamba@v2.0.2 + with: + micromamba-version: '2.0.4-0' + environment-file: ci/environment_lfortran.yml + + - name: Run standalone tests with LFortran with and without optimization + shell: bash -e -x -l {0} + run: | + cd tests + FC="lfortran" ./run_tests.sh + FC="lfortran --fast" ./run_tests.sh + Compile_POT3D_with_GFortran: name: "Build POT3D and validate with GFortran" runs-on: ${{ matrix.os }} diff --git a/tests/run_tests.sh b/tests/run_tests.sh index 7a8740e..6981144 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -11,13 +11,22 @@ fi $CC -I$CONDA_PREFIX/include -c ../src/mpi_wrapper.c $FC -c ../src/mpi_c_bindings.f90 $FC -c ../src/mpi.f90 -$FC -c -cpp cart_sub.f90 -$FC mpi_wrapper.o mpi_c_bindings.o mpi.o cart_sub.o -o cart_sub -L$CONDA_PREFIX/lib -lmpi -Wl,-rpath,$CONDA_PREFIX/lib -echo "Running cart_sub with 1 MPI rank..." -${MPIEXEC} -np 1 cart_sub -echo "Done!" +for file in *.f90; do + filename=$(basename "$file" .f90) + # TODO: currently "allreduce.f90" fails to compile, hence + # we skip that test for now + if [ "$filename" == "allreduce" ]; then + continue + fi + $FC -c $file + $FC mpi_wrapper.o mpi_c_bindings.o mpi.o $filename.o -o $filename -L$CONDA_PREFIX/lib -lmpi -Wl,-rpath,$CONDA_PREFIX/lib -echo "Running cart_sub with 2 MPI rank..." -${MPIEXEC} -np 2 cart_sub -echo "Done!" + echo "Running cart_sub with 1 MPI rank..." + ${MPIEXEC} -np 1 $filename + echo "Done!" + + echo "Running cart_sub with 2 MPI rank..." + ${MPIEXEC} -np 2 $filename + echo "Done!" +done From ff5dad9a4f8cc7413dad8b50d585c4e4a4a94e33 Mon Sep 17 00:00:00 2001 From: Gaurav Dhingra Date: Tue, 18 Mar 2025 17:04:30 +0530 Subject: [PATCH 4/4] fix filename in run_tests.sh script --- tests/run_tests.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/run_tests.sh b/tests/run_tests.sh index 6981144..18e1b1d 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -22,11 +22,11 @@ for file in *.f90; do $FC -c $file $FC mpi_wrapper.o mpi_c_bindings.o mpi.o $filename.o -o $filename -L$CONDA_PREFIX/lib -lmpi -Wl,-rpath,$CONDA_PREFIX/lib - echo "Running cart_sub with 1 MPI rank..." + echo "Running $filename with 1 MPI rank..." ${MPIEXEC} -np 1 $filename echo "Done!" - echo "Running cart_sub with 2 MPI rank..." + echo "Running $filename with 2 MPI rank..." ${MPIEXEC} -np 2 $filename echo "Done!" done