Files
rocm-systems/projects/rocprofiler-systems/examples/fork/CMakeLists.txt
T

忽略 .git-blame-ignore-revs 中的修訂。點擊 這裡 以繞過並查看正常的 Blame 視圖。

103 行
3.2 KiB
CMake
原始文件 標準檢視 歷史記錄

cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
2023-02-08 01:31:38 -06:00
project(rocprofiler-systems-fork LANGUAGES CXX)
2023-02-08 01:31:38 -06:00
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
string(REPLACE " " ";" _FLAGS "${CMAKE_CXX_FLAGS_DEBUG}")
2025-07-31 07:59:41 -04:00
list(APPEND _FLAGS -fno-inline)
2023-02-08 01:31:38 -06:00
find_package(Threads REQUIRED)
find_package(rocprofiler-systems REQUIRED COMPONENTS user)
# Basic fork example
2023-02-08 01:31:38 -06:00
add_executable(fork-example fork.cpp)
2025-06-22 10:44:33 -04:00
target_link_libraries(
fork-example
PRIVATE Threads::Threads rocprofiler-systems::rocprofiler-systems
)
2023-02-08 01:31:38 -06:00
target_compile_options(fork-example PRIVATE ${_FLAGS})
if(ROCPROFSYS_INSTALL_EXAMPLES)
2025-06-22 10:44:33 -04:00
install(TARGETS fork-example DESTINATION bin COMPONENT rocprofiler-systems-examples)
2023-02-08 01:31:38 -06:00
endif()
# HIP fork example (multi-process concurrency test)
find_package(hip QUIET HINTS ${ROCmVersion_DIR} PATHS ${ROCmVersion_DIR})
find_program(
HIPCC_EXECUTABLE
NAMES hipcc
HINTS ${ROCmVersion_DIR} ${ROCM_PATH}
ENV ROCM_PATH
/opt/rocm
PATHS ${ROCmVersion_DIR} ${ROCM_PATH}
ENV ROCM_PATH
/opt/rocm
NO_CACHE
)
mark_as_advanced(HIPCC_EXECUTABLE)
if(HIPCC_EXECUTABLE)
if(NOT CMAKE_CXX_COMPILER_IS_HIPCC AND HIPCC_EXECUTABLE)
if(
CMAKE_CXX_COMPILER STREQUAL HIPCC_EXECUTABLE
OR "${CMAKE_CXX_COMPILER}" MATCHES "hipcc"
)
set(CMAKE_CXX_COMPILER_IS_HIPCC 1 CACHE BOOL "HIP compiler")
endif()
endif()
if(
CMAKE_CXX_COMPILER_IS_HIPCC
OR hip_FOUND
OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND HIPCC_EXECUTABLE)
OR COMMAND rocprofiler_systems_custom_compilation
)
add_executable(hipMallocConcurrencyMproc hipMallocConcurrencyMproc.cpp)
target_link_libraries(hipMallocConcurrencyMproc PRIVATE Threads::Threads)
if(
CMAKE_CXX_COMPILER_ID MATCHES "Clang"
AND NOT CMAKE_CXX_COMPILER_IS_HIPCC
AND NOT HIPCC_EXECUTABLE
)
target_link_libraries(
hipMallocConcurrencyMproc
PRIVATE
$<TARGET_NAME_IF_EXISTS:rocprofiler-systems::rocprofiler-systems-compile-options>
$<TARGET_NAME_IF_EXISTS:hip::host>
$<TARGET_NAME_IF_EXISTS:hip::device>
)
else()
target_compile_options(hipMallocConcurrencyMproc PRIVATE -W -Wall)
endif()
if("${CMAKE_BUILD_TYPE}" MATCHES "Release")
target_compile_options(hipMallocConcurrencyMproc PRIVATE -g1)
endif()
if(NOT CMAKE_CXX_COMPILER_IS_HIPCC AND HIPCC_EXECUTABLE)
# defined in MacroUtilities.cmake
rocprofiler_systems_custom_compilation(COMPILER ${HIPCC_EXECUTABLE} TARGET hipMallocConcurrencyMproc)
endif()
if(ROCPROFSYS_INSTALL_EXAMPLES)
install(
TARGETS hipMallocConcurrencyMproc
DESTINATION bin
COMPONENT rocprofiler-systems-examples
)
endif()
else()
message(
AUTHOR_WARNING
"hipMallocConcurrencyMproc target could not be built (missing HIP support)"
)
endif()
else()
message(
AUTHOR_WARNING
"hipcc could not be found. Cannot build hipMallocConcurrencyMproc target"
)
endif()