mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 08:20:18 -06:00
FindMPI: Use physical cores for MPIEXEC_MAX_NUMPROCS
Since commit v3.9.0-rc1~224^2~1 (FindMPI: MPIEXEC handling improvements, 2017-04-21) the `ProcessorCount` module is being used to initialize `MPIEXEC_MAX_NUMPROCS`. However, this leads to the logical cores being counted rather than the physical ones, and some MPI implementations like OpenMPI will error if mpiexec is called with that number. Switch it to the number of physical cores using `cmake_host_system_information`. This ensures that if `MPIEXEC_MAX_NUMPROCS` is being used to set up MPI tests with CTest or similar that the tests won't spuriously fail due to OpenMPI refusing to start the application.
This commit is contained in:
committed by
Brad King
parent
a91eb5e41f
commit
1610f757ac
@@ -1036,13 +1036,8 @@ set(MPIEXEC_NUMPROC_FLAG "-n" CACHE STRING "Flag used by MPI to specify the num
|
||||
set(MPIEXEC_PREFLAGS "" CACHE STRING "These flags will be directly before the executable that is being run by mpiexec.")
|
||||
set(MPIEXEC_POSTFLAGS "" CACHE STRING "These flags will be placed after all flags passed to mpiexec.")
|
||||
|
||||
# Set the number of processes to the processor count and the previous default
|
||||
# of 2 if that couldn't be determined.
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/ProcessorCount.cmake)
|
||||
ProcessorCount(_MPIEXEC_NUMPROCS)
|
||||
if("${_MPIEXEC_NUMPROCS}" EQUAL "0")
|
||||
set(_MPIEXEC_NUMPROCS 2)
|
||||
endif()
|
||||
# Set the number of processes to the physical processor count
|
||||
cmake_host_system_information(RESULT _MPIEXEC_NUMPROCS QUERY NUMBER_OF_PHYSICAL_CORES)
|
||||
set(MPIEXEC_MAX_NUMPROCS "${_MPIEXEC_NUMPROCS}" CACHE STRING "Maximum number of processors available to run MPI applications.")
|
||||
unset(_MPIEXEC_NUMPROCS)
|
||||
mark_as_advanced(MPIEXEC_EXECUTABLE MPIEXEC_NUMPROC_FLAG MPIEXEC_PREFLAGS MPIEXEC_POSTFLAGS MPIEXEC_MAX_NUMPROCS)
|
||||
|
||||
Reference in New Issue
Block a user