Skip to content
Permalink
Browse files

Pull out MPI logic

Centralize the TEST_NP and MPIEXEC_OVERSUBSCRIBE default value
deduction mechanism to the dedicated unit_test module.
  • Loading branch information
jngrad committed Nov 21, 2019
1 parent c91ea5e commit 75cb7aa6c9bfa5b1dc9afc7db00bb7973e643c7f
Showing with 10 additions and 26 deletions.
  1. +8 −4 cmake/unit_test.cmake
  2. +2 −0 testsuite/CMakeLists.txt
  3. +0 −16 testsuite/python/CMakeLists.txt
  4. +0 −6 testsuite/scripts/CMakeLists.txt
@@ -1,3 +1,9 @@
if(NOT DEFINED TEST_NP)
include(ProcessorCount)
ProcessorCount(NP)
math(EXPR TEST_NP "${NP}/2 + 1")
endif()

if(EXISTS ${MPIEXEC})
# OpenMPI 3.0 and higher checks the number of processes against the number of CPUs
execute_process(COMMAND ${MPIEXEC} --version RESULT_VARIABLE mpi_version_result OUTPUT_VARIABLE mpi_version_output ERROR_VARIABLE mpi_version_output)
@@ -35,10 +41,8 @@ function(UNIT_TEST)

# If NUM_PROC is given, set up MPI parallel test case
if( TEST_NUM_PROC )
if(DEFINED TEST_NP)
if(${TEST_NUM_PROC} GREATER ${TEST_NP})
set(TEST_NUM_PROC ${TEST_NP})
endif()
if(${TEST_NUM_PROC} GREATER ${TEST_NP})
set(TEST_NUM_PROC ${TEST_NP})
endif()

add_test(${TEST_NAME} ${MPIEXEC} ${MPIEXEC_OVERSUBSCRIBE} ${MPIEXEC_NUMPROC_FLAG} ${TEST_NUM_PROC} ${MPIEXEC_PREFLAGS} ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME} ${MPIEXEC_POSTFLAGS})
@@ -1,3 +1,5 @@
include(unit_test)

add_subdirectory(python)
add_subdirectory(cmake)

@@ -1,19 +1,3 @@
if(NOT DEFINED TEST_NP)
include(ProcessorCount)
ProcessorCount(NP)
math(EXPR TEST_NP "${NP}/2 + 1")
endif()

if(EXISTS ${MPIEXEC})
# OpenMPI 3.0 and higher checks the number of processes against the number of CPUs
execute_process(COMMAND ${MPIEXEC} --version RESULT_VARIABLE mpi_version_result OUTPUT_VARIABLE mpi_version_output ERROR_VARIABLE mpi_version_output)
if (mpi_version_result EQUAL 0 AND mpi_version_output MATCHES "\\(Open(RTE| MPI)\\) ([3-9]\\.|1[0-9])")
set(MPIEXEC_OVERSUBSCRIBE "-oversubscribe")
else()
set(MPIEXEC_OVERSUBSCRIBE "")
endif()
endif()

function(PYTHON_TEST)
cmake_parse_arguments(TEST "" "FILE;MAX_NUM_PROC;SUFFIX" "DEPENDS;DEPENDENCIES;LABELS" ${ARGN})
get_filename_component(TEST_NAME ${TEST_FILE} NAME_WE)
@@ -1,9 +1,3 @@
if(NOT DEFINED TEST_NP)
include(ProcessorCount)
ProcessorCount(NP)
math(EXPR TEST_NP "${NP}/2 + 1")
endif()

set(TEST_FILE_CONFIGURED_IMPORTLIB_WRAPPER ${CMAKE_CURRENT_BINARY_DIR}/test_importlib_wrapper.py)
configure_file(importlib_wrapper.py ${CMAKE_CURRENT_BINARY_DIR}/importlib_wrapper.py)
configure_file(test_importlib_wrapper.py ${TEST_FILE_CONFIGURED_IMPORTLIB_WRAPPER})

0 comments on commit 75cb7aa

Please sign in to comment.
You can’t perform that action at this time.