]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add support for mpirun=x syntax
authorMatthias Maier <tamiko@kyomu.43-1.org>
Fri, 6 Sep 2013 02:24:12 +0000 (02:24 +0000)
committerMatthias Maier <tamiko@kyomu.43-1.org>
Fri, 6 Sep 2013 02:24:12 +0000 (02:24 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_port_the_testsuite@30616 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/cmake/macros/macro_deal_ii_add_test.cmake
deal.II/cmake/macros/macro_deal_ii_pickup_tests.cmake

index 714eb27d65f822b463d011135be302ece06a27d2..5bd819908a79cbd98957363f92c9c0d4133f7ee7 100644 (file)
 #
 #
 # Usage:
-#     DEAL_II_ADD_TEST(category test_name comparison_file [configurations])
+#     DEAL_II_ADD_TEST(category test_name comparison_file n_cpu [configurations])
 #
 # This macro assumes that a source file
 #
 #   ./tests/category/<test_name>.cc
 #
+# as well as the comparison file
+#
+#   ./tests/category/<comparison_file>
+#
 # is available in the testsuite.
 #
+# If <n_cpu> is equal to 0, the plain, generated executable will be run. If
+# <n_cpu> is a number larger than 0, the mpirun loader will be used to
+# launch the executable
+#
 # [configurations] is a list of configurations against this test should be
 # run. Possible values are an empty list, DEBUG, RELEASE or
 # "DEBUG;RELEASE".
@@ -44,7 +52,7 @@
 # <comparison_file>.
 #
 
-MACRO(DEAL_II_ADD_TEST _category _test_name _comparison_file)
+MACRO(DEAL_II_ADD_TEST _category _test_name _comparison_file _n_cpu)
 
   FOREACH(_build ${DEAL_II_BUILD_TYPES})
 
@@ -82,17 +90,24 @@ MACRO(DEAL_II_ADD_TEST _category _test_name _comparison_file)
         ${DEAL_II_BASE_NAME}${DEAL_II_${_build}_SUFFIX}
         )
 
+      #
+      # Build up the command line to run the test depending on _n_cpu:
+      #
+      IF("${_n_cpu}" STREQUAL "0")
+        SET(_run_command ${_full_test})
+      ELSE()
+        SET(_run_command mpirun -np ${_n_cpu} ${_full_test})
+      ENDIF()
 
       #
       # Add a top level target to run and compare the test:
       #
-
       ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_test}/output
         COMMAND
           # A this stage a build is always successful: :-)
           ${CMAKE_COMMAND} -E echo "${_full_test}: BUILD successful"
         COMMAND
-          ${_full_test}
+          ${_run_command}
           || (echo "${_full_test}: RUN failed. Output:"
               && cat output
               && rm output
@@ -109,7 +124,6 @@ MACRO(DEAL_II_ADD_TEST _category _test_name _comparison_file)
           ${_full_test}
           ${CMAKE_SOURCE_DIR}/cmake/scripts/normalize.pl
         )
-
       ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_test}/diff
         COMMAND
           ${TEST_DIFF}
@@ -137,7 +151,6 @@ MACRO(DEAL_II_ADD_TEST _category _test_name _comparison_file)
       #
       # And finally add the test:
       #
-
       ADD_TEST(NAME ${_category}/${_test}
         COMMAND ${CMAKE_COMMAND}
           -DTEST=${_full_test}.diff
@@ -149,10 +162,6 @@ MACRO(DEAL_II_ADD_TEST _category _test_name _comparison_file)
         LABEL "${_category}"
         TIMEOUT ${TEST_TIME_LIMIT}
         )
-
     ENDIF()
-
   ENDFOREACH()
-
 ENDMACRO()
-
index 3342bc92a468a496de3311c6774f23ec554d6c25..de26c18acc974a3c8dba34c3514b91eefd185f73 100644 (file)
@@ -28,7 +28,6 @@ MACRO(DEAL_II_PICKUP_TESTS)
   GET_FILENAME_COMPONENT(_category ${CMAKE_CURRENT_SOURCE_DIR} NAME)
 
   FILE(GLOB _tests "*.output")
-
   FOREACH(_test ${_tests})
 
     #
@@ -44,8 +43,8 @@ MACRO(DEAL_II_PICKUP_TESTS)
     ENDIF()
 
     #
-    # Query configuration and check whether we support it. Otherwise do
-    # not define test:
+    # Query configuration and check whether we support it. Otherwise
+    # set _define_test to FALSE:
     #
     STRING(REGEX MATCHALL "WITH_([0-9]|[A-Z]|_)*=(ON|OFF)" _matches ${_test})
     FOREACH(_match ${_matches})
@@ -60,10 +59,19 @@ MACRO(DEAL_II_PICKUP_TESTS)
       ENDIF()
     ENDFOREACH()
 
+
     IF(_define_test)
+
       #
-      # TODO: mpirun support
+      # Determine whether the test should be run with mpirun:
       #
+      STRING(REGEX MATCH "mpirun=([0-9]*)" _n_cpu ${_test})
+      IF("${_n_cpu}" STREQUAL "")
+        # 0 indicates that no mpirun should be used
+        SET(_n_cpu 0)
+      ELSE()
+        STRING(REGEX REPLACE "^mpirun=([0-9]*)$" "\\1" _n_cpu ${_n_cpu})
+      ENDIF()
 
       IF(_test MATCHES debug)
         SET(_configuration DEBUG)
@@ -75,7 +83,7 @@ MACRO(DEAL_II_PICKUP_TESTS)
 
       SET(_comparison ${_test})
       STRING(REGEX REPLACE "\\..*" "" _test ${_test})
-      DEAL_II_ADD_TEST(${_category} ${_test} ${_comparison} ${_configuration})
+      DEAL_II_ADD_TEST(${_category} ${_test} ${_comparison} ${_n_cpu} ${_configuration})
     ENDIF()
 
   ENDFOREACH()

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.