From 51ea16a85a14e3ba30f885b55b79aa55e8ebb368 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Date: Mon, 14 Apr 2025 09:11:53 +0200 Subject: [PATCH] Check packages and features once Also move libompv detection to its own cmake module. --- CMakeLists.txt | 8 ++++++++ cmake/FindLibompv.cmake | 21 +++++++++++++++++++++ test/bench/openmp/CMakeLists.txt | 16 +++++----------- test/rt/nanos6/CMakeLists.txt | 5 +---- test/rt/nodes/CMakeLists.txt | 3 --- test/rt/nosv/CMakeLists.txt | 3 --- test/rt/openmp/CMakeLists.txt | 24 +++++++++--------------- 7 files changed, 44 insertions(+), 36 deletions(-) create mode 100644 cmake/FindLibompv.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 14ab1b0..7bc5694 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,6 +96,14 @@ if (NOT HAVE_CLOCK_GETTIME) endif() endif() +# Check packages and features once +find_package(Nanos6) +find_package(Nodes) +find_package(Nosv) +find_package(Libompv) +include(CheckPerfParanoid) +include(CheckOmpSs2Compiler) + add_subdirectory(include) add_subdirectory(src) diff --git a/cmake/FindLibompv.cmake b/cmake/FindLibompv.cmake new file mode 100644 index 0000000..f7eabf1 --- /dev/null +++ b/cmake/FindLibompv.cmake @@ -0,0 +1,21 @@ +# Copyright (c) 2025 Barcelona Supercomputing Center (BSC) +# SPDX-License-Identifier: GPL-3.0-or-later + +set(LIBOMPV_FLAG "-fopenmp=libompv") + +include(CheckCCompilerFlag) + +# Add the flag at compile and link time +set(CMAKE_REQUIRED_LINK_OPTIONS "${LIBOMPV_FLAG}") +check_c_compiler_flag("${LIBOMPV_FLAG}" LIBOMPV_FOUND) + +if(NOT LIBOMPV_FOUND) + message(STATUS "Compiler doesn't support -fopenmp=libompv") + return() +endif() + +if(NOT TARGET Libompv) + add_library(Libompv INTERFACE) + target_compile_options(Libompv INTERFACE "${LIBOMPV_FLAG}") + target_link_options(Libompv INTERFACE "${LIBOMPV_FLAG}") +endif() diff --git a/test/bench/openmp/CMakeLists.txt b/test/bench/openmp/CMakeLists.txt index 626e5c5..f2681e0 100644 --- a/test/bench/openmp/CMakeLists.txt +++ b/test/bench/openmp/CMakeLists.txt @@ -1,26 +1,20 @@ # Copyright (c) 2025 Barcelona Supercomputing Center (BSC) # SPDX-License-Identifier: GPL-3.0-or-later -check_c_compiler_flag("-fopenmp=libompv" OPENMPV_COMPILER_FOUND) -check_linker_flag(C "-fopenmp=libompv" OPENMPV_LINKER_FOUND) -cmake_path(GET CMAKE_C_COMPILER PARENT_PATH CMAKE_C_COMPILER_PATH) - -if(NOT OPENMPV_COMPILER_FOUND OR NOT OPENMPV_LINKER_FOUND) +if(NOT LIBOMPV_FOUND) if(ENABLE_ALL_TESTS) - message(FATAL_ERROR "Compiler doesn't support -fopenmp=libompv flag, cannot enable OpenMP-V RT tests") + message(FATAL_ERROR "Compiler doesn't support -fopenmp=libompv flag, cannot enable libompv bench tests") else() - message(STATUS "Compiler doesn't support -fopenmp=libompv flag, disabling OpenMP-V RT tests") + message(STATUS "Compiler doesn't support -fopenmp=libompv flag, disabling libompv bench tests") endif() return() endif() -find_package(Nosv) - if(NOT NOSV_FOUND) if(ENABLE_ALL_TESTS) - message(FATAL_ERROR "nOS-V not found, cannot enable OpenMP-V RT tests") + message(FATAL_ERROR "nOS-V not found, cannot enable libompv bench tests") else() - message(STATUS "nOS-V not found, disabling OpenMP-V RT tests") + message(STATUS "nOS-V not found, disabling libompv bench tests") endif() return() endif() diff --git a/test/rt/nanos6/CMakeLists.txt b/test/rt/nanos6/CMakeLists.txt index df79cb4..8eb06c1 100644 --- a/test/rt/nanos6/CMakeLists.txt +++ b/test/rt/nanos6/CMakeLists.txt @@ -1,9 +1,6 @@ -# Copyright (c) 2022-2024 Barcelona Supercomputing Center (BSC) +# Copyright (c) 2022-2025 Barcelona Supercomputing Center (BSC) # SPDX-License-Identifier: GPL-3.0-or-later -find_package(Nanos6) -include(CheckOmpSs2Compiler) - if(NOT OMPSS2_COMPILER_FOUND) if(ENABLE_ALL_TESTS) message(FATAL_ERROR "Compiler doesn't support -fompss-2 flag, cannot enable Nanos6 RT tests") diff --git a/test/rt/nodes/CMakeLists.txt b/test/rt/nodes/CMakeLists.txt index 449a58e..ae60900 100644 --- a/test/rt/nodes/CMakeLists.txt +++ b/test/rt/nodes/CMakeLists.txt @@ -1,7 +1,6 @@ # Copyright (c) 2022-2025 Barcelona Supercomputing Center (BSC) # SPDX-License-Identifier: GPL-3.0-or-later -find_package(Nodes) include(CheckOmpSs2Compiler) if(NOT OMPSS2_COMPILER_FOUND) @@ -72,8 +71,6 @@ nodes_rt_test(../nanos6/several-tasks.c NAME several-tasks-breakdown-level-2 LEV nodes_rt_test(../nanos6/several-tasks.c NAME several-tasks-breakdown-level-3 LEVEL 3 SORT BREAKDOWN) nodes_rt_test(../nanos6/several-tasks.c NAME several-tasks-breakdown-level-4 LEVEL 4 SORT BREAKDOWN) - -include(CheckPerfParanoid) if (PERF_PARANOID_KERNEL) message(STATUS "Enabling perf paranoid tests for NODES") nodes_rt_test(fibonacci.c SORT LEVEL 3 DRIVER "fibonacci.driver.sh") diff --git a/test/rt/nosv/CMakeLists.txt b/test/rt/nosv/CMakeLists.txt index 4c23ccf..e9c9d25 100644 --- a/test/rt/nosv/CMakeLists.txt +++ b/test/rt/nosv/CMakeLists.txt @@ -1,8 +1,6 @@ # Copyright (c) 2021-2025 Barcelona Supercomputing Center (BSC) # SPDX-License-Identifier: GPL-3.0-or-later -find_package(Nosv) - if(NOT NOSV_FOUND) if(ENABLE_ALL_TESTS) message(FATAL_ERROR "nOS-V not found, cannot enable nOS-V RT tests") @@ -66,7 +64,6 @@ nosv_test(several-tasks.c SORT NAME several-tasks-breakdown-level-2 LEVEL 2 BREA nosv_test(several-tasks.c SORT NAME several-tasks-breakdown-level-3 LEVEL 3 BREAKDOWN) nosv_test(several-tasks.c SORT NAME several-tasks-breakdown-level-4 LEVEL 4 BREAKDOWN) -include(CheckPerfParanoid) if (PERF_PARANOID_KERNEL) message(STATUS "Enabling perf paranoid tests for nOS-V") nosv_test(kernel.c NAME kernel-overflow DRIVER "kernel-overflow.driver.sh") diff --git a/test/rt/openmp/CMakeLists.txt b/test/rt/openmp/CMakeLists.txt index bfc317e..20f0f78 100644 --- a/test/rt/openmp/CMakeLists.txt +++ b/test/rt/openmp/CMakeLists.txt @@ -1,36 +1,30 @@ # Copyright (c) 2022-2025 Barcelona Supercomputing Center (BSC) # SPDX-License-Identifier: GPL-3.0-or-later -check_c_compiler_flag("-fopenmp=libompv" OPENMPV_COMPILER_FOUND) -check_linker_flag(C "-fopenmp=libompv" OPENMPV_LINKER_FOUND) -cmake_path(GET CMAKE_C_COMPILER PARENT_PATH CMAKE_C_COMPILER_PATH) - -if(NOT OPENMPV_COMPILER_FOUND OR NOT OPENMPV_LINKER_FOUND) +if(NOT LIBOMPV_FOUND) if(ENABLE_ALL_TESTS) - message(FATAL_ERROR "Compiler doesn't support -fopenmp=libompv flag, cannot enable OpenMP-V RT tests") + message(FATAL_ERROR "Compiler doesn't support -fopenmp=libompv flag, cannot enable libompv RT tests") else() - message(STATUS "Compiler doesn't support -fopenmp=libompv flag, disabling OpenMP-V RT tests") + message(STATUS "Compiler doesn't support -fopenmp=libompv flag, disabling libompv RT tests") endif() return() endif() -find_package(Nosv) - if(NOT NOSV_FOUND) if(ENABLE_ALL_TESTS) - message(FATAL_ERROR "nOS-V not found, cannot enable OpenMP-V RT tests") + message(FATAL_ERROR "nOS-V not found, cannot enable libompv RT tests") else() - message(STATUS "nOS-V not found, disabling OpenMP-V RT tests") + message(STATUS "nOS-V not found, disabling libompv RT tests") endif() return() endif() +message(STATUS "Enabling libompv RT tests") + function(openmp_rt_test) ovni_test(${ARGN} SORT) - target_compile_options("${OVNI_TEST_NAME}" PUBLIC "-fopenmp=libompv" - "-no-pedantic") - target_link_options("${OVNI_TEST_NAME}" PUBLIC "-fopenmp=libompv") - target_link_libraries("${OVNI_TEST_NAME}" PRIVATE "m" PkgConfig::NOSV) + target_compile_options("${OVNI_TEST_NAME}" PUBLIC "-no-pedantic") + target_link_libraries("${OVNI_TEST_NAME}" PRIVATE "m" Libompv PkgConfig::NOSV) set_property(TEST "${OVNI_TEST_NAME}" APPEND PROPERTY ENVIRONMENT "OMP_OVNI=1") set_property(TEST "${OVNI_TEST_NAME}" APPEND PROPERTY