Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ The project release numbers follow [Semantic Versioning](http://semver.org/spec/

## [Unreleased] - Release date yyyy-mm-dd

### Added
- Adds `PROCESSORS` property to tests based on the number of mpi ranks (`NUM_MPI_THREADS`) and OpenMP threads (`NUM_OMP_THREADS`).
This gives CTest more context for scheduling tests.

### Changed
- Removed default use of `/bigobj` flag for Visual Studio builds. Projects should add this flag explicitly if needed for windows builds.
- Removed `-Winline` from being added to GoogleTest for Clang/Intel as it is a noop and caused a warning on Intel.
Expand Down
27 changes: 27 additions & 0 deletions cmake/BLTMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -490,10 +490,37 @@ macro(blt_add_test)

# Handle OpenMP
if( arg_NUM_OMP_THREADS )
# Ensure the number of OpenMP threads is a positive integer
string(REGEX MATCH "^-?[0-9]+$" _is_integer "${arg_NUM_OMP_THREADS}")
if( NOT _is_integer OR arg_NUM_OMP_THREADS LESS 1)
message(FATAL_ERROR "In blt_add_test(), attempted to run a test with invalid NUM_OMP_THREADS: ${arg_NUM_OMP_THREADS}")
endif()

set_property(TEST ${arg_NAME}
APPEND PROPERTY ENVIRONMENT OMP_NUM_THREADS=${arg_NUM_OMP_THREADS})
endif()

# Inform CTest how many processor slots this test needs for scheduling.
# When tests are parallelized with `ctest --parallel/-j`, CTest uses this
# property to avoid oversubscribing the available resources.
set(_blt_num_mpi_tasks 1)
if( arg_NUM_MPI_TASKS )
set(_blt_num_mpi_tasks ${arg_NUM_MPI_TASKS})
endif()

set(_blt_num_omp_threads 1)
if( arg_NUM_OMP_THREADS )
set(_blt_num_omp_threads ${arg_NUM_OMP_THREADS})
endif()

math(EXPR _blt_test_processors "${_blt_num_mpi_tasks} * ${_blt_num_omp_threads}")
if(_blt_test_processors LESS 1)
set(_blt_test_processors 1)
endif()

set_tests_properties(${arg_NAME}
PROPERTIES PROCESSORS ${_blt_test_processors})

endmacro(blt_add_test)


Expand Down
4 changes: 4 additions & 0 deletions docs/api/target.rst
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ is useful on machines that require extra arguments to ``MPIEXEC``.
If ``NUM_OMP_THREADS`` is given, this macro will set the environment variable ``OMP_NUM_THREADS``
before running this test. This is done by appending to the CMake tests property.

This macro also sets the CTest ``PROCESSORS`` property to help with test scheduling when using
``ctest --parallel/-j``. The value is computed as ``NUM_MPI_TASKS * NUM_OMP_THREADS``, treating
any omitted value as 1.

.. note::
If you do not require this macros command line assistance, you can call CMake's
``add_test()`` directly. For example, you may have a script checked into your
Expand Down