Skip to content

Commit

Permalink
Merge branch 'ebourne_tokam_axi_null_advection' into 'main'
Browse files Browse the repository at this point in the history
Add a null advection in the Vpar direction

See merge request gysela-developpers/gyselalibxx!741

--------------------------------------------
  • Loading branch information
EmilyBourne committed Oct 25, 2024
1 parent e1403a7 commit cb4b494
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 5 deletions.
11 changes: 11 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,14 @@ cppcheck_static_analysis:
python3 ci_tools/gyselalib_static_analysis.py ${CHANGED_FILES}
allow_failure:
exit_codes: [1, 2] # Allow failure due to style or error but not fatal

cmake_static_analysis:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
stage: static_analysis
needs: [ setup_env_mr ]
image: ghcr.io/gyselax/gyselalibxx_env
variables:
GIT_SUBMODULE_STRATEGY: recursive
script: |
python3 ci_tools/cmake_checker.py
33 changes: 33 additions & 0 deletions ci_tools/cmake_checker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""
A script to ensure that any rules about CMake contents are respected.
"""
import glob
from pathlib import Path
import sys

HOME_DIR = Path(__file__).parent.parent.absolute()

if __name__ == '__main__':
cmake_files = glob.glob(str(HOME_DIR / '**' / 'CMakeLists.txt'), recursive=True)

success = True

for f_name in cmake_files:
with open(f_name, encoding='utf-8') as f:
code = f.read()

# Check that all tests are discovered in PRE_TEST mode
while 'gtest_discover_tests' in code:
code = code.split('gtest_discover_tests', 1)[1].split('(', 1)[1]
gtest_arg_str, code = code.split(')', 1)
gtest_args = gtest_arg_str.split()
try:
discovery_index = gtest_args.index('DISCOVERY_MODE')
except ValueError:
discovery_index = None
if discovery_index is None or gtest_args[discovery_index+1] != 'PRE_TEST':
success = False
print(f"Tests for target {gtest_args[0]} should be discovered before running the test (not during build). Please add 'DISCOVERY_MODE PRE_TEST' to the arguments of gtest_discover_tests in {f_name}")

if not success:
sys.exit(1)
24 changes: 19 additions & 5 deletions tests/mpi_parallelisation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ target_link_libraries(unit_tests_parallelisation_layout

)

gtest_discover_tests(unit_tests_parallelisation_layout)
gtest_discover_tests(unit_tests_parallelisation_layout DISCOVERY_MODE PRE_TEST)

add_executable(unit_tests_parallelisation
alltoall.cpp
Expand All @@ -34,7 +34,21 @@ target_link_libraries(unit_tests_parallelisation

)

set_property(TARGET unit_tests_parallelisation PROPERTY CROSSCOMPILING_EMULATOR '${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} 2')

gtest_discover_tests(unit_tests_parallelisation)

function(make_mpi_test test_name)
add_test(NAME ${test_name}
COMMAND
"${MPIEXEC_EXECUTABLE}"
"-n"
"2"
"$<TARGET_FILE:unit_tests_parallelisation>"
"--gtest_filter=${test_name}"
)
endfunction()

make_mpi_test(MPIParallelisation.AllToAll2D_CPU)
make_mpi_test(MPIParallelisation.AllToAll2D_GPU)
make_mpi_test(MPIParallelisation.AllToAll3D_CPU)
make_mpi_test(MPIParallelisation.AllToAll4D_CPU)
make_mpi_test(Layout.MinimalDomainDistribution)
make_mpi_test(Layout.SpreadDomainDistribution)
make_mpi_test(Layout.DomainSelection)
6 changes: 6 additions & 0 deletions tests/mpi_parallelisation/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ int main(int argc, char** argv)
::Kokkos::ScopeGuard kokkos_scope(argc, argv);
::ddc::ScopeGuard ddc_scope(argc, argv);
MPI_Init(&argc, &argv);
::testing::TestEventListeners& listeners = ::testing::UnitTest::GetInstance()->listeners();
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (rank != 0) {
delete listeners.Release(listeners.default_result_printer());
}
int result = RUN_ALL_TESTS();
MPI_Finalize();
return result;
Expand Down

0 comments on commit cb4b494

Please sign in to comment.