Check packages and features once

Also move libompv detection to its own cmake module.
This commit is contained in:
Rodrigo Arias 2025-04-14 09:11:53 +02:00
parent 44dd6fa7dd
commit 51ea16a85a
7 changed files with 44 additions and 36 deletions

View File

@ -96,6 +96,14 @@ if (NOT HAVE_CLOCK_GETTIME)
endif() endif()
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(include)
add_subdirectory(src) add_subdirectory(src)

21
cmake/FindLibompv.cmake Normal file
View File

@ -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()

View File

@ -1,26 +1,20 @@
# Copyright (c) 2025 Barcelona Supercomputing Center (BSC) # Copyright (c) 2025 Barcelona Supercomputing Center (BSC)
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
check_c_compiler_flag("-fopenmp=libompv" OPENMPV_COMPILER_FOUND) if(NOT LIBOMPV_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(ENABLE_ALL_TESTS) 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() 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() endif()
return() return()
endif() endif()
find_package(Nosv)
if(NOT NOSV_FOUND) if(NOT NOSV_FOUND)
if(ENABLE_ALL_TESTS) 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() else()
message(STATUS "nOS-V not found, disabling OpenMP-V RT tests") message(STATUS "nOS-V not found, disabling libompv bench tests")
endif() endif()
return() return()
endif() endif()

View File

@ -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 # SPDX-License-Identifier: GPL-3.0-or-later
find_package(Nanos6)
include(CheckOmpSs2Compiler)
if(NOT OMPSS2_COMPILER_FOUND) if(NOT OMPSS2_COMPILER_FOUND)
if(ENABLE_ALL_TESTS) if(ENABLE_ALL_TESTS)
message(FATAL_ERROR "Compiler doesn't support -fompss-2 flag, cannot enable Nanos6 RT tests") message(FATAL_ERROR "Compiler doesn't support -fompss-2 flag, cannot enable Nanos6 RT tests")

View File

@ -1,7 +1,6 @@
# Copyright (c) 2022-2025 Barcelona Supercomputing Center (BSC) # Copyright (c) 2022-2025 Barcelona Supercomputing Center (BSC)
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
find_package(Nodes)
include(CheckOmpSs2Compiler) include(CheckOmpSs2Compiler)
if(NOT OMPSS2_COMPILER_FOUND) 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-3 LEVEL 3 SORT BREAKDOWN)
nodes_rt_test(../nanos6/several-tasks.c NAME several-tasks-breakdown-level-4 LEVEL 4 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) if (PERF_PARANOID_KERNEL)
message(STATUS "Enabling perf paranoid tests for NODES") message(STATUS "Enabling perf paranoid tests for NODES")
nodes_rt_test(fibonacci.c SORT LEVEL 3 DRIVER "fibonacci.driver.sh") nodes_rt_test(fibonacci.c SORT LEVEL 3 DRIVER "fibonacci.driver.sh")

View File

@ -1,8 +1,6 @@
# Copyright (c) 2021-2025 Barcelona Supercomputing Center (BSC) # Copyright (c) 2021-2025 Barcelona Supercomputing Center (BSC)
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
find_package(Nosv)
if(NOT NOSV_FOUND) if(NOT NOSV_FOUND)
if(ENABLE_ALL_TESTS) if(ENABLE_ALL_TESTS)
message(FATAL_ERROR "nOS-V not found, cannot enable nOS-V RT 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-3 LEVEL 3 BREAKDOWN)
nosv_test(several-tasks.c SORT NAME several-tasks-breakdown-level-4 LEVEL 4 BREAKDOWN) nosv_test(several-tasks.c SORT NAME several-tasks-breakdown-level-4 LEVEL 4 BREAKDOWN)
include(CheckPerfParanoid)
if (PERF_PARANOID_KERNEL) if (PERF_PARANOID_KERNEL)
message(STATUS "Enabling perf paranoid tests for nOS-V") message(STATUS "Enabling perf paranoid tests for nOS-V")
nosv_test(kernel.c NAME kernel-overflow DRIVER "kernel-overflow.driver.sh") nosv_test(kernel.c NAME kernel-overflow DRIVER "kernel-overflow.driver.sh")

View File

@ -1,36 +1,30 @@
# Copyright (c) 2022-2025 Barcelona Supercomputing Center (BSC) # Copyright (c) 2022-2025 Barcelona Supercomputing Center (BSC)
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
check_c_compiler_flag("-fopenmp=libompv" OPENMPV_COMPILER_FOUND) if(NOT LIBOMPV_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(ENABLE_ALL_TESTS) 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() 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() endif()
return() return()
endif() endif()
find_package(Nosv)
if(NOT NOSV_FOUND) if(NOT NOSV_FOUND)
if(ENABLE_ALL_TESTS) 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() else()
message(STATUS "nOS-V not found, disabling OpenMP-V RT tests") message(STATUS "nOS-V not found, disabling libompv RT tests")
endif() endif()
return() return()
endif() endif()
message(STATUS "Enabling libompv RT tests")
function(openmp_rt_test) function(openmp_rt_test)
ovni_test(${ARGN} SORT) ovni_test(${ARGN} SORT)
target_compile_options("${OVNI_TEST_NAME}" PUBLIC "-fopenmp=libompv" target_compile_options("${OVNI_TEST_NAME}" PUBLIC "-no-pedantic")
"-no-pedantic") target_link_libraries("${OVNI_TEST_NAME}" PRIVATE "m" Libompv PkgConfig::NOSV)
target_link_options("${OVNI_TEST_NAME}" PUBLIC "-fopenmp=libompv")
target_link_libraries("${OVNI_TEST_NAME}" PRIVATE "m" PkgConfig::NOSV)
set_property(TEST "${OVNI_TEST_NAME}" APPEND PROPERTY set_property(TEST "${OVNI_TEST_NAME}" APPEND PROPERTY
ENVIRONMENT "OMP_OVNI=1") ENVIRONMENT "OMP_OVNI=1")
set_property(TEST "${OVNI_TEST_NAME}" APPEND PROPERTY set_property(TEST "${OVNI_TEST_NAME}" APPEND PROPERTY