Add 'projects/rocprofiler-sdk/' from commit 'bf0fad1d5406fbc51403ba1aa9621a9d4a9bce2b'

git-subtree-dir: projects/rocprofiler-sdk
git-subtree-mainline: 50a90550e9
git-subtree-split: bf0fad1d54
Cette révision appartient à :
systems-assistant[bot]
2025-07-22 22:52:46 +00:00
révision ad0fb25ed5
1272 fichiers modifiés avec 230117 ajouts et 0 suppressions
+94
Voir le fichier
@@ -0,0 +1,94 @@
# Try to find libdw headers and libraries.
#
# Usage of this module as follows:
#
# find_package(libdw)
#
# Variables used by this module, they can change the default behaviour and need
# to be set before calling find_package:
#
# libdw_ROOT Set this variable to the root installation of
# libdw if the module has problems finding the
# proper installation path.
#
# Variables defined by this module:
#
# libdw_FOUND System has libdw libraries and headers
# libdw_LIBRARIES The libdw library
# libdw_INCLUDE_DIRS The location of libdw headers
#
# Interface targets defined by this module:
#
# libdw::libdw
#
find_package(PkgConfig)
if(PkgConfig_FOUND)
set(ENV{PKG_CONFIG_SYSTEM_INCLUDE_PATH} "")
pkg_check_modules(DW libdw)
if(DW_FOUND
AND DW_INCLUDE_DIRS
AND DW_LINK_LIBRARIES)
set(libdw_INCLUDE_DIR
"${DW_INCLUDE_DIRS}"
CACHE FILEPATH "libdw include directory")
set(libdw_LIBRARY
"${DW_LINK_LIBRARIES}"
CACHE FILEPATH "libdw libraries")
if(DW_PREFIX)
set(libdw_ROOT_DIR
"${DW_PREFIX}"
CACHE FILEPATH "libdw root directory")
endif()
if(DW_VERSION)
set(libdw_VERSION
"${DW_VERSION}"
CACHE FILEPATH "libdw version")
endif()
endif()
endif()
if(NOT libdw_INCLUDE_DIR OR NOT libdw_LIBRARY)
find_path(
libdw_ROOT_DIR
NAMES include/elfutils/libdw.h
HINTS ${libdw_ROOT}
PATHS ${libdw_ROOT})
mark_as_advanced(libdw_ROOT_DIR)
find_path(
libdw_INCLUDE_DIR
NAMES elfutils/libdw.h
HINTS ${libdw_ROOT}
PATHS ${libdw_ROOT}
PATH_SUFFIXES include)
find_library(
libdw_LIBRARY
NAMES dw
HINTS ${libdw_ROOT}
PATHS ${libdw_ROOT}
PATH_SUFFIXES lib lib64)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(libdw DEFAULT_MSG libdw_LIBRARY libdw_INCLUDE_DIR)
if(libdw_FOUND)
if(NOT TARGET libdw::libdw)
add_library(libdw::libdw INTERFACE IMPORTED)
if(TARGET PkgConfig::DW AND DW_FOUND)
target_link_libraries(libdw::libdw INTERFACE PkgConfig::DW)
else()
target_link_libraries(libdw::libdw INTERFACE ${libdw_LIBRARY})
target_include_directories(libdw::libdw SYSTEM INTERFACE ${libdw_INCLUDE_DIR})
endif()
endif()
endif()
mark_as_advanced(libdw_INCLUDE_DIR libdw_LIBRARY)
+83
Voir le fichier
@@ -0,0 +1,83 @@
# Try to find libelf headers and libraries.
#
# Usage of this module as follows:
#
# find_package(libelf)
#
# Variables used by this module, they can change the default behaviour and need
# to be set before calling find_package:
#
# libelf_ROOT Set this variable to the root installation of
# libelf if the module has problems finding the
# proper installation path.
#
# Variables defined by this module:
#
# libelf_FOUND System has libelf libraries and headers
# libelf_LIBRARIES The libelf library
# libelf_INCLUDE_DIRS The location of libelf headers
#
# Interface targets defined by this module:
#
# libelf::libelf
#
find_package(PkgConfig)
if(PkgConfig_FOUND)
set(ENV{PKG_CONFIG_SYSTEM_INCLUDE_PATH} "")
pkg_check_modules(ELF libelf)
if(ELF_FOUND
AND ELF_INCLUDE_DIRS
AND ELF_LIBRARIES)
set(libelf_INCLUDE_DIR
"${ELF_INCLUDE_DIRS}"
CACHE FILEPATH "libelf include directory")
set(libelf_LIBRARY
"${ELF_LIBRARIES}"
CACHE FILEPATH "libelf libraries")
endif()
endif()
if(NOT libelf_INCLUDE_DIR OR NOT libelf_LIBRARY)
find_path(
libelf_ROOT_DIR
NAMES include/elf.h
HINTS ${libelf_ROOT}
PATHS ${libelf_ROOT})
mark_as_advanced(libelf_ROOT_DIR)
find_path(
libelf_INCLUDE_DIR
NAMES elf.h
HINTS ${libelf_ROOT}
PATHS ${libelf_ROOT}
PATH_SUFFIXES include)
find_library(
libelf_LIBRARY
NAMES elf
HINTS ${libelf_ROOT}
PATHS ${libelf_ROOT}
PATH_SUFFIXES lib lib64)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(libelf DEFAULT_MSG libelf_LIBRARY libelf_INCLUDE_DIR)
if(libelf_FOUND)
if(NOT TARGET libelf::libelf)
add_library(libelf::libelf INTERFACE IMPORTED)
endif()
if(TARGET PkgConfig::ELF AND ELF_FOUND)
target_link_libraries(libelf::libelf INTERFACE PkgConfig::ELF)
else()
target_link_libraries(libelf::libelf INTERFACE ${libelf_LIBRARY})
target_include_directories(libelf::libelf SYSTEM INTERFACE ${libelf_INCLUDE_DIR})
endif()
endif()
mark_as_advanced(libelf_INCLUDE_DIR libelf_LIBRARY)
+90
Voir le fichier
@@ -0,0 +1,90 @@
################################################################################
# Copyright (c) 2024 - 2025 Advanced Micro Devices, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
################################################################################
include_guard(DIRECTORY)
# find rocDecode - library and headers
find_path(
rocDecode_ROOT_DIR
NAMES include/rocdecode
HINTS ${ROCM_PATH}
PATHS ${ROCM_PATH})
mark_as_advanced(rocDecode_ROOT_DIR)
find_path(
rocDecode_INCLUDE_DIR
NAMES rocdecode/rocdecode.h
HINTS ${rocDecode_ROOT_DIR}
PATHS ${rocDecode_ROOT_DIR}
PATH_SUFFIXES include)
find_library(
rocDecode_LIBRARY
NAMES rocdecode
HINTS ${rocDecode_ROOT_DIR}
PATHS ${rocDecode_ROOT_DIR}
PATH_SUFFIXES lib)
function(_rocdecode_read_version_header _VERSION_VAR)
if(rocDecode_INCLUDE_DIR AND EXISTS
"${rocDecode_INCLUDE_DIR}/rocdecode/rocdecode_version.h")
file(READ "${rocDecode_INCLUDE_DIR}/rocdecode/rocdecode_version.h"
_rocdecode_version)
macro(_rocdecode_get_version_num _VAR _NAME)
string(REGEX MATCH "define([ \t]+)${_NAME}([ \t]+)([0-9]+)" _tmp
"${_rocdecode_version}")
set(${_VAR} 0)
if(_tmp MATCHES "([0-9]+)")
string(REGEX REPLACE "(.*${_NAME}[ ]+)([0-9]+)" "\\2" ${_VAR} "${_tmp}")
endif()
endmacro()
_rocdecode_get_version_num(_major "ROCDECODE_MAJOR_VERSION")
_rocdecode_get_version_num(_minor "ROCDECODE_MINOR_VERSION")
_rocdecode_get_version_num(_patch "ROCDECODE_PATCH_VERSION")
set(${_VERSION_VAR}
${_major}.${_minor}.${_patch}
PARENT_SCOPE)
endif()
endfunction()
_rocdecode_read_version_header(rocDecode_VERSION)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
rocDecode
FOUND_VAR rocDecode_FOUND
VERSION_VAR rocDecode_VERSION
REQUIRED_VARS rocDecode_INCLUDE_DIR rocDecode_LIBRARY)
if(rocDecode_FOUND)
if(NOT TARGET rocDecode::rocDecode)
add_library(rocDecode::rocDecode INTERFACE IMPORTED)
target_link_libraries(rocDecode::rocDecode INTERFACE ${rocDecode_LIBRARY})
target_include_directories(rocDecode::rocDecode
INTERFACE ${rocDecode_INCLUDE_DIR})
endif()
endif()
mark_as_advanced(rocDecode_INCLUDE_DIR rocDecode_LIBRARY)
+87
Voir le fichier
@@ -0,0 +1,87 @@
################################################################################
# Copyright (c) 2024 - 2025 Advanced Micro Devices, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
################################################################################
include_guard(DIRECTORY)
# find rocJPEG - library and headers
find_path(
rocJPEG_ROOT_DIR
NAMES include/rocjpeg
HINTS ${ROCM_PATH}
PATHS ${ROCM_PATH})
mark_as_advanced(rocJPEG_ROOT_DIR)
find_path(
rocJPEG_INCLUDE_DIR
NAMES rocjpeg/rocjpeg.h
HINTS ${rocJPEG_ROOT_DIR}
PATHS ${rocJPEG_ROOT_DIR}
PATH_SUFFIXES include)
find_library(
rocJPEG_LIBRARY
NAMES rocjpeg
HINTS ${rocJPEG_ROOT_DIR}
PATHS ${rocJPEG_ROOT_DIR}
PATH_SUFFIXES lib)
function(_rocjpeg_read_version_header _VERSION_VAR)
if(rocJPEG_INCLUDE_DIR AND EXISTS "${rocJPEG_INCLUDE_DIR}/rocjpeg/rocjpeg_version.h")
file(READ "${rocJPEG_INCLUDE_DIR}/rocjpeg/rocjpeg_version.h" _rocjpeg_version)
macro(_rocjpeg_get_version_num _VAR _NAME)
string(REGEX MATCH "define([ \t]+)${_NAME}([ \t]+)([0-9]+)" _tmp
"${_rocjpeg_version}")
set(${_VAR} 0)
if(_tmp MATCHES "([0-9]+)")
string(REGEX REPLACE "(.*${_NAME}[ ]+)([0-9]+)" "\\2" ${_VAR} "${_tmp}")
endif()
endmacro()
_rocjpeg_get_version_num(_major "ROCJPEG_MAJOR_VERSION")
_rocjpeg_get_version_num(_minor "ROCJPEG_MINOR_VERSION")
_rocjpeg_get_version_num(_patch "ROCJPEG_MICRO_VERSION")
set(${_VERSION_VAR}
${_major}.${_minor}.${_patch}
PARENT_SCOPE)
endif()
endfunction()
_rocjpeg_read_version_header(rocJPEG_VERSION)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
rocJPEG
FOUND_VAR rocJPEG_FOUND
VERSION_VAR rocJPEG_VERSION
REQUIRED_VARS rocJPEG_INCLUDE_DIR rocJPEG_LIBRARY)
if(rocJPEG_FOUND)
if(NOT TARGET rocJPEG::rocJPEG)
add_library(rocJPEG::rocJPEG INTERFACE IMPORTED)
target_link_libraries(rocJPEG::rocJPEG INTERFACE ${rocJPEG_LIBRARY})
target_include_directories(rocJPEG::rocJPEG INTERFACE ${rocJPEG_INCLUDE_DIR})
endif()
endif()
mark_as_advanced(rocJPEG_INCLUDE_DIR rocJPEG_LIBRARY)
+302
Voir le fichier
@@ -0,0 +1,302 @@
#[=======================================================================[.rst:
Findrocm_version
---------------
Search the <ROCM_PATH>/.info/version* files to determine the version of ROCm
Use this module by invoking find_package with the form::
find_package(rocm_version
[version] [EXACT]
[REQUIRED])
This module finds the version info for ROCm. The cached variables are::
rocm_version_FOUND - Whether the ROCm versioning was found
rocm_version_FULL_VERSION - The exact string from `<ROCM_PATH>/.info/version` or similar
rocm_version_MAJOR_VERSION - Major version, e.g. 4 in 4.5.2.100-40502
rocm_version_MINOR_VERSION - Minor version, e.g. 5 in 4.5.2.100-40502
rocm_version_PATCH_VERSION - Patch version, e.g. 2 in 4.5.2.100-40502
rocm_version_TWEAK_VERSION - Tweak version, e.g. 100 in 4.5.2.100-40502
rocm_version_REVISION_VERSION - Revision version, e.g. 40502 in 4.5.2.100-40502.
rocm_version_EPOCH_VERSION - See deb-version for a description of epochs. Epochs are used when versioning system change
rocm_version_CANONICAL_VERSION - `[<EPOCH>:]<MAJOR>.<MINOR>.<MINOR>[.<TWEAK>][-<REVISION>]`
rocm_version_NUMERIC_VERSION - e.g. `10000*<MAJOR> + 100*<MINOR> + <PATCH>`, e.g. 40502 for ROCm 4.5.2
rocm_version_TRIPLE_VERSION - e.g. `<MAJOR>.<MINOR>.<PATCH>`, e.g. 4.5.2 for ROCm 4.5.2
These variables are relevant for the find procedure::
rocm_version_DEBUG - Print info about processing
rocm_version_VERSION_FILE - `<FILE>` to read from in `<ROCM_PATH>/.info/<FILE>`, e.g. `version`, `version-dev`, `version-hip-libraries`, etc.
It may also be a full path
rocm_version_DIR - Root location for <ROCM_PATH>
#]=======================================================================]
set(rocm_version_VARIABLES
EPOCH
MAJOR
MINOR
PATCH
TWEAK
REVISION
TRIPLE
NUMERIC
CANONICAL
FULL)
function(ROCM_VERSION_MESSAGE _TYPE)
if(rocm_version_DEBUG)
message(${_TYPE} "[rocm_version] ${ARGN}")
endif()
endfunction()
# read a .info/version* file and propagate the variables to the calling scope
function(ROCM_VERSION_COMPUTE FULL_VERSION_STRING _VAR_PREFIX)
# remove any line endings
string(REGEX REPLACE "(\n|\r)" "" FULL_VERSION_STRING "${FULL_VERSION_STRING}")
# store the full version so it can be set later
set(FULL_VERSION "${FULL_VERSION_STRING}")
# get number and remove from full version string
string(REGEX REPLACE "([0-9]+)\:(.*)" "\\1" EPOCH_VERSION "${FULL_VERSION_STRING}")
string(REGEX REPLACE "([0-9]+)\:(.*)" "\\2" FULL_VERSION_STRING
"${FULL_VERSION_STRING}")
if(EPOCH_VERSION STREQUAL FULL_VERSION)
set(EPOCH_VERSION)
endif()
# get number and remove from full version string
string(REGEX REPLACE "([0-9]+)(.*)" "\\1" MAJOR_VERSION "${FULL_VERSION_STRING}")
string(REGEX REPLACE "([0-9]+)(.*)" "\\2" FULL_VERSION_STRING
"${FULL_VERSION_STRING}")
# get number and remove from full version string
string(REGEX REPLACE "\.([0-9]+)(.*)" "\\1" MINOR_VERSION "${FULL_VERSION_STRING}")
string(REGEX REPLACE "\.([0-9]+)(.*)" "\\2" FULL_VERSION_STRING
"${FULL_VERSION_STRING}")
# get number and remove from full version string
string(REGEX REPLACE "\.([0-9]+)(.*)" "\\1" PATCH_VERSION "${FULL_VERSION_STRING}")
string(REGEX REPLACE "\.([0-9]+)(.*)" "\\2" FULL_VERSION_STRING
"${FULL_VERSION_STRING}")
if(NOT PATCH_VERSION LESS 100)
set(PATCH_VERSION 0)
endif()
# get number and remove from full version string
string(REGEX REPLACE "\.([0-9]+)(.*)" "\\1" TWEAK_VERSION "${FULL_VERSION_STRING}")
string(REGEX REPLACE "\.([0-9]+)(.*)" "\\2" FULL_VERSION_STRING
"${FULL_VERSION_STRING}")
# get number
string(REGEX REPLACE "-([0-9A-Za-z+~]+)" "\\1" REVISION_VERSION
"${FULL_VERSION_STRING}")
set(CANONICAL_VERSION)
set(_MAJOR_SEP ":")
set(_MINOR_SEP ".")
set(_PATCH_SEP ".")
set(_TWEAK_SEP ".")
set(_REVISION_SEP "-")
foreach(_V EPOCH MAJOR MINOR PATCH TWEAK REVISION)
if(${_V}_VERSION)
set(CANONICAL_VERSION "${CANONICAL_VERSION}${_${_V}_SEP}${${_V}_VERSION}")
else()
set(CANONICAL_VERSION "${CANONICAL_VERSION}${_${_V}_SEP}0")
endif()
endforeach()
set(_MAJOR_SEP "")
foreach(_V MAJOR MINOR PATCH)
if(${_V}_VERSION)
set(TRIPLE_VERSION "${TRIPLE_VERSION}${_${_V}_SEP}${${_V}_VERSION}")
else()
set(TRIPLE_VERSION "${TRIPLE_VERSION}${_${_V}_SEP}0")
endif()
endforeach()
math(
EXPR
NUMERIC_VERSION
"(10000 * (${MAJOR_VERSION}+0)) + (100 * (${MINOR_VERSION}+0)) + (${PATCH_VERSION}+0)"
)
# propagate to parent scopes
foreach(_V ${rocm_version_VARIABLES})
set(${_VAR_PREFIX}_${_V}_VERSION
${${_V}_VERSION}
PARENT_SCOPE)
endforeach()
endfunction()
# this macro watches for changes in the variables and unsets the remaining cache varaible
# when they change
function(ROCM_VERSION_WATCH_FOR_CHANGE _var)
set(_rocm_version_watch_var_name rocm_version_WATCH_VALUE_${_var})
if(DEFINED ${_rocm_version_watch_var_name})
if("${${_var}}" STREQUAL "${${_rocm_version_watch_var_name}}")
if(NOT "${${_var}}" STREQUAL "")
rocm_version_message(STATUS "${_var} :: ${${_var}}")
endif()
list(REMOVE_ITEM _REMAIN_VARIABLES ${_var})
set(_REMAIN_VARIABLES
"${_REMAIN_VARIABLES}"
PARENT_SCOPE)
return()
else()
rocm_version_message(
STATUS
"${_var} changed :: ${${_rocm_version_watch_var_name}} --> ${${_var}}")
foreach(_V ${_REMAIN_VARIABLES})
rocm_version_message(
STATUS "${_var} changed :: Unsetting cache variable ${_V}...")
unset(${_V} CACHE)
endforeach()
endif()
else()
if(NOT "${${_var}}" STREQUAL "")
rocm_version_message(STATUS "${_var} :: ${${_var}}")
endif()
endif()
# store the value for the next run
set(${_rocm_version_watch_var_name}
"${${_var}}"
CACHE INTERNAL "Last value of ${_var}" FORCE)
endfunction()
# scope this to a function to avoid leaking local variables
function(ROCM_VERSION_PARSE_VERSION_FILES)
# the list of variables set by module. when one of these changes, we need to unset the
# cache variables after it
set(_ALL_VARIABLES)
foreach(_V ${rocm_version_VARIABLES})
list(APPEND _ALL_VARIABLES rocm_version_${_V}_VERSION)
endforeach()
set(_REMAIN_VARIABLES ${_ALL_VARIABLES})
# read a .info/version* file and propagate the variables to the calling scope
function(ROCM_VERSION_READ_FILE _FILE _VAR_PREFIX)
file(READ "${_FILE}" FULL_VERSION_STRING LIMIT_COUNT 1)
rocm_version_compute("${FULL_VERSION_STRING}" "${_VAR_PREFIX}")
# propagate to parent scopes
foreach(_V ${rocm_version_VARIABLES})
set(${_VAR_PREFIX}_${_V}_VERSION
${${_VAR_PREFIX}_${_V}_VERSION}
PARENT_SCOPE)
endforeach()
endfunction()
# search for HIP to set ROCM_PATH if(NOT hip_FOUND) find_package(hip) endif()
function(COMPUTE_ROCM_VERSION_DIR)
if(EXISTS "${rocm_version_VERSION_FILE}" AND IS_ABSOLUTE
"${rocm_version_VERSION_FILE}")
get_filename_component(_VERSION_DIR "${rocm_version_VERSION_FILE}" PATH)
get_filename_component(_VERSION_DIR "${_VERSION_DIR}/.." REALPATH)
set(rocm_version_DIR
"${_VERSION_DIR}"
CACHE PATH "Root path to ROCm's .info/${rocm_version_VERSION_FILE}"
${ARGN})
rocm_version_watch_for_change(rocm_version_DIR)
endif()
endfunction()
if(rocm_version_VERSION_FILE)
get_filename_component(_VERSION_FILE "${rocm_version_VERSION_FILE}" NAME)
set(_VERSION_FILES ${_VERSION_FILE})
compute_rocm_version_dir(FORCE)
else()
set(_VERSION_FILES version version-dev version-hip-libraries version-hiprt
version-hiprt-devel version-hip-sdk version-libs version-utils)
rocm_version_message(STATUS "rocm_version version files: ${_VERSION_FILES}")
endif()
# convert env to cache if not defined
foreach(_PATH rocm_version_DIR rocm_version_ROOT rocm_version_ROOT_DIR
ROCPROFILER_DEFAULT_ROCM_PATH ROCM_PATH)
if(NOT DEFINED ${_PATH} AND DEFINED ENV{${_PATH}})
set(_VAL "$ENV{${_PATH}}")
get_filename_component(_VAL "${_VAL}" REALPATH)
set(${_PATH}
"${_VAL}"
CACHE PATH "Search path for ROCm version for rocm_version")
endif()
endforeach()
if(rocm_version_DIR)
set(_PATHS ${rocm_version_DIR})
else()
set(_PATHS)
foreach(
_DIR
${rocm_version_DIR} ${rocm_version_ROOT} ${rocm_version_ROOT_DIR}
$ENV{CMAKE_PREFIX_PATH} ${CMAKE_PREFIX_PATH} ${ROCPROFILER_DEFAULT_ROCM_PATH}
${ROCM_PATH} /opt/rocm)
if(EXISTS ${_DIR})
get_filename_component(_ABS_DIR "${_DIR}" REALPATH)
list(APPEND _PATHS ${_ABS_DIR})
endif()
endforeach()
rocm_version_message(STATUS "rocm_version search paths: ${_PATHS}")
endif()
string(REPLACE ":" ";" _PATHS "${_PATHS}")
foreach(_PATH ${_PATHS})
foreach(_FILE ${_VERSION_FILES})
set(_F ${_PATH}/.info/${_FILE})
if(EXISTS ${_F})
set(rocm_version_VERSION_FILE
"${_F}"
CACHE FILEPATH "File with versioning info")
rocm_version_watch_for_change(rocm_version_VERSION_FILE)
compute_rocm_version_dir()
else()
rocm_version_message(AUTHOR_WARNING "File does not exist: ${_F}")
endif()
endforeach()
endforeach()
if(EXISTS "${rocm_version_VERSION_FILE}")
set(_F "${rocm_version_VERSION_FILE}")
rocm_version_message(STATUS "Reading ${_F}...")
get_filename_component(_B "${_F}" NAME)
string(REPLACE "." "_" _B "${_B}")
string(REPLACE "-" "_" _B "${_B}")
rocm_version_read_file(${_F} ${_B})
foreach(_V ${rocm_version_VARIABLES})
set(_CACHE_VAR rocm_version_${_V}_VERSION)
set(_LOCAL_VAR ${_B}_${_V}_VERSION)
set(rocm_version_${_V}_VERSION
"${${_LOCAL_VAR}}"
CACHE STRING "ROCm ${_V} version")
rocm_version_watch_for_change(${_CACHE_VAR})
endforeach()
endif()
endfunction()
# execute
rocm_version_parse_version_files()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
rocm_version
VERSION_VAR rocm_version_FULL_VERSION
REQUIRED_VARS rocm_version_FULL_VERSION rocm_version_TRIPLE_VERSION rocm_version_DIR
rocm_version_VERSION_FILE)
# don't add major/minor/patch/etc. version variables to required vars because they might
# be zero, which will cause CMake to evaluate it as not set
@@ -0,0 +1,90 @@
#
# Custom compilation of source code
#
include_guard(GLOBAL)
# ----------------------------------------------------------------------------------------#
# this provides a function to easily select which files use alternative compiler:
#
# * GLOBAL --> all files
# * TARGET --> all files in a target
# * SOURCE --> specific source files
# * DIRECTORY --> all files in directory
# * PROJECT --> all files/targets in a project/subproject
#
function(rocprofiler_sdk_custom_compilation)
cmake_parse_arguments(COMP "GLOBAL;PROJECT" "COMPILER" "DIRECTORY;TARGET;SOURCE"
${ARGN})
# find rocprofiler-sdk-launch-compiler
find_program(
ROCPROFILER_SDK_COMPILE_LAUNCHER
NAMES rocprofiler-sdk-launch-compiler
HINTS ${rocprofiler-sdk_ROOT_DIR} ${PROJECT_BINARY_DIR} ${CMAKE_BINARY_DIR}
PATHS ${rocprofiler-sdk_ROOT_DIR} ${PROJECT_BINARY_DIR} ${CMAKE_BINARY_DIR}
PATH_SUFFIXES libexec/rocprofiler-sdk)
if(NOT COMP_COMPILER)
message(
FATAL_ERROR
"rocprofiler_sdk_custom_compilation not provided COMPILER argument")
elseif(NOT EXISTS "${COMP_COMPILER}")
cmake_path(GET COMP_COMPILER FILENAME COMP_COMPILER_BASE)
find_program(
ROCPROFILER_SDK_COMPILER_${COMP_COMPILER_BASE}
NAMES ${COMP_COMPILER_BASE}
PATH_SUFFIXES bin REQUIRED)
set(COMP_COMPILER ROCPROFILER_SDK_COMPILER_${COMP_COMPILER_BASE})
endif()
if(NOT ROCPROFILER_SDK_COMPILE_LAUNCHER)
message(
FATAL_ERROR
"rocprofiler-sdk could not find 'rocprofiler-sdk-launch-compiler'. Please set '-DROCPROFILER_SDK_COMPILE_LAUNCHER=/path/to/launcher'"
)
endif()
if(COMP_GLOBAL)
# if global, don't bother setting others
set_property(
GLOBAL
PROPERTY
RULE_LAUNCH_COMPILE
"${ROCPROFILER_SDK_COMPILE_LAUNCHER} ${COMP_COMPILER} ${CMAKE_CXX_COMPILER}"
)
set_property(
GLOBAL
PROPERTY
RULE_LAUNCH_LINK
"${ROCPROFILER_SDK_COMPILE_LAUNCHER} ${COMP_COMPILER} ${CMAKE_CXX_COMPILER}"
)
else()
foreach(_TYPE PROJECT DIRECTORY TARGET SOURCE)
# make project/subproject scoping easy, e.g.
# rocprofiler_sdk_custom_compilation(PROJECT) after project(...)
if("${_TYPE}" STREQUAL "PROJECT" AND COMP_${_TYPE})
list(APPEND COMP_DIRECTORY ${PROJECT_SOURCE_DIR})
unset(COMP_${_TYPE})
endif()
# set the properties if defined
if(COMP_${_TYPE})
foreach(_VAL ${COMP_${_TYPE}})
set_property(
${_TYPE} ${_VAL}
PROPERTY
RULE_LAUNCH_COMPILE
"${ROCPROFILER_SDK_COMPILE_LAUNCHER} ${COMP_COMPILER} ${CMAKE_CXX_COMPILER}"
)
set_property(
${_TYPE} ${_VAL}
PROPERTY
RULE_LAUNCH_LINK
"${ROCPROFILER_SDK_COMPILE_LAUNCHER} ${COMP_COMPILER} ${CMAKE_CXX_COMPILER}"
)
endforeach()
endif()
endforeach()
endif()
endfunction()
+110
Voir le fichier
@@ -0,0 +1,110 @@
#
# Miscellaneous cmake functions for rocprofiler-sdk
#
include_guard(GLOBAL)
function(rocprofiler_sdk_get_gfx_architectures _VAR)
cmake_parse_arguments(ARG "ECHO" "PREFIX;DELIM" "" ${ARGN})
if(NOT DEFINED ARG_DELIM)
set(ARG_DELIM ", ")
endif()
set(CMAKE_MESSAGE_INDENT "[${PROJECT_NAME}]${ARG_PREFIX} ")
find_program(
rocminfo_EXECUTABLE
NAMES rocminfo
HINTS ${rocprofiler-sdk_ROOT_DIR} ${rocm_version_DIR} ${ROCM_PATH} /opt/rocm
PATHS ${rocprofiler-sdk_ROOT_DIR} ${rocm_version_DIR} ${ROCM_PATH} /opt/rocm
PATH_SUFFIXES bin)
if(rocminfo_EXECUTABLE)
execute_process(
COMMAND ${rocminfo_EXECUTABLE}
RESULT_VARIABLE rocminfo_RET
OUTPUT_VARIABLE rocminfo_OUT
ERROR_VARIABLE rocminfo_ERR
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_STRIP_TRAILING_WHITESPACE)
if(rocminfo_RET EQUAL 0)
string(REGEX MATCHALL "gfx([0-9A-Fa-f]+)" rocminfo_GFXINFO "${rocminfo_OUT}")
list(REMOVE_DUPLICATES rocminfo_GFXINFO)
set(${_VAR}
"${rocminfo_GFXINFO}"
PARENT_SCOPE)
if(ARG_ECHO)
string(REPLACE ";" "${ARG_DELIM}" _GFXINFO_ECHO "${rocminfo_GFXINFO}")
message(STATUS "${ARG_PREFIX}System architectures: ${_GFXINFO_ECHO}")
endif()
else()
message(
AUTHOR_WARNING
"${rocminfo_EXECUTABLE} returned ${rocminfo_RET}\nstderr:\n${rocminfo_ERR}\nstdout:\n${rocminfo_OUT}"
)
endif()
endif()
endfunction()
# In case the underlying architecture does not support PC sampling, this function will
# tell us whether the PC sampling is disabled
function(rocprofiler_sdk_pc_sampling_disabled _VAR)
cmake_parse_arguments(ARG "ECHO" "PREFIX" "" ${ARGN})
set(CMAKE_MESSAGE_INDENT "[${PROJECT_NAME}]${ARG_PREFIX} ")
rocprofiler_sdk_get_gfx_architectures(rocprofiler-sdk-tests-gfx-info ECHO)
list(GET rocprofiler-sdk-tests-gfx-info 0 pc-sampling-gpu-0-gfx-info)
if("${pc-sampling-gpu-0-gfx-info}" MATCHES "^gfx90a$"
OR "${pc-sampling-gpu-0-gfx-info}" MATCHES "^gfx94[0-9]$"
OR "${pc-sampling-gpu-0-gfx-info}" MATCHES "^gfx95[0-9]$")
# PC sampling is enabled on this architecture.
set(${_VAR}
FALSE
PARENT_SCOPE)
if(ARG_ECHO)
message(STATUS "PC Sampling is enabled for ${pc-sampling-gpu-0-gfx-info}")
endif()
else()
# PC sampling is disabled on this architecture.
set(${_VAR}
TRUE
PARENT_SCOPE)
if(ARG_ECHO)
message(STATUS "PC Sampling is disabled for ${pc-sampling-gpu-0-gfx-info}")
endif()
endif()
endfunction()
# In case the underlying architecture does not support stochastic PC sampling, this
# function will tell us whether the PC sampling is disabled
function(rocprofiler_sdk_pc_sampling_stochastic_disabled _VAR)
cmake_parse_arguments(ARG "ECHO" "PREFIX" "" ${ARGN})
set(CMAKE_MESSAGE_INDENT "[${PROJECT_NAME}]${ARG_PREFIX} ")
rocprofiler_sdk_get_gfx_architectures(rocprofiler-sdk-tests-gfx-info ECHO)
list(GET rocprofiler-sdk-tests-gfx-info 0 pc-sampling-gpu-0-gfx-info)
if("${pc-sampling-gpu-0-gfx-info}" MATCHES "^gfx94[0-9]$"
OR "${pc-sampling-gpu-0-gfx-info}" MATCHES "^gfx95[0-9]$")
# PC sampling is enabled on this architecture.
set(${_VAR}
FALSE
PARENT_SCOPE)
if(ARG_ECHO)
message(STATUS "PC Sampling is enabled for ${pc-sampling-gpu-0-gfx-info}")
endif()
else()
# PC sampling is disabled on this architecture.
set(${_VAR}
TRUE
PARENT_SCOPE)
if(ARG_ECHO)
message(STATUS "PC Sampling is disabled for ${pc-sampling-gpu-0-gfx-info}")
endif()
endif()
endfunction()