From 2d38d047849a860581979912ef3743b0bdf20445 Mon Sep 17 00:00:00 2001 From: scivision Date: Wed, 13 Dec 2023 19:26:09 -0500 Subject: [PATCH] use TEST_LAUNCHER for CMake 3.29+ --- CMakeLists.txt | 2 +- meson.build | 2 +- src/CMakeLists.txt | 59 --------------------------------- test/CMakeLists.txt | 62 +++++++++++++++++++++++++++++++++++ {src => test}/basic.c | 0 {src => test}/basic.f90 | 0 {src => test}/helloworld.f90 | 0 {src => test}/meson.build | 0 {src => test}/mpivers.c | 0 {src => test}/mpivers.f90 | 0 {src => test}/thread_pass.f90 | 0 11 files changed, 64 insertions(+), 61 deletions(-) delete mode 100644 src/CMakeLists.txt create mode 100644 test/CMakeLists.txt rename {src => test}/basic.c (100%) rename {src => test}/basic.f90 (100%) rename {src => test}/helloworld.f90 (100%) rename {src => test}/meson.build (100%) rename {src => test}/mpivers.c (100%) rename {src => test}/mpivers.f90 (100%) rename {src => test}/thread_pass.f90 (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d4ae19..7f468e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,6 @@ enable_testing() include(cmake/compilers.cmake) -add_subdirectory(src) +add_subdirectory(test) file(GENERATE OUTPUT .gitignore CONTENT "*") diff --git a/meson.build b/meson.build index 41bd085..10d55df 100644 --- a/meson.build +++ b/meson.build @@ -18,4 +18,4 @@ endif mpiexec = find_program('mpiexec', required : false, disabler: true) # MS-MPI has only mpiexec -subdir('src') +subdir('test') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt deleted file mode 100644 index 65cd50b..0000000 --- a/src/CMakeLists.txt +++ /dev/null @@ -1,59 +0,0 @@ -set_property(DIRECTORY PROPERTY LABELS mpi) - -add_executable(mpi_basic-C basic.c) -target_link_libraries(mpi_basic-C MPI::MPI_C) -add_test(NAME mpi_Cbasic -COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} 1 $ -) - -add_executable(mpi_version-C mpivers.c) -target_link_libraries(mpi_version-C MPI::MPI_C) -add_test(NAME mpi_Cversion -COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} 1 $ -) - -# --- Fortran MPI-3 - -add_executable(mpi_basic basic.f90) -target_link_libraries(mpi_basic MPI::MPI_Fortran) -add_test(NAME mpi_Fbasic -COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} 1 $ -) - -add_executable(mpi_version mpivers.f90) -target_link_libraries(mpi_version MPI::MPI_Fortran) -add_test(NAME mpi_version -COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} 1 $ -) - -# --- more than one MPI image - -add_executable(mpi_hello helloworld.f90) -target_link_libraries(mpi_hello MPI::MPI_Fortran) - -add_test(NAME mpi:hello -COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} $ -) -set_property(TEST mpi:hello PROPERTY FIXTURES_SETUP mpi_fxt) - -# --- actual message passing - -add_executable(mpi_pass thread_pass.f90) -target_link_libraries(mpi_pass MPI::MPI_Fortran) - -if(MPIEXEC_MAX_NUMPROCS GREATER_EQUAL 2) - -add_test(NAME mpi:pass -COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} 2 $ -) -set_property(TEST mpi:pass PROPERTY FIXTURES_REQUIRED mpi_fxt) - -endif() - - -get_property(tests DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY TESTS) -set_property(TEST ${tests} PROPERTY cpu_mpi) - -if(DEFINED mpi_tmpdir) - set_property(TEST ${tests} PROPERTY ENVIRONMENT TMPDIR=${mpi_tmpdir}) -endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..4e9644d --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,62 @@ +add_executable(mpi_basic_C basic.c) +target_link_libraries(mpi_basic_C PRIVATE MPI::MPI_C) +add_test(NAME mpi_basic_C COMMAND mpi_basic_C) + +add_executable(mpi_version_C mpivers.c) +target_link_libraries(mpi_version_C PRIVATE MPI::MPI_C) +add_test(NAME mpi_version_C COMMAND mpi_version_C) + +# --- Fortran MPI-3 + +add_executable(mpi_basic_Fortran basic.f90) +target_link_libraries(mpi_basic_Fortran PRIVATE MPI::MPI_Fortran) +add_test(NAME mpi_basic_Fortran COMMAND mpi_basic_Fortran) + +add_executable(mpi_version_Fortran mpivers.f90) +target_link_libraries(mpi_version_Fortran PRIVATE MPI::MPI_Fortran) +add_test(NAME mpi_version_Fortran COMMAND mpi_version_Fortran) + +# --- more than one MPI image + +add_executable(mpi_hello helloworld.f90) +target_link_libraries(mpi_hello PRIVATE MPI::MPI_Fortran) +add_test(NAME mpi_hello COMMAND mpi_hello) +set_property(TEST mpi_hello PROPERTY FIXTURES_SETUP mpi_fxt) + +# --- actual message passing + +add_executable(mpi_pass thread_pass.f90) +target_link_libraries(mpi_pass PRIVATE MPI::MPI_Fortran) + +if(MPIEXEC_MAX_NUMPROCS GREATER_EQUAL 2) + +add_test(NAME mpi_pass COMMAND mpi_pass) +set_property(TEST mpi_pass PROPERTY FIXTURES_REQUIRED mpi_fxt) + +endif() + + +get_property(tests DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY TESTS) +set_property(TEST ${tests} PROPERTY cpu_mpi) + +# convenience vars +set(single mpi_basic_C mpi_version_C mpi_basic_Fortran mpi_version_Fortran) +set(_m ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG}) + +if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.29) + +set_property(TEST ${single} PROPERTY TEST_LAUNCHER ${_m} 1) +set_property(TEST mpi_hello PROPERTY TEST_LAUNCHER ${_m} ${MPIEXEC_MAX_NUMPROCS}) +set_property(TEST mpi_pass PROPERTY TEST_LAUNCHER ${_m} 2) + +else() + +set_property(TARGET ${single} PROPERTY CROSSCOMPILING_EMULATOR ${_m} 1) +set_property(TARGET mpi_hello PROPERTY CROSSCOMPILING_EMULATOR ${_m} ${MPIEXEC_MAX_NUMPROCS}) +set_property(TARGET mpi_pass PROPERTY CROSSCOMPILING_EMULATOR ${_m} 2) + +endif() + +if(DEFINED mpi_tmpdir) + set_property(TEST ${tests} PROPERTY ENVIRONMENT TMPDIR=${mpi_tmpdir}) +endif() diff --git a/src/basic.c b/test/basic.c similarity index 100% rename from src/basic.c rename to test/basic.c diff --git a/src/basic.f90 b/test/basic.f90 similarity index 100% rename from src/basic.f90 rename to test/basic.f90 diff --git a/src/helloworld.f90 b/test/helloworld.f90 similarity index 100% rename from src/helloworld.f90 rename to test/helloworld.f90 diff --git a/src/meson.build b/test/meson.build similarity index 100% rename from src/meson.build rename to test/meson.build diff --git a/src/mpivers.c b/test/mpivers.c similarity index 100% rename from src/mpivers.c rename to test/mpivers.c diff --git a/src/mpivers.f90 b/test/mpivers.f90 similarity index 100% rename from src/mpivers.f90 rename to test/mpivers.f90 diff --git a/src/thread_pass.f90 b/test/thread_pass.f90 similarity index 100% rename from src/thread_pass.f90 rename to test/thread_pass.f90