Skip to content

Commit

Permalink
Merge branch 'fix-mpi-bind' into 'master'
Browse files Browse the repository at this point in the history
More `mpirun --bind-to none`

See merge request ogs/ogs!5080
  • Loading branch information
endJunction committed Aug 20, 2024
2 parents f5313b3 + daf96ff commit 570aec0
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 27 deletions.
6 changes: 3 additions & 3 deletions ProcessLib/PhaseField/Tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ AddTest(

if(OGS_USE_PETSC)
NotebookTest(NOTEBOOKFILE PhaseField/surfing_jupyter_notebook/surfing_pyvista.ipynb RUNTIME 25)
NotebookTest(NOTEBOOKFILE PhaseField/beam_jupyter_notebook/beam.ipynb RUNTIME 500 PROPERTIES PROCESSORS 3 RUN_SERIAL TRUE)
NotebookTest(NOTEBOOKFILE PhaseField/tpb_jupyter_notebook/TPB.ipynb RUNTIME 110 PROPERTIES PROCESSORS 4 RUN_SERIAL TRUE)
NotebookTest(NOTEBOOKFILE PhaseField/beam_jupyter_notebook/beam.ipynb RUNTIME 500 PROPERTIES PROCESSORS 3)
NotebookTest(NOTEBOOKFILE PhaseField/tpb_jupyter_notebook/TPB.ipynb RUNTIME 110 PROPERTIES PROCESSORS 4)
NotebookTest(NOTEBOOKFILE PhaseField/kregime_jupyter_notebook/Kregime_Static_jupyter.ipynb RUNTIME 40)
NotebookTest(NOTEBOOKFILE PhaseField/PForthotropy_jupyter_notebook/sen_shear.ipynb RUNTIME 500 PROPERTIES PROCESSORS 4 RUN_SERIAL TRUE)
NotebookTest(NOTEBOOKFILE PhaseField/PForthotropy_jupyter_notebook/sen_shear.ipynb RUNTIME 500 PROPERTIES PROCESSORS 4)
NotebookTest(NOTEBOOKFILE PhaseField/Kregime_Propagating_jupyter_notebook/Kregime_Propagating_jupyter.ipynb RUNTIME 550)
endif()
3 changes: 2 additions & 1 deletion Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,9 @@ set(TESTRUNNER_ADDITIONAL_ARGUMENTS ${TESTRUNNER_ADDITIONAL_ARGUMENTS}
add_custom_target(tests-cleanup ${CMAKE_COMMAND} -E remove -f testrunner.xml)

if(OGS_USE_PETSC)
set(MPIRUN_ARGS --bind-to none)
if("${HOSTNAME}" MATCHES "frontend.*")
set(MPIRUN_ARGS --mca btl_openib_allow_ib 1 --bind-to none)
list(APPEND MPIRUN_ARGS --mca btl_openib_allow_ib 1)
endif()
set(TEST_FILTER_MPI --gtest_filter=-MPITest*)
add_custom_target(tests
Expand Down
59 changes: 37 additions & 22 deletions scripts/cmake/test/AddTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ function(AddTest)
if(NOT DEFINED AddTest_RUNTIME)
set(AddTest_RUNTIME 1)
elseif(AddTest_RUNTIME GREATER 750)
# Set a timeout on jobs larger than the default ctest timeout of 1500 (s).
# The allowed runtime is twice as long as the given RUNTIME parameter.
# Set a timeout on jobs larger than the default ctest timeout of 1500
# (s). The allowed runtime is twice as long as the given RUNTIME
# parameter.
math(EXPR timeout "${AddTest_RUNTIME} * 2")
set(timeout TIMEOUT ${timeout})
endif()
Expand Down Expand Up @@ -152,10 +153,9 @@ function(AddTest)
elseif(AddTest_WRAPPER STREQUAL "mpirun")
if(MPIRUN_TOOL_PATH)
if("${HOSTNAME}" MATCHES "frontend.*")
set(AddTest_WRAPPER_ARGS ${AddTest_WRAPPER_ARGS} --mca
btl_openib_allow_ib 1
)
list(APPEND AddTest_WRAPPER_ARGS --mca btl_openib_allow_ib 1)
endif()
list(APPEND AddTest_WRAPPER_ARGS --bind-to none)
set(WRAPPER_COMMAND ${MPIRUN_TOOL_PATH})
if("${AddTest_WRAPPER_ARGS}" MATCHES "-np;([0-9]*)")
set(MPI_PROCESSORS ${CMAKE_MATCH_1})
Expand Down Expand Up @@ -347,7 +347,10 @@ macro(_add_test TEST_NAME)
endif()

isTestCommandExpectedToSucceed(${TEST_NAME} ${AddTest_PROPERTIES})
message(DEBUG "Is test '${TEST_NAME}' expected to succeed? → ${TEST_COMMAND_IS_EXPECTED_TO_SUCCEED}")
message(
DEBUG
"Is test '${TEST_NAME}' expected to succeed? → ${TEST_COMMAND_IS_EXPECTED_TO_SUCCEED}"
)

add_test(
NAME ${TEST_NAME}
Expand Down Expand Up @@ -614,17 +617,17 @@ Use six arguments version of AddTest with absolute and relative tolerances"
endmacro()

# Checks if a test is expected to succeed based on the properties WILL_FAIL,
# PASS_REGULAR_EXPRESSION and FAIL_REGULAR_EXPRESSION.
# The function expects the test name (used only for debugging purposes) and the
# test properties as arguments.
# The test does not need to exist, yet. This function does not query any test
# case, but only uses the passed list of properties
# PASS_REGULAR_EXPRESSION and FAIL_REGULAR_EXPRESSION. The function expects the
# test name (used only for debugging purposes) and the test properties as
# arguments. The test does not need to exist, yet. This function does not query
# any test case, but only uses the passed list of properties
function(isTestCommandExpectedToSucceed TEST_NAME)
set(options WILL_FAIL)
set(oneValueArgs PASS_REGULAR_EXPRESSION FAIL_REGULAR_EXPRESSION)
set(multiValueArgs)
cmake_parse_arguments(TEST_FAILURE "${options}" "${oneValueArgs}"
"${multiValueArgs}" ${ARGN})
cmake_parse_arguments(
TEST_FAILURE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}
)

message(DEBUG "failure properties for test ${TEST_NAME}:")
list(APPEND CMAKE_MESSAGE_INDENT " ")
Expand All @@ -633,26 +636,38 @@ function(isTestCommandExpectedToSucceed TEST_NAME)
message(DEBUG "FAIL_RE: ${TEST_FAILURE_FAIL_REGULAR_EXPRESSION}")
list(POP_BACK CMAKE_MESSAGE_INDENT)

if (${TEST_FAILURE_WILL_FAIL})
if (DEFINED TEST_FAILURE_PASS_REGULAR_EXPRESSION)
if(${TEST_FAILURE_WILL_FAIL})
if(DEFINED TEST_FAILURE_PASS_REGULAR_EXPRESSION)
# Note: if the test property PASS_REGULAR_EXPRESSION is set, the
# process return code will be ignored, see https://cmake.org/cmake/help/latest/prop_test/PASS_REGULAR_EXPRESSION.html
message(SEND_ERROR "Error in test '${TEST_NAME}': Please do not use both WILL_FAIL and PASS_REGULAR_EXPRESSION in the same test. The logic will be unclear, then.")
# process return code will be ignored, see
# https://cmake.org/cmake/help/latest/prop_test/PASS_REGULAR_EXPRESSION.html
message(
SEND_ERROR
"Error in test '${TEST_NAME}': Please do not use both WILL_FAIL and PASS_REGULAR_EXPRESSION in the same test. The logic will be unclear, then."
)
endif()
if (DEFINED TEST_FAILURE_FAIL_REGULAR_EXPRESSION)
message(SEND_ERROR "Error in test '${TEST_NAME}': Please do not use both WILL_FAIL and FAIL_REGULAR_EXPRESSION in the same test. The logic will be unclear, then.")
if(DEFINED TEST_FAILURE_FAIL_REGULAR_EXPRESSION)
message(
SEND_ERROR
"Error in test '${TEST_NAME}': Please do not use both WILL_FAIL and FAIL_REGULAR_EXPRESSION in the same test. The logic will be unclear, then."
)
endif()

set(TEST_COMMAND_IS_EXPECTED_TO_SUCCEED false)
elseif(DEFINED TEST_FAILURE_PASS_REGULAR_EXPRESSION)
if (DEFINED TEST_FAILURE_FAIL_REGULAR_EXPRESSION)
message(SEND_ERROR "Error in test '${TEST_NAME}': Please do not use both PASS_REGULAR_EXPRESSION and FAIL_REGULAR_EXPRESSION in the same test. The logic will be unclear, then.")
if(DEFINED TEST_FAILURE_FAIL_REGULAR_EXPRESSION)
message(
SEND_ERROR
"Error in test '${TEST_NAME}': Please do not use both PASS_REGULAR_EXPRESSION and FAIL_REGULAR_EXPRESSION in the same test. The logic will be unclear, then."
)
endif()

set(TEST_COMMAND_IS_EXPECTED_TO_SUCCEED false)
else()
set(TEST_COMMAND_IS_EXPECTED_TO_SUCCEED true)
endif()

set(TEST_COMMAND_IS_EXPECTED_TO_SUCCEED "${TEST_COMMAND_IS_EXPECTED_TO_SUCCEED}" PARENT_SCOPE)
set(TEST_COMMAND_IS_EXPECTED_TO_SUCCEED
"${TEST_COMMAND_IS_EXPECTED_TO_SUCCEED}" PARENT_SCOPE
)
endfunction()
6 changes: 5 additions & 1 deletion scripts/cmake/test/OgsTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ function(OgsTest)
string(REGEX MATCH "^[^ ]+" WRAPPER ${OgsTest_WRAPPER})
if(WRAPPER STREQUAL "mpirun")
set(TEST_NAME "${TEST_NAME}-mpi")
list(APPEND OgsTest_WRAPPER --bind-to none)
endif()
endif()

Expand Down Expand Up @@ -102,7 +103,10 @@ macro(_ogs_add_test TEST_NAME)
string(REPLACE "/" "_" TEST_NAME_UNDERSCORE ${TEST_NAME})

isTestCommandExpectedToSucceed(${TEST_NAME} ${OgsTest_PROPERTIES})
message(DEBUG "Is test '${TEST_NAME}' expected to succeed? → ${TEST_COMMAND_IS_EXPECTED_TO_SUCCEED}")
message(
DEBUG
"Is test '${TEST_NAME}' expected to succeed? → ${TEST_COMMAND_IS_EXPECTED_TO_SUCCEED}"
)

add_test(
NAME ${TEST_NAME}
Expand Down

0 comments on commit 570aec0

Please sign in to comment.