From e10b92a9193e386dd2c7ed01a3f5bea2b4849bd4 Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Tue, 12 Mar 2024 11:18:31 +0100 Subject: [PATCH 1/2] Add `OCTOPUS_TESTS_OpenMP_THREADS` to control OpenMP parallelization Signed-off-by: Cristian Le --- CMakeLists.txt | 20 ++++++++++++++++++++ testsuite/CMakeLists.txt | 22 +++++++++------------- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d20071cc5b..686cb2d733 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,10 +60,30 @@ option(OCTOPUS_OpenCL "Octopus: Build with OpenCL support" OFF) add_feature_info(OCTOPUS_OpenCL OCTOPUS_OpenCL "OpenCL graphics driver support") option(OCTOPUS_DOXYGEN "Octopus: Build with Doxygen support for in-source documentation" OFF) add_feature_info(OCTOPUS_DOXYGEN OCTOPUS_DOXYGEN "Doxygen source documentation support") +# Set OpenMP test threads depending on configuration +if (NOT OCTOPUS_OpenMP) + # Always setting OMP_NUM_THREADS to 1 on non-openmp build + # Note that this does affect the library dependency's parallelization + set(omp_num_threads 1) + set(omp_num_threads_help "(Because: OCTOPUS_OpenMP=OFF)") +else () + if (DEFINED ENV{OMP_NUM_THREADS}) + set(omp_num_threads $ENV{OMP_NUM_THREADS}) + set(omp_num_threads_help "(Because: OCTOPUS_OpenMP=ON, OMP_NUM_THREADS=$ENV{OMP_NUM_THREADS})") + else () + # Default OMP_NUM_THREADS to 2 if it was not defined in any other way + set(omp_num_threads 2) + set(omp_num_threads_help "(Because: OCTOPUS_OpenMP=ON, OMP_NUM_THREADS=undefined)") + endif () +endif () +set(OCTOPUS_TESTS_OpenMP_THREADS "${omp_num_threads}" CACHE STRING "Octopus: OpenMP threads to use for testing (Default: ${omp_num_threads} ${omp_num_threads_help})") if (NOT OCTOPUS_MKL AND NOT OCTOPUS_FFTW) message(FATAL_ERROR "No FFTW vendor enabled. Either MKL or FFTW must be enabled.") endif () +if (NOT OCTOPUS_TESTS_OpenMP_THREADS MATCHES "^[0-9]+$") + message(FATAL_ERROR "OCTOPUS_TESTS_OpenMP_THREADS must be an integer number") +endif () #[==============================================================================================[ # Project configuration # diff --git a/testsuite/CMakeLists.txt b/testsuite/CMakeLists.txt index 636d0f4658..e62af72867 100644 --- a/testsuite/CMakeLists.txt +++ b/testsuite/CMakeLists.txt @@ -98,16 +98,6 @@ function(Octopus_add_test name) "TMPDIR=${CMAKE_CURRENT_BINARY_DIR}/${ARGS_TEST_NAME}" ) - # Set the appropriate parallelization properties - # Note: In principle these should be done dynamically using `TEST_INCLUDE_FILE`, however this functionality cannot - # get and manipulate the test properties - # https://gitlab.kitware.com/cmake/cmake/-/issues/25362 - if (OCTOPUS_OpenMP AND DEFINED ENV{OMP_NUM_THREADS}) - set(omp_num_threads $ENV{OMP_NUM_THREADS}) - else () - set(omp_num_threads 1) - endif () - if (OCTOPUS_TESTS_RUN_SERIAL) set(mpi_processes 1) else () @@ -130,12 +120,18 @@ function(Octopus_add_test name) endforeach () endif () endif () + + # Set the appropriate parallelization properties + # Note: In principle these should be done dynamically using `TEST_INCLUDE_FILE`, however this functionality cannot + # get and manipulate the test properties + # https://gitlab.kitware.com/cmake/cmake/-/issues/25362 + # Make sure OMP_NUM_THREADS is set to an appropriate value set_property(TEST ${ARGS_TEST_NAME} APPEND PROPERTY - ENVIRONMENT "OMP_NUM_THREADS=${omp_num_threads}" + ENVIRONMENT "OMP_NUM_THREADS=${OCTOPUS_TESTS_OpenMP_THREADS}" ) - # Set PROCESSORS property to omp_num_threads * mpi_processes - math(EXPR test_processors "${omp_num_threads} * ${mpi_processes}") + # Set PROCESSORS property to OCTOPUS_TESTS_OpenMP_THREADS * mpi_processes + math(EXPR test_processors "${OCTOPUS_TESTS_OpenMP_THREADS} * ${mpi_processes}") set_tests_properties(${ARGS_TEST_NAME} PROPERTIES PROCESSORS ${test_processors} ) -- GitLab From ae26f65a0fa4dd50bb4d7f775f795c12a164d094 Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Tue, 12 Mar 2024 14:54:01 +0100 Subject: [PATCH 2/2] Add OpenMP boilerplate presets DftbPlus is disabled because the packaging files create a dummy OpenMP::OpenMP_Fortran target Signed-off-by: Cristian Le --- cmake/CMakePresets-buildbot.json | 220 +++++++++++++++++++++++++++++++ 1 file changed, 220 insertions(+) diff --git a/cmake/CMakePresets-buildbot.json b/cmake/CMakePresets-buildbot.json index a45a2d3e35..c986bbb48a 100644 --- a/cmake/CMakePresets-buildbot.json +++ b/cmake/CMakePresets-buildbot.json @@ -162,6 +162,27 @@ ], "binaryDir": "cmake-build-ci-foss-min-mpi" }, + { + "name": "foss-min-mpi-omp", + "displayName": "Buildbot - Foss toolchain + min + OpenMP + MPI", + "inherits": [ + "_openmp", + "_buildbot-mpi", + "_buildbot-foss", + "_min" + ], + "binaryDir": "cmake-build-ci-foss-min-mpi-omp", + "cacheVariables": { + "CMAKE_DISABLE_FIND_PACKAGE_DftbPlus": { + "type": "BOOL", + "value": true + }, + "CMAKE_REQUIRE_FIND_PACKAGE_DftbPlus": { + "type": "BOOL", + "value": false + } + } + }, { "name": "foss-full", "displayName": "Buildbot - Foss toolchain + full + serial", @@ -204,6 +225,47 @@ ], "binaryDir": "cmake-build-ci-foss-full-mpi" }, + { + "name": "foss-full-omp", + "displayName": "Buildbot - Foss toolchain + full + OpenMP", + "inherits": [ + "_openmp", + "_buildbot-foss", + "_full-required" + ], + "binaryDir": "cmake-build-ci-foss-full-omp", + "cacheVariables": { + "CMAKE_DISABLE_FIND_PACKAGE_DftbPlus": { + "type": "BOOL", + "value": true + }, + "CMAKE_REQUIRE_FIND_PACKAGE_DftbPlus": { + "type": "BOOL", + "value": false + } + } + }, + { + "name": "foss-full-mpi-omp", + "displayName": "Buildbot - Foss toolchain + full + OpenMP + MPI", + "inherits": [ + "_openmp", + "_buildbot-mpi", + "_buildbot-foss", + "_full-mpi-required" + ], + "binaryDir": "cmake-build-ci-foss-full-mpi-omp", + "cacheVariables": { + "CMAKE_DISABLE_FIND_PACKAGE_DftbPlus": { + "type": "BOOL", + "value": true + }, + "CMAKE_REQUIRE_FIND_PACKAGE_DftbPlus": { + "type": "BOOL", + "value": false + } + } + }, { "name": "foss-full-cuda-mpi", "displayName": "Buildbot - Foss toolchain + full + CUDA + MPI", @@ -290,6 +352,27 @@ ], "binaryDir": "cmake-build-ci-intel-min-mpi" }, + { + "name": "intel-min-mpi-omp", + "displayName": "Buildbot - Intel toolchain + min + OpenMP + MPI", + "inherits": [ + "_openmp", + "_buildbot-mpi", + "_buildbot-intel", + "_min" + ], + "binaryDir": "cmake-build-ci-intel-min-mpi-omp", + "cacheVariables": { + "CMAKE_DISABLE_FIND_PACKAGE_DftbPlus": { + "type": "BOOL", + "value": true + }, + "CMAKE_REQUIRE_FIND_PACKAGE_DftbPlus": { + "type": "BOOL", + "value": false + } + } + }, { "name": "intel-full", "displayName": "Buildbot - Intel toolchain + full + serial", @@ -332,6 +415,47 @@ ], "binaryDir": "cmake-build-ci-intel-full-mpi" }, + { + "name": "intel-full-omp", + "displayName": "Buildbot - Intel toolchain + full + OpenMP", + "inherits": [ + "_openmp", + "_buildbot-intel", + "_full-required" + ], + "binaryDir": "cmake-build-ci-intel-full-omp", + "cacheVariables": { + "CMAKE_DISABLE_FIND_PACKAGE_DftbPlus": { + "type": "BOOL", + "value": true + }, + "CMAKE_REQUIRE_FIND_PACKAGE_DftbPlus": { + "type": "BOOL", + "value": false + } + } + }, + { + "name": "intel-full-mpi-omp", + "displayName": "Buildbot - Intel toolchain + full + OpenMP + MPI", + "inherits": [ + "_openmp", + "_buildbot-mpi", + "_buildbot-intel", + "_full-mpi-required" + ], + "binaryDir": "cmake-build-ci-intel-full-mpi-omp", + "cacheVariables": { + "CMAKE_DISABLE_FIND_PACKAGE_DftbPlus": { + "type": "BOOL", + "value": true + }, + "CMAKE_REQUIRE_FIND_PACKAGE_DftbPlus": { + "type": "BOOL", + "value": false + } + } + }, { "name": "intel-full-cuda-mpi", "displayName": "Buildbot - Intel toolchain + full + CUDA + MPI", @@ -424,6 +548,14 @@ ], "configurePreset": "foss-min-mpi" }, + { + "name": "foss-min-mpi-omp", + "displayName": "Buildbot - Foss toolchain + min + OpenMP + MPI", + "inherits": [ + "_buildbot-base" + ], + "configurePreset": "foss-min-mpi-omp" + }, { "name": "foss-full", "displayName": "Buildbot - Foss toolchain + full + serial", @@ -456,6 +588,22 @@ ], "configurePreset": "foss-full-mpi" }, + { + "name": "foss-full-omp", + "displayName": "Buildbot - Foss toolchain + full + OpenMP", + "inherits": [ + "_buildbot-base" + ], + "configurePreset": "foss-full-omp" + }, + { + "name": "foss-full-mpi-omp", + "displayName": "Buildbot - Foss toolchain + full + OpenMP + MPI", + "inherits": [ + "_buildbot-base" + ], + "configurePreset": "foss-full-mpi-omp" + }, { "name": "foss-full-cuda-mpi", "displayName": "Buildbot - Foss toolchain + full + CUDA + MPI", @@ -504,6 +652,14 @@ ], "configurePreset": "intel-min-mpi" }, + { + "name": "intel-min-mpi-omp", + "displayName": "Buildbot - Intel toolchain + min + OpenMP + MPI", + "inherits": [ + "_buildbot-base" + ], + "configurePreset": "intel-min-mpi-omp" + }, { "name": "intel-full", "displayName": "Buildbot - Intel toolchain + full + serial", @@ -536,6 +692,22 @@ ], "configurePreset": "intel-full-mpi" }, + { + "name": "intel-full-omp", + "displayName": "Buildbot - Intel toolchain + full + OpenMP", + "inherits": [ + "_buildbot-base" + ], + "configurePreset": "intel-full-omp" + }, + { + "name": "intel-full-mpi-omp", + "displayName": "Buildbot - Intel toolchain + full + OpenMP + MPI", + "inherits": [ + "_buildbot-base" + ], + "configurePreset": "intel-full-mpi-omp" + }, { "name": "intel-full-cuda-mpi", "displayName": "Buildbot - Intel toolchain + full + CUDA + MPI", @@ -611,6 +783,14 @@ ], "configurePreset": "foss-min-mpi" }, + { + "name": "foss-min-mpi-omp", + "displayName": "Buildbot - Foss toolchain + min + OpenMP + MPI", + "inherits": [ + "_buildbot-base" + ], + "configurePreset": "foss-min-mpi-omp" + }, { "name": "foss-full", "displayName": "Buildbot - Foss toolchain + full + serial", @@ -645,6 +825,22 @@ ], "configurePreset": "foss-full-mpi" }, + { + "name": "foss-full-omp", + "displayName": "Buildbot - Foss toolchain + full + OpenMP", + "inherits": [ + "_buildbot-base" + ], + "configurePreset": "foss-full-omp" + }, + { + "name": "foss-full-mpi-omp", + "displayName": "Buildbot - Foss toolchain + full + OpenMP + MPI", + "inherits": [ + "_buildbot-base" + ], + "configurePreset": "foss-full-mpi-omp" + }, { "name": "foss-full-cuda-mpi", "displayName": "Buildbot - Foss toolchain + full + CUDA + MPI", @@ -697,6 +893,14 @@ ], "configurePreset": "intel-min-mpi" }, + { + "name": "intel-min-mpi-omp", + "displayName": "Buildbot - Intel toolchain + min + OpenMP + MPI", + "inherits": [ + "_buildbot-base" + ], + "configurePreset": "intel-min-mpi-omp" + }, { "name": "intel-full", "displayName": "Buildbot - Intel toolchain + full + serial", @@ -731,6 +935,22 @@ ], "configurePreset": "intel-full-mpi" }, + { + "name": "intel-full-omp", + "displayName": "Buildbot - Intel toolchain + full + OpenMP", + "inherits": [ + "_buildbot-base" + ], + "configurePreset": "intel-full-omp" + }, + { + "name": "intel-full-mpi-omp", + "displayName": "Buildbot - Intel toolchain + full + OpenMP + MPI", + "inherits": [ + "_buildbot-base" + ], + "configurePreset": "intel-full-mpi-omp" + }, { "name": "intel-full-cuda-mpi", "displayName": "Buildbot - Intel toolchain + full + CUDA + MPI", -- GitLab