2025-09-12 09:52:16 -04:00
|
|
|
# Copyright (c) Advanced Micro Devices, Inc.
|
|
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
|
|
2025-08-21 15:56:47 -04:00
|
|
|
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
|
2022-05-31 01:51:18 -05:00
|
|
|
|
2024-10-15 11:20:40 -04:00
|
|
|
project(rocprofiler-systems-openmp LANGUAGES CXX)
|
2022-03-07 20:40:48 -06:00
|
|
|
|
2024-12-16 14:31:56 -05:00
|
|
|
if(ROCPROFSYS_DISABLE_EXAMPLES)
|
|
|
|
|
get_filename_component(_DIR ${CMAKE_CURRENT_LIST_DIR} NAME)
|
|
|
|
|
|
2025-06-22 10:44:33 -04:00
|
|
|
if(
|
|
|
|
|
${PROJECT_NAME} IN_LIST ROCPROFSYS_DISABLE_EXAMPLES
|
|
|
|
|
OR ${_DIR} IN_LIST ROCPROFSYS_DISABLE_EXAMPLES
|
|
|
|
|
)
|
2024-12-16 14:31:56 -05:00
|
|
|
return()
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
2022-03-07 20:40:48 -06:00
|
|
|
file(GLOB common_source ${CMAKE_CURRENT_SOURCE_DIR}/common/*.cpp)
|
|
|
|
|
add_library(openmp-common OBJECT ${common_source})
|
|
|
|
|
target_include_directories(openmp-common PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/common)
|
|
|
|
|
|
2025-06-22 10:44:33 -04:00
|
|
|
add_executable(
|
|
|
|
|
openmp-cg
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/CG/cg.cpp
|
|
|
|
|
$<TARGET_OBJECTS:openmp-common>
|
|
|
|
|
)
|
|
|
|
|
add_executable(
|
|
|
|
|
openmp-lu
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/LU/lu.cpp
|
|
|
|
|
$<TARGET_OBJECTS:openmp-common>
|
|
|
|
|
)
|
2022-03-07 20:40:48 -06:00
|
|
|
|
2022-10-17 12:54:26 -05:00
|
|
|
option(USE_CLANG_OMP "Use the clang OpenMP if available" ON)
|
2025-11-08 11:36:12 -05:00
|
|
|
|
2022-05-31 01:51:18 -05:00
|
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
2025-11-08 11:36:12 -05:00
|
|
|
set(OpenMP_C_FLAGS "-fopenmp=libomp")
|
|
|
|
|
set(OpenMP_CXX_FLAGS "-fopenmp=libomp")
|
|
|
|
|
|
2022-03-07 20:40:48 -06:00
|
|
|
find_package(OpenMP REQUIRED)
|
|
|
|
|
target_link_libraries(openmp-common PUBLIC OpenMP::OpenMP_CXX)
|
2024-10-15 11:20:40 -04:00
|
|
|
set(ROCPROFSYS_OPENMP_USING_LIBOMP_LIBRARY
|
2022-08-31 01:24:31 -05:00
|
|
|
ON
|
2025-06-22 10:44:33 -04:00
|
|
|
CACHE INTERNAL
|
|
|
|
|
"Used by rocprofiler-systems testing"
|
|
|
|
|
FORCE
|
|
|
|
|
)
|
2022-05-31 01:51:18 -05:00
|
|
|
else()
|
|
|
|
|
find_program(CLANGXX_EXECUTABLE NAMES clang++)
|
|
|
|
|
find_library(
|
|
|
|
|
LIBOMP_LIBRARY
|
2025-06-22 10:44:33 -04:00
|
|
|
NAMES omp omp5 ${CMAKE_SHARED_LIBRARY_PREFIX}omp${CMAKE_SHARED_LIBRARY_SUFFIX}.5
|
|
|
|
|
)
|
|
|
|
|
if(
|
|
|
|
|
CLANGXX_EXECUTABLE
|
|
|
|
|
AND LIBOMP_LIBRARY
|
|
|
|
|
AND COMMAND rocprofiler_systems_custom_compilation
|
|
|
|
|
AND USE_CLANG_OMP
|
|
|
|
|
)
|
2022-05-31 01:51:18 -05:00
|
|
|
target_compile_options(openmp-common PUBLIC -W -Wall -fopenmp=libomp)
|
2022-07-17 21:52:09 -05:00
|
|
|
target_link_libraries(openmp-common PUBLIC ${LIBOMP_LIBRARY})
|
2025-05-05 21:49:46 -04:00
|
|
|
rocprofiler_systems_custom_compilation(COMPILER ${CLANGXX_EXECUTABLE}
|
2025-06-22 10:44:33 -04:00
|
|
|
TARGET openmp-common
|
|
|
|
|
)
|
2025-05-05 21:49:46 -04:00
|
|
|
rocprofiler_systems_custom_compilation(COMPILER ${CLANGXX_EXECUTABLE}
|
2025-06-22 10:44:33 -04:00
|
|
|
TARGET openmp-cg
|
|
|
|
|
)
|
2025-05-05 21:49:46 -04:00
|
|
|
rocprofiler_systems_custom_compilation(COMPILER ${CLANGXX_EXECUTABLE}
|
2025-06-22 10:44:33 -04:00
|
|
|
TARGET openmp-lu
|
|
|
|
|
)
|
2024-10-15 11:20:40 -04:00
|
|
|
set(ROCPROFSYS_OPENMP_USING_LIBOMP_LIBRARY
|
2022-08-31 01:24:31 -05:00
|
|
|
ON
|
2025-06-22 10:44:33 -04:00
|
|
|
CACHE INTERNAL
|
|
|
|
|
"Used by rocprofiler-systems testing"
|
|
|
|
|
FORCE
|
|
|
|
|
)
|
2022-05-31 01:51:18 -05:00
|
|
|
else()
|
|
|
|
|
find_package(OpenMP REQUIRED)
|
|
|
|
|
target_link_libraries(openmp-common PUBLIC OpenMP::OpenMP_CXX)
|
2024-10-15 11:20:40 -04:00
|
|
|
set(ROCPROFSYS_OPENMP_USING_LIBOMP_LIBRARY
|
2022-08-31 01:24:31 -05:00
|
|
|
OFF
|
2025-06-22 10:44:33 -04:00
|
|
|
CACHE INTERNAL
|
|
|
|
|
"Used by rocprofiler-systems testing"
|
|
|
|
|
FORCE
|
|
|
|
|
)
|
2022-05-31 01:51:18 -05:00
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
2022-07-17 21:52:09 -05:00
|
|
|
target_link_libraries(openmp-cg PRIVATE openmp-common)
|
|
|
|
|
target_link_libraries(openmp-lu PRIVATE openmp-common)
|
|
|
|
|
|
2026-01-15 21:51:16 -05:00
|
|
|
set(OPENMP_EXAMPLES openmp-cg openmp-lu)
|
|
|
|
|
|
|
|
|
|
foreach(OPENMP_EXAMPLE IN LISTS OPENMP_EXAMPLES)
|
|
|
|
|
if(ROCPROFSYS_INSTALL_EXAMPLES AND TARGET ${OPENMP_EXAMPLE})
|
|
|
|
|
install(
|
|
|
|
|
TARGETS ${OPENMP_EXAMPLE}
|
|
|
|
|
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/rocprofiler-systems/examples
|
|
|
|
|
COMPONENT rocprofiler-systems-examples
|
|
|
|
|
)
|
|
|
|
|
endif()
|
|
|
|
|
endforeach()
|
2024-11-07 16:49:32 -05:00
|
|
|
|
2025-09-12 09:52:16 -04:00
|
|
|
if(ROCPROFSYS_USE_ROCM)
|
|
|
|
|
add_subdirectory(external)
|
|
|
|
|
else()
|
|
|
|
|
rocprofiler_systems_message(
|
|
|
|
|
WARNING
|
|
|
|
|
"ROCPROFSYS OMPVV CTests requires ROCm to be installed. Disabling OMPVV CTests..."
|
|
|
|
|
)
|
|
|
|
|
endif()
|
|
|
|
|
|
2024-12-16 14:31:56 -05:00
|
|
|
if(ROCPROFSYS_DISABLE_EXAMPLES)
|
|
|
|
|
if(NOT "openmp-target" IN_LIST ROCPROFSYS_DISABLE_EXAMPLES)
|
|
|
|
|
add_subdirectory(target)
|
|
|
|
|
endif()
|
|
|
|
|
else()
|
|
|
|
|
add_subdirectory(target)
|
|
|
|
|
endif()
|