]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: add a TEST_MPI_RANK_LIMIT variable to enforce a limit on MPI ranks
authorMatthias Maier <tamiko@43-1.org>
Tue, 8 Feb 2022 22:42:42 +0000 (16:42 -0600)
committerMatthias Maier <tamiko@43-1.org>
Wed, 9 Feb 2022 09:42:45 +0000 (03:42 -0600)
cmake/macros/macro_deal_ii_add_test.cmake
cmake/macros/macro_deal_ii_pickup_tests.cmake

index 18f3bb9d8fc88c303ce147ced1129865ff64c546..3c460fba5cd9f3d9e3e6178a88de32092232afdf 100644 (file)
 #     - 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()
index 4a1ef85f73b756825b55a8033007bfc038e83740..2722cb2a5916ed4b775fbfe1b6b4426b80e791c3 100644 (file)
 #     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:
   #

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.