From: Matthias Maier Date: Tue, 8 Feb 2022 22:42:42 +0000 (-0600) Subject: CMake: add a TEST_MPI_RANK_LIMIT variable to enforce a limit on MPI ranks X-Git-Tag: v9.4.0-rc1~518^2~7 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5bda473c976eca77e9e0b953fd037c00d32c75f2;p=dealii.git CMake: add a TEST_MPI_RANK_LIMIT variable to enforce a limit on MPI ranks --- diff --git a/cmake/macros/macro_deal_ii_add_test.cmake b/cmake/macros/macro_deal_ii_add_test.cmake index 18f3bb9d8f..3c460fba5c 100644 --- a/cmake/macros/macro_deal_ii_add_test.cmake +++ b/cmake/macros/macro_deal_ii_add_test.cmake @@ -72,11 +72,17 @@ # - specifying the maximal wall clock time in seconds a test is allowed # to run # +# TEST_MPI_RANK_LIMIT +# - specifying the maximal number of MPI ranks that can be used. If a +# test variant configures a larger number of MPI ranks (via +# .mpirun=N. in the output file) than this limit the test will be +# dropped. The special value "0" enforces no limit. +# # Usage: # DEAL_II_ADD_TEST(category test_name comparison_file) # -MACRO(DEAL_II_ADD_TEST _category _test_name _comparison_file) +FUNCTION(DEAL_II_ADD_TEST _category _test_name _comparison_file) IF(NOT DEAL_II_PROJECT_CONFIG_INCLUDED) MESSAGE(FATAL_ERROR @@ -108,6 +114,14 @@ MACRO(DEAL_II_ADD_TEST _category _test_name _comparison_file) STRING(REGEX REPLACE "^mpirun=([0-9]*)$" "\\1" _n_cpu ${_n_cpu}) ENDIF() + # + # If the number of MPI ranks specified for the test via .mpirun=N. + # exceeds the limit ${TEST_MPI_RANK_LIMIT}, skip defining the test + # + IF(TEST_MPI_RANK_LIMIT GREATER 0 AND _n_cpu GREATER TEST_MPI_RANK_LIMIT) + RETURN() + ENDIF() + # # Determine the expected build stage of this test: # @@ -391,9 +405,9 @@ MACRO(DEAL_II_ADD_TEST _category _test_name _comparison_file) DEPENDS ${TEST_DEPENDENCIES_${_target}} ) ENDIF() - SET(TEST_DEPENDENCIES_${_target} ${_test_full}) + SET(TEST_DEPENDENCIES_${_target} ${_test_full} PARENT_SCOPE) ENDIF() ENDIF() ENDFOREACH() -ENDMACRO() +ENDFUNCTION() diff --git a/cmake/macros/macro_deal_ii_pickup_tests.cmake b/cmake/macros/macro_deal_ii_pickup_tests.cmake index 4a1ef85f73..2722cb2a59 100644 --- a/cmake/macros/macro_deal_ii_pickup_tests.cmake +++ b/cmake/macros/macro_deal_ii_pickup_tests.cmake @@ -36,6 +36,12 @@ # TEST_TIME_LIMIT # - Specifies the maximal wall clock time in seconds a test is # allowed to run. Defaults to 600. +# TEST_MPI_RANK_LIMIT +# - specifying the maximal number of MPI ranks that can be used. If a +# test variant configures a larger number of MPI ranks (via +# .mpirun=N. in the output file) than this limit the test will be +# dropped. The special value "0" enforces no limit. +# # TEST_PICKUP_REGEX # - A regular expression to select only a subset of tests during setup. # An empty string is interpreted as a catchall (this is the default). @@ -47,9 +53,6 @@ # DEAL_II_PICKUP_TESTS() # -# We use CONTINUE(), which is new in cmake 3.2 -CMAKE_MINIMUM_REQUIRED(VERSION 3.2.0) - # # Two very small macros that are used below: # @@ -172,12 +175,15 @@ MACRO(DEAL_II_PICKUP_TESTS) ENDIF() # - # Set time limit: + # Set various limits: # SET_IF_EMPTY(TEST_TIME_LIMIT "$ENV{TEST_TIME_LIMIT}") SET_IF_EMPTY(TEST_TIME_LIMIT 600) + SET_IF_EMPTY(TEST_MPI_RANK_LIMIT "$ENV{TEST_MPI_RANK_LIMIT}") + SET_IF_EMPTY(TEST_MPI_RANK_LIMIT 0) + # # ... and finally pick up tests: #