698ac6b8bc
## Motivation - Added `check_rocminfo` function that returns true if the provided regex was found, false otherwise. Can also use `GET_OUTPUT` to get the raw output filtered with or without a regex. - Moved `rocprofiler_systems_get_gfx_archs()` to `MacroUtilities.cmake` - Added `rocprofiler_systems_lookup_gfx()`, which detects whether a given `gfx` is from the `instinct`, `radeon` or `apu` family. - Added `ROCPROFSYS_GFX_TARGETS` as a build argument. Used to specify the offloading architectures that GPU examples should compile for. If empty, defaults to whatever your system has. - GPU examples now check if the given `gfx` targets (from `ROCPROFSYS_GFX_TARGETS`) are supported. - OMPVV offload tests now only compile if `amdflang` version is `>= 20` - Improve link time by reducing the number of GFX targets that binaries need to support. - RCCL is now passed a `GPU_TARGETS` var specifying the architectures to build/link against.
120 Zeilen
3.5 KiB
CMake
120 Zeilen
3.5 KiB
CMake
# Copyright (c) Advanced Micro Devices, Inc.
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
|
|
|
|
project(rocprofiler-systems-openmp LANGUAGES CXX)
|
|
|
|
if(ROCPROFSYS_DISABLE_EXAMPLES)
|
|
get_filename_component(_DIR ${CMAKE_CURRENT_LIST_DIR} NAME)
|
|
|
|
if(
|
|
${PROJECT_NAME} IN_LIST ROCPROFSYS_DISABLE_EXAMPLES
|
|
OR ${_DIR} IN_LIST ROCPROFSYS_DISABLE_EXAMPLES
|
|
)
|
|
return()
|
|
endif()
|
|
endif()
|
|
|
|
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)
|
|
|
|
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>
|
|
)
|
|
|
|
option(USE_CLANG_OMP "Use the clang OpenMP if available" ON)
|
|
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|
set(OpenMP_C_FLAGS "-fopenmp=libomp")
|
|
set(OpenMP_CXX_FLAGS "-fopenmp=libomp")
|
|
|
|
find_package(OpenMP REQUIRED)
|
|
target_link_libraries(openmp-common PUBLIC OpenMP::OpenMP_CXX)
|
|
set(ROCPROFSYS_OPENMP_USING_LIBOMP_LIBRARY
|
|
ON
|
|
CACHE INTERNAL
|
|
"Used by rocprofiler-systems testing"
|
|
FORCE
|
|
)
|
|
else()
|
|
find_program(CLANGXX_EXECUTABLE NAMES clang++)
|
|
find_library(
|
|
LIBOMP_LIBRARY
|
|
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
|
|
)
|
|
target_compile_options(openmp-common PUBLIC -W -Wall -fopenmp=libomp)
|
|
target_link_libraries(openmp-common PUBLIC ${LIBOMP_LIBRARY})
|
|
rocprofiler_systems_custom_compilation(COMPILER ${CLANGXX_EXECUTABLE}
|
|
TARGET openmp-common
|
|
)
|
|
rocprofiler_systems_custom_compilation(COMPILER ${CLANGXX_EXECUTABLE}
|
|
TARGET openmp-cg
|
|
)
|
|
rocprofiler_systems_custom_compilation(COMPILER ${CLANGXX_EXECUTABLE}
|
|
TARGET openmp-lu
|
|
)
|
|
set(ROCPROFSYS_OPENMP_USING_LIBOMP_LIBRARY
|
|
ON
|
|
CACHE INTERNAL
|
|
"Used by rocprofiler-systems testing"
|
|
FORCE
|
|
)
|
|
else()
|
|
find_package(OpenMP REQUIRED)
|
|
target_link_libraries(openmp-common PUBLIC OpenMP::OpenMP_CXX)
|
|
set(ROCPROFSYS_OPENMP_USING_LIBOMP_LIBRARY
|
|
OFF
|
|
CACHE INTERNAL
|
|
"Used by rocprofiler-systems testing"
|
|
FORCE
|
|
)
|
|
endif()
|
|
endif()
|
|
|
|
target_link_libraries(openmp-cg PRIVATE openmp-common)
|
|
target_link_libraries(openmp-lu PRIVATE openmp-common)
|
|
|
|
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()
|
|
|
|
if(ROCPROFSYS_USE_ROCM)
|
|
add_subdirectory(external)
|
|
else()
|
|
rocprofiler_systems_message(
|
|
WARNING
|
|
"ROCPROFSYS OMPVV CTests requires ROCm to be installed. Disabling OMPVV CTests..."
|
|
)
|
|
endif()
|
|
|
|
if(ROCPROFSYS_DISABLE_EXAMPLES)
|
|
if(NOT "openmp-target" IN_LIST ROCPROFSYS_DISABLE_EXAMPLES)
|
|
add_subdirectory(target)
|
|
endif()
|
|
else()
|
|
add_subdirectory(target)
|
|
endif()
|