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

git-subtree-dir: projects/rocprofiler-sdk
git-subtree-mainline: 50a90550e9
git-subtree-split: bf0fad1d54
このコミットが含まれているのは:
systems-assistant[bot] committed 2025-07-22 22:52:46 +00:00
コミット ad0fb25ed5
1272ファイル変更
+230117

検索条件に一致するファイルはありません

+8
ファイルの表示
@@ -0,0 +1,8 @@
#
#
#
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "development")
add_subdirectory(rocprofiler-sdk)
add_subdirectory(rocprofiler-sdk-roctx)
add_subdirectory(rocprofiler-sdk-rocpd)
+18
ファイルの表示
@@ -0,0 +1,18 @@
#
#
# Installation of public headers
#
#
configure_file(${CMAKE_CURRENT_LIST_DIR}/version.h.in
${CMAKE_CURRENT_BINARY_DIR}/version.h @ONLY)
set(ROCPD_HEADER_FILES
# core headers
rocpd.h
# secondary headers
defines.h types.h ${CMAKE_CURRENT_BINARY_DIR}/version.h)
install(
FILES ${ROCPD_HEADER_FILES}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocprofiler-sdk-rocpd
COMPONENT rocpd)
+130
ファイルの表示
@@ -0,0 +1,130 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
/**
* @defgroup SYMBOL_VERSIONING_GROUP Symbol Versions
*
* @brief The names used for the shared library versioned symbols.
*
* Every function is annotated with one of the version macros defined in this
* section. Each macro specifies a corresponding symbol version string. After
* dynamically loading the shared library with @p dlopen, the address of each
* function can be obtained using @p dlsym with the name of the function and
* its corresponding symbol version string. An error will be reported by @p
* dlvsym if the installed library does not support the version for the
* function specified in this version of the interface.
*
* @{
*/
/**
* @brief The function was introduced in version 0.0 of the interface and has the
* symbol version string of ``"ROCPROFILER_SDK_ROCPD_0.0"``.
*/
#define ROCPROFILER_SDK_ROCPD_VERSION_0_0
/** @} */
#if !defined(ROCPD_ATTRIBUTE)
# if defined(_MSC_VER)
# define ROCPD_ATTRIBUTE(...) __declspec(__VA_ARGS__)
# else
# define ROCPD_ATTRIBUTE(...) __attribute__((__VA_ARGS__))
# endif
#endif
#if !defined(ROCPD_PUBLIC_API)
# if defined(_MSC_VER)
# define ROCPD_PUBLIC_API ROCPD_ATTRIBUTE(dllexport)
# else
# define ROCPD_PUBLIC_API ROCPD_ATTRIBUTE(visibility("default"))
# endif
#endif
#if !defined(ROCPD_HIDDEN_API)
# if defined(_MSC_VER)
# define ROCPD_HIDDEN_API
# else
# define ROCPD_HIDDEN_API ROCPD_ATTRIBUTE(visibility("hidden"))
# endif
#endif
#if !defined(ROCPD_EXPORT_DECORATOR)
# define ROCPD_EXPORT_DECORATOR ROCPD_PUBLIC_API
#endif
#if !defined(ROCPD_IMPORT_DECORATOR)
# if defined(_MSC_VER)
# define ROCPD_IMPORT_DECORATOR ROCPD_ATTRIBUTE(dllimport)
# else
# define ROCPD_IMPORT_DECORATOR
# endif
#endif
#define ROCPD_EXPORT ROCPD_EXPORT_DECORATOR
#define ROCPD_IMPORT ROCPD_IMPORT_DECORATOR
#if !defined(ROCPD_API)
# if defined(rocpd_EXPORTS)
# define ROCPD_API ROCPD_EXPORT
# else
# define ROCPD_API ROCPD_IMPORT
# endif
#endif
#if defined(__has_attribute)
# if __has_attribute(nonnull)
# define ROCPD_NONNULL(...) __attribute__((nonnull(__VA_ARGS__)))
# else
# define ROCPD_NONNULL(...)
# endif
#else
# if defined(__GNUC__)
# define ROCPD_NONNULL(...) __attribute__((nonnull(__VA_ARGS__)))
# else
# define ROCPD_NONNULL(...)
# endif
#endif
#ifdef __cplusplus
# define ROCPD_EXTERN_C_INIT extern "C" {
# define ROCPD_EXTERN_C_FINI }
#else
# define ROCPD_EXTERN_C_INIT
# define ROCPD_EXTERN_C_FINI
#endif
#if !defined(ROCPD_EXPERIMENTAL_WARNINGS)
# define ROCPD_EXPERIMENTAL_WARNINGS 0
#endif
#define ROCPD_EXPERIMENTAL_MESSAGE \
ROCPD_DEPRECATED_MESSAGE("Note: this feature has been marked as experimental. Define " \
"ROCPD_EXPERIMENTAL_WARNINGS=0 to silence this message.")
#if defined(ROCPD_EXPERIMENTAL_WARNINGS) && ROCPD_EXPERIMENTAL_WARNINGS > 0
# define ROCPD_EXPERIMENTAL ROCPD_EXPERIMENTAL_MESSAGE
#else
# define ROCPD_EXPERIMENTAL
#endif
+118
ファイルの表示
@@ -0,0 +1,118 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
/**
* @file rocpd.h
* @brief rocPD API interface for AMD profiling data analysis
*
* @mainpage rocPD API Specification
*
*/
#include "rocprofiler-sdk-rocpd/defines.h"
#include "rocprofiler-sdk-rocpd/types.h"
/**
* @defgroup VERSIONING_GROUP Library Versioning
* @brief Version information about the interface and the associated installed library.
*
* The semantic version of the interface following semver.org rules. A context
* that uses this interface is only compatible with the installed library if
* the major version numbers match and the interface minor version number is
* less than or equal to the installed library minor version number.
*
* @{
*/
#include "rocprofiler-sdk-rocpd/version.h"
ROCPD_EXTERN_C_INIT
/**
* @fn rocpd_status_t rocpd_get_version(uint32_t* major, uint32_t* minor, uint32_t*
* patch)
* @brief Query the version of the installed library.
*
* Returns the version of the rocprofiler-sdk library loaded at runtime. This can be used to check
* if the runtime version is equal to or compatible with the version of rocprofiler-sdk used during
* compilation time. This function can be invoked before tool initialization.
*
* @param [out] major The major version number is stored if non-NULL.
* @param [out] minor The minor version number is stored if non-NULL.
* @param [out] patch The patch version number is stored if non-NULL.
* @return ::rocpd_status_t
* @retval ::ROCPD_STATUS_SUCCESS Always returned
*/
rocpd_status_t
rocpd_get_version(uint32_t* major, uint32_t* minor, uint32_t* patch) ROCPD_API;
/**
* @brief Simplified alternative to ::rocpd_get_version
*
* Returns the version of the rocprofiler-sdk library loaded at runtime. This can be used to check
* if the runtime version is equal to or compatible with the version of rocprofiler-sdk used during
* compilation time. This function can be invoked before tool initialization.
*
* @param [out] info Pointer to version triplet struct which will be populated by the function call.
* @return ::rocpd_status_t
* @retval ::ROCPD_STATUS_SUCCESS Always returned
*/
rocpd_status_t
rocpd_get_version_triplet(rocpd_version_triplet_t* info) ROCPD_API ROCPD_NONNULL(1);
ROCPD_EXTERN_C_FINI
/** @} */
#include "rocprofiler-sdk-rocpd/sql.h"
ROCPD_EXTERN_C_INIT
/**
* @defgroup MISCELLANEOUS_GROUP Miscellaneous Utility Functions
* @brief utility functions for library
* @{
*/
/**
* @fn const char* rocpd_get_status_name(rocpd_status_t status)
* @brief Return the string encoding of ::rocpd_status_t value
* @param [in] status error code value
* @return Will return a nullptr if invalid/unsupported ::rocpd_status_t value is provided.
*/
const char*
rocpd_get_status_name(rocpd_status_t status) ROCPD_API;
/**
* @fn const char* rocpd_get_status_string(rocpd_status_t status)
* @brief Return the message associated with ::rocpd_status_t value
* @param [in] status error code value
* @return Will return a nullptr if invalid/unsupported ::rocpd_status_t value is provided.
*/
const char*
rocpd_get_status_string(rocpd_status_t status) ROCPD_API;
/** @} */
ROCPD_EXTERN_C_FINI
+151
ファイルの表示
@@ -0,0 +1,151 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk-rocpd/defines.h>
#include <rocprofiler-sdk-rocpd/types.h>
#include <stdint.h>
ROCPD_EXTERN_C_INIT
/**
* @defgroup SQL rocPD SQL Utilities
* @brief Functions for reading rocpd SQL schema
* @{
*/
/**
* @brief (experimental) Supported SQL engines. Initial support is for SQLite3, other engines such
* as MySQL may be added
*/
typedef enum ROCPD_EXPERIMENTAL rocpd_sql_engine_t
{
ROCPD_SQL_ENGINE_NONE = 0,
ROCPD_SQL_ENGINE_SQLITE3, ///< Ensure compatibility with SQLite3
ROCPD_SQL_ENGINE_LAST,
} rocpd_sql_engine_t;
/**
* @brief (experimental) Supported SQL schema kinds
*/
typedef enum ROCPD_EXPERIMENTAL rocpd_sql_schema_kind_t
{
ROCPD_SQL_SCHEMA_NONE = 0,
ROCPD_SQL_SCHEMA_ROCPD_TABLES,
ROCPD_SQL_SCHEMA_ROCPD_INDEXES,
ROCPD_SQL_SCHEMA_ROCPD_VIEWS,
ROCPD_SQL_SCHEMA_ROCPD_DATA_VIEWS,
ROCPD_SQL_SCHEMA_ROCPD_SUMMARY_VIEWS,
ROCPD_SQL_SCHEMA_ROCPD_MARKER_VIEWS,
ROCPD_SQL_SCHEMA_LAST,
} rocpd_sql_schema_kind_t;
/**
* @brief (experimental) Supported SQL options
*/
typedef enum ROCPD_EXPERIMENTAL rocpd_sql_options_t
{
ROCPD_SQL_OPTIONS_NONE = 0,
ROCPD_SQL_OPTIONS_PERSIST_STRINGS = 0x01, ///< do not delete strings
ROCPD_SQL_OPTIONS_SQLITE3_PRAGMA_FOREIGN_KEYS = 0x02, ///< enable SQLite3 foreign keys
ROCPD_SQL_OPTIONS_LAST = 0xFFFFFFFF,
} rocpd_sql_options_t;
/**
* @brief (experimental) Schema jinja variable substitution values. In general, the struct member
* variable replaces jinja variables of the same name, e.g. the struct member variable `uuid`
* replaces `{{uuid}}` in the schema definition.
*
* When the schema variable `{{uuid}}` is a non-null and non-empty string, it
* will be prefixed with a leading underscore (`_`) and all hyphens will be replaced with
* underscores. This is because this variable is used in SQL table names. The leading
* underscore improves the readability of the table name and the replacement of hyphens with
* underscores is reduces problems.
*/
typedef struct ROCPD_EXPERIMENTAL rocpd_sql_schema_jinja_variables_t
{
uint64_t size; ///< Size of this struct (minus reserved padding)
const char* uuid; ///< Substitution for `{{uuid}}` (non-empty adds leading underscore)
const char* guid; ///< Substitution for `{{guid}}`
} rocpd_sql_schema_jinja_variables_t;
/**
* @brief (experimental) Callback providing the schema content after variable substitution.
*
* @param [in] engine Schema conforms to this SQL database engine
* @param [in] kind Schema category
* @param [in] options Schema options included in content
* @param [in] variables Jinja variables which were substituted
* @param [in] schema_path Filesystem path to base schema file
* @param [in] schema_content SQL schema content is pass to database
* @param [in] user_data User provided data
*/
ROCPD_EXPERIMENTAL typedef void (*rocpd_sql_load_schema_cb_t)(
rocpd_sql_engine_t engine,
rocpd_sql_schema_kind_t kind,
rocpd_sql_options_t options,
const rocpd_sql_schema_jinja_variables_t* variables,
const char* schema_path,
const char* schema_content,
void* user_data);
/**
* @brief (experimental) Invoke the callback which provides the schema kind definition for the given
* SQL engine + the addition of the requested options + jinja variable substitution.
*
* @param [in] engine SQL schema contents should be compatible with this SQL database engine
* @param [in] kind SQL schema kind (tables, indexes, views, etc.)
* @param [in] options Options for the callback and schema
* @param [in] variables Defines variables for jinja substitution. If nullptr, no jinja variables
* will be substituted. For each member variable that is a nullptr, jinja for that member variable
* will not be substituted. To replace jinja variables with empty strings, assign all member
* variables to empty string.
* @param [in] callback Callback function which provides the schema contents
* @param [in] schema_path_hints Suggests for where to find the schema templates
* @param [in] num_schema_path_hints Number of schema path hints
* @param [in] user_data Pointer to pass back into callback
* @return ::rocpd_status_t
* @retval ROCPD_STATUS_SUCCESS if all parameter specifications were applied and callback
* successfully invoked
* @retval ROCPD_STATUS_ERROR_INVALID_ARGUMENT Invalid SQL engine
* @retval ROCPD_STATUS_ERROR_NOT_AVAILABLE Schema file could not be found
* @retval ROCPD_STATUS_ERROR_PERMISSION_DENIED Schema file could not be found
* @retval ROCPD_STATUS_ERROR_KIND_NOT_FOUND Invalid SQL schema kind
* @retval ROCPD_STATUS_ERROR There was some issue with parameters
* @retval ROCPD_STATUS_ERROR_INVALID_ARGUMENT ::rocpd_sql_schema_jinja_variables_t size parameter
* not set
*/
ROCPD_EXPERIMENTAL rocpd_status_t
rocpd_sql_load_schema(rocpd_sql_engine_t engine,
rocpd_sql_schema_kind_t kind,
rocpd_sql_options_t options,
const rocpd_sql_schema_jinja_variables_t* variables,
rocpd_sql_load_schema_cb_t callback,
const char** schema_path_hints,
uint64_t num_schema_path_hints,
void* user_data) ROCPD_API ROCPD_NONNULL(5);
/** @} */
ROCPD_EXTERN_C_FINI
+81
ファイルの表示
@@ -0,0 +1,81 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include "rocprofiler-sdk-rocpd/defines.h"
#include <stdint.h>
/** @defgroup DATA_TYPE rocPD Data types
*
* Data types defined or aliased by rocPD
*
* @{
*/
//--------------------------------------------------------------------------------------//
//
// ENUMERATIONS
//
//--------------------------------------------------------------------------------------//
/**
* @defgroup BASIC_DATA_TYPES Basic data types
* @brief Basic data types and typedefs
*
* @{
*/
/**
* @brief Status codes.
*/
typedef enum rocpd_status_t // NOLINT(performance-enum-size)
{
ROCPD_STATUS_SUCCESS = 0, ///< No error occurred
ROCPD_STATUS_ERROR, ///< Generalized error
ROCPD_STATUS_ERROR_INVALID_ARGUMENT, ///< Argument is invalid
ROCPD_STATUS_ERROR_SQL_ERROR, ///< General SQL error
ROCPD_STATUS_ERROR_SQL_INVALID_ENGINE, ///< SQL engine is invalid
ROCPD_STATUS_ERROR_SQL_INVALID_SCHEMA_KIND, ///< SQL schema kind not found
ROCPD_STATUS_ERROR_SQL_SCHEMA_NOT_FOUND, ///< SQL schema does not exist
ROCPD_STATUS_ERROR_SQL_SCHEMA_PERMISSION_DENIED, ///< SQL schema not accessible
ROCPD_STATUS_LAST,
} rocpd_status_t;
//--------------------------------------------------------------------------------------//
//
// STRUCTS
//
//--------------------------------------------------------------------------------------//
/**
* @brief Versioning info.
*/
typedef struct rocpd_version_triplet_t
{
uint32_t major;
uint32_t minor;
uint32_t patch;
} rocpd_version_triplet_t;
/** @} */
+115
ファイルの表示
@@ -0,0 +1,115 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
/**
* @def ROCPD_IS_ROCPROFILER_SDK
* @brief Preprocessor define indicating the rocpd header is a rocprofiler-sdk project
* @addtogroup VERSIONING_GROUP
*
* @def ROCPD_VERSION_MAJOR
* @brief The major version of the interface as a macro so it can be used
* by the preprocessor.
* @addtogroup VERSIONING_GROUP
*
* @def ROCPD_VERSION_MINOR
* @brief The minor version of the interface as a macro so it can be used
* by the preprocessor.
* @addtogroup VERSIONING_GROUP
*
* @def ROCPD_VERSION_PATCH
* @brief The patch version of the interface as a macro so it can be used
* by the preprocessor.
* @addtogroup VERSIONING_GROUP
*
* @def ROCPD_VERSION
* @brief Numerically increasing version number encoding major, minor, and patch via
computing `((10000 * <MAJOR>) + (100 * <MINOR>) + <PATCH>)`.
* @addtogroup VERSIONING_GROUP
*
* @def ROCPD_SOVERSION
* @brief Shared object versioning value whose value is at least `(10000 * <MAJOR>)`.
* @addtogroup VERSIONING_GROUP
*
* @def ROCPD_VERSION_STRING
* @brief Version string in form: `<MAJOR>.<MINOR>.<PATCH>`.
* @addtogroup VERSIONING_GROUP
*
* @def ROCPD_GIT_DESCRIBE
* @brief String encoding of `git describe --tags` when rocprofiler was built.
* @addtogroup VERSIONING_GROUP
*
* @def ROCPD_GIT_REVISION
* @brief String encoding of `git rev-parse HEAD` when rocprofiler was built.
* @addtogroup VERSIONING_GROUP
*
* @def ROCPD_LIBRARY_ARCH
* @brief Architecture triplet of rocprofiler build.
* @addtogroup VERSIONING_GROUP
*
* @def ROCPD_SYSTEM_NAME
* @brief Target operating system for rocprofiler build, e.g. Linux.
* @addtogroup VERSIONING_GROUP
*
* @def ROCPD_SYSTEM_PROCESSOR
* @brief Target architecture for rocprofiler build.
* @addtogroup VERSIONING_GROUP
*
* @def ROCPD_SYSTEM_VERSION
* @brief Version of the operating system which built rocprofiler
* @addtogroup VERSIONING_GROUP
*
* @def ROCPD_COMPILER_ID
* @brief C++ compiler identifier which built rocprofiler, e.g., GNU
* @addtogroup VERSIONING_GROUP
*
* @def ROCPD_COMPILER_VERSION
* @brief C++ compiler version which built rocprofiler
* @addtogroup VERSIONING_GROUP
*/
#define ROCPD_IS_ROCPROFILER_SDK 1
// clang-format off
#define ROCPD_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
#define ROCPD_VERSION_MINOR @PROJECT_VERSION_MINOR@
#define ROCPD_VERSION_PATCH @PROJECT_VERSION_PATCH@
#define ROCPD_SOVERSION (10000 * @PROJECT_VERSION_MAJOR@)
#define ROCPD_VERSION_STRING "@FULL_VERSION_STRING@"
#define ROCPD_GIT_DESCRIBE "@ROCPROFILER_SDK_GIT_DESCRIBE@"
#define ROCPD_GIT_REVISION "@ROCPROFILER_SDK_GIT_REVISION@"
// system info during compilation
#define ROCPD_LIBRARY_ARCH "@CMAKE_LIBRARY_ARCHITECTURE@"
#define ROCPD_SYSTEM_NAME "@CMAKE_SYSTEM_NAME@"
#define ROCPD_SYSTEM_PROCESSOR "@CMAKE_SYSTEM_PROCESSOR@"
#define ROCPD_SYSTEM_VERSION "@CMAKE_SYSTEM_VERSION@"
// compiler information
#define ROCPD_COMPILER_ID "@CMAKE_CXX_COMPILER_ID@"
#define ROCPD_COMPILER_VERSION "@CMAKE_CXX_COMPILER_VERSION@"
// clang-format on
#define ROCPD_VERSION \
((10000 * ROCPD_VERSION_MAJOR) + (100 * ROCPD_VERSION_MINOR) + ROCPD_VERSION_PATCH)
+18
ファイルの表示
@@ -0,0 +1,18 @@
#
#
# Installation of public headers
#
#
configure_file(${CMAKE_CURRENT_LIST_DIR}/version.h.in
${CMAKE_CURRENT_BINARY_DIR}/version.h @ONLY)
set(ROCTX_HEADER_FILES
# core headers
roctx.h
# secondary headers
api_trace.h defines.h types.h ${CMAKE_CURRENT_BINARY_DIR}/version.h)
install(
FILES ${ROCTX_HEADER_FILES}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocprofiler-sdk-roctx
COMPONENT roctx)
+88
ファイルの表示
@@ -0,0 +1,88 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include "rocprofiler-sdk-roctx/defines.h"
#include "rocprofiler-sdk-roctx/types.h"
#include "rocprofiler-sdk-roctx/version.h"
#include <sched.h>
#include <stddef.h>
#include <stdint.h>
ROCTX_EXTERN_C_INIT
#define ROCTX_API_TABLE_VERSION_MAJOR 0
#define ROCTX_API_TABLE_VERSION_STEP 0
#define ROCTX_CORE_API_TABLE_VERSION_MAJOR 0
#define ROCTX_CORE_API_TABLE_VERSION_STEP 0
#define ROCTX_CONTROL_API_TABLE_VERSION_MAJOR 0
#define ROCTX_CONTROL_API_TABLE_VERSION_STEP 0
#define ROCTX_RESOURCE_API_TABLE_VERSION_MAJOR 0
#define ROCTX_RESOURCE_API_TABLE_VERSION_STEP 0
typedef uint64_t roctx_range_id_t;
typedef void (*roctxMarkA_fn_t)(const char* message);
typedef int (*roctxRangePushA_fn_t)(const char* message);
typedef int (*roctxRangePop_fn_t)(void);
typedef roctx_range_id_t (*roctxRangeStartA_fn_t)(const char* message);
typedef void (*roctxRangeStop_fn_t)(roctx_range_id_t id);
typedef int (*roctxProfilerPause_fn_t)(roctx_thread_id_t tid);
typedef int (*roctxProfilerResume_fn_t)(roctx_thread_id_t tid);
typedef int (*roctxNameOsThread_fn_t)(const char* name);
typedef int (*roctxNameHsaAgent_fn_t)(const char* name, const struct hsa_agent_s* agent);
typedef int (*roctxNameHipDevice_fn_t)(const char* name, int device_id);
typedef int (*roctxNameHipStream_fn_t)(const char* name, const struct ihipStream_t* stream);
typedef int (*roctxGetThreadId_fn_t)(roctx_thread_id_t* tid);
typedef struct roctxCoreApiTable_t
{
uint64_t size;
roctxMarkA_fn_t roctxMarkA_fn;
roctxRangePushA_fn_t roctxRangePushA_fn;
roctxRangePop_fn_t roctxRangePop_fn;
roctxRangeStartA_fn_t roctxRangeStartA_fn;
roctxRangeStop_fn_t roctxRangeStop_fn;
roctxGetThreadId_fn_t roctxGetThreadId_fn;
} roctxCoreApiTable_t;
typedef struct roctxControlApiTable_t
{
uint64_t size;
roctxProfilerPause_fn_t roctxProfilerPause_fn;
roctxProfilerResume_fn_t roctxProfilerResume_fn;
} roctxControlApiTable_t;
typedef struct roctxNameApiTable_t
{
uint64_t size;
roctxNameOsThread_fn_t roctxNameOsThread_fn;
roctxNameHsaAgent_fn_t roctxNameHsaAgent_fn;
roctxNameHipDevice_fn_t roctxNameHipDevice_fn;
roctxNameHipStream_fn_t roctxNameHipStream_fn;
} roctxNameApiTable_t;
ROCTX_EXTERN_C_FINI
+116
ファイルの表示
@@ -0,0 +1,116 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
/**
* @defgroup SYMBOL_VERSIONING_GROUP Symbol Versions
*
* @brief The names used for the shared library versioned symbols.
*
* Every function is annotated with one of the version macros defined in this
* section. Each macro specifies a corresponding symbol version string. After
* dynamically loading the shared library with @p dlopen, the address of each
* function can be obtained using @p dlsym with the name of the function and
* its corresponding symbol version string. An error will be reported by @p
* dlsym if the installed library does not support the version for the
* function specified in this version of the interface.
*
* @{
*/
/**
* @brief The function was introduced in version 0.0 of the interface and has the
* symbol version string of ``"ROCPROFILER_SDK_ROCTX_0.0"``.
*/
#define ROCPROFILER_SDK_ROCTX_VERSION_0_0
/** @} */
#if !defined(ROCTX_ATTRIBUTE)
# if defined(_MSC_VER)
# define ROCTX_ATTRIBUTE(...) __declspec(__VA_ARGS__)
# else
# define ROCTX_ATTRIBUTE(...) __attribute__((__VA_ARGS__))
# endif
#endif
#if !defined(ROCTX_PUBLIC_API)
# if defined(_MSC_VER)
# define ROCTX_PUBLIC_API ROCTX_ATTRIBUTE(dllexport)
# else
# define ROCTX_PUBLIC_API ROCTX_ATTRIBUTE(visibility("default"))
# endif
#endif
#if !defined(ROCTX_HIDDEN_API)
# if defined(_MSC_VER)
# define ROCTX_HIDDEN_API
# else
# define ROCTX_HIDDEN_API ROCTX_ATTRIBUTE(visibility("hidden"))
# endif
#endif
#if !defined(ROCTX_EXPORT_DECORATOR)
# define ROCTX_EXPORT_DECORATOR ROCTX_PUBLIC_API
#endif
#if !defined(ROCTX_IMPORT_DECORATOR)
# if defined(_MSC_VER)
# define ROCTX_IMPORT_DECORATOR ROCTX_ATTRIBUTE(dllimport)
# else
# define ROCTX_IMPORT_DECORATOR
# endif
#endif
#define ROCTX_EXPORT ROCTX_EXPORT_DECORATOR
#define ROCTX_IMPORT ROCTX_IMPORT_DECORATOR
#if !defined(ROCTX_API)
# if defined(roctx_EXPORTS)
# define ROCTX_API ROCTX_EXPORT
# else
# define ROCTX_API ROCTX_IMPORT
# endif
#endif
#if defined(__has_attribute)
# if __has_attribute(nonnull)
# define ROCTX_NONNULL(...) __attribute__((nonnull(__VA_ARGS__)))
# else
# define ROCTX_NONNULL(...)
# endif
#else
# if defined(__GNUC__)
# define ROCTX_NONNULL(...) __attribute__((nonnull(__VA_ARGS__)))
# else
# define ROCTX_NONNULL(...)
# endif
#endif
#ifdef __cplusplus
# define ROCTX_EXTERN_C_INIT extern "C" {
# define ROCTX_EXTERN_C_FINI }
#else
# define ROCTX_EXTERN_C_INIT
# define ROCTX_EXTERN_C_FINI
#endif
+310
ファイルの表示
@@ -0,0 +1,310 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
/**
* @file roctx.h
* @brief ROCTx API interface for AMD code annotation and profiling
*
* @mainpage ROCTx API Specification
*
* @section introduction Introduction
* ROCTx is a comprehensive library that implements the AMD code annotation API. It provides
* essential functionality for:
* - Event annotation and marking
* - Code range tracking and management
* - Profiler control and customization
* - Thread and device naming capabilities
*
* Key features:
* - Nested range tracking with push/pop functionality
* - Process-wide range management
* - Thread-specific and global profiler control
* - Device and stream naming support
* - HSA agent and HIP device management
*
* The API is divided into several main components:
* 1. Markers - For single event annotations
* 2. Ranges - For tracking code execution spans
* 3. Profiler Control - For managing profiling tool behavior
* 4. Naming Utilities - For labeling threads, devices, and streams
*
* Thread Safety:
* - Range operations are thread-local and thread-safe
* - Marking operations are thread-safe
* - Profiler control operations are process-wide
*
* Integration:
* - Compatible with HIP runtime
* - Supports HSA (Heterogeneous System Architecture)
* - Provides both C and C++ interfaces
*
* Performance Considerations:
* - Minimal overhead for marking and range operations
* - Thread-local storage for efficient range stacking
* - Lightweight profiler control mechanisms
*
* @note All string parameters must be null-terminated
* @warning Proper nesting of range push/pop operations is user's responsibility
*/
#include <stddef.h>
#include <stdint.h>
#include "rocprofiler-sdk-roctx/defines.h"
#include "rocprofiler-sdk-roctx/types.h"
#include "rocprofiler-sdk-roctx/version.h"
ROCTX_EXTERN_C_INIT
/** @defgroup marker_group ROCTx Markers
*
* @brief Markers are used to annotate specific events in the code execution.
*
* @{
*/
/**
* Mark an event.
*
* @param[in] message The message associated with the event.
*/
void
roctxMarkA(const char* message) ROCTX_API ROCTX_NONNULL(1);
/** @} */
/** @defgroup range_group ROCTx Ranges
*
* @brief Ranges are used to describe a span of code execution in a ROCm application.
*
* Ranges can be nested, and the API provides functions to start and stop ranges.
* Ranges are thread-local, meaning that each thread can have its own stack of
* ranges. The API provides functions to push and pop ranges from the stack.
* The API also provides functions to start and stop ranges, which are
* process-wide. Each range is assigned a unique ID, which can be used to
* identify the range when stopping it.
* @{
*/
/**
* Start a new nested range.
*
* Nested ranges are stacked and local to the current CPU thread.
*
* @param[in] message The message associated with this range.
*
* @return Returns the level this nested range is started at. Nested range
* levels are 0 based.
*/
int
roctxRangePushA(const char* message) ROCTX_API ROCTX_NONNULL(1);
/**
* Stop the current nested range.
*
* Stop the current nested range, and pop it from the stack. If a nested range
* was active before the last one was started, it becomes again the current
* nested range.
*
* @return Returns the level the stopped nested range was started at, or a
* negative value if there was no nested range active.
*/
int
roctxRangePop() ROCTX_API;
/**
* @brief Starts a process range.
*
* Start/stop ranges can be started and stopped in different threads. Each
* timespan is assigned a unique range ID.
*
* @param [in] message The message associated with this range.
*
* @return Returns the ID of the new range.
*/
roctx_range_id_t
roctxRangeStartA(const char* message) ROCTX_API ROCTX_NONNULL(1);
/**
* Stop a process range.
*
* @param [in] id ::roctx_range_id_t returned from ::roctxRangeStartA to stop
*/
void
roctxRangeStop(roctx_range_id_t id) ROCTX_API;
/** @} */
/** @defgroup PROFILER_COMM ROCTx Application control/customization of profiling tools
*
* @brief Applications can invoke these functions to control/customize profiling tool behavior.
*
* @{
*/
/**
* @brief Request any currently running profiling tool that is should stop collecting data.
*
* Within a profiling tool, it is recommended that the tool cache all active contexts at the time of
* the request and then stop them. By convention, the application should pass zero to indicate a
* global pause of the profiler in the current process. If the application wishes to pause only the
* current thread, the application should obtain the thread ID via @ref roctxGetThreadId.
*
* @param [in] tid Zero for all threads in current process or non-zero for a specific thread
*
* @return int A profiling tool may choose to set this value to a non-zero value to indicate a
* failure while executing the request or lack of support. If the profiling tool supports pausing
* but is already paused, the tool should ignore the request and return zero.
*/
int
roctxProfilerPause(roctx_thread_id_t tid) ROCTX_API;
/**
* @brief Request any currently running profiling tool that is should resume collecting data.
*
* Within a profiling tool, it is recommended that the tool re-activated the active contexts which
* were cached when the pause request was issued. By convention, the application should pass zero to
* indicate a global pause of the profiler in the current process. If the application wishes to
* pause only the current thread, the application should obtain the thread ID via @ref
* roctxGetThreadId.
*
* @param [in] tid Zero for all threads in current process or non-zero for a specific thread
*
* @return int A profiling tool may choose to set this value to a non-zero value to indicate a
* failure while executing the request or lack of support. If the profiling tool is supports
* resuming but is already active, the tool should ignore the request and return zero.
*/
int
roctxProfilerResume(roctx_thread_id_t tid) ROCTX_API;
/** @} */
/** \defgroup UTILITIES ROCTx Utility functions
*
* @brief Utility functions for profiling tools to customize their behavior.
*
* @{
*/
/**
* @brief Indicate to a profiling tool that, where possible, you would like the current CPU OS
* thread to be labeled by the provided name in the output of the profiling tool.
*
* Rocprofiler does not provide explicit support for how profiling tools handle this request:
* support for this capability is tool specific. ROCTx does NOT rename the thread via
* `pthread_setname_np`.
*
* @param [in] name Name for the current OS thread
*
* @return int A profiling tool may choose to set this value to a non-zero value to indicate a
* failure while executing the request or lack of support
*/
int
roctxNameOsThread(const char* name) ROCTX_API ROCTX_NONNULL(1);
/**
* @brief Indicate to a profiling tool that, where possible, you would like the given HSA agent
* to be labeled by the provided name in the output of the profiling tool.
*
* Rocprofiler does not provide any explicit support for how profiling tools handle this request:
* support for this capability is tool specific.
*
* @param [in] name Name for the specified agent
* @param [in] agent Pointer to a HSA agent identifier
*
* @return int A profiling tool may choose to set this value to a non-zero value to indicate a
* failure while executing the request or lack of support
*/
int
roctxNameHsaAgent(const char* name, const struct hsa_agent_s* agent) ROCTX_API ROCTX_NONNULL(1, 2);
/**
* @brief Indicate to a profiling tool that, where possible, you would like the given HIP device id
* to be labeled by the provided name in the output of the profiling tool.
*
* Rocprofiler does not provide any explicit support for how profiling tools handle this request:
* support for this capability is tool specific.
*
* @param [in] name Name for the specified device
* @param [in] device_id HIP device ordinal
*
* @return int A profiling tool may choose to set this value to a non-zero value to indicate a
* failure while executing the request or lack of support
*/
int
roctxNameHipDevice(const char* name, int device_id) ROCTX_API ROCTX_NONNULL(1);
/**
* @brief Indicate to a profiling tool that, where possible, you would like the given HIP stream
* to be labeled by the provided name in the output of the profiling tool.
*
* Rocprofiler does not provide any explicit support for how profiling tools handle this request:
* support for this capability is tool specific.
*
* @param [in] name Name for the specified stream
* @param [in] stream A `hipStream_t` value (hipStream_t == ihipStream_t*)
*
* @return int A profiling tool may choose to set this value to a non-zero value to indicate a
* failure while executing the request or lack of support
*/
int
roctxNameHipStream(const char* name, const struct ihipStream_t* stream) ROCTX_API ROCTX_NONNULL(1);
/** @} */
/** @defgroup UTILITIES ROCTx Utility functions
*
* @{
*/
/**
* @brief Retrieve a id value for the current thread which will be identical to the id value a
* profiling tool gets via `rocprofiler_get_thread_id(rocprofiler_thread_id_t*)`
*
* @param tid [out] Pointer to where the value should be placed
*
* @return int A profiling tool may choose to set this value to a non-zero value to indicate a
* failure while executing the request or lack of support
*/
int
roctxGetThreadId(roctx_thread_id_t* tid) ROCTX_API ROCTX_NONNULL(1);
/** @} */
ROCTX_EXTERN_C_FINI
#if !defined(roctxRangeStart)
/** @brief For future compatibility */
# define roctxRangeStart(message) roctxRangeStartA(message)
#endif
#if !defined(roctxMark)
/** @brief For future compatibility */
# define roctxMark(message) roctxMarkA(message)
#endif
#if !defined(roctxRangePush)
/** @brief For future compatibility */
# define roctxRangePush(message) roctxRangePushA(message)
#endif
+56
ファイルの表示
@@ -0,0 +1,56 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include "rocprofiler-sdk-roctx/defines.h"
#include <stdint.h>
/** \defgroup BASIC_DATA_TYPES ROCTx Data types
*
* @brief Data types defined or aliased by ROCTx
*
* @{
*/
/**
* ROCTx range ID.
*
* This is the range ID used to identify start/end ranges.
*/
/**
* @brief ROCTx range ID.
*
* This is the range ID used to identify start/end ranges.
*/
typedef uint64_t roctx_range_id_t;
/**
* @brief ROCTx thread ID.
*
* This is the thread ID used to identify OS threads
*/
typedef uint64_t roctx_thread_id_t;
/** @} */
+115
ファイルの表示
@@ -0,0 +1,115 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
/**
* @def ROCTX_IS_ROCPROFILER_SDK
* @brief Preprocessor define indicating the roctx header is a rocprofiler-sdk project
* @addtogroup VERSIONING_GROUP
*
* @def ROCTX_VERSION_MAJOR
* @brief The major version of the interface as a macro so it can be used
* by the preprocessor.
* @addtogroup VERSIONING_GROUP
*
* @def ROCTX_VERSION_MINOR
* @brief The minor version of the interface as a macro so it can be used
* by the preprocessor.
* @addtogroup VERSIONING_GROUP
*
* @def ROCTX_VERSION_PATCH
* @brief The patch version of the interface as a macro so it can be used
* by the preprocessor.
* @addtogroup VERSIONING_GROUP
*
* @def ROCTX_VERSION
* @brief Numerically increasing version number encoding major, minor, and patch via
computing `((10000 * <MAJOR>) + (100 * <MINOR>) + <PATCH>)`.
* @addtogroup VERSIONING_GROUP
*
* @def ROCTX_SOVERSION
* @brief Shared object versioning value whose value is at least `(10000 * <MAJOR>)`.
* @addtogroup VERSIONING_GROUP
*
* @def ROCTX_VERSION_STRING
* @brief Version string in form: `<MAJOR>.<MINOR>.<PATCH>`.
* @addtogroup VERSIONING_GROUP
*
* @def ROCTX_GIT_DESCRIBE
* @brief String encoding of `git describe --tags` when rocprofiler was built.
* @addtogroup VERSIONING_GROUP
*
* @def ROCTX_GIT_REVISION
* @brief String encoding of `git rev-parse HEAD` when rocprofiler was built.
* @addtogroup VERSIONING_GROUP
*
* @def ROCTX_LIBRARY_ARCH
* @brief Architecture triplet of rocprofiler build.
* @addtogroup VERSIONING_GROUP
*
* @def ROCTX_SYSTEM_NAME
* @brief Target operating system for rocprofiler build, e.g. Linux.
* @addtogroup VERSIONING_GROUP
*
* @def ROCTX_SYSTEM_PROCESSOR
* @brief Target architecture for rocprofiler build.
* @addtogroup VERSIONING_GROUP
*
* @def ROCTX_SYSTEM_VERSION
* @brief Version of the operating system which built rocprofiler
* @addtogroup VERSIONING_GROUP
*
* @def ROCTX_COMPILER_ID
* @brief C++ compiler identifier which built rocprofiler, e.g., GNU
* @addtogroup VERSIONING_GROUP
*
* @def ROCTX_COMPILER_VERSION
* @brief C++ compiler version which built rocprofiler
* @addtogroup VERSIONING_GROUP
*/
#define ROCTX_IS_ROCPROFILER_SDK 1
// clang-format off
#define ROCTX_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
#define ROCTX_VERSION_MINOR @PROJECT_VERSION_MINOR@
#define ROCTX_VERSION_PATCH @PROJECT_VERSION_PATCH@
#define ROCTX_SOVERSION (10000 * @PROJECT_VERSION_MAJOR@)
#define ROCTX_VERSION_STRING "@FULL_VERSION_STRING@"
#define ROCTX_GIT_DESCRIBE "@ROCPROFILER_SDK_GIT_DESCRIBE@"
#define ROCTX_GIT_REVISION "@ROCPROFILER_SDK_GIT_REVISION@"
// system info during compilation
#define ROCTX_LIBRARY_ARCH "@CMAKE_LIBRARY_ARCHITECTURE@"
#define ROCTX_SYSTEM_NAME "@CMAKE_SYSTEM_NAME@"
#define ROCTX_SYSTEM_PROCESSOR "@CMAKE_SYSTEM_PROCESSOR@"
#define ROCTX_SYSTEM_VERSION "@CMAKE_SYSTEM_VERSION@"
// compiler information
#define ROCTX_COMPILER_ID "@CMAKE_CXX_COMPILER_ID@"
#define ROCTX_COMPILER_VERSION "@CMAKE_CXX_COMPILER_VERSION@"
// clang-format on
#define ROCTX_VERSION \
((10000 * ROCTX_VERSION_MAJOR) + (100 * ROCTX_VERSION_MINOR) + ROCTX_VERSION_PATCH)
+58
ファイルの表示
@@ -0,0 +1,58 @@
#
#
# Installation of public headers
#
#
configure_file(${CMAKE_CURRENT_LIST_DIR}/version.h.in
${CMAKE_CURRENT_BINARY_DIR}/version.h @ONLY)
configure_file(${CMAKE_CURRENT_LIST_DIR}/ext_version.h.in
${CMAKE_CURRENT_BINARY_DIR}/ext_version.h @ONLY)
set(ROCPROFILER_HEADER_FILES
# core headers
rocprofiler.h
# secondary headers
agent.h
buffer.h
buffer_tracing.h
callback_tracing.h
context.h
counter_config.h
counters.h
defines.h
device_counting_service.h
dispatch_counting_service.h
external_correlation.h
fwd.h
hip.h
hsa.h
intercept_table.h
internal_threading.h
marker.h
ompt.h
pc_sampling.h
rccl.h
registration.h
rocdecode.h
rocjpeg.h
spm.h
${CMAKE_CURRENT_BINARY_DIR}/version.h
${CMAKE_CURRENT_BINARY_DIR}/ext_version.h)
install(
FILES ${ROCPROFILER_HEADER_FILES}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocprofiler-sdk
COMPONENT development)
add_subdirectory(hip)
add_subdirectory(hsa)
add_subdirectory(marker)
add_subdirectory(ompt)
add_subdirectory(rccl)
add_subdirectory(rocdecode)
add_subdirectory(rocjpeg)
add_subdirectory(cxx)
add_subdirectory(kfd)
add_subdirectory(experimental)
add_subdirectory(deprecated)
+301
ファイルの表示
@@ -0,0 +1,301 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/defines.h>
#include <rocprofiler-sdk/fwd.h>
#include <hsakmt/hsakmttypes.h>
#include <stdint.h>
ROCPROFILER_EXTERN_C_INIT
/**
* @defgroup AGENTS Agent Information
* @brief needs brief description
*
* @{
*/
/**
* @brief Enumeration ID for version of the rocprofiler_agent_v*_t struct in rocprofiler_i
*
*/
typedef enum rocprofiler_agent_version_t
{
ROCPROFILER_AGENT_INFO_VERSION_NONE = 0,
ROCPROFILER_AGENT_INFO_VERSION_0 = 1,
ROCPROFILER_AGENT_INFO_VERSION_LAST,
} rocprofiler_agent_version_t;
/**
* @brief Cache information for an agent.
*/
typedef struct rocprofiler_agent_cache_t
{
uint64_t processor_id_low; ///< Identifies the processor number
uint64_t size; ///< Size of the cache
uint32_t level; ///< Integer representing level: 1, 2, 3, 4, etc.
uint32_t cache_line_size; ///< Cache line size in bytes
uint32_t cache_lines_per_tag; ///< Cache lines per Cache Tag
uint32_t association; ///< Cache Associativity
uint32_t latency; ///< Cache latency in ns
HsaCacheType type;
} rocprofiler_agent_cache_t;
/**
* @brief IO link information for an agent.
*/
typedef struct rocprofiler_agent_io_link_t
{
HSA_IOLINKTYPE type; ///< Discoverable IoLink Properties (optional)
uint32_t version_major; ///< Bus interface version (optional)
uint32_t version_minor; ///< Bus interface version (optional)
uint32_t node_from; ///< See ::rocprofiler_agent_id_t
uint32_t node_to; ///< See ::rocprofiler_agent_id_t
uint32_t weight; ///< weight factor (derived from CDIT)
uint32_t min_latency; ///< minimum cost of time to transfer (rounded to ns)
uint32_t max_latency; ///< maximum cost of time to transfer (rounded to ns)
uint32_t min_bandwidth; ///< minimum interface Bandwidth in MB/s
uint32_t max_bandwidth; ///< maximum interface Bandwidth in MB/s
uint32_t recommended_transfer_size; ///< recommended transfer size to reach maximum bandwidth
///< in bytes
HSA_LINKPROPERTY flags; ///< override flags (may be active for specific platforms)
} rocprofiler_agent_io_link_t;
/**
* @brief Memory bank information for an agent.
*/
typedef struct rocprofiler_agent_mem_bank_t
{
HSA_HEAPTYPE heap_type;
HSA_MEMORYPROPERTY flags;
uint32_t width; ///< the number of parallel bits of the memoryinterface
uint32_t mem_clk_max; ///< clock for the memory, this allows computing the available
///< bandwidth to the memory when needed
uint64_t size_in_bytes; ///< physical memory size of the memory range in bytes
} rocprofiler_agent_mem_bank_t;
/**
* @brief Provides an *estimate* about the runtime visibility of an agent based on the environment
* variables (ROCR_VISIBLE_DEVICES, HIP_VISIBLE_DEVICES, GPU_DEVICE_ORDINAL, CUDA_VISIBLE_DEVICES).
* Reference: https://rocm.docs.amd.com/en/latest/conceptual/gpu-isolation.html
*/
typedef struct rocprofiler_agent_runtime_visiblity_t
{
// Note: HSA == ROCR
uint32_t hsa : 1; ///> if not visible to HSA, agent not visible to anything built on HSA
uint32_t hip : 1; ///> Built on HSA
uint32_t rccl : 1; ///> Built on HIP
uint32_t rocdecode : 1; ///> Built on HIP
uint32_t reserved : 28;
} rocprofiler_agent_runtime_visiblity_t;
ROCPROFILER_CXX_CODE(
static_assert(
sizeof(rocprofiler_agent_runtime_visiblity_t) == sizeof(uint32_t),
"Increasing the size of the rocprofiler_agent_runtime_visiblity_t is not permitted");)
/**
* @brief Stores the properties of an agent (CPU, GPU, etc.)
*
* The `node_id` member is the KFD topology node id. It should be considered the "universal"
* indexing number. It is equivalent to the HSA-runtime HSA_AMD_AGENT_INFO_DRIVER_NODE_ID property
* of a `hsa_agent_t`. The `const char*` fields (`name`, `vendor_name`, etc.) are guaranteed to be
* valid pointers to null-terminated strings during tool finalization. Pointers to the agents via
* @see ::rocprofiler_query_available_agents are constant and will not be deallocated until after
* tool finalization. Making copies of the agent struct is also valid.
*/
typedef struct rocprofiler_agent_v0_t
{
uint64_t size; ///< set to sizeof(rocprofiler_agent_t) by rocprofiler. This can be used for
///< versioning and compatibility handling
rocprofiler_agent_id_t id; ///< Internal opaque identifier
rocprofiler_agent_type_t type; ///< Enumeration for identifying the agent type (CPU, GPU, etc.)
uint32_t cpu_cores_count; ///< # of latency (= CPU) cores present on this HSA node. This value
///< is 0 for a HSA node with no such cores, e.g a "discrete HSA GPU"
uint32_t simd_count; ///< # of HSA throughtput (= GPU) FCompute cores ("SIMD") present in a
///< node. This value is 0 if no FCompute cores are present (e.g. pure
///< "CPU node").
uint32_t mem_banks_count; ///< # of discoverable memory bank affinity properties on this
///< "H-NUMA" node.
uint32_t caches_count; ///< # of discoverable cache affinity properties on this "H-NUMA" node.
uint32_t io_links_count; ///< # of discoverable IO link affinity properties of this node
///< connecting to other nodes.
uint32_t cpu_core_id_base; ///< low value of the logical processor ID of the latency (= CPU)
///< cores available on this node
uint32_t simd_id_base; ///< low value of the logical processor ID of the throughput (= GPU)
///< units available on this node
uint32_t max_waves_per_simd; ///< This identifies the max. number of launched waves per SIMD.
///< If NumFComputeCores is 0, this value is ignored.
uint32_t lds_size_in_kb; ///< Size of Local Data Store in Kilobytes per SIMD Wavefront
uint32_t gds_size_in_kb; ///< Size of Global Data Store in Kilobytes shared across SIMD
///< Wavefronts
uint32_t num_gws; ///< Number of GWS barriers
uint32_t wave_front_size; ///< Number of SIMD cores per wavefront executed, typically 64, may
///< be 32 or a different value for some HSA based architectures
uint32_t num_xcc; ///< Number of XCC
uint32_t cu_count; ///< Number of compute units
uint32_t array_count; ///< Number of SIMD arrays
uint32_t num_shader_banks; ///< Number of Shader Banks or Shader Engines, typical values are 1
///< or 2
uint32_t simd_arrays_per_engine; ///< Number of SIMD arrays per engine
uint32_t cu_per_simd_array; ///< Number of Compute Units (CU) per SIMD array
uint32_t simd_per_cu; ///< Number of SIMD representing a Compute Unit (CU)
uint32_t max_slots_scratch_cu; ///< Number of temp. memory ("scratch") wave slots available to
///< access, may be 0 if HW has no restrictions
uint32_t gfx_target_version; ///< major_version=((value / 10000) % 100)
///< minor_version=((value / 100) % 100)
///< patch_version=(value % 100)
uint16_t vendor_id; ///< GPU vendor id; 0 on latency (= CPU)-only nodes
uint16_t device_id; ///< GPU device id; 0 on latency (= CPU)-only nodes
uint32_t location_id; ///< GPU BDF (Bus/Device/function number) - identifies the device
///< location in the overall system
uint32_t domain; ///< PCI domain of the GPU
uint32_t drm_render_minor; ///< DRM render device minor device number
uint32_t num_sdma_engines; ///< number of PCIe optimized SDMA engines
uint32_t num_sdma_xgmi_engines; ///< number of XGMI optimized SDMA engines
uint32_t num_sdma_queues_per_engine; ///< number of SDMA queue per one engine
uint32_t num_cp_queues; ///< number of Compute queues
uint32_t max_engine_clk_ccompute; ///< maximum engine clocks for CPU, including any boost
///< capabilities
uint32_t max_engine_clk_fcompute; ///< GPU only. Maximum engine clocks for GPU, including any
///< boost capabilities
HSA_ENGINE_VERSION sdma_fw_version; ///< GPU only
HSA_ENGINE_ID fw_version;
HSA_CAPABILITY capability; ///< GPU only
uint32_t cu_per_engine; ///< computed
uint32_t max_waves_per_cu; ///< computed
uint32_t family_id; ///< Family code
uint32_t workgroup_max_size; ///< GPU only. Maximum total number of work-items in a work-group.
uint32_t grid_max_size; ///< GPU only. Maximum number of fbarriers per work-group. Must be at
///< least 32.
uint64_t local_mem_size; ///< GPU only. Local memory size
uint64_t hive_id;
uint64_t gpu_id; ///< GPU only. KFD identifier
rocprofiler_dim3_t workgroup_max_dim; ///< GPU only. Maximum number of work-items of each
///< dimension of a work-group.
rocprofiler_dim3_t grid_max_dim; ///< GPU only. Maximum number of work-items of each dimension
///< of a grid.
const rocprofiler_agent_mem_bank_t* mem_banks; ///< array of memory bank info
const rocprofiler_agent_cache_t* caches; ///< array of cache info
const rocprofiler_agent_io_link_t* io_links; ///< array of IO link info
const char* name; ///< name of the agent
const char* vendor_name; ///< Vendor of agent (will be AMD)
const char* product_name; ///< Marketing name
const char* model_name;
uint32_t node_id;
int32_t logical_node_id;
int32_t logical_node_type_id;
rocprofiler_agent_runtime_visiblity_t runtime_visibility;
rocprofiler_uuid_t uuid; ///< GPU only. Universally unique identifier.
/// @var fw_version
/// @brief GPU only. Identifier (rev) of the GPU uEngine or Firmware, may be 0
///
/// @var hive_id
/// @brief XGMI Hive the GPU node belongs to in the system. It is an opaque and
/// static number hash created by the PSP
///
/// @var name
/// @brief Name of the agent. Will be identical to product name for CPU
///
/// @var model_name
/// @brief GPU only. Will be something like vega20, mi200, etc.
///
/// @var node_id
/// @brief Node sequence number. This will be equivalent to the HSA-runtime
/// HSA_AMD_AGENT_INFO_DRIVER_NODE_ID property
///
/// @var logical_node_id
/// @brief Logical sequence number. This will always be [0..N) where N is the total number of
/// agents
///
/// @var logical_node_type_id
/// @brief Logical sequence number with respect to other agents of same type. This will always
/// be [0..N) where N is the total number of X agents (where X is a ::rocprofiler_agent_type_t
/// value). This field is intended to help with environment variable indexing used to mask GPUs
/// at runtime (i.e. HIP_VISIBLE_DEVICES and ROCR_VISIBLE_DEVICES) which start at zero and only
/// apply to GPUs, e.g., logical_node_type_id value for first GPU will be 0, second GPU will
/// have value of 1, etc., regardless of however many agents of a different type preceeded (and
/// thus increased the ::rocprofiler_agent_v0_t.node_id or
/// ::rocprofiler_agent_v0_t.logical_node_id).
///
/// Example: a system with 2 CPUs and 2 GPUs, where the node ids are 0=CPU, 1=GPU, 2=CPU, 3=GPU,
/// then then CPU node_ids 0 and 2 would have logical_node_type_id values of 0 and 1,
/// respectively, and GPU node_ids 1 and 3 would also have logical_node_type_id values of 0
/// and 1.
///
/// @var runtime_visibility
/// @brief See ::rocprofiler_runtime_library_t. This is an estimate about whether this agent
/// will be visible for the runtimes, e.g. if (`::rocprofiler_agent_t.runtime_visibility &
/// ::ROCPROFILER_HIP_LIBRARY) != 0` then we believe this agent will be visible to the HIP
/// library. However, this is an estimate and we cannot be certain until the HIP runtime is
/// initialized. This will always be true for CPU agents.
} rocprofiler_agent_v0_t;
/**
* @brief Typedef for the current ::rocprofiler_agent_version_t
*
*/
typedef rocprofiler_agent_v0_t rocprofiler_agent_t;
/**
* @brief Callback function type for querying the available agents.
*
* If callback is invoked, returns the ::rocprofiler_status_t value returned from callback
*
* @param [in] version Enum specifying the version of agent info
* @param [in] agents Array of pointers to agents
* @param [in] num_agents Number of agents in array
* @param [in] user_data Data pointer passback
* @return ::rocprofiler_status_t
* @retval ::ROCPROFILER_STATUS_ERROR_INCOMPATIBLE_ABI size of the agent struct in application is
* larger than the agent struct for rocprofiler-sdk
* @retval ::ROCPROFILER_STATUS_ERROR_INVALID_ARGUMENT Invalid ::rocprofiler_agent_version_t value
*/
typedef rocprofiler_status_t (*rocprofiler_query_available_agents_cb_t)(
rocprofiler_agent_version_t version,
const void** agents,
size_t num_agents,
void* user_data);
/**
* @brief Receive synchronous callback with an array of available agents at moment of invocation
*
* @param [in] version Enum value specifying the struct type of the agent info
* @param [in] callback Callback function accepting list of agents
* @param [in] agent_size Should be set to sizeof(rocprofiler_agent_t)
* @param [in] user_data Data pointer provided to callback
* @return ::rocprofiler_status_t
*/
rocprofiler_status_t
rocprofiler_query_available_agents(rocprofiler_agent_version_t version,
rocprofiler_query_available_agents_cb_t callback,
size_t agent_size,
void* user_data) ROCPROFILER_API ROCPROFILER_NONNULL(2);
/** @} */
ROCPROFILER_EXTERN_C_FINI
+110
ファイルの表示
@@ -0,0 +1,110 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/defines.h>
#include <rocprofiler-sdk/fwd.h>
ROCPROFILER_EXTERN_C_INIT
/**
* @defgroup BUFFER_HANDLING Buffer Handling
* @brief Creation, destruction, and flushing of buffers populated with data from rocprofiler
*
* @{
*
* Every Buffer is associated with a specific service kind.
* OR
* Every Buffer is associated with a specific service ID.
*
*/
/**
* @brief Async callback function.
*
* @code{.cpp}
* for(size_t i = 0; i < num_headers; ++i)
* {
* rocprofiler_record_header_t* hdr = headers[i];
* if(hdr->kind == ROCPROFILER_RECORD_KIND_PC_SAMPLE)
* {
* auto* data = static_cast<rocprofiler_pc_sample_t*>(&hdr->payload);
* ...
* }
* }
* @endcode
*/
typedef void (*rocprofiler_buffer_tracing_cb_t)(rocprofiler_context_id_t context,
rocprofiler_buffer_id_t buffer_id,
rocprofiler_record_header_t** headers,
size_t num_headers,
void* data,
uint64_t drop_count);
/**
* @brief Create buffer.
*
* @param [in] context Context identifier associated with buffer
* @param [in] size Size of the buffer in bytes
* @param [in] watermark - watermark size, where the callback is called, if set
* to 0 then the callback will be called on every record
* @param [in] policy Behavior policy when buffer is full
* @param [in] callback Callback to invoke when buffer is flushed/full
* @param [in] callback_data Data to provide in callback function
* @param [out] buffer_id Identification handle for buffer
* @return ::rocprofiler_status_t
*/
rocprofiler_status_t
rocprofiler_create_buffer(rocprofiler_context_id_t context,
size_t size,
size_t watermark,
rocprofiler_buffer_policy_t policy,
rocprofiler_buffer_tracing_cb_t callback,
void* callback_data,
rocprofiler_buffer_id_t* buffer_id) ROCPROFILER_API
ROCPROFILER_NONNULL(5, 7);
/**
* @brief Destroy buffer.
*
* @param [in] buffer_id
* @return ::rocprofiler_status_t
*
* Note: This will destroy the buffer even if it is not empty. The user can
* call @ref ::rocprofiler_flush_buffer before it to make sure the buffer is empty.
*/
rocprofiler_status_t
rocprofiler_destroy_buffer(rocprofiler_buffer_id_t buffer_id) ROCPROFILER_API;
/**
* @brief Flush buffer.
*
* @param [in] buffer_id
* @return ::rocprofiler_status_t
*/
rocprofiler_status_t
rocprofiler_flush_buffer(rocprofiler_buffer_id_t buffer_id) ROCPROFILER_API;
/** @} */
ROCPROFILER_EXTERN_C_FINI
+743
ファイルの表示
@@ -0,0 +1,743 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/agent.h>
#include <rocprofiler-sdk/defines.h>
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/hip/api_args.h>
#include <rocprofiler-sdk/kfd/kfd_id.h>
#include <rocprofiler-sdk/rocdecode/api_args.h>
#include <rocprofiler-sdk/rocdecode/api_id.h>
#include <stdint.h>
ROCPROFILER_EXTERN_C_INIT
/**
* @defgroup BUFFER_TRACING_SERVICE Asynchronous Tracing Service
* @brief Receive callbacks for batches of records from an internal (background) thread
*
* @{
*/
/**
* @brief ROCProfiler Buffer HSA API Tracer Record.
*/
typedef struct rocprofiler_buffer_tracing_hsa_api_record_t
{
uint64_t size; ///< size of this struct
rocprofiler_buffer_tracing_kind_t kind;
rocprofiler_tracing_operation_t operation;
rocprofiler_correlation_id_t correlation_id; ///< correlation ids for record
rocprofiler_timestamp_t start_timestamp; ///< start time in nanoseconds
rocprofiler_timestamp_t end_timestamp; ///< end time in nanoseconds
rocprofiler_thread_id_t thread_id; ///< id for thread generating this record
/// @var kind
/// @brief ::ROCPROFILER_CALLBACK_TRACING_HSA_CORE_API,
/// ::ROCPROFILER_CALLBACK_TRACING_HSA_AMD_EXT_API,
/// ::ROCPROFILER_CALLBACK_TRACING_HSA_IMAGE_EXT_API, or
/// ::ROCPROFILER_CALLBACK_TRACING_HSA_FINALIZE_EXT_API
/// @var operation
/// @brief Specification of the API function, e.g., ::rocprofiler_hsa_core_api_id_t,
/// ::rocprofiler_hsa_amd_ext_api_id_t, ::rocprofiler_hsa_image_ext_api_id_t, or
/// ::rocprofiler_hsa_finalize_ext_api_id_t
} rocprofiler_buffer_tracing_hsa_api_record_t;
/**
* @brief ROCProfiler Buffer HIP API Tracer Record.
*/
typedef struct rocprofiler_buffer_tracing_hip_api_record_t
{
uint64_t size; ///< size of this struct
rocprofiler_buffer_tracing_kind_t kind;
rocprofiler_tracing_operation_t operation;
rocprofiler_correlation_id_t correlation_id; ///< correlation ids for record
rocprofiler_timestamp_t start_timestamp; ///< start time in nanoseconds
rocprofiler_timestamp_t end_timestamp; ///< end time in nanoseconds
rocprofiler_thread_id_t thread_id; ///< id for thread generating this record
/// @var kind
/// @brief ::ROCPROFILER_CALLBACK_TRACING_HIP_RUNTIME_API or
/// ::ROCPROFILER_CALLBACK_TRACING_HIP_COMPILER_API
/// @var operation
/// @brief Specification of the API function, e.g., ::rocprofiler_hip_runtime_api_id_t or
/// ::rocprofiler_hip_compiler_api_id_t
} rocprofiler_buffer_tracing_hip_api_record_t;
/**
* @brief ROCProfiler Buffer HIP API Tracer Record.
*/
typedef struct rocprofiler_buffer_tracing_hip_api_ext_record_t
{
uint64_t size; ///< size of this struct
rocprofiler_buffer_tracing_kind_t kind;
rocprofiler_tracing_operation_t operation;
rocprofiler_correlation_id_t correlation_id; ///< correlation ids for record
rocprofiler_timestamp_t start_timestamp; ///< start time in nanoseconds
rocprofiler_timestamp_t end_timestamp; ///< end time in nanoseconds
rocprofiler_thread_id_t thread_id; ///< id for thread generating this record
rocprofiler_hip_api_args_t args; ///< arguments of function call
rocprofiler_hip_api_retval_t retval; ///< return value of function call
/// @var kind
/// @brief ::ROCPROFILER_CALLBACK_TRACING_HIP_RUNTIME_API or
/// ::ROCPROFILER_CALLBACK_TRACING_HIP_COMPILER_API
/// @var operation
/// @brief Specification of the API function, e.g., ::rocprofiler_hip_runtime_api_id_t or
/// ::rocprofiler_hip_compiler_api_id_t
} rocprofiler_buffer_tracing_hip_api_ext_record_t;
/**
* @brief Additional trace data for OpenMP target routines
*/
typedef struct rocprofiler_buffer_tracing_ompt_target_t
{
int32_t kind; // ompt_target_t target region kind
int32_t device_num; // ompt device number for the region
uint64_t task_id; // Task ID from the task_data argument to the OMPT callback
uint64_t target_id; // Target identifier from the target_data argument to the callback
const void* codeptr_ra; // pointer to the callsite of the target region
} rocprofiler_buffer_tracing_ompt_target_t;
typedef struct rocprofiler_buffer_tracing_ompt_target_data_op_t
{
uint64_t host_op_id; // from the host_op_id argument to the OMPT callback
int32_t optype; // ompt_target_data_op_t kind of operation
int32_t src_device_num; // ompt device number for data source
int32_t dst_device_num; // ompt device number for data destination
int32_t reserved; // for padding
uint64_t bytes; // size in bytes of the operation
const void* codeptr_ra; // pointer to the callsite of the target_data_op
} rocprofiler_buffer_tracing_ompt_target_data_op_t;
typedef struct rocprofiler_buffer_tracing_ompt_target_kernel_t
{
uint64_t host_op_id; // from the host_op_id argument to the OMPT callback
int32_t device_num; // strangely missing from the OpenMP spec,
uint32_t requested_num_teams; // from the compiler
} rocprofiler_buffer_tracing_ompt_target_kernel_t;
/**
* @brief ROCProfiler Buffer OMPT Tracer Record.
*/
typedef struct rocprofiler_buffer_tracing_ompt_record_t
{
uint64_t size; ///< size of this struct
rocprofiler_buffer_tracing_kind_t kind;
rocprofiler_tracing_operation_t operation;
rocprofiler_correlation_id_t correlation_id; ///< correlation ids for record
rocprofiler_timestamp_t start_timestamp; ///< start time in nanoseconds
rocprofiler_timestamp_t end_timestamp; ///< end time in nanoseconds
rocprofiler_thread_id_t thread_id; ///< id for thread generating this record
union
{
rocprofiler_buffer_tracing_ompt_target_t target;
rocprofiler_buffer_tracing_ompt_target_data_op_t target_data_op;
rocprofiler_buffer_tracing_ompt_target_kernel_t target_kernel;
uint64_t reserved[5];
};
/// @var kind
/// @brief ::ROCPROFILER_BUFFER_TRACING_OMPT
/// @var operation
/// @brief Specification of the ::rocprofiler_ompt_operation_t
} rocprofiler_buffer_tracing_ompt_record_t;
/**
* @brief ROCProfiler Buffer Marker Tracer Record.
*/
typedef struct rocprofiler_buffer_tracing_marker_api_record_t
{
uint64_t size; ///< size of this struct
rocprofiler_buffer_tracing_kind_t kind;
rocprofiler_tracing_operation_t operation;
rocprofiler_correlation_id_t correlation_id; ///< correlation ids for record
rocprofiler_timestamp_t start_timestamp; ///< start time in nanoseconds
rocprofiler_timestamp_t end_timestamp; ///< end time in nanoseconds
rocprofiler_thread_id_t thread_id; ///< id for thread generating this record
/// @var kind
/// @brief ::ROCPROFILER_CALLBACK_TRACING_MARKER_CORE_API,
/// ::ROCPROFILER_CALLBACK_TRACING_MARKER_CONTROL_API, or
/// ::ROCPROFILER_CALLBACK_TRACING_MARKER_NAME_API
/// @var operation
/// @brief Specification of the API function, e.g., ::rocprofiler_marker_core_api_id_t,
/// ::rocprofiler_marker_control_api_id_t, or
/// ::rocprofiler_marker_name_api_id_t
} rocprofiler_buffer_tracing_marker_api_record_t;
/**
* @brief ROCProfiler Buffer RCCL API Record.
*/
typedef struct rocprofiler_buffer_tracing_rccl_api_record_t
{
uint64_t size; ///< size of this struct
rocprofiler_buffer_tracing_kind_t kind;
rocprofiler_tracing_operation_t operation;
rocprofiler_correlation_id_t correlation_id; ///< correlation ids for record
rocprofiler_timestamp_t start_timestamp; ///< start time in nanoseconds
rocprofiler_timestamp_t end_timestamp; ///< end time in nanoseconds
rocprofiler_thread_id_t thread_id; ///< id for thread generating this record
/// @var kind
/// @brief ::ROCPROFILER_CALLBACK_TRACING_RCCL_API
/// @var operation
/// @brief Specification of the API function, e.g., ::rocprofiler_rccl_api_id_t
} rocprofiler_buffer_tracing_rccl_api_record_t;
/**
* @brief ROCProfiler Buffer rocDecode API Record.
*/
typedef struct rocprofiler_buffer_tracing_rocdecode_api_record_t
{
uint64_t size; ///< size of this struct
rocprofiler_buffer_tracing_kind_t kind;
rocprofiler_rocdecode_api_id_t operation;
rocprofiler_correlation_id_t correlation_id; ///< correlation ids for record
rocprofiler_timestamp_t start_timestamp; ///< start time in nanoseconds
rocprofiler_timestamp_t end_timestamp; ///< end time in nanoseconds
rocprofiler_thread_id_t thread_id; ///< id for thread generating this record
/// @var kind
/// @brief ::ROCPROFILER_CALLBACK_TRACING_ROCDECODE_API
/// @var operation
/// @brief Specification of the API function, e.g., ::rocprofiler_rocdecode_api_id_t
} rocprofiler_buffer_tracing_rocdecode_api_record_t;
/**
* @brief An extended ROCProfiler rocDecode API Tracer Record which includes function arguments.
* Pointers are not dereferenced.
*/
typedef struct rocprofiler_buffer_tracing_rocdecode_api_ext_record_t
{
uint64_t size; ///< size of this struct
rocprofiler_buffer_tracing_kind_t kind;
rocprofiler_rocdecode_api_id_t operation;
rocprofiler_correlation_id_t correlation_id; ///< correlation ids for record
rocprofiler_timestamp_t start_timestamp; ///< start time in nanoseconds
rocprofiler_timestamp_t end_timestamp; ///< end time in nanoseconds
rocprofiler_thread_id_t thread_id; ///< id for thread generating this record
rocprofiler_rocdecode_api_args_t args; ///< arguments of function call
rocprofiler_rocdecode_api_retval_t retval; ///< return value of function call
/// @var kind
/// @brief ::ROCPROFILER_BUFFER_TRACING_ROCDECODE_API_EXT
/// @var operation
/// @brief Specification of the API function (@see
/// ::rocprofiler_rocdecode_api_id_t)
} rocprofiler_buffer_tracing_rocdecode_api_ext_record_t;
/**
* @brief ROCProfiler Buffer rocJPEG API Record.
*/
typedef struct rocprofiler_buffer_tracing_rocjpeg_api_record_t
{
uint64_t size; ///< size of this struct
rocprofiler_buffer_tracing_kind_t kind;
rocprofiler_tracing_operation_t operation;
rocprofiler_correlation_id_t correlation_id; ///< correlation ids for record
rocprofiler_timestamp_t start_timestamp; ///< start time in nanoseconds
rocprofiler_timestamp_t end_timestamp; ///< end time in nanoseconds
rocprofiler_thread_id_t thread_id; ///< id for thread generating this record
/// @var kind
/// @brief ::ROCPROFILER_CALLBACK_TRACING_ROCJPEG_API
/// @var operation
/// @brief Specification of the API function (@see
/// ::rocprofiler_rocjpeg_api_id_t)
} rocprofiler_buffer_tracing_rocjpeg_api_record_t;
/**
* @brief ROCProfiler Buffer Memory Copy Tracer Record.
*/
typedef struct rocprofiler_buffer_tracing_memory_copy_record_t
{
uint64_t size; ///< size of this struct
rocprofiler_buffer_tracing_kind_t kind;
rocprofiler_memory_copy_operation_t operation;
rocprofiler_async_correlation_id_t correlation_id; ///< correlation ids for record
rocprofiler_thread_id_t thread_id; ///< id for thread that triggered copy
rocprofiler_timestamp_t start_timestamp; ///< start time in nanoseconds
rocprofiler_timestamp_t end_timestamp; ///< end time in nanoseconds
rocprofiler_agent_id_t dst_agent_id; ///< destination agent of copy
rocprofiler_agent_id_t src_agent_id; ///< source agent of copy
uint64_t bytes; ///< bytes copied
rocprofiler_address_t dst_address; ///< destination address
rocprofiler_address_t src_address; ///< source address
/// @var kind
/// @brief ::ROCPROFILER_BUFFER_TRACING_MEMORY_COPY
/// @var operation
/// @brief Specification of the memory copy direction (@see
/// ::rocprofiler_memory_copy_operation_t)
} rocprofiler_buffer_tracing_memory_copy_record_t;
/**
* @brief ROCProfiler Buffer Memory Allocation Tracer Record.
*/
typedef struct rocprofiler_buffer_tracing_memory_allocation_record_t
{
uint64_t size; ///< size of this struct
rocprofiler_buffer_tracing_kind_t kind;
rocprofiler_memory_allocation_operation_t operation;
rocprofiler_correlation_id_t correlation_id; ///< correlation ids for record
rocprofiler_thread_id_t thread_id; ///< id for thread that triggered copy
rocprofiler_timestamp_t start_timestamp; ///< start time in nanoseconds
rocprofiler_timestamp_t end_timestamp; ///< end time in nanoseconds
rocprofiler_agent_id_t agent_id; ///< agent information for memory allocation
rocprofiler_address_t address; ///< starting address for memory allocation
uint64_t allocation_size; ///< size for memory allocation
/// @var kind
/// @brief ::ROCPROFILER_BUFFER_TRACING_MEMORY_ALLOCATION
/// @var operation
/// @brief Specification of the memory allocation function (@see
/// ::rocprofiler_memory_allocation_operation_t
} rocprofiler_buffer_tracing_memory_allocation_record_t;
/**
* @brief ROCProfiler Buffer Kernel Dispatch Tracer Record.
*/
typedef struct rocprofiler_buffer_tracing_kernel_dispatch_record_t
{
uint64_t size; ///< size of this struct
rocprofiler_buffer_tracing_kind_t kind; ///< ::ROCPROFILER_BUFFER_TRACING_KERNEL_DISPATCH
rocprofiler_kernel_dispatch_operation_t operation;
rocprofiler_async_correlation_id_t correlation_id; ///< correlation ids for record
rocprofiler_thread_id_t thread_id; ///< id for thread that launched kernel
rocprofiler_timestamp_t start_timestamp; ///< start time in nanoseconds
rocprofiler_timestamp_t end_timestamp; ///< end time in nanoseconds
rocprofiler_kernel_dispatch_info_t dispatch_info; ///< Dispatch info
/// @var operation
/// @brief Kernel dispatch buffer records only report the ::ROCPROFILER_KERNEL_DISPATCH_COMPLETE
/// operation because there are no "real" wrapper around the enqueuing of an individual kernel
/// dispatch
} rocprofiler_buffer_tracing_kernel_dispatch_record_t;
/**
* @brief ROCProfiler Buffer Page Migration event record from KFD.
*/
typedef struct rocprofiler_buffer_tracing_kfd_event_page_migrate_record_t
{
uint64_t size; ///< Size of this struct
rocprofiler_buffer_tracing_kind_t kind;
rocprofiler_kfd_event_page_migrate_operation_t operation;
rocprofiler_timestamp_t timestamp; ///< Timestamp of the event as reported by KFD
uint32_t pid; ///< PID of the process as reported by KFD
rocprofiler_address_t start_address; ///< Start address of the memory range being migrated
rocprofiler_address_t end_address; ///< End address of the memory range being migrated
rocprofiler_agent_id_t src_agent; ///< Source agent from which pages were migrated
rocprofiler_agent_id_t dst_agent; ///< Destination agent to which pages were migrated
rocprofiler_agent_id_t prefetch_agent;
rocprofiler_agent_id_t preferred_agent;
int32_t error_code; ///< Non-zero if there was an error at migrate-end
///< @var kind
///< @brief ::ROCPROFILER_BUFFER_TRACING_KFD_EVENT_PAGE_MIGRATE
///< @var operation
///< @brief @see rocprofiler_kfd_page_migrate_operation_t
///< @var prefetch_agent
///< @brief Agent to which memory is to be prefetched.
/// This field should be ignored on a migrate-end event
///< @var preferred_agent
///< @brief Preferred location for this memory
/// This field should be ignored on a migrate-end event
} rocprofiler_buffer_tracing_kfd_event_page_migrate_record_t;
/**
* @brief ROCProfiler Buffer Page Fault event record from KFD.
*/
typedef struct rocprofiler_buffer_tracing_kfd_event_page_fault_record_t
{
uint64_t size; ///< Size of this struct
rocprofiler_buffer_tracing_kind_t kind; ///< ::ROCPROFILER_BUFFER_TRACING_KFD_EVENT_PAGE_FAULT
rocprofiler_kfd_event_page_fault_operation_t operation;
rocprofiler_timestamp_t timestamp; ///< Timestamp of the event as reported by KFD
uint32_t pid; ///< PID of the process as reported by KFD
rocprofiler_agent_id_t agent_id; ///< Agent ID which generated the fault
rocprofiler_address_t address; ///< Memory access that generated the fault event
///< @var operation
///< @brief @see rocprofiler_kfd_page_fault_operation_t
} rocprofiler_buffer_tracing_kfd_event_page_fault_record_t;
/**
* @brief ROCProfiler Buffer Queue event record from KFD.
*/
typedef struct rocprofiler_buffer_tracing_kfd_event_queue_record_t
{
uint64_t size; ///< Size of this struct
rocprofiler_buffer_tracing_kind_t kind; ///< ::ROCPROFILER_BUFFER_TRACING_KFD_EVENT_QUEUE
rocprofiler_kfd_event_queue_operation_t operation; ///< @see rocprofiler_kfd_queue_operation_t
rocprofiler_timestamp_t timestamp; ///< Timestamp of the event as reported by KFD
uint32_t pid; ///< PID of the process as reported by KFD
rocprofiler_agent_id_t agent_id; ///< Agent ID on which this event occurred
} rocprofiler_buffer_tracing_kfd_event_queue_record_t;
/**
* @brief ROCProfiler Buffer Unmap of memory from GPU event record from KFD.
*/
typedef struct rocprofiler_buffer_tracing_kfd_event_unmap_from_gpu_record_t
{
uint64_t size; ///< Size of this struct
rocprofiler_buffer_tracing_kind_t kind;
rocprofiler_kfd_event_unmap_from_gpu_operation_t operation;
rocprofiler_timestamp_t timestamp; ///< Timestamp of the event as reported by KFD
uint32_t pid; ///< PID of the process as reported by KFD
rocprofiler_agent_id_t agent_id; ///< Agent ID on which memory ranges were unmapped
rocprofiler_address_t start_address; ///< Start address of the memory range being unmapped
rocprofiler_address_t end_address; ///< End address of the memory range being unmapped
///< @var kind
///< @brief ::ROCPROFILER_BUFFER_TRACING_KFD_EVENT_UNMAP_FROM_GPU
///< @var operation
///< @brief @see rocprofiler_kfd_unmap_from_gpu_operation_t
} rocprofiler_buffer_tracing_kfd_event_unmap_from_gpu_record_t;
/**
* @brief ROCProfiler Buffer Dropped events event record, for when KFD reports
* that it has dropped some events.
*/
typedef struct rocprofiler_buffer_tracing_kfd_event_dropped_events_record_t
{
uint64_t size; ///< Size of this struct
rocprofiler_buffer_tracing_kind_t kind;
rocprofiler_kfd_event_dropped_events_operation_t operation;
rocprofiler_timestamp_t timestamp; ///< Timestamp of the event as reported by KFD
uint32_t pid; ///< PID of the process as reported by KFD
uint32_t count; ///< Number of records that KFD dropped
///< @var kind
///< @brief ::ROCPROFILER_BUFFER_TRACING_KFD_EVENT_DROPPED_EVENTS
///< @var operation
///< @brief @see rocprofiler_kfd_event_dropped_events_operation_t
} rocprofiler_buffer_tracing_kfd_event_dropped_events_record_t;
/**
* @brief ROCProfiler Buffer Page Migration (paired) record from KFD.
*/
typedef struct rocprofiler_buffer_tracing_kfd_page_migrate_record_t
{
uint64_t size; ///< Size of this struct
rocprofiler_buffer_tracing_kind_t kind; ///< ::ROCPROFILER_BUFFER_TRACING_KFD_PAGE_MIGRATE
rocprofiler_kfd_page_migrate_operation_t operation;
rocprofiler_timestamp_t start_timestamp; ///< Start timestamp as reported by KFD
rocprofiler_timestamp_t end_timestamp; ///< End timestamp as reported by KFD
uint32_t pid; ///< PID of the process as reported by KFD
rocprofiler_address_t start_address; ///< Start address of the memory range being migrated
rocprofiler_address_t end_address; ///< End address of the memory range being migrated
rocprofiler_agent_id_t src_agent; ///< Source agent from which pages were migrated
rocprofiler_agent_id_t dst_agent; ///< Destination agent to which pages were migrated
rocprofiler_agent_id_t prefetch_agent;
rocprofiler_agent_id_t preferred_agent;
int32_t error_code; ///< Non-zero codes are errors, as reported by KFD
///< @var operation
///< @brief @see rocprofiler_kfd_page_migrate_operation_t
///< @var prefetch_agent
///< @brief Agent to which memory is to be prefetched.
///< @var preferred_agent
///< @brief Preferred location for this memory
} rocprofiler_buffer_tracing_kfd_page_migrate_record_t;
/**
* @brief ROCProfiler Buffer Page Fault (paired) record from KFD.
*/
typedef struct rocprofiler_buffer_tracing_kfd_page_fault_record_t
{
uint64_t size; ///< Size of this struct
rocprofiler_buffer_tracing_kind_t kind; ///< ::ROCPROFILER_BUFFER_TRACING_KFD_PAGE_FAULT
rocprofiler_kfd_page_fault_operation_t operation;
rocprofiler_timestamp_t start_timestamp; ///< Start timestamp as reported by KFD
rocprofiler_timestamp_t end_timestamp; ///< End timestamp as reported by KFD
uint32_t pid; ///< PID of the process as reported by KFD
rocprofiler_agent_id_t agent_id; ///< Agent ID which generated the fault
rocprofiler_address_t address; ///< Memory access that generated the page fault
///< @var operation
///< @brief @see rocprofiler_kfd_page_fault_operation_t
} rocprofiler_buffer_tracing_kfd_page_fault_record_t;
/**
* @brief ROCProfiler Buffer Queue suspend (paired) record from KFD.
*/
typedef struct rocprofiler_buffer_tracing_kfd_queue_record_t
{
uint64_t size; ///< Size of this struct
rocprofiler_buffer_tracing_kind_t kind; ///< ::ROCPROFILER_BUFFER_TRACING_KFD_QUEUE
rocprofiler_kfd_queue_operation_t operation; ///< @see rocprofiler_kfd_queue_operation_t
rocprofiler_timestamp_t start_timestamp; ///< Start timestamp as reported by KFD
rocprofiler_timestamp_t end_timestamp; ///< End timestamp as reported by KFD
uint32_t pid; ///< PID of the process as reported by KFD
rocprofiler_agent_id_t agent_id; ///< Agent ID on which this event occurred
} rocprofiler_buffer_tracing_kfd_queue_record_t;
/**
* @brief ROCProfiler Buffer Scratch Memory Tracer Record
*/
typedef struct rocprofiler_buffer_tracing_scratch_memory_record_t
{
uint64_t size; ///< size of this struct
rocprofiler_buffer_tracing_kind_t kind; ///< ::ROCPROFILER_BUFFER_TRACING_SCRATCH_MEMORY
rocprofiler_scratch_memory_operation_t operation; ///< specification of the kind
rocprofiler_correlation_id_t correlation_id; ///< correlation ids for record
rocprofiler_agent_id_t agent_id; ///< agent kernel was dispatched on
rocprofiler_queue_id_t queue_id; ///< queue kernel was dispatched on
rocprofiler_thread_id_t thread_id; ///< id for thread generating this record
rocprofiler_timestamp_t start_timestamp; ///< start time in nanoseconds
rocprofiler_timestamp_t end_timestamp; ///< end time in nanoseconds
rocprofiler_scratch_alloc_flag_t flags;
uint64_t allocation_size; ///< size of scratch memory allocation in bytes
} rocprofiler_buffer_tracing_scratch_memory_record_t;
/**
* @brief ROCProfiler Buffer Correlation ID Retirement Tracer Record.
*/
typedef struct rocprofiler_buffer_tracing_correlation_id_retirement_record_t
{
uint64_t size; ///< size of this struct
rocprofiler_buffer_tracing_kind_t kind;
rocprofiler_timestamp_t timestamp;
uint64_t internal_correlation_id;
/// @var kind
/// @brief ::ROCPROFILER_BUFFER_TRACING_CORRELATION_ID_RETIREMENT
/// @var timestamp
/// @brief Timestamp (in nanosec) of when rocprofiler detected the correlation ID could be
/// retired. Due to clock skew between the CPU and GPU, this may at times, *appear* to be before
/// the kernel or memory copy completed but the reality is that if this ever occurred, the API
/// would report a FATAL error
/// @var internal_correlation_id
/// @brief Only internal correlation ID is provided
} rocprofiler_buffer_tracing_correlation_id_retirement_record_t;
/**
* @brief ROCProfiler Buffer Runtime Initialization Tracer Record.
*/
typedef struct rocprofiler_buffer_tracing_runtime_initialization_record_t
{
uint64_t size; ///< size of this struct
rocprofiler_buffer_tracing_kind_t kind;
rocprofiler_runtime_initialization_operation_t operation;
rocprofiler_correlation_id_t correlation_id;
rocprofiler_thread_id_t thread_id;
rocprofiler_timestamp_t timestamp;
uint64_t version;
uint64_t instance;
/// @var kind
/// @brief ::ROCPROFILER_BUFFER_TRACING_RUNTIME_INITIALIZATION
/// @var operation
/// @brief Indicates which runtime was initialized/loaded
/// @var correlation_id
/// @brief Correlation ID for these records are always zero
/// @var thread_id
/// @brief ID for thread which loaded this runtime
/// @var timestamp
/// @brief Timestamp (in nanosec) of when runtime was initialized/loaded
/// @var version
/// @brief The version number of the runtime
///
/// Version number is encoded as: (10000 * MAJOR) + (100 * MINOR) + PATCH
/// @var instance
/// @brief Number of times this runtime had been loaded previously
} rocprofiler_buffer_tracing_runtime_initialization_record_t;
/**
* @brief Callback function for mapping ::rocprofiler_buffer_tracing_kind_t ids to
* string names. @see rocprofiler_iterate_buffer_trace_kind_names.
*/
typedef int (*rocprofiler_buffer_tracing_kind_cb_t)(rocprofiler_buffer_tracing_kind_t kind,
void* data);
/**
* @brief Callback function for mapping the operations of a given @ref
* rocprofiler_buffer_tracing_kind_t to string names. @see
* rocprofiler_iterate_buffer_trace_kind_operation_names.
*/
typedef int (*rocprofiler_buffer_tracing_kind_operation_cb_t)(
rocprofiler_buffer_tracing_kind_t kind,
rocprofiler_tracing_operation_t operation,
void* data);
/**
* @brief Configure Buffer Tracing Service.
*
* @param [in] context_id Associated context to control activation of service
* @param [in] kind Buffer tracing category
* @param [in] operations Array of specific operations (if desired)
* @param [in] operations_count Number of specific operations (if non-null set of operations)
* @param [in] buffer_id Buffer to store the records in
* @return ::rocprofiler_status_t
* @retval ::ROCPROFILER_STATUS_ERROR_CONFIGURATION_LOCKED ::rocprofiler_configure initialization
* phase has passed
* @retval ::ROCPROFILER_STATUS_ERROR_CONTEXT_NOT_FOUND context is not valid
* @retval ::ROCPROFILER_STATUS_ERROR_SERVICE_ALREADY_CONFIGURED Context has already been configured
* for the ::rocprofiler_buffer_tracing_kind_t kind
* @retval ::ROCPROFILER_STATUS_ERROR_KIND_NOT_FOUND Invalid ::rocprofiler_buffer_tracing_kind_t
* @retval ::ROCPROFILER_STATUS_ERROR_OPERATION_NOT_FOUND Invalid operation id for
* ::rocprofiler_buffer_tracing_kind_t kind was found
*
*/
rocprofiler_status_t
rocprofiler_configure_buffer_tracing_service(rocprofiler_context_id_t context_id,
rocprofiler_buffer_tracing_kind_t kind,
const rocprofiler_tracing_operation_t* operations,
size_t operations_count,
rocprofiler_buffer_id_t buffer_id) ROCPROFILER_API;
/**
* @brief Query the name of the buffer tracing kind. The name retrieved from this function is a
* string literal that is encoded in the read-only section of the binary (i.e. it is always
* "allocated" and never "deallocated").
*
* @param [in] kind Buffer tracing domain
* @param [out] name If non-null and the name is a constant string that does not require dynamic
* allocation, this paramter will be set to the address of the string literal, otherwise it will
* be set to nullptr
* @param [out] name_len If non-null, this will be assigned the length of the name (regardless of
* the name is a constant string or requires dynamic allocation)
* @return ::rocprofiler_status_t
* @retval ::ROCPROFILER_STATUS_ERROR_KIND_NOT_FOUND Returned if the domain id is not valid
* @retval ::ROCPROFILER_STATUS_SUCCESS Returned if a valid domain, regardless if there is a
* constant string or not.
*/
rocprofiler_status_t
rocprofiler_query_buffer_tracing_kind_name(rocprofiler_buffer_tracing_kind_t kind,
const char** name,
uint64_t* name_len) ROCPROFILER_API;
/**
* @brief Query the name of the buffer tracing kind. The name retrieved from this function is a
* string literal that is encoded in the read-only section of the binary (i.e. it is always
* "allocated" and never "deallocated").
*
* @param [in] kind Buffer tracing domain
* @param [in] operation Enumeration id value which maps to a specific API function or event type
* @param [out] name If non-null and the name is a constant string that does not require dynamic
* allocation, this paramter will be set to the address of the string literal, otherwise it will
* be set to nullptr
* @param [out] name_len If non-null, this will be assigned the length of the name (regardless of
* the name is a constant string or requires dynamic allocation)
* @return ::rocprofiler_status_t
* @retval ::ROCPROFILER_STATUS_ERROR_KIND_NOT_FOUND An invalid domain id
* @retval ::ROCPROFILER_STATUS_ERROR_OPERATION_NOT_FOUND The operation number is not recognized for
* the given domain
* @retval ::ROCPROFILER_STATUS_ERROR_NOT_IMPLEMENTED Rocprofiler does not support providing the
* operation name within this domain
* @retval ::ROCPROFILER_STATUS_SUCCESS Valid domain and operation, regardless of whether there is a
* constant string or not.
*/
rocprofiler_status_t
rocprofiler_query_buffer_tracing_kind_operation_name(rocprofiler_buffer_tracing_kind_t kind,
rocprofiler_tracing_operation_t operation,
const char** name,
uint64_t* name_len) ROCPROFILER_API;
/**
* @brief Iterate over all the buffer tracing kinds and invokes the callback for each buffer tracing
* kind.
*
* This is typically used to invoke ::rocprofiler_iterate_buffer_tracing_kind_operations for each
* buffer tracing kind.
*
* @param [in] callback Callback function invoked for each enumeration value in @ref
* rocprofiler_buffer_tracing_kind_t with the exception of the `NONE` and `LAST` values.
* @param [in] data User data passed back into the callback
* @return ::rocprofiler_status_t
*/
rocprofiler_status_t
rocprofiler_iterate_buffer_tracing_kinds(rocprofiler_buffer_tracing_kind_cb_t callback,
void* data) ROCPROFILER_API ROCPROFILER_NONNULL(1);
/**
* @brief Iterates over all the operations for a given @ref
* rocprofiler_buffer_tracing_kind_t and invokes the callback with the kind and operation
* id. This is useful to build a map of the operation names during tool initialization instead of
* querying rocprofiler everytime in the callback hotpath.
*
* @param [in] kind which buffer tracing kind operations to iterate over
* @param [in] callback Callback function invoked for each operation associated with @ref
* rocprofiler_buffer_tracing_kind_t with the exception of the `NONE` and `LAST` values.
* @param [in] data User data passed back into the callback
* @return ::rocprofiler_status_t
*/
rocprofiler_status_t
rocprofiler_iterate_buffer_tracing_kind_operations(
rocprofiler_buffer_tracing_kind_t kind,
rocprofiler_buffer_tracing_kind_operation_cb_t callback,
void* data) ROCPROFILER_API ROCPROFILER_NONNULL(2);
/**
* @brief Callback function for iterating over the function arguments to a traced function.
* This function will be invoked for each argument.
* @see rocprofiler_iterate_buffer_tracing_record_args
*
* @param [in] kind domain
* @param [in] operation associated domain operation
* @param [in] arg_number the argument number, starting at zero
* @param [in] arg_value_addr the address of the argument stored by rocprofiler.
* @param [in] arg_indirection_count the total number of indirection levels for the argument, e.g.
* int == 0, int* == 1, int** == 2
* @param [in] arg_type the typeid name of the argument (not demangled)
* @param [in] arg_name the name of the argument in the prototype (or rocprofiler union)
* @param [in] arg_value_str conversion of the argument to a string, e.g. operator<< overload
* @param [in] data user data
*/
typedef int (*rocprofiler_buffer_tracing_operation_args_cb_t)(
rocprofiler_buffer_tracing_kind_t kind,
rocprofiler_tracing_operation_t operation,
uint32_t arg_number,
const void* const arg_value_addr,
int32_t arg_indirection_count,
const char* arg_type,
const char* arg_name,
const char* arg_value_str,
void* data);
/**
* @brief Iterates over all the arguments for the traced function (when available). This is
* particularly useful when tools want to annotate traces with the function arguments. See
* @example samples/api_buffered_tracing/client.cpp for a usage example.
*
* In contrast to ::rocprofiler_iterate_callback_tracing_kind_operation_args, this function
* cannot dereference pointer arguments since there is a high probability that the pointer
* address references the stack and the buffer tracing record is delivered after the
* stack variables of the corresponding function have been destroyed.
*
* @param [in] record Buffer record
* @param [in] callback The callback function which will be invoked for each argument
* @param [in] user_data Data to be passed to each invocation of the callback
* @return ::rocprofiler_status_t
*/
rocprofiler_status_t
rocprofiler_iterate_buffer_tracing_record_args(
rocprofiler_record_header_t record,
rocprofiler_buffer_tracing_operation_args_cb_t callback,
void* user_data) ROCPROFILER_API ROCPROFILER_NONNULL(2);
/** @} */
ROCPROFILER_EXTERN_C_FINI
+594
ファイルの表示
@@ -0,0 +1,594 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/defines.h>
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/hip.h>
#include <rocprofiler-sdk/hsa.h>
#include <rocprofiler-sdk/marker.h>
#include <rocprofiler-sdk/ompt.h>
#include <rocprofiler-sdk/rccl.h>
#include <rocprofiler-sdk/rocdecode.h>
#include <rocprofiler-sdk/rocjpeg.h>
#include <hsa/hsa.h>
#include <hsa/hsa_amd_tool.h>
#include <hsa/hsa_ext_amd.h>
#include <hsa/hsa_ven_amd_loader.h>
#include <stdint.h>
ROCPROFILER_EXTERN_C_INIT
/**
* @defgroup CALLBACK_TRACING_SERVICE Synchronous Tracing Services
* @brief Receive immediate callbacks on the calling thread
*
* @{
*/
/**
* @brief ROCProfiler Enumeration for code object storage types (identical values to
* `hsa_ven_amd_loader_code_object_storage_type_t` enumeration)
*/
typedef enum rocprofiler_code_object_storage_type_t
{
ROCPROFILER_CODE_OBJECT_STORAGE_TYPE_NONE = HSA_VEN_AMD_LOADER_CODE_OBJECT_STORAGE_TYPE_NONE,
ROCPROFILER_CODE_OBJECT_STORAGE_TYPE_FILE = HSA_VEN_AMD_LOADER_CODE_OBJECT_STORAGE_TYPE_FILE,
ROCPROFILER_CODE_OBJECT_STORAGE_TYPE_MEMORY =
HSA_VEN_AMD_LOADER_CODE_OBJECT_STORAGE_TYPE_MEMORY,
ROCPROFILER_CODE_OBJECT_STORAGE_TYPE_LAST,
} rocprofiler_code_object_storage_type_t;
/**
* @brief ROCProfiler HSA API Callback Data.
*/
typedef struct rocprofiler_callback_tracing_hsa_api_data_t
{
uint64_t size; ///< size of this struct
rocprofiler_hsa_api_args_t args;
rocprofiler_hsa_api_retval_t retval;
} rocprofiler_callback_tracing_hsa_api_data_t;
/**
* @brief ROCProfiler HIP runtime and compiler API Tracer Callback Data.
*/
typedef struct rocprofiler_callback_tracing_hip_api_data_t
{
uint64_t size; ///< size of this struct
rocprofiler_hip_api_args_t args;
rocprofiler_hip_api_retval_t retval; ///< return value of function call
/// @var args
/// @brief Arguments of the function call. @see
/// ::rocprofiler_iterate_callback_tracing_kind_operation_args for generic
/// access/stringification of the arguments.
} rocprofiler_callback_tracing_hip_api_data_t;
/**
* @brief ROCProfiler OMPT Callback Data
*/
typedef struct rocprofiler_callback_tracing_ompt_data_t
{
uint64_t size; ///< size of this struct
rocprofiler_ompt_args_t args;
} rocprofiler_callback_tracing_ompt_data_t;
/**
* @brief ROCProfiler Marker Tracer Callback Data.
*/
typedef struct rocprofiler_callback_tracing_marker_api_data_t
{
uint64_t size; ///< size of this struct
rocprofiler_marker_api_args_t args;
rocprofiler_marker_api_retval_t retval;
} rocprofiler_callback_tracing_marker_api_data_t;
/**
* @brief ROCProfiler RCCL API Callback Data.
*/
typedef struct rocprofiler_callback_tracing_rccl_api_data_t
{
uint64_t size; ///< size of this struct
rocprofiler_rccl_api_args_t args;
rocprofiler_rccl_api_retval_t retval;
} rocprofiler_callback_tracing_rccl_api_data_t;
/**
* @brief ROCProfiler rocDecode API Callback Data.
*/
typedef struct rocprofiler_callback_tracing_rocdecode_api_data_t
{
uint64_t size; ///< size of this struct
rocprofiler_rocdecode_api_args_t args;
rocprofiler_rocdecode_api_retval_t retval;
} rocprofiler_callback_tracing_rocdecode_api_data_t;
/**
* @brief ROCProfiler rocJPEG API Callback Data.
*/
typedef struct rocprofiler_callback_tracing_rocjpeg_api_data_t
{
uint64_t size; ///< size of this struct
rocprofiler_rocjpeg_api_args_t args;
rocprofiler_rocjpeg_api_retval_t retval;
} rocprofiler_callback_tracing_rocjpeg_api_data_t;
/**
* @brief ROCProfiler Code Object Load Tracer Callback Record.
*/
typedef struct rocprofiler_callback_tracing_code_object_load_data_t
{
uint64_t size; ///< size of this struct
uint64_t code_object_id; ///< unique code object identifier
union
{
rocprofiler_agent_id_t rocp_agent; ///< Deprecated. Renamed to agent_id
rocprofiler_agent_id_t agent_id; ///< The agent on which this loaded code object is loaded
};
hsa_agent_t hsa_agent; ///< Deprecated. The agent on which this loaded code object is loaded
const char* uri; ///< The URI name from which the code object was loaded
uint64_t load_base;
uint64_t load_size;
int64_t load_delta;
rocprofiler_code_object_storage_type_t storage_type;
/// @var load_base
/// @brief The base memory address at which the code object is loaded. This is the base address
/// of the allocation for the lowest addressed segment of the code object that is loaded. Note
/// that any non-loaded segments before the first loaded segment are ignored.
///
/// @var load_size
/// @brief The byte size of the loaded code objects contiguous memory allocation.
///
/// @var load_delta
/// @brief The signed byte address difference of the memory address at which the code object is
/// loaded minus the virtual address specified in the code object that is loaded.
///
/// @var storage_type
/// @brief storage type of the code object reader used to load the loaded code object
///
union
{
struct
{
int storage_file; ///< file descriptor of the code object that was loaded. Access this
///< field if ::rocprofiler_code_object_storage_type_t is
///< ::ROCPROFILER_CODE_OBJECT_STORAGE_TYPE_FILE
};
struct
{
uint64_t memory_base; ///< The memory address of the first byte of the code object that
///< was loaded. Access this
///< field if ::rocprofiler_code_object_storage_type_t is
///< ::ROCPROFILER_CODE_OBJECT_STORAGE_TYPE_MEMORY
uint64_t
memory_size; ///< The memory size in bytes of the code object that was loaded.
///< Access this field if ::rocprofiler_code_object_storage_type_t is
///< ::ROCPROFILER_CODE_OBJECT_STORAGE_TYPE_MEMORY
};
};
} rocprofiler_callback_tracing_code_object_load_data_t;
/**
* @brief The NULL value of a code object id. Used when code object is unknown.
*/
#define ROCPROFILER_CODE_OBJECT_ID_NONE ROCPROFILER_UINT64_C(0)
/**
* @brief ROCProfiler Code Object Kernel Symbol Tracer Callback Record.
*
*/
typedef struct rocprofiler_callback_tracing_code_object_kernel_symbol_register_data_t
{
uint64_t size; ///< size of this struct
uint64_t kernel_id; ///< unique symbol identifier value
uint64_t code_object_id; ///< parent unique code object identifier
const char* kernel_name; ///< name of the kernel
uint64_t kernel_object;
uint32_t kernarg_segment_size;
uint32_t kernarg_segment_alignment;
uint32_t group_segment_size;
uint32_t private_segment_size;
uint32_t sgpr_count; ///< Scalar general purpose register count
uint32_t arch_vgpr_count; ///< Architecture vector general purpose register count
uint32_t accum_vgpr_count; ///< Accum vector general purpose register count
int64_t kernel_code_entry_byte_offset;
rocprofiler_address_t kernel_address;
/// @var kernel_object
/// @brief kernel object handle, used in the kernel dispatch packet
///
/// @var kernarg_segment_size
/// @brief size of memory (in bytes) allocated for kernel arguments. Will be multiple of 16
///
/// @var kernarg_segment_alignment
/// @brief Alignment (in bytes) of the buffer used to pass arguments to the kernel
///
/// @var group_segment_size
/// @brief Size of static group segment memory required by the kernel (per work-group), in
/// bytes. AKA: LDS size
///
/// @var private_segment_size
/// @brief Size of static private, spill, and arg segment memory required by this kernel (per
/// work-item), in bytes. AKA: scratch size
///
/// @var kernel_code_entry_byte_offset
/// @brief Relative offset from kernel_object address to calculate the first address of a
/// kernel.
///
/// @var kernel_address
/// @brief The first address of a kernel. Useful for PC sampling.
///
} rocprofiler_callback_tracing_code_object_kernel_symbol_register_data_t;
// rename struct
typedef struct rocprofiler_callback_tracing_code_object_host_kernel_symbol_register_data_t
{
uint64_t size; ///< size of this struct
uint64_t host_function_id; ///< unique host function identifier value
uint64_t kernel_id; ///< unique symbol identifier value
uint64_t code_object_id; ///< parent unique code object identifier
rocprofiler_address_t host_function; ///< kernel host function pointer
rocprofiler_address_t modules; ///< reference address where modules will be loaded
const char* device_function;
uint32_t thread_limit; ///< thread limit
rocprofiler_dim3_t thread_ids; ///< thread ids address
rocprofiler_dim3_t block_ids; ///< block ids address
rocprofiler_dim3_t block_dims; ///< block dimensions address
rocprofiler_dim3_t grid_dims; ///< grid dimensions address
uint64_t workgroup_size; ///< workgroup size address
/// @var device_function
/// @brief device function name used to map the metadata during kernel launch
} rocprofiler_callback_tracing_code_object_host_kernel_symbol_register_data_t;
/**
* @brief ROCProfiler Kernel Dispatch Callback Tracer Record.
*
*/
typedef struct rocprofiler_callback_tracing_kernel_dispatch_data_t
{
uint64_t size; ///< size of this struct
rocprofiler_timestamp_t start_timestamp; ///< start time in nanoseconds
rocprofiler_timestamp_t end_timestamp; ///< end time in nanoseconds
rocprofiler_kernel_dispatch_info_t dispatch_info; ///< Dispatch info
} rocprofiler_callback_tracing_kernel_dispatch_data_t;
/**
* @brief ROCProfiler Memory Copy Callback Tracer Record.
*
* The timestamps in this record will only be non-zero in the ::ROCPROFILER_CALLBACK_PHASE_EXIT
* callback
*/
typedef struct rocprofiler_callback_tracing_memory_copy_data_t
{
uint64_t size; ///< size of this struct
rocprofiler_timestamp_t start_timestamp; ///< start time in nanoseconds
rocprofiler_timestamp_t end_timestamp; ///< end time in nanoseconds
rocprofiler_agent_id_t dst_agent_id; ///< destination agent of copy
rocprofiler_agent_id_t src_agent_id; ///< source agent of copy
uint64_t bytes; ///< bytes copied
rocprofiler_address_t dst_address; ///< destination address
rocprofiler_address_t src_address; ///< source address
} rocprofiler_callback_tracing_memory_copy_data_t;
/**
* @brief ROCProfiler Memory Allocation Tracer Record.
*/
typedef struct rocprofiler_callback_tracing_memory_allocation_data_t
{
uint64_t size; ///< size of this struct
rocprofiler_timestamp_t start_timestamp; ///< start time in nanoseconds
rocprofiler_timestamp_t end_timestamp; ///< end time in nanoseconds
rocprofiler_agent_id_t agent_id; ///< agent id for memory allocation
rocprofiler_address_t address; ///< starting address for memory allocation
uint64_t allocation_size; ///< size of memory allocation
} rocprofiler_callback_tracing_memory_allocation_data_t;
/**
* @brief ROCProfiler Scratch Memory Callback Data.
*/
typedef struct rocprofiler_callback_tracing_scratch_memory_data_t
{
uint64_t size; ///< size of this struct
rocprofiler_agent_id_t agent_id;
rocprofiler_queue_id_t queue_id;
rocprofiler_scratch_alloc_flag_t flags;
hsa_amd_tool_event_kind_t args_kind;
rocprofiler_scratch_memory_args_t args;
} rocprofiler_callback_tracing_scratch_memory_data_t;
/**
* @brief ROCProfiler Runtime Initialization Data.
*/
typedef struct rocprofiler_callback_tracing_runtime_initialization_data_t
{
uint64_t size; ///< size of this struct
uint64_t version;
uint64_t instance; ///< Number of times this runtime had been loaded previously
/// @var version
/// @brief The version number of the library
///
/// Version number is encoded as: (10000 * MAJOR) + (100 * MINOR) + PATCH
} rocprofiler_callback_tracing_runtime_initialization_data_t;
/**
* @brief ROCProfiler Stream Handle Callback Data.
*/
typedef struct rocprofiler_callback_tracing_hip_stream_data_t
{
uint64_t size; ///< size of this struct
rocprofiler_stream_id_t stream_id; ///< HIP stream ID
rocprofiler_address_t stream_value; ///< HIP stream value
} rocprofiler_callback_tracing_hip_stream_data_t;
/**
* @brief API Tracing callback function. This function is invoked twice per API function: once
* before the function is invoked and once after the function is invoked. The external correlation
* id value within the record is assigned the value at the top of the external correlation id stack.
* It is permissible to invoke ::rocprofiler_push_external_correlation_id within the enter phase;
* when a new external correlation id is pushed during the enter phase, rocprofiler will use that
* external correlation id for any async events and provide the new external correlation id during
* the exit callback... In other words, pushing a new external correlation id within the enter
* callback will result in that external correlation id value in the exit callback (which may or may
* not be different from the external correlation id value in the enter callback). If a tool pushes
* new external correlation ids in the enter phase, it is recommended to pop the external
* correlation id in the exit callback.
*
* @param [in] record Callback record data
* @param [in,out] user_data This paramter can be used to retain information in between the enter
* and exit phases.
* @param [in] callback_data User data provided when configuring the callback tracing service
*/
typedef void (*rocprofiler_callback_tracing_cb_t)(rocprofiler_callback_tracing_record_t record,
rocprofiler_user_data_t* user_data,
void* callback_data) ROCPROFILER_NONNULL(2);
/**
* @brief Callback function for mapping ::rocprofiler_callback_tracing_kind_t ids to
* string names. @see rocprofiler_iterate_callback_tracing_kind_names.
*/
typedef int (*rocprofiler_callback_tracing_kind_cb_t)(rocprofiler_callback_tracing_kind_t kind,
void* data);
/**
* @brief Callback function for mapping the operations of a given
* ::rocprofiler_callback_tracing_kind_t to string names. @see
* rocprofiler_iterate_callback_tracing_kind_operation_names.
*/
typedef int (*rocprofiler_callback_tracing_kind_operation_cb_t)(
rocprofiler_callback_tracing_kind_t kind,
rocprofiler_tracing_operation_t operation,
void* data);
/**
* @brief Callback function for iterating over the function arguments to a traced function.
* This function will be invoked for each argument.
* @see rocprofiler_iterate_callback_tracing_operation_args
*
* @param [in] kind domain
* @param [in] operation associated domain operation
* @param [in] arg_number the argument number, starting at zero
* @param [in] arg_value_addr the address of the argument stored by rocprofiler.
* @param [in] arg_indirection_count the total number of indirection levels for the argument, e.g.
* int == 0, int* == 1, int** == 2
* @param [in] arg_type the typeid name of the argument
* @param [in] arg_name the name of the argument in the prototype (or rocprofiler union)
* @param [in] arg_value_str conversion of the argument to a string, e.g. operator<< overload
* @param [in] arg_dereference_count the number of times the argument was dereferenced when it was
* converted to a string
* @param [in] data user data
*/
typedef int (*rocprofiler_callback_tracing_operation_args_cb_t)(
rocprofiler_callback_tracing_kind_t kind,
rocprofiler_tracing_operation_t operation,
uint32_t arg_number,
const void* const arg_value_addr,
int32_t arg_indirection_count,
const char* arg_type,
const char* arg_name,
const char* arg_value_str,
int32_t arg_dereference_count,
void* data);
/**
* @brief Configure Callback Tracing Service. The callback tracing service provides two synchronous
* callbacks around an API function on the same thread as the application which is invoking the API
* function. This function can only be invoked once per ::rocprofiler_callback_tracing_kind_t value,
* i.e. it can be invoked once for the HSA API, once for the HIP API, and so on but it will fail if
* it is invoked for the HSA API twice. Please note, the callback API does have the potentially
* non-trivial overhead of copying the function arguments into the record. If you are willing to let
* rocprofiler record the timestamps, do not require synchronous notifications of the API calls, and
* want to lowest possible overhead, use the
* @see BUFFER_TRACING_SERVICE.
*
* @param [in] context_id Context to associate the service with
* @param [in] kind The domain of the callback tracing service
* @param [in] operations Array of operations in the domain (i.e. enum values which identify
* specific API functions). If this is null, all API functions in the domain will be traced
* @param [in] operations_count If the operations array is non-null, set this to the size of the
* array.
* @param [in] callback The function to invoke before and after an API function
* @param [in] callback_args Data provided to every invocation of the callback function
* @return ::rocprofiler_status_t
* @retval ::ROCPROFILER_STATUS_ERROR_CONFIGURATION_LOCKED Invoked outside of the initialization
* function in ::rocprofiler_tool_configure_result_t provided to rocprofiler via
* ::rocprofiler_configure function
* @retval ::ROCPROFILER_STATUS_ERROR_CONTEXT_NOT_FOUND The provided context is not valid/registered
* @retval ::ROCPROFILER_STATUS_ERROR_SERVICE_ALREADY_CONFIGURED if the same
* ::rocprofiler_callback_tracing_kind_t value is provided more than once (per context) -- in other
* words, we do not support overriding or combining the operations in separate function calls.
*
*/
rocprofiler_status_t
rocprofiler_configure_callback_tracing_service(rocprofiler_context_id_t context_id,
rocprofiler_callback_tracing_kind_t kind,
const rocprofiler_tracing_operation_t* operations,
size_t operations_count,
rocprofiler_callback_tracing_cb_t callback,
void* callback_args) ROCPROFILER_API;
/**
* @brief Query the name of the callback tracing kind. The name retrieved from this function is a
* string literal that is encoded in the read-only section of the binary (i.e. it is always
* "allocated" and never "deallocated").
*
* @param [in] kind Callback tracing domain
* @param [out] name If non-null and the name is a constant string that does not require dynamic
* allocation, this paramter will be set to the address of the string literal, otherwise it will
* be set to nullptr
* @param [out] name_len If non-null, this will be assigned the length of the name (regardless of
* the name is a constant string or requires dynamic allocation)
* @return ::rocprofiler_status_t
*/
rocprofiler_status_t
rocprofiler_query_callback_tracing_kind_name(rocprofiler_callback_tracing_kind_t kind,
const char** name,
uint64_t* name_len) ROCPROFILER_API;
/**
* @brief Query the name of the callback tracing kind. The name retrieved from this function is a
* string literal that is encoded in the read-only section of the binary (i.e. it is always
* "allocated" and never "deallocated").
*
* @param [in] kind Callback tracing domain
* @param [in] operation Enumeration id value which maps to a specific API function or event type
* @param [out] name If non-null and the name is a constant string that does not require dynamic
* allocation, this paramter will be set to the address of the string literal, otherwise it will
* be set to nullptr
* @param [out] name_len If non-null, this will be assigned the length of the name (regardless of
* the name is a constant string or requires dynamic allocation)
* @return ::rocprofiler_status_t
* @retval ::ROCPROFILER_STATUS_ERROR_KIND_NOT_FOUND Domain id is not valid
* @retval ::ROCPROFILER_STATUS_SUCCESS Valid domain provided, regardless if there is a constant
* string or not.
*/
rocprofiler_status_t
rocprofiler_query_callback_tracing_kind_operation_name(rocprofiler_callback_tracing_kind_t kind,
rocprofiler_tracing_operation_t operation,
const char** name,
uint64_t* name_len) ROCPROFILER_API;
/**
* @brief Iterate over all the mappings of the callback tracing kinds and get a callback for each
* kind.
*
* @param [in] callback Callback function invoked for each enumeration value in
* ::rocprofiler_callback_tracing_kind_t with the exception of the `NONE` and `LAST` values.
* @param [in] data User data passed back into the callback
* @return ::rocprofiler_status_t
*/
rocprofiler_status_t
rocprofiler_iterate_callback_tracing_kinds(rocprofiler_callback_tracing_kind_cb_t callback,
void* data) ROCPROFILER_API ROCPROFILER_NONNULL(1);
/**
* @brief Iterates over all the mappings of the operations for a given
* ::rocprofiler_callback_tracing_kind_t and invokes the callback with the kind id, operation id,
* and user-provided data.
*
* @param [in] kind which tracing callback kind operations to iterate over
* @param [in] callback Callback function invoked for each operation associated with
* ::rocprofiler_callback_tracing_kind_t with the exception of the `NONE` and `LAST` values.
* @param [in] data User data passed back into the callback
* @return ::rocprofiler_status_t
* @retval ::ROCPROFILER_STATUS_ERROR_KIND_NOT_FOUND Invalid domain id
* @retval ::ROCPROFILER_STATUS_SUCCESS Valid domain
*/
rocprofiler_status_t
rocprofiler_iterate_callback_tracing_kind_operations(
rocprofiler_callback_tracing_kind_t kind,
rocprofiler_callback_tracing_kind_operation_cb_t callback,
void* data) ROCPROFILER_API ROCPROFILER_NONNULL(2);
/**
* @brief Iterates over all the arguments for the traced function (when available). This is
* particularly useful when tools want to annotate traces with the function arguments. See
* @example samples/api_callback_tracing/client.cpp for a usage example.
*
* It is recommended to use this function when the record phase is ::ROCPROFILER_CALLBACK_PHASE_EXIT
* or ::ROCPROFILER_CALLBACK_PHASE_NONE. When the phase is ::ROCPROFILER_CALLBACK_PHASE_ENTER, the
* function may have output parameters which have not set. In the case of an output parameter with
* one level of indirection, e.g. `int* output_len`, this is considered safe since the output
* parameter is either null or, in the worst case scenario, pointing to an uninitialized value which
* will result in garbage values to be stringified. However, if the output parameter has more than
* one level of indirection, e.g. `const char** output_name`, this can result in a segmentation
* fault because the dereferenced output parameter may be uninitialized and point to an invalid
address. E.g.:
*
* @code{.cpp}
* struct dim3
* {
* int x;
* int y;
* int z;
* };
*
* static dim3 default_dims = {.x = 1, .y = 1, .z = 1};
*
* void set_dim_x(int val, dim3* output_dims) { output_dims->x = val; }
*
* void get_default_dims(dim3** output_dims) { *output_dims = default_dims; }
*
* int main()
* {
* dim3 my_dims; // uninitialized value. x, y, and z may be set to random values
* dim3* current_dims; // uninitialized pointer. May be set to invalid address
*
* set_dim_x(3, &my_dims); // if rocprofiler-sdk wrapped this function and tried to stringify
* // in the enter phase, dereferencing my_dims is not problematic
* // since there is an actual dim3 allocation
*
* get_default_dims(&current_dims); // if rocprofiler-sdk wrapped this function,
* // and tried to stringify in the enter phase,
* // current_dims may point to an address outside
* // of the address space of this process and
* // cause a segfault
* }
* @endcode
*
*
* @param[in] record Record provided by service callback
* @param[in] callback The callback function which will be invoked for each argument
* @param[in] max_dereference_count In the callback enter phase, certain arguments may be output
* parameters which have not been set. When the output parameter has multiple levels of indirection,
* it may be invalid to dereference the output parameter more than once and doing so may result in a
* segmentation fault. Thus, it is recommended to set this parameter to a maximum value of 1 when
* the phase is ::ROCPROFILER_CALLBACK_PHASE_ENTER to ensure that output parameters which point to
* uninitialized pointers do not cause segmentation faults.
* @param[in] user_data Data to be passed to each invocation of the callback
*/
rocprofiler_status_t
rocprofiler_iterate_callback_tracing_kind_operation_args(
rocprofiler_callback_tracing_record_t record,
rocprofiler_callback_tracing_operation_args_cb_t callback,
int32_t max_dereference_count,
void* user_data) ROCPROFILER_API ROCPROFILER_NONNULL(2);
/** @} */
ROCPROFILER_EXTERN_C_FINI
+98
ファイルの表示
@@ -0,0 +1,98 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/defines.h>
#include <rocprofiler-sdk/fwd.h>
ROCPROFILER_EXTERN_C_INIT
/**
* @defgroup CONTEXT_OPERATIONS Context Handling
* @brief Associate services with a handle. This handle is used to activate/deactivate the services
* during the application runtime.
*
* @{
*/
/**
* The NULL Context handle.
*/
#define ROCPROFILER_CONTEXT_NONE ROCPROFILER_HANDLE_LITERAL(rocprofiler_context_id_t, 0UL)
/**
* @brief Create context.
*
* @param [out] context_id Context identifier
* @return ::rocprofiler_status_t
*/
rocprofiler_status_t
rocprofiler_create_context(rocprofiler_context_id_t* context_id) ROCPROFILER_API
ROCPROFILER_NONNULL(1);
/**
* @brief Start context.
*
* @param [in] context_id Identifier for context to be activated
* @return ::rocprofiler_status_t
*/
rocprofiler_status_t
rocprofiler_start_context(rocprofiler_context_id_t context_id) ROCPROFILER_API;
/**
* @brief Stop context.
*
* @param [in] context_id Identifier for context to be deactivated
* @return ::rocprofiler_status_t
*/
rocprofiler_status_t
rocprofiler_stop_context(rocprofiler_context_id_t context_id) ROCPROFILER_API;
/**
* @brief Query whether context is currently active.
*
* @param [in] context_id Context identifier for the query
* @param [out] status If context is active, this will be a nonzero value
* @return ::rocprofiler_status_t
* @retval ::ROCPROFILER_STATUS_SUCCESS The input context id identified a registered context
* @retval ::ROCPROFILER_STATUS_ERROR_CONTEXT_NOT_FOUND The input context id did not identify a
* registered context
*/
rocprofiler_status_t
rocprofiler_context_is_active(rocprofiler_context_id_t context_id, int* status) ROCPROFILER_API
ROCPROFILER_NONNULL(2);
/**
* @brief Query whether the context is valid
*
* @param [in] context_id Context identifier for the query
* @param [out] status If context is invalid, this will be a nonzero value
* @return ::rocprofiler_status_t
*/
rocprofiler_status_t
rocprofiler_context_is_valid(rocprofiler_context_id_t context_id, int* status) ROCPROFILER_API
ROCPROFILER_NONNULL(2);
/** @} */
ROCPROFILER_EXTERN_C_FINI
+82
ファイルの表示
@@ -0,0 +1,82 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/agent.h>
#include <rocprofiler-sdk/defines.h>
#include <rocprofiler-sdk/fwd.h>
ROCPROFILER_EXTERN_C_INIT
/**
* @defgroup COUNTER_CONFIG HW Counter Configurations
* @brief Group one or more hardware counters into a unique handle
*
* @{
*/
/**
* @brief (experimental) Create Counter Configuration. A config is bound to an agent but can
* be used across many contexts. The config has a fixed set of counters
* that are collected (and specified by counter_list). The available
* counters for an agent can be queried using
* ::rocprofiler_iterate_agent_supported_counters. An existing config
* may be supplied via config_id to use as a base for the new config.
* All counters in the existing config will be copied over to the new
* config. The existing config will remain unmodified and usable with
* the new config id being returned in config_id.
*
* @param [in] agent_id Agent identifier
* @param [in] counters_list List of GPU counters
* @param [in] counters_count Size of counters list
* @param [in,out] config_id Identifier for GPU counters group. If an existing
config is supplied, that profiles counters will be copied
over to a new config (returned via this id)
* @return ::rocprofiler_status_t
* @retval ROCPROFILER_STATUS_SUCCESS if config created
* @retval ROCPROFILER_STATUS_ERROR if config could not be created
*
*/
ROCPROFILER_SDK_EXPERIMENTAL
rocprofiler_status_t
rocprofiler_create_counter_config(rocprofiler_agent_id_t agent_id,
rocprofiler_counter_id_t* counters_list,
size_t counters_count,
rocprofiler_counter_config_id_t* config_id) ROCPROFILER_API
ROCPROFILER_NONNULL(4);
/**
* @brief (experimental) Destroy Profile Configuration.
*
* @param [in] config_id
* @return ::rocprofiler_status_t
* @retval ROCPROFILER_STATUS_SUCCESS if config destroyed
* @retval ROCPROFILER_STATUS_ERROR if config could not be destroyed
*/
ROCPROFILER_SDK_EXPERIMENTAL
rocprofiler_status_t
rocprofiler_destroy_counter_config(rocprofiler_counter_config_id_t config_id) ROCPROFILER_API;
/** @} */
ROCPROFILER_EXTERN_C_FINI
+257
ファイルの表示
@@ -0,0 +1,257 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/agent.h>
#include <rocprofiler-sdk/defines.h>
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/deprecated/counters.h>
ROCPROFILER_EXTERN_C_INIT
/**
* @defgroup COUNTERS Hardware counters Information
* @brief Query functions related to hardware counters
* @{
*/
/**
* @brief (experimental) Counter info struct version 0
*/
typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_counter_info_v0_t
{
rocprofiler_counter_id_t id; ///< Id of this counter
const char* name; ///< Name of the counter
const char* description; ///< Description of the counter
const char* block; ///< Block of the counter (non-derived only)
const char* expression; ///< Counter expression (derived counters only)
uint8_t is_constant : 1; ///< If this counter is HW constant
uint8_t is_derived : 1; ///< If this counter is a derived counter
} rocprofiler_counter_info_v0_t;
/**
* @brief (experimental) Represents metadata about a single dimension of a counter instance.
*
* This structure provides the name of the dimension (e.g., "XCC", "SE", etc.)
* and the index indicating the position of a specific counter instance within that dimension.
*/
typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_counter_dimension_info_t
{
uint64_t size; ///< Size of this structure. Used for versioning and validation.
const char* dimension_name;
size_t index;
/**
* @var dimension_name
* @brief Name of the dimension this instance belongs to.
* @var index
* @brief Position (zero-based) of the instance within the specified dimension.
*/
} rocprofiler_counter_dimension_info_t;
/**
* @brief (experimental) Describes a specific counter instance and its position across multiple
* dimensions.
*
* This structure provides the unique instance ID, associated counter ID, number of dimensions for
* the instance, and a pointer to an array of metadata describing each dimension's name and index.
*/
typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_counter_record_dimension_instance_info_t
{
uint64_t size; ///< Size of this structure. Used for versioning and validation.
rocprofiler_counter_instance_id_t instance_id;
uint64_t counter_id;
uint64_t dimensions_count;
const rocprofiler_counter_dimension_info_t** dimensions;
/**
* @var instance_id
* @brief Encoded identifier for the instance, which includes the counter ID and all dimension
positions.
* @var counter_id
* @brief Identifier of the counter associated with this instance.
* @var dimensions_count
* @brief Number of dimensions associated with this instance.
* @var dimensions
* @brief Array of pointers to dimension info structures, each representing one dimension
* and the position of this instance within that dimension.
*
* The array has `dimensions_count` elements, and each element is a pointer to a
* `rocprofiler_counter_dimension_info_t` structure.
*/
} rocprofiler_counter_record_dimension_instance_info_t;
/**
* @brief (experimental) Counter info struct version 1. Combines information from
* ::rocprofiler_counter_info_v0_t with the dimension information.
*/
typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_counter_info_v1_t
{
uint64_t size; ///< Size of this structure. Used for versioning and validation.
rocprofiler_counter_id_t id; ///< Id of this counter
const char* name; ///< Name of the counter
const char* description; ///< Description of the counter
const char* block; ///< Block of the counter (non-derived only)
const char* expression; ///< Counter expression (derived counters only)
uint8_t is_constant : 1; ///< If this counter is HW constant
uint8_t is_derived : 1; ///< If this counter is a derived counter
uint64_t dimensions_count;
const rocprofiler_counter_record_dimension_info_t** dimensions;
uint64_t dimensions_instances_count;
const rocprofiler_counter_record_dimension_instance_info_t** dimensions_instances;
/// @var dimensions_count
/// @brief Number of dimensions for the counter
///
/// @var dimensions
/// @brief Dimension information of the counter
///
/// @var dimensions_instances_count
/// @brief Number of unique instances for this counter, across all dimension combinations.
///
/// @var dimensions_instances
/// @brief Array of pointers to instance info structs, each describing a unique instance
/// and its specific dimension mapping.
} rocprofiler_counter_info_v1_t;
/**
* @brief (experimental) Query counter id information from record_id.
*
* @param [in] id record id from rocprofiler_counter_record_t
* @param [out] counter_id counter id associated with the record
* @return ::rocprofiler_status_t
* @retval ROCPROFILER_STATUS_SUCCESS if id decoded
*/
ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_status_t
rocprofiler_query_record_counter_id(rocprofiler_counter_instance_id_t id,
rocprofiler_counter_id_t* counter_id) ROCPROFILER_API
ROCPROFILER_NONNULL(2);
/**
* @brief (experimental) Query dimension position from record_id. If the dimension does not exist
* in the counter, the return will be 0.
*
* @param [in] id record id from ::rocprofiler_counter_record_t
* @param [in] dim dimension for which positional info is requested (currently only
* 0 is allowed, i.e. flat array without dimension).
* @param [out] pos value of the dimension in id
* @return ::rocprofiler_status_t
* @retval ROCPROFILER_STATUS_SUCCESS if dimension decoded
*/
ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_status_t
rocprofiler_query_record_dimension_position(rocprofiler_counter_instance_id_t id,
rocprofiler_counter_dimension_id_t dim,
size_t* pos) ROCPROFILER_API ROCPROFILER_NONNULL(3);
/**
* @brief (experimental) Query Counter info such as name or description.
*
* @param [in] counter_id counter to get info for
* @param [in] version Version of struct in info, see ::rocprofiler_counter_info_version_id_t for
* available types
* @param [out] info rocprofiler_counter_info_{version}_t struct to write info to.
* @return ::rocprofiler_status_t
* @retval ROCPROFILER_STATUS_SUCCESS if counter found
* @retval ROCPROFILER_STATUS_ERROR_COUNTER_NOT_FOUND if counter not found
* @retval ROCPROFILER_STATUS_ERROR_INCOMPATIBLE_ABI Version is not supported
*/
ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_status_t
rocprofiler_query_counter_info(rocprofiler_counter_id_t counter_id,
rocprofiler_counter_info_version_id_t version,
void* info) ROCPROFILER_API ROCPROFILER_NONNULL(3);
/**
* @brief (experimental) Callback that gives a list of counters available on an agent. The
* counters variable is owned by rocprofiler and should not be free'd.
*
* @param [in] agent_id Agent ID of the current callback
* @param [in] counters An array of counters that are avialable on the agent
* ::rocprofiler_iterate_agent_supported_counters was called on.
* @param [in] num_counters Number of counters contained in counters
* @param [in] user_data User data supplied by
* ::rocprofiler_iterate_agent_supported_counters
*/
ROCPROFILER_SDK_EXPERIMENTAL typedef rocprofiler_status_t (*rocprofiler_available_counters_cb_t)(
rocprofiler_agent_id_t agent_id,
rocprofiler_counter_id_t* counters,
size_t num_counters,
void* user_data);
/**
* @brief (experimental) Query Agent Counters Availability.
*
* @param [in] agent_id GPU agent identifier
* @param [in] cb callback to caller to get counters
* @param [in] user_data data to pass into the callback
* @return ::rocprofiler_status_t
* @retval ROCPROFILER_STATUS_SUCCESS if counters found for agent
* @retval ROCPROFILER_STATUS_ERROR if no counters found for agent
*/
ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_status_t
rocprofiler_iterate_agent_supported_counters(rocprofiler_agent_id_t agent_id,
rocprofiler_available_counters_cb_t cb,
void* user_data) ROCPROFILER_API
ROCPROFILER_NONNULL(2);
/**
* @brief (experimental) Creates a new counter based on a derived metric provided. The counter will
* only be available for counter collection profiles created after the addition of this counter. Due
* to the regeneration of internal ASTs and dimension cache, this call may be slow and should
* generally be avoided in performance sensitive code blocks (i.e. dispatch callbacks).
*
* @param [in] name The name of the new counter.
* @param [in] name_len The length of the counter name.
* @param [in] expr The counter expression, formatted identically to YAML counter definitions.
* @param [in] expr_len The length of the expression.
* @param [in] agent The rocprofiler_agent_id_t specifying the agent for which to create the
* counter.
* @param [in] description The description of the new counter (optional).
* @param [in] description_len The length of the description.
* @param [out] counter_id The rocprofiler_counter_id_t of the created counter.
* @return ::rocprofiler_status_t
* @retval ROCPROFILER_STATUS_SUCCESS if the counter was successfully created.
* @retval ROCPROFILER_STATUS_ERROR_AST_GENERATION_FAILED if the counter could not be created.
* @retval ROCPROFILER_STATUS_ERROR_INVALID_ARGUMENT if a counter argument is incorrect
* @retval ROCPROFILER_STATUS_ERROR_AGENT_NOT_FOUND if the agent is not found
*/
ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_status_t
rocprofiler_create_counter(const char* name,
size_t name_len,
const char* expr,
size_t expr_len,
const char* description,
size_t description_len,
rocprofiler_agent_id_t agent,
rocprofiler_counter_id_t* counter_id) ROCPROFILER_NONNULL(1, 3, 8);
/** @} */
ROCPROFILER_EXTERN_C_FINI
+17
ファイルの表示
@@ -0,0 +1,17 @@
#
#
# Installation of public C++ headers
#
#
set(ROCPROFILER_CXX_HEADER_FILES enum_string.hpp hash.hpp name_info.hpp operators.hpp
perfetto.hpp utility.hpp serialization.hpp version.hpp)
install(
FILES ${ROCPROFILER_CXX_HEADER_FILES}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocprofiler-sdk/cxx
COMPONENT development)
add_subdirectory(codeobj)
add_subdirectory(details)
add_subdirectory(serialization)
add_subdirectory(container)
+6
ファイルの表示
@@ -0,0 +1,6 @@
set(ROCPROFILER_CXX_CODEOBJ_HEADERS code_printing.hpp disassembly.hpp segment.hpp)
install(
FILES ${ROCPROFILER_CXX_CODEOBJ_HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocprofiler-sdk/cxx/codeobj
COMPONENT development)
+693
ファイルの表示
@@ -0,0 +1,693 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include "disassembly.hpp"
#include "segment.hpp"
#include <dwarf.h>
#include <elfutils/libdw.h>
#include <hsa/amd_hsa_elf.h>
#include <algorithm>
#include <cstring>
#include <fstream>
#include <iostream>
#include <map>
#include <memory>
#include <optional>
#include <string>
#include <unordered_map>
#include <vector>
namespace rocprofiler
{
namespace sdk
{
namespace codeobj
{
namespace disassembly
{
using marker_id_t = segment::marker_id_t;
struct Instruction
{
Instruction() = default;
Instruction(std::string&& _inst, size_t _size)
: inst(std::move(_inst))
, size(_size)
{}
std::string inst{};
std::string comment{};
uint64_t faddr{0};
uint64_t vaddr{0};
size_t size{0};
uint64_t ld_addr{0}; // Instruction load address, if from loaded codeobj
marker_id_t codeobj_id{0}; // Instruction code object load id, if from loaded codeobj
static constexpr std::string_view separator = " -> ";
};
class CodeobjDecoderComponent
{
struct ProtectedFd
{
ProtectedFd(std::string_view uri)
{
#if defined(_GNU_SOURCE) && defined(MFD_ALLOW_SEALING) && defined(MFD_CLOEXEC)
m_fd = ::memfd_create(uri.data(), MFD_ALLOW_SEALING | MFD_CLOEXEC);
#endif
if(m_fd == -1) m_fd = ::open("/tmp", O_TMPFILE | O_RDWR, 0666);
if(m_fd == -1) throw std::runtime_error("Could not create a file for codeobj!");
}
~ProtectedFd()
{
if(m_fd != -1) ::close(m_fd);
}
int m_fd{-1};
};
public:
CodeobjDecoderComponent(const char* codeobj_data, uint64_t codeobj_size)
{
ProtectedFd prot("");
if(::write(prot.m_fd, codeobj_data, codeobj_size) != static_cast<int64_t>(codeobj_size))
throw std::runtime_error("Could not write to temporary file!");
::lseek(prot.m_fd, 0, SEEK_SET);
fsync(prot.m_fd);
m_line_number_map = {};
std::unique_ptr<Dwarf, void (*)(Dwarf*)> dbg(dwarf_begin(prot.m_fd, DWARF_C_READ),
[](Dwarf* _dbg) { dwarf_end(_dbg); });
if(dbg)
{
Dwarf_Off cu_offset{0}, next_offset;
size_t header_size;
std::map<uint64_t, std::string> line_addrs;
while(
dwarf_nextcu(
dbg.get(), cu_offset, &next_offset, &header_size, nullptr, nullptr, nullptr) ==
0)
{
Dwarf_Die die;
if(!dwarf_offdie(dbg.get(), cu_offset + header_size, &die))
{
cu_offset = next_offset;
continue;
}
Dwarf_Lines* lines;
size_t line_count;
if(dwarf_getsrclines(&die, &lines, &line_count) != 0)
{
cu_offset = next_offset;
continue;
}
for(size_t i = 0; i < line_count; ++i)
{
Dwarf_Addr addr;
int line_number;
Dwarf_Line* line = dwarf_onesrcline(lines, i);
if(line && dwarf_lineaddr(line, &addr) == 0 &&
dwarf_lineno(line, &line_number) == 0 && line_number != 0)
{
std::string src = dwarf_linesrc(line, nullptr, nullptr);
auto dwarf_line = src + ':' + std::to_string(line_number);
auto call_stack_info = extractInlinedCallStackInfo(dbg.get(), addr);
size_t capacity = dwarf_line.size() +
Instruction::separator.size() * call_stack_info.size();
for(const auto& call : call_stack_info)
capacity += call.size();
dwarf_line.reserve(capacity);
for(const auto& call : call_stack_info)
{
dwarf_line += Instruction::separator;
dwarf_line += call;
}
line_addrs[addr] = std::move(dwarf_line);
}
}
cu_offset = next_offset;
}
auto it = line_addrs.begin();
if(it != line_addrs.end())
{
while(std::next(it) != line_addrs.end())
{
uint64_t delta = std::next(it)->first - it->first;
auto segment = segment::address_range_t{it->first, delta, 0};
m_line_number_map.emplace(segment, std::move(it->second));
it++;
}
auto segment = segment::address_range_t{it->first, codeobj_size - it->first, 0};
m_line_number_map.emplace(segment, std::move(it->second));
}
}
// Can throw
disassembly = std::make_unique<DisassemblyInstance>(codeobj_data, codeobj_size);
try
{
m_symbol_map = disassembly->GetKernelMap(); // Can throw
} catch(...)
{}
}
~CodeobjDecoderComponent() = default;
std::optional<uint64_t> va2fo(uint64_t vaddr) const
{
if(disassembly) return disassembly->va2fo(vaddr);
return std::nullopt;
};
std::unique_ptr<Instruction> disassemble_instruction(uint64_t faddr, uint64_t vaddr)
{
if(!disassembly) throw std::exception();
auto pair = disassembly->ReadInstruction(faddr);
auto inst = std::make_unique<Instruction>(std::move(pair.first), pair.second);
inst->faddr = faddr;
inst->vaddr = vaddr;
auto it = m_line_number_map.find({vaddr, 0, 0});
if(it != m_line_number_map.end()) inst->comment = it->second;
return inst;
}
std::map<uint64_t, SymbolInfo> m_symbol_map{};
std::vector<std::shared_ptr<Instruction>> instructions{};
std::unique_ptr<DisassemblyInstance> disassembly{};
std::map<segment::address_range_t, std::string> m_line_number_map{};
private:
/**
* @brief Extracts inlined function call stack information for a given address
*
* This function searches through DWARF debug information to find all inlined functions
* that contain the specified address, building a complete call stack from the outermost
* function down to the innermost inlined function.
*
* @param dbg DWARF debug information handle
* @param addr The address to analyze for inlined function information
* @return Vector of strings representing the call stack, formatted as "filename:line"
* The stack is ordered from caller to callee (outermost to innermost)
*/
static std::vector<std::string> extractInlinedCallStackInfo(Dwarf* dbg, Dwarf_Addr addr);
/**
* @brief Checks if a DWARF Debug Information Entry (DIE) contains a specific address
*
* This function recursively searches through a DIE and its children to determine
* if any of them contain the specified address within their address ranges.
* Used as an optimization to quickly determine if a compilation unit or function
* contains the target address before doing expensive traversal.
*
* @param die Pointer to the DWARF DIE to check
* @param addr The address to search for
* @return true if the DIE or any of its children contain the address, false otherwise
*/
static bool checkDIEContainsAddress(Dwarf_Die* die, Dwarf_Addr addr);
/**
* @brief Recursively traverses all DWARF DIEs to find inlined functions at a specific address
*
* This function performs a depth-first traversal of the DWARF debug information tree,
* checking each DIE for inlined function information that covers the specified address.
* It processes both the current DIE and all its children (including siblings at each level)
* to ensure comprehensive coverage of all possible inlined function contexts.
*
* The traversal is necessary because inlined functions can be nested (function A inlines
* function B which inlines function C) and multiple inlined functions can exist at the
* same scope level as siblings in the DWARF tree.
*
* @param die Pointer to the current DWARF DIE to examine
* @param addr The address to search for inlined function information
* @param call_stack Reference to vector that accumulates the call stack information
*/
static void traverseAllDIEs(Dwarf_Die* die,
Dwarf_Addr addr,
std::vector<std::string>& call_stack);
/**
* @brief Examines a specific DWARF DIE for inlined function information at an address
*
* This function checks if a given DIE represents an inlined subroutine that contains
* the specified address. If it does, it extracts the call site information (filename
* and line number where the function was inlined) and adds it to the call stack.
*
* The function specifically looks for DW_TAG_inlined_subroutine DIEs and validates
* that the address falls within the DIE's address range (either contiguous via
* low_pc/high_pc or non-contiguous via ranges attribute). It then extracts the
* call site information using DW_AT_call_file and DW_AT_call_line attributes.
*
* @param die Pointer to the DWARF DIE to examine
* @param addr The address to check against the DIE's address ranges
* @param call_stack Reference to vector where call site info will be added
*
* @note Only processes DW_TAG_inlined_subroutine DIEs. Regular functions
* (DW_TAG_subprogram) are ignored since this function specifically
* extracts inlined function call information.
*/
static void checkDIEForInlinedFunction(Dwarf_Die* die,
Dwarf_Addr addr,
std::vector<std::string>& call_stack);
};
class LoadedCodeobjDecoder
{
public:
LoadedCodeobjDecoder(const char* filepath, uint64_t _load_addr, uint64_t _memsize)
: load_addr(_load_addr)
, load_end(_load_addr + _memsize)
{
if(!filepath) throw std::runtime_error("Empty filepath.");
std::string_view fpath(filepath);
if(fpath.rfind(".out") + 4 == fpath.size())
{
std::ifstream file(filepath, std::ios::in | std::ios::binary);
if(!file.is_open()) throw std::runtime_error("Invalid file " + std::string(filepath));
std::vector<char> buffer;
file.seekg(0, file.end);
buffer.resize(file.tellg());
file.seekg(0, file.beg);
file.read(buffer.data(), buffer.size());
decoder = std::make_unique<CodeobjDecoderComponent>(buffer.data(), buffer.size());
}
else
{
std::unique_ptr<CodeObjectBinary> binary = std::make_unique<CodeObjectBinary>(filepath);
auto& buffer = binary->buffer;
decoder = std::make_unique<CodeobjDecoderComponent>(buffer.data(), buffer.size());
}
}
LoadedCodeobjDecoder(const void* data, uint64_t size, uint64_t _load_addr, size_t _memsize)
: load_addr(_load_addr)
, load_end(load_addr + _memsize)
{
decoder = std::make_unique<CodeobjDecoderComponent>(static_cast<const char*>(data), size);
}
std::unique_ptr<Instruction> get(uint64_t ld_addr)
{
if(!decoder || ld_addr < load_addr) return nullptr;
uint64_t voffset = ld_addr - load_addr;
auto faddr = decoder->va2fo(voffset);
if(!faddr) return nullptr;
auto unique = decoder->disassemble_instruction(*faddr, voffset);
if(unique == nullptr || unique->size == 0) return nullptr;
unique->ld_addr = ld_addr;
return unique;
}
uint64_t begin() const { return load_addr; };
uint64_t end() const { return load_end; }
uint64_t size() const { return load_end - load_addr; }
bool inrange(uint64_t addr) const { return addr >= begin() && addr < end(); }
const char* getSymbolName(uint64_t addr) const
{
if(!decoder) return nullptr;
auto it = decoder->m_symbol_map.find(addr - load_addr);
if(it != decoder->m_symbol_map.end()) return it->second.name.data();
return nullptr;
}
std::map<uint64_t, SymbolInfo>& getSymbolMap() const
{
if(!decoder) throw std::exception();
return decoder->m_symbol_map;
}
const uint64_t load_addr;
private:
uint64_t load_end{0};
std::unique_ptr<CodeobjDecoderComponent> decoder{nullptr};
};
/**
* @brief Maps ID and offsets into instructions
*/
class CodeobjMap
{
public:
CodeobjMap() = default;
virtual ~CodeobjMap() = default;
virtual void addDecoder(const char* filepath,
marker_id_t id,
uint64_t load_addr,
uint64_t memsize)
{
decoders[id] = std::make_shared<LoadedCodeobjDecoder>(filepath, load_addr, memsize);
}
virtual void addDecoder(const void* data,
size_t memory_size,
marker_id_t id,
uint64_t load_addr,
uint64_t memsize)
{
decoders[id] =
std::make_shared<LoadedCodeobjDecoder>(data, memory_size, load_addr, memsize);
}
virtual bool removeDecoderbyId(marker_id_t id) { return decoders.erase(id) != 0; }
std::unique_ptr<Instruction> get(marker_id_t id, uint64_t offset)
{
try
{
auto& decoder = decoders.at(id);
auto inst = decoder->get(decoder->begin() + offset);
if(inst != nullptr) inst->codeobj_id = id;
return inst;
} catch(std::out_of_range&)
{}
return nullptr;
}
const char* getSymbolName(marker_id_t id, uint64_t offset)
{
try
{
auto& decoder = decoders.at(id);
uint64_t vaddr = decoder->begin() + offset;
if(decoder->inrange(vaddr)) return decoder->getSymbolName(vaddr);
} catch(std::out_of_range&)
{}
return nullptr;
}
protected:
std::unordered_map<marker_id_t, std::shared_ptr<LoadedCodeobjDecoder>> decoders{};
};
/**
* @brief Translates virtual addresses to elf file offsets
*/
class CodeobjAddressTranslate : public CodeobjMap
{
using Super = CodeobjMap;
public:
CodeobjAddressTranslate() = default;
~CodeobjAddressTranslate() override = default;
void addDecoder(const char* filepath,
marker_id_t id,
uint64_t load_addr,
uint64_t memsize) override
{
this->Super::addDecoder(filepath, id, load_addr, memsize);
auto ptr = decoders.at(id);
table.insert({ptr->begin(), ptr->size(), id});
}
void addDecoder(const void* data,
size_t memory_size,
marker_id_t id,
uint64_t load_addr,
uint64_t memsize) override
{
this->Super::addDecoder(data, memory_size, id, load_addr, memsize);
auto ptr = decoders.at(id);
table.insert({ptr->begin(), ptr->size(), id});
}
bool removeDecoder(marker_id_t id, uint64_t load_addr)
{
return table.remove(load_addr) && this->Super::removeDecoderbyId(id);
}
bool removeDecoder(marker_id_t id)
{
uint64_t addr = 0;
if(decoders.find(id) != decoders.end()) addr = decoders.at(id)->begin();
return removeDecoder(id, addr);
}
std::unique_ptr<Instruction> get(uint64_t vaddr)
{
auto addr_range = table.find_codeobj_in_range(vaddr);
return this->Super::get(addr_range.id, vaddr - addr_range.addr);
}
std::unique_ptr<Instruction> get(marker_id_t id, uint64_t offset)
{
if(id == 0)
return get(offset);
else
return this->Super::get(id, offset);
}
const char* getSymbolName(uint64_t vaddr)
{
for(auto& [_, decoder] : decoders)
{
if(!decoder->inrange(vaddr)) continue;
return decoder->getSymbolName(vaddr);
}
return nullptr;
}
std::map<uint64_t, SymbolInfo> getSymbolMap() const
{
std::map<uint64_t, SymbolInfo> symbols;
for(const auto& [_, dec] : decoders)
{
auto& smap = dec->getSymbolMap();
for(auto& [vaddr, sym] : smap)
symbols[vaddr + dec->load_addr] = sym;
}
return symbols;
}
std::map<uint64_t, SymbolInfo> getSymbolMap(marker_id_t id) const
{
if(decoders.find(id) == decoders.end()) return {};
try
{
return decoders.at(id)->getSymbolMap();
} catch(...)
{
return {};
}
}
private:
segment::CodeobjTableTranslator table{};
};
inline std::vector<std::string>
CodeobjDecoderComponent::extractInlinedCallStackInfo(Dwarf* dbg, Dwarf_Addr addr)
{
std::vector<std::string> call_stack{};
// Iterate through all compilation units to find the one containing our address
Dwarf_Off cu_offset{};
Dwarf_Off next_offset{};
size_t header_size{};
while(dwarf_nextcu(dbg, cu_offset, &next_offset, &header_size, nullptr, nullptr, nullptr) == 0)
{
Dwarf_Die cu_die{};
if(!dwarf_offdie(dbg, cu_offset + header_size, &cu_die))
{
cu_offset = next_offset;
continue;
}
bool cu_contains_addr = false;
// Try to get low_pc and high_pc from CU
// If no simple range, check if any child DIE contains this address
Dwarf_Addr low_pc{};
Dwarf_Addr high_pc{};
if(dwarf_lowpc(&cu_die, &low_pc) == 0 && dwarf_highpc(&cu_die, &high_pc) == 0)
cu_contains_addr = (addr >= low_pc && addr < high_pc);
else
cu_contains_addr = checkDIEContainsAddress(&cu_die, addr);
if(cu_contains_addr)
{
traverseAllDIEs(&cu_die, addr, call_stack);
break;
}
cu_offset = next_offset;
}
// Reverse the call stack to show from caller to callee
std::reverse(call_stack.begin(), call_stack.end());
return call_stack;
}
inline bool
CodeobjDecoderComponent::checkDIEContainsAddress(Dwarf_Die* die, Dwarf_Addr addr)
{
if(die == nullptr) return false;
// Check current DIE's address range
Dwarf_Addr low_pc{};
Dwarf_Addr high_pc{};
if(dwarf_lowpc(die, &low_pc) == 0 && dwarf_highpc(die, &high_pc) == 0)
{
if(addr >= low_pc && addr < high_pc) return true;
}
else
{
// Check ranges attribute for non-contiguous ranges
Dwarf_Addr base{};
ptrdiff_t offset = 0;
while((offset = dwarf_ranges(die, offset, &base, &low_pc, &high_pc)) > 0)
if(addr >= low_pc && addr < high_pc) return true;
}
// Check children recursively
Dwarf_Die child{};
if(dwarf_child(die, &child) == 0)
if(checkDIEContainsAddress(&child, addr)) return true;
return false;
}
inline void
CodeobjDecoderComponent::traverseAllDIEs(Dwarf_Die* die,
Dwarf_Addr addr,
std::vector<std::string>& call_stack)
{
if(die == nullptr) return;
// Check current DIE for inlined function information
checkDIEForInlinedFunction(die, addr, call_stack);
// Traverse children recursively (depth-first)
Dwarf_Die child{};
if(dwarf_child(die, &child) == 0)
{
// Check all children AND their siblings at this level
// This is crucial because inlined functions can appear as siblings
// when multiple functions are inlined at the same scope level
do
{
traverseAllDIEs(&child, addr, call_stack);
} while(dwarf_siblingof(&child, &child) == 0);
}
}
inline void
CodeobjDecoderComponent::checkDIEForInlinedFunction(Dwarf_Die* die,
Dwarf_Addr addr,
std::vector<std::string>& call_stack)
{
// Only process inlined subroutines - these are functions that were
// expanded inline at compile time and have call site information
if(die == nullptr || dwarf_tag(die) != DW_TAG_inlined_subroutine) return;
Dwarf_Addr low_pc{};
Dwarf_Addr high_pc{};
bool has_range{false};
// Check if this inlined subroutine covers the target address
// First try simple contiguous range (low_pc to high_pc)
if(dwarf_lowpc(die, &low_pc) == 0 && dwarf_highpc(die, &high_pc) == 0)
{
// Simple contiguous range - check if address falls within
has_range = (addr >= low_pc && addr < high_pc);
}
else
{
// Function may have non-contiguous ranges (optimized code)
// Check all address ranges associated with this DIE
Dwarf_Addr base{};
ptrdiff_t offset{};
while((offset = dwarf_ranges(die, offset, &base, &low_pc, &high_pc)) > 0)
{
if(addr >= low_pc && addr < high_pc)
{
has_range = true;
break;
}
}
}
// If address doesn't fall within this inlined function, skip it
if(!has_range) return;
// Extract call site information - where this function was inlined
Dwarf_Attribute call_file_attr{};
Dwarf_Attribute call_line_attr{};
Dwarf_Word call_file{};
Dwarf_Word call_line{};
// Get the file and line number where this function was called/inlined
if(!dwarf_attr(die, DW_AT_call_file, &call_file_attr) ||
!dwarf_attr(die, DW_AT_call_line, &call_line_attr) ||
dwarf_formudata(&call_file_attr, &call_file) != 0 ||
dwarf_formudata(&call_line_attr, &call_line) != 0)
return; // No call site information available
// Get the compilation unit to resolve file names
Dwarf_Die cu_die{};
if(!dwarf_diecu(die, &cu_die, nullptr, nullptr)) return;
// Get the source files table for this compilation unit
Dwarf_Files* files{};
size_t nfiles{};
if(dwarf_getsrcfiles(&cu_die, &files, &nfiles) == 0 && call_file < nfiles)
if(const char* filename = dwarf_filesrc(files, call_file, nullptr, nullptr))
// Add "filename:line" to call stack showing where this function was inlined
call_stack.push_back(std::string(filename) + ":" + std::to_string(call_line));
}
} // namespace disassembly
} // namespace codeobj
} // namespace sdk
} // namespace rocprofiler
+308
ファイルの表示
@@ -0,0 +1,308 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <amd_comgr/amd_comgr.h>
#include <hsa/amd_hsa_elf.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <algorithm>
#include <cstring>
#include <fstream>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <optional>
#include <string>
#include <unordered_map>
#include <vector>
#define THROW_COMGR(call) \
if(amd_comgr_status_s status = call) \
{ \
const char* reason = ""; \
amd_comgr_status_string(status, &reason); \
std::cerr << __FILE__ << ':' << __LINE__ << " code: " << status << " failed: " << reason \
<< "\n"; \
throw std::exception(); \
}
#define RETURN_COMGR(call) \
if(amd_comgr_status_s status = call) \
{ \
const char* reason = ""; \
amd_comgr_status_string(status, &reason); \
std::cerr << __FILE__ << ':' << __LINE__ << " code: " << status << " failed: " << reason \
<< "\n"; \
return AMD_COMGR_STATUS_ERROR; \
}
namespace rocprofiler
{
namespace sdk
{
namespace codeobj
{
namespace disassembly
{
class CodeObjectBinary
{
public:
CodeObjectBinary(std::string _uri)
: m_uri(std::move(_uri))
{
const std::string protocol_delim{"://"};
size_t protocol_end = m_uri.find(protocol_delim);
std::string protocol = m_uri.substr(0, protocol_end);
protocol_end += protocol_delim.length();
std::transform(protocol.begin(), protocol.end(), protocol.begin(), [](unsigned char c) {
return std::tolower(c);
});
std::string path;
size_t path_end = m_uri.find_first_of("#?", protocol_end);
if(path_end != std::string::npos)
{
path = m_uri.substr(protocol_end, path_end++ - protocol_end);
}
else
{
path = m_uri.substr(protocol_end);
}
/* %-decode the string. */
std::string decoded_path;
decoded_path.reserve(path.length());
for(size_t i = 0; i < path.length(); ++i)
{
if(path[i] == '%' && std::isxdigit(path[i + 1]) != 0 && std::isxdigit(path[i + 2]) != 0)
{
decoded_path += std::stoi(path.substr(i + 1, 2), nullptr, 16);
i += 2;
}
else
{
decoded_path += path[i];
}
}
/* Tokenize the query/fragment. */
std::vector<std::string> tokens;
size_t pos, last = path_end;
while((pos = m_uri.find('&', last)) != std::string::npos)
{
tokens.emplace_back(m_uri.substr(last, pos - last));
last = pos + 1;
}
if(last != std::string::npos)
{
tokens.emplace_back(m_uri.substr(last));
}
/* Create a tag-value map from the tokenized query/fragment. */
std::unordered_map<std::string, std::string> params;
std::for_each(tokens.begin(), tokens.end(), [&](std::string& token) {
size_t delim = token.find('=');
if(delim != std::string::npos)
{
params.emplace(token.substr(0, delim), token.substr(delim + 1));
}
});
buffer = std::vector<char>{};
size_t offset = 0;
size_t size = 0;
if(auto offset_it = params.find("offset"); offset_it != params.end())
{
offset = std::stoul(offset_it->second, nullptr, 0);
}
if(auto size_it = params.find("size"); size_it != params.end())
{
if((size = std::stoul(size_it->second, nullptr, 0)) == 0) return;
}
if(protocol == "memory") throw std::runtime_error(protocol + " protocol not supported!");
std::ifstream file(decoded_path, std::ios::in | std::ios::binary);
if(!file || !file.is_open()) throw std::runtime_error("could not open " + decoded_path);
if(size == 0)
{
file.ignore(std::numeric_limits<std::streamsize>::max());
size_t bytes = file.gcount();
file.clear();
if(bytes < offset) throw std::runtime_error("invalid uri " + decoded_path);
size = bytes - offset;
}
file.seekg(offset, std::ios_base::beg);
buffer.resize(size);
file.read(buffer.data(), size);
}
std::string m_uri;
std::vector<char> buffer;
};
struct SymbolInfo
{
std::string name{};
uint64_t faddr = 0;
uint64_t vaddr = 0;
uint64_t mem_size = 0;
};
class DisassemblyInstance
{
public:
DisassemblyInstance(const char* codeobj_data, uint64_t codeobj_size)
{
buffer = std::vector<char>(codeobj_size, 0);
std::memcpy(buffer.data(), codeobj_data, codeobj_size);
THROW_COMGR(amd_comgr_create_data(AMD_COMGR_DATA_KIND_EXECUTABLE, &data));
THROW_COMGR(amd_comgr_set_data(data, buffer.size(), buffer.data()));
size_t isa_size = 128;
std::string input_isa{};
input_isa.resize(isa_size);
THROW_COMGR(amd_comgr_get_data_isa_name(data, &isa_size, input_isa.data()));
THROW_COMGR(amd_comgr_create_disassembly_info(
input_isa.data(),
&DisassemblyInstance::memory_callback,
&DisassemblyInstance::inst_callback,
[](uint64_t, void*) {},
&info));
}
~DisassemblyInstance()
{
amd_comgr_release_data(data);
amd_comgr_destroy_disassembly_info(info);
}
std::pair<std::string, size_t> ReadInstruction(uint64_t faddr)
{
uint64_t size_read;
uint64_t addr_in_buffer = reinterpret_cast<uint64_t>(buffer.data()) + faddr;
THROW_COMGR(
amd_comgr_disassemble_instruction(info, addr_in_buffer, (void*) this, &size_read));
return {std::move(this->last_instruction), size_read};
}
std::map<uint64_t, SymbolInfo>& GetKernelMap()
{
symbol_map = {};
THROW_COMGR(amd_comgr_iterate_symbols(data, &DisassemblyInstance::symbol_callback, this));
return symbol_map;
}
static amd_comgr_status_t symbol_callback(amd_comgr_symbol_t symbol, void* user_data)
{
amd_comgr_symbol_type_t type;
RETURN_COMGR(amd_comgr_symbol_get_info(symbol, AMD_COMGR_SYMBOL_INFO_TYPE, &type));
if(type != AMD_COMGR_SYMBOL_TYPE_FUNC) return AMD_COMGR_STATUS_SUCCESS;
uint64_t vaddr = 0;
uint64_t mem_size = 0;
uint64_t name_size = 0;
RETURN_COMGR(amd_comgr_symbol_get_info(symbol, AMD_COMGR_SYMBOL_INFO_VALUE, &vaddr));
RETURN_COMGR(amd_comgr_symbol_get_info(symbol, AMD_COMGR_SYMBOL_INFO_SIZE, &mem_size));
RETURN_COMGR(
amd_comgr_symbol_get_info(symbol, AMD_COMGR_SYMBOL_INFO_NAME_LENGTH, &name_size));
std::string name;
name.resize(name_size);
RETURN_COMGR(amd_comgr_symbol_get_info(symbol, AMD_COMGR_SYMBOL_INFO_NAME, name.data()));
DisassemblyInstance& instance = *static_cast<DisassemblyInstance*>(user_data);
std::optional<uint64_t> faddr = instance.va2fo(vaddr);
if(faddr) instance.symbol_map[vaddr] = {name, *faddr, vaddr, mem_size};
return AMD_COMGR_STATUS_SUCCESS;
}
static uint64_t memory_callback(uint64_t from, char* to, uint64_t size, void* user_data)
{
DisassemblyInstance& instance = *static_cast<DisassemblyInstance*>(user_data);
int64_t copysize = reinterpret_cast<int64_t>(instance.buffer.data()) +
instance.buffer.size() - static_cast<int64_t>(from);
copysize = std::min<int64_t>(size, copysize);
// NOLINTNEXTLINE(performance-no-int-to-ptr)
std::memcpy(to, (char*) from, copysize);
return copysize;
}
static void inst_callback(const char* instruction, void* user_data)
{
DisassemblyInstance& instance = *static_cast<DisassemblyInstance*>(user_data);
if(!instruction) return;
while(*instruction == '\t' || *instruction == ' ')
instruction++;
instance.last_instruction = instruction;
}
std::optional<uint64_t> va2fo(uint64_t va) const
{
uint64_t offset = 0;
uint64_t slicesize = 0;
bool nobits = false;
auto status = amd_comgr_map_elf_virtual_address_to_code_object_offset(
data, va, &offset, &slicesize, &nobits);
if(status != AMD_COMGR_STATUS_SUCCESS || nobits)
return std::nullopt;
else
return offset;
}
std::vector<char> buffer{};
std::string last_instruction{};
amd_comgr_disassembly_info_t info{};
amd_comgr_data_t data{};
std::map<uint64_t, SymbolInfo> symbol_map{};
};
} // namespace disassembly
} // namespace codeobj
} // namespace sdk
} // namespace rocprofiler
+96
ファイルの表示
@@ -0,0 +1,96 @@
// MIT License
//
// Copyright (c) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <algorithm>
#include <iostream>
#include <random>
#include <set>
#include <string>
#include <unordered_set>
#include <vector>
namespace rocprofiler
{
namespace sdk
{
namespace codeobj
{
namespace segment
{
using marker_id_t = size_t;
struct address_range_t
{
uint64_t addr{0};
uint64_t size{0};
marker_id_t id{0};
bool operator==(const address_range_t& other) const
{
return (addr >= other.addr && addr < other.addr + other.size) ||
(other.addr >= addr && other.addr < addr + size);
}
bool operator<(const address_range_t& other) const
{
if(*this == other) return false;
return addr < other.addr;
}
bool inrange(uint64_t _addr) const { return addr <= _addr && addr + size > _addr; };
};
/**
* @brief Finds a candidate codeobj for the given vaddr
*/
class CodeobjTableTranslator : public std::set<address_range_t>
{
using Super = std::set<address_range_t>;
public:
address_range_t find_codeobj_in_range(uint64_t addr)
{
if(!cached_segment.inrange(addr))
{
auto it = this->find(address_range_t{addr, 0, 0});
if(it == this->end()) throw std::exception();
cached_segment = *it;
}
return cached_segment;
}
void clear_cache() { cached_segment = {}; }
bool remove(const address_range_t& range)
{
clear_cache();
return this->erase(range) != 0;
}
bool remove(uint64_t addr) { return remove(address_range_t{addr, 0, 0}); }
private:
address_range_t cached_segment{};
};
} // namespace segment
} // namespace codeobj
} // namespace sdk
} // namespace rocprofiler
@@ -0,0 +1,11 @@
#
#
# Installation of public C++ headers (implementations)
#
#
set(ROCPROFILER_CXX_CONTAINERS_HEADER_FILES c_array.hpp)
install(
FILES ${ROCPROFILER_CXX_CONTAINERS_HEADER_FILES}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocprofiler-sdk/cxx/container
COMPONENT development)
+136
ファイルの表示
@@ -0,0 +1,136 @@
// MIT License
//
// Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
//
#pragma once
#include <cstddef>
#include <cstdint>
#include <stdexcept>
#include <string>
namespace rocprofiler
{
namespace sdk
{
namespace container
{
template <typename Tp>
struct c_array
{
// Construct an array wrapper from a base pointer and array size
c_array(Tp* _base, size_t _size)
: m_base{_base}
, m_size{_size}
{}
~c_array() = default;
c_array(const c_array&) = default;
c_array(c_array&&) noexcept = default;
c_array& operator=(const c_array&) = default;
c_array& operator=(c_array&&) noexcept = default;
// Get the size of the wrapped array
size_t size() const { return m_size; }
// Access an element by index
Tp& operator[](size_t i) { return m_base[i]; }
// Access an element by index
const Tp& operator[](size_t i) const { return m_base[i]; }
// Access an element by index with bounds check
Tp& at(size_t i)
{
if(i < m_size) return m_base[i];
throw std::out_of_range(std::string{typeid(*this).name()} + std::to_string(i) +
" exceeds size " + std::to_string(m_size));
}
// Access an element by index with bounds check
const Tp& at(size_t i) const
{
if(i < m_size) return m_base[i];
throw std::out_of_range(std::string{typeid(*this).name()} + std::to_string(i) +
" exceeds size " + std::to_string(m_size));
}
// Get a slice of this array, from a start index (inclusive) to end index (exclusive)
c_array<Tp> slice(size_t start, size_t end) { return c_array<Tp>(&m_base[start], end - start); }
void pop_front()
{
++m_base;
--m_size;
}
void pop_back() { --m_size; }
operator Tp*() const { return m_base; }
// Iterator class for convenient range-based for loop support
template <typename Up>
struct iterator
{
// Start the iterator at a given pointer
iterator(Tp* p)
: m_ptr{p}
{}
// Advance to the next element
void operator++() { ++m_ptr; }
void operator++(int) { m_ptr++; }
// Get the current element
Up& operator*() const { return *m_ptr; }
// Compare iterators
bool operator==(const iterator& rhs) const { return m_ptr == rhs.m_ptr; }
bool operator!=(const iterator& rhs) const { return m_ptr != rhs.m_ptr; }
private:
Tp* m_ptr = nullptr;
};
// Get an iterator positioned at the beginning of the wrapped array
iterator<Tp> begin() { return iterator<Tp>{m_base}; }
iterator<const Tp> begin() const { return iterator<const Tp>{m_base}; }
// Get an iterator positioned at the end of the wrapped array
iterator<Tp> end() { return iterator<Tp>{&m_base[m_size]}; }
iterator<const Tp> end() const { return iterator<const Tp>{&m_base[m_size]}; }
private:
Tp* m_base = nullptr;
size_t m_size = 0;
};
// Function for automatic template argument deduction
template <typename Tp>
c_array<Tp>
make_c_array(Tp* base, size_t size)
{
return c_array<Tp>(base, size);
}
} // namespace container
} // namespace sdk
} // namespace rocprofiler
+11
ファイルの表示
@@ -0,0 +1,11 @@
#
#
# Installation of public C++ headers (implementations)
#
#
set(ROCPROFILER_CXX_DETAILS_HEADER_FILES tokenize.hpp join.hpp mpl.hpp name_info.hpp)
install(
FILES ${ROCPROFILER_CXX_DETAILS_HEADER_FILES}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocprofiler-sdk/cxx/details
COMPONENT development)
+281
ファイルの表示
@@ -0,0 +1,281 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/cxx/details/mpl.hpp>
#include <array>
#include <cstring>
#include <initializer_list>
#include <ios>
#include <sstream>
#include <string>
#include <string_view>
#include <tuple>
#include <type_traits>
namespace rocprofiler
{
namespace sdk
{
namespace join
{
template <typename... ArgsT>
inline void
consume_args(ArgsT&&...)
{}
enum
{
NoQuoteStrings = 0x0,
QuoteStrings = 0x1
};
template <size_t Idx>
struct triplet_config
{
static constexpr auto index() { return Idx; }
std::string_view delimiter = {};
std::string_view prefix = {};
std::string_view suffix = {};
};
using generic_config = triplet_config<0>;
using array_config = triplet_config<1>;
using pair_config = triplet_config<2>;
struct config : generic_config
{
using format_flags_t = std::ios_base::fmtflags;
using base_type = generic_config;
config() = default;
~config() = default;
config(const config&) = default;
config(config&&) noexcept = default;
config& operator=(const config&) = default;
config& operator=(config&&) noexcept = default;
// converting constructor
config(std::string_view _delim)
: base_type{_delim}
{}
// converting constructor
config(const char* const _delim)
: base_type{_delim}
{}
config(generic_config _cfg)
: base_type{_cfg}
{}
config(array_config _cfg)
: array{_cfg}
{}
config(pair_config _cfg)
: pair{_cfg}
{}
config(generic_config _generic, array_config _array)
: base_type{_generic}
, array{_array}
{}
config(generic_config _generic, pair_config _pair)
: base_type{_generic}
, pair{_pair}
{}
config(array_config _array, pair_config _pair)
: array{_array}
, pair{_pair}
{}
format_flags_t flags = std::ios_base::boolalpha;
array_config array = {", ", "[", "]"};
pair_config pair = {", ", "{", "}"};
};
namespace impl
{
template <int TraitT, typename ArgT>
inline decltype(auto)
join_arg(config _cfg, ArgT&& _v)
{
using arg_type = mpl::basic_identity_t<ArgT>;
constexpr bool _is_string_type = mpl::is_string_type<arg_type>::value;
constexpr bool _is_iterable = mpl::is_iterable<arg_type>(0);
constexpr bool _has_traits_type = mpl::has_traits<arg_type>(0);
constexpr bool _has_key_type = mpl::has_key_type<arg_type>(0);
constexpr bool _has_value_type = mpl::has_value_type<arg_type>(0);
constexpr bool _has_mapped_type = mpl::has_mapped_type<arg_type>(0);
if constexpr(_is_string_type)
{
if constexpr(TraitT == QuoteStrings)
{
return std::string{"\""} + std::string{std::forward<ArgT>(_v)} + std::string{"\""};
}
else
{
return std::forward<ArgT>(_v);
}
}
else if constexpr(_is_iterable && !_has_traits_type &&
(_has_value_type || (_has_key_type && _has_mapped_type)))
{
if constexpr(_has_key_type && _has_mapped_type)
{
std::stringstream _ss{};
_ss.setf(_cfg.flags);
for(auto&& itr : std::forward<ArgT>(_v))
_ss << _cfg.array.delimiter << _cfg.pair.prefix << join_arg<TraitT>(_cfg, itr.first)
<< _cfg.pair.delimiter << join_arg<TraitT>(_cfg, itr.second)
<< _cfg.pair.suffix;
auto _ret = _ss.str();
auto&& _len = _cfg.array.delimiter.length();
return (_ret.length() > _len) ? (std::string{_cfg.array.prefix} + _ret.substr(_len) +
std::string{_cfg.array.suffix})
: std::string{};
}
else if constexpr(_has_value_type)
{
std::stringstream _ss{};
_ss.setf(_cfg.flags);
for(auto&& itr : std::forward<ArgT>(_v))
_ss << _cfg.array.delimiter << join_arg<TraitT>(_cfg, itr);
auto _ret = _ss.str();
auto&& _len = _cfg.array.delimiter.length();
return (_ret.length() > _len) ? (std::string{_cfg.array.prefix} + _ret.substr(_len) +
std::string{_cfg.array.suffix})
: std::string{};
}
}
else if constexpr(mpl::supports_ostream<ArgT>(0))
{
return std::forward<ArgT>(_v);
}
else
{
static_assert(_is_iterable, "Type is not iterable");
static_assert(!_has_traits_type, "Type has a traits type");
if constexpr(!_has_value_type)
{
static_assert(_has_key_type && _has_mapped_type,
"Type must have a key_type and mapped_type if there is no value_type");
}
else
{
static_assert(_has_value_type,
"Type must have a value_type if there is no key_type and mapped_type");
}
static_assert(std::is_empty<ArgT>::value,
"Error! argument type cannot be written to output stream");
}
// suppress any unused but set variable warnings
consume_args(_is_string_type,
_is_iterable,
_has_traits_type,
_has_key_type,
_has_value_type,
_has_mapped_type);
}
} // namespace impl
template <int TraitT = NoQuoteStrings, typename... Args>
auto
join(config _cfg, Args&&... _args)
{
static_assert(std::is_trivially_copyable<config>::value,
"Error! config is not trivially copyable");
std::stringstream _ss{};
_ss.setf(_cfg.flags);
((_ss << ((mpl::is_empty(_args)) ? std::string_view{} : std::string_view{_cfg.delimiter})
<< impl::join_arg<TraitT>(_cfg, _args)),
...);
auto _ret = _ss.str();
auto&& _len = _cfg.delimiter.length();
auto _cmp =
strncmp(std::string_view{_ret}.data(), std::string_view{_cfg.delimiter}.data(), _len) == 0;
return (_ret.length() > _len) ? (std::string{_cfg.prefix} +
((_cmp) ? _ret.substr(_len) : _ret) + std::string{_cfg.suffix})
: std::string{};
}
template <int TraitT = NoQuoteStrings, typename... Args>
auto
join(std::array<std::string_view, 3>&& _delims, Args&&... _args)
{
auto _cfg = config{};
_cfg.delimiter = _delims.at(0);
_cfg.prefix = _delims.at(1);
_cfg.suffix = _delims.at(2);
return join(_cfg, std::forward<Args>(_args)...);
}
template <int TraitT = NoQuoteStrings,
typename DelimT,
typename... Args,
std::enable_if_t<!mpl::is_basic_same<config, DelimT>::value, int> = 0>
auto
join(DelimT&& _delim, Args&&... _args)
{
using delim_type = mpl::basic_identity_t<DelimT>;
if constexpr(std::is_constructible<config, delim_type>::value)
{
auto _cfg = config{std::forward<DelimT>(_delim)};
return join<TraitT>(_cfg, std::forward<Args>(_args)...);
}
else if constexpr(std::is_same<delim_type, char>::value)
{
auto _cfg = config{};
const char _delim_c[2] = {_delim, '\0'};
_cfg.delimiter = _delim_c;
return join<TraitT>(_cfg, std::forward<Args>(_args)...);
}
else
{
auto _cfg = config{};
_cfg.delimiter = std::string_view{_delim};
return join<TraitT>(_cfg, std::forward<Args>(_args)...);
}
}
template <typename ArgT>
auto
quoted(ArgT&& _arg)
{
auto _cfg = config{};
_cfg.prefix = "\"";
_cfg.suffix = "\"";
return join(_cfg, std::forward<ArgT>(_arg));
}
} // namespace join
} // namespace sdk
} // namespace rocprofiler
+263
ファイルの表示
@@ -0,0 +1,263 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
//
#pragma once
#include <cstddef>
#include <cstdint>
#include <optional>
#include <string>
#include <string_view>
#include <type_traits>
#include <utility>
#define ROCPROFILER_IMPL_HAS_CONCEPT(NAME, TRAIT) \
template <typename Tp, typename = typename Tp::TRAIT> \
inline constexpr bool NAME(int) \
{ \
return true; \
} \
\
template <typename Tp> \
inline constexpr bool NAME(long) \
{ \
return false; \
}
#define ROCPROFILER_IMPL_SFINAE_CONCEPT(NAME, ...) \
template <typename Tp> \
struct NAME \
{ \
private: \
static constexpr auto sfinae(int) -> decltype(__VA_ARGS__, bool()) { return true; } \
\
static constexpr auto sfinae(long) { return false; } \
\
public: \
static constexpr bool value = sfinae(0); \
constexpr auto operator()() const { return sfinae(0); } \
};
namespace rocprofiler
{
namespace sdk
{
namespace mpl
{
template <typename Tp>
struct unqualified_identity
{
using type = std::remove_cv_t<std::remove_reference_t<std::decay_t<Tp>>>;
};
template <typename Tp>
using unqualified_identity_t = typename unqualified_identity<Tp>::type;
template <typename Tp, typename Up>
struct is_same_unqualified_identity
: std::is_same<unqualified_identity_t<Tp>, unqualified_identity_t<Up>>
{};
template <typename Tp>
struct string_support
{
using type = Tp;
using return_type = void;
static constexpr auto value = false;
static constexpr void default_value() {}
};
template <>
struct string_support<const char*>
{
using type = const char*;
using return_type = type;
static constexpr auto value = true;
static constexpr type default_value() { return nullptr; }
type operator()(const char* val) const { return val; }
};
template <>
struct string_support<std::string_view>
{
using type = std::string_view;
using return_type = type;
static constexpr auto value = true;
static constexpr type default_value() { return type{}; }
type operator()(const char* val) const { return type{val}; }
};
template <>
struct string_support<std::string>
{
using type = std::string;
using return_type = type;
static constexpr auto value = true;
static type default_value() { return type{}; }
type operator()(const char* val) const { return type{val}; }
};
namespace impl
{
template <typename Tp>
struct is_string_type : std::false_type
{};
template <>
struct is_string_type<std::string> : std::true_type
{};
template <>
struct is_string_type<char*> : std::true_type
{};
template <>
struct is_string_type<const char*> : std::true_type
{};
template <>
struct is_string_type<std::string_view> : std::true_type
{};
} // namespace impl
template <typename Tp>
struct is_string_type : impl::is_string_type<unqualified_identity_t<Tp>>
{};
// template <typename Tp>
// struct can_stringify
// {
// private:
// static constexpr auto sfinae(int)
// -> decltype(std::declval<std::ostream&>() << std::declval<Tp>(), bool())
// {
// return true;
// }
// static constexpr auto sfinae(long) { return false; }
// public:
// static constexpr bool value = sfinae(0);
// constexpr auto operator()() const { return sfinae(0); }
// };
ROCPROFILER_IMPL_HAS_CONCEPT(has_traits, traits_type)
ROCPROFILER_IMPL_HAS_CONCEPT(has_value_type, value_type)
ROCPROFILER_IMPL_HAS_CONCEPT(has_key_type, key_type)
ROCPROFILER_IMPL_HAS_CONCEPT(has_mapped_type, mapped_type)
ROCPROFILER_IMPL_SFINAE_CONCEPT(has_empty_member_function, std::declval<Tp>().empty())
ROCPROFILER_IMPL_SFINAE_CONCEPT(can_stringify, std::declval<std::ostream&>() << std::declval<Tp>())
ROCPROFILER_IMPL_SFINAE_CONCEPT(is_iterable,
std::begin(std::declval<Tp>()),
std::end(std::declval<Tp>()))
// compatability
template <typename Tp>
using supports_ostream = can_stringify<Tp>;
template <typename ArgT>
inline bool
is_empty(ArgT&& _v)
{
using arg_type = unqualified_identity_t<ArgT>;
if constexpr(has_empty_member_function<arg_type>::value)
{
return std::forward<ArgT>(_v).empty();
}
else if constexpr(is_string_type<arg_type>::value)
{
static_assert(std::is_constructible<std::string_view, ArgT>::value,
"not string_view constructible");
return std::string_view{std::forward<ArgT>(_v)}.empty();
}
return false;
}
namespace impl
{
template <typename ContainerT, typename... Args>
inline auto
emplace(ContainerT& _c, int, Args&&... _args)
-> decltype(_c.emplace_back(std::forward<Args>(_args)...))
{
return _c.emplace_back(std::forward<Args>(_args)...);
}
template <typename ContainerT, typename... Args>
inline auto
emplace(ContainerT& _c, long, Args&&... _args) -> decltype(_c.emplace(std::forward<Args>(_args)...))
{
return _c.emplace(std::forward<Args>(_args)...);
}
template <typename ContainerT, typename ArgT>
inline auto
reserve(ContainerT& _c, int, ArgT _arg) -> decltype(_c.reserve(_arg), bool())
{
_c.reserve(_arg);
return true;
}
template <typename ContainerT, typename ArgT>
inline auto
reserve(ContainerT&, long, ArgT)
{
return false;
}
} // namespace impl
template <typename ContainerT, typename... Args>
inline auto
emplace(ContainerT& _c, Args&&... _args)
{
return impl::emplace(_c, 0, std::forward<Args>(_args)...);
}
template <typename ContainerT, typename ArgT>
inline auto
reserve(ContainerT& _c, ArgT _arg)
{
return impl::reserve(_c, 0, _arg);
}
template <typename Tp>
struct assert_false
{
static constexpr auto value = false;
};
} // namespace mpl
} // namespace sdk
} // namespace rocprofiler
#undef ROCPROFILER_IMPL_HAS_CONCEPT
#undef ROCPROFILER_IMPL_SFINAE_CONCEPT
+182
ファイルの表示
@@ -0,0 +1,182 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
//
#pragma once
#if !defined(ROCPROFILER_SDK_CXX_NAME_INFO_HPP_)
# include <rocprofiler-sdk/cxx/name_info.hpp>
#endif
#include <rocprofiler-sdk/buffer_tracing.h>
#include <rocprofiler-sdk/callback_tracing.h>
#include <rocprofiler-sdk/fwd.h>
#include <string_view>
#include <type_traits>
#include <vector>
namespace rocprofiler
{
namespace sdk
{
namespace utility
{
template <typename EnumT, typename ValueT>
typename name_info_impl<EnumT, ValueT>::item_array_t
name_info_impl<EnumT, ValueT>::items() const
{
auto ret = item_array_t{};
ret.reserve(operations.size());
rocprofiler_tracing_operation_t _idx = 0;
for(const auto& itr : operations)
ret.emplace_back(_idx++, &itr);
return ret;
}
template <typename EnumT, typename ValueT>
inline void
name_info<EnumT, ValueT>::emplace(EnumT idx, const char* name)
{
impl.resize(idx + 1, value_type{});
impl.at(idx).value = idx;
impl.at(idx).name = support_type{}(name);
}
template <typename EnumT, typename ValueT>
inline void
name_info<EnumT, ValueT>::emplace(EnumT idx,
rocprofiler_tracing_operation_t opidx,
const char* name)
{
impl.resize(idx + 1, value_type{});
impl.at(idx).operations.resize(opidx + 1, support_type::default_value());
impl.at(idx).operations.at(opidx) = support_type{}(name);
}
template <typename EnumT, typename ValueT>
typename name_info<EnumT, ValueT>::return_type
name_info<EnumT, ValueT>::at(EnumT idx) const
{
return impl.at(idx).name;
}
template <typename EnumT, typename ValueT>
typename name_info<EnumT, ValueT>::return_type
name_info<EnumT, ValueT>::at(EnumT idx, rocprofiler_tracing_operation_t opidx) const
{
return impl.at(idx).operations.at(opidx);
}
template <typename EnumT, typename ValueT>
typename name_info<EnumT, ValueT>::item_array_t
name_info<EnumT, ValueT>::items() const
{
auto ret = item_array_t{};
ret.reserve(impl.size());
for(const auto& itr : impl)
ret.emplace_back(&itr);
return ret;
}
} // namespace utility
constexpr auto success_v = ROCPROFILER_STATUS_SUCCESS;
template <typename Tp>
inline callback_name_info_t<Tp>
get_callback_tracing_names()
{
auto cb_name_info = callback_name_info_t<Tp>{};
//
// callback for each kind operation
//
static auto tracing_kind_operation_cb = [](rocprofiler_callback_tracing_kind_t kindv,
rocprofiler_tracing_operation_t operation,
void* data_v) {
auto* name_info_v = static_cast<callback_name_info_t<Tp>*>(data_v);
const char* name = nullptr;
auto status = rocprofiler_query_callback_tracing_kind_operation_name(
kindv, operation, &name, nullptr);
if(status == success_v && name) name_info_v->emplace(kindv, operation, name);
return 0;
};
//
// callback for each buffer kind (i.e. domain)
//
static auto tracing_kind_cb = [](rocprofiler_callback_tracing_kind_t kind, void* data) {
// store the buffer kind name
auto* name_info_v = static_cast<callback_name_info_t<Tp>*>(data);
const char* name = nullptr;
auto status = rocprofiler_query_callback_tracing_kind_name(kind, &name, nullptr);
if(status == success_v && name) name_info_v->emplace(kind, name);
rocprofiler_iterate_callback_tracing_kind_operations(kind, tracing_kind_operation_cb, data);
return 0;
};
rocprofiler_iterate_callback_tracing_kinds(tracing_kind_cb, &cb_name_info);
return cb_name_info;
}
template <typename Tp>
inline buffer_name_info_t<Tp>
get_buffer_tracing_names()
{
auto cb_name_info = buffer_name_info_t<Tp>{};
//
// callback for each kind operation
//
static auto tracing_kind_operation_cb = [](rocprofiler_buffer_tracing_kind_t kindv,
rocprofiler_tracing_operation_t operation,
void* data_v) {
auto* name_info_v = static_cast<buffer_name_info_t<Tp>*>(data_v);
const char* name = nullptr;
auto status =
rocprofiler_query_buffer_tracing_kind_operation_name(kindv, operation, &name, nullptr);
if(status == success_v && name) name_info_v->emplace(kindv, operation, name);
return 0;
};
//
// callback for each buffer kind (i.e. domain)
//
static auto tracing_kind_cb = [](rocprofiler_buffer_tracing_kind_t kind, void* data) {
// store the buffer kind name
auto* name_info_v = static_cast<buffer_name_info_t<Tp>*>(data);
const char* name = nullptr;
auto status = rocprofiler_query_buffer_tracing_kind_name(kind, &name, nullptr);
if(status == success_v && name) name_info_v->emplace(kind, name);
rocprofiler_iterate_buffer_tracing_kind_operations(kind, tracing_kind_operation_cb, data);
return 0;
};
rocprofiler_iterate_buffer_tracing_kinds(tracing_kind_cb, &cb_name_info);
return cb_name_info;
}
} // namespace sdk
} // namespace rocprofiler
+235
ファイルの表示
@@ -0,0 +1,235 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/cxx/details/mpl.hpp>
#include <functional>
#include <sstream>
#include <stdexcept>
#include <string>
#include <string_view>
#include <vector>
namespace rocprofiler
{
namespace sdk
{
namespace parse
{
template <typename Tp>
inline Tp
from_string(const std::string& str)
{
auto ss = std::stringstream{str};
auto val = Tp{};
ss >> val;
return val;
}
template <typename Tp>
inline Tp
from_string(const char* cstr)
{
auto ss = std::stringstream{cstr};
auto val = Tp{};
ss >> val;
return val;
}
/// \brief tokenize a string into a set
///
template <typename ContainerT = std::vector<std::string>,
typename ValueT = typename ContainerT::value_type,
typename PredicateT = std::function<ValueT(ValueT&&)>>
inline ContainerT
tokenize(
std::string_view line,
std::string_view delimiters = "\"',;: ",
PredicateT&& predicate = [](ValueT&& s) -> ValueT { return s; })
{
using value_type = ValueT;
size_t _beginp = 0; // position that is the beginning of the new string
size_t _delimp = 0; // position of the delimiter in the string
ContainerT _result = {};
if(mpl::reserve(_result, 0))
{
size_t _nmax = 0;
for(char itr : line)
{
if(delimiters.find(itr) != std::string::npos) ++_nmax;
}
mpl::reserve(_result, _nmax);
}
while(_beginp < line.length() && _delimp < line.length())
{
// find the first character (starting at _delimp) that is not a delimiter
_beginp = line.find_first_not_of(delimiters, _delimp);
// if no a character after or at _end that is not a delimiter is not found
// then we are done
if(_beginp == std::string::npos) break;
// starting at the position of the new string, find the next delimiter
_delimp = line.find_first_of(delimiters, _beginp);
auto _tmp = value_type{};
// starting at the position of the new string, get the characters
// between this position and the next delimiter
if(_beginp < line.length()) _tmp = line.substr(_beginp, _delimp - _beginp);
// don't add empty strings
if(!_tmp.empty())
{
mpl::emplace(_result, std::forward<PredicateT>(predicate)(std::move(_tmp)));
}
}
return _result;
}
/// \brief tokenize a string into a set
///
template <typename ContainerT = std::vector<std::string>,
typename DelimT = std::string_view,
typename ValueT = typename ContainerT::value_type,
typename PredicateT = ValueT (*)(DelimT&&)>
inline ContainerT
tokenize(
std::string_view line,
const std::vector<DelimT>& delimiters,
PredicateT&& predicate = [](DelimT&& s) -> ValueT { return ValueT{s}; })
{
ContainerT _result = {};
size_t _start = 0;
size_t _end = std::string::npos;
while(_start != std::string::npos)
{
_end = std::string::npos;
// Find the earliest occurrence of any delimiter
for(const auto& itr : delimiters)
{
size_t pos = line.find(itr, _start);
if(pos != std::string::npos && (_end == std::string::npos || pos < _end))
{
_end = pos;
}
}
// Extract token and update start position
if(_end != std::string::npos)
{
mpl::emplace(_result,
std::forward<PredicateT>(predicate)(line.substr(_start, _end - _start)));
_start = _end;
// Move start past the delimiter
for(const auto& delimiter : delimiters)
{
if(line.compare(_start, delimiter.size(), delimiter) == 0)
{
_start += delimiter.size();
break;
}
}
}
else
{
// Last token after the final delimiter
mpl::emplace(_result, std::forward<PredicateT>(predicate)(line.substr(_start)));
break;
}
}
return _result;
}
/// \brief apply a string transformation to substring in between a common delimiter.
///
template <typename PredicateT = std::function<std::string(const std::string&)>>
inline std::string
str_transform(std::string_view input,
std::string_view _begin,
std::string_view _end,
PredicateT&& predicate)
{
size_t _beg_pos = 0; // position that is the beginning of the new string
size_t _end_pos = 0; // position of the delimiter in the string
std::string _result = std::string{input};
while(_beg_pos < _result.length() && _end_pos < _result.length())
{
// find the first sequence of characters after the end-position
_beg_pos = _result.find(_begin, _end_pos);
// if sequence wasn't found, we are done
if(_beg_pos == std::string::npos) break;
// starting after the position of the first delimiter, find the end sequence
if(!_end.empty())
_end_pos = _result.find(_end, _beg_pos + 1);
else
_end_pos = _beg_pos + _begin.length();
// break if not found
if(_end_pos == std::string::npos) break;
// length of the substr being operated on
auto _len = _end_pos - _beg_pos;
// get the substring between the two delimiters (including first delimiter)
auto _sub = _result.substr(_beg_pos, _len);
// apply the transform
auto _transformed = predicate(_sub);
// only replace if necessary
if(_sub != _transformed)
{
_result = _result.replace(_beg_pos, _len, _transformed);
// move end to the end of transformed string
_end_pos = _beg_pos + _transformed.length();
}
}
return _result;
}
inline std::string
strip(std::string&& str, std::string_view characters)
{
constexpr auto npos = std::string_view::npos;
auto bpos = str.find_first_not_of(characters);
auto epos = str.find_last_not_of(characters);
if(bpos != npos && epos != npos)
return str.substr(bpos, (epos - bpos + 1));
else if(bpos != npos)
return str.substr(bpos);
else if(epos != npos)
return str.substr(0, epos + 1);
return str;
}
} // namespace parse
} // namespace sdk
} // namespace rocprofiler
ファイル差分が大きすぎるため表示されません。 差分を読み込み
+75
ファイルの表示
@@ -0,0 +1,75 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
//
#pragma once
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/hsa.h>
#include <rocprofiler-sdk/internal_threading.h>
namespace rocprofiler
{
namespace sdk
{
namespace hash
{
template <typename Tp>
struct handle_hasher
{
static_assert(sizeof(Tp) == sizeof(uint64_t), "error! only for opaque handle types");
size_t operator()(Tp val) const { return val.handle; }
};
} // namespace hash
} // namespace sdk
} // namespace rocprofiler
namespace std
{
template <typename Tp>
struct hash;
#define ROCPROFILER_CXX_SPECIALIZE_HANDLE_HASHER(TYPE) \
template <> \
struct hash<TYPE> : public rocprofiler::sdk::hash::handle_hasher<TYPE> \
{ \
using parent_type = ::rocprofiler::sdk::hash::handle_hasher<TYPE>; \
using parent_type::operator(); \
};
ROCPROFILER_CXX_SPECIALIZE_HANDLE_HASHER(rocprofiler_context_id_t)
ROCPROFILER_CXX_SPECIALIZE_HANDLE_HASHER(rocprofiler_agent_id_t)
ROCPROFILER_CXX_SPECIALIZE_HANDLE_HASHER(rocprofiler_address_t)
ROCPROFILER_CXX_SPECIALIZE_HANDLE_HASHER(rocprofiler_queue_id_t)
ROCPROFILER_CXX_SPECIALIZE_HANDLE_HASHER(rocprofiler_stream_id_t)
ROCPROFILER_CXX_SPECIALIZE_HANDLE_HASHER(rocprofiler_buffer_id_t)
ROCPROFILER_CXX_SPECIALIZE_HANDLE_HASHER(rocprofiler_counter_id_t)
ROCPROFILER_CXX_SPECIALIZE_HANDLE_HASHER(rocprofiler_counter_config_id_t)
ROCPROFILER_CXX_SPECIALIZE_HANDLE_HASHER(rocprofiler_callback_thread_t)
ROCPROFILER_CXX_SPECIALIZE_HANDLE_HASHER(hsa_agent_t)
ROCPROFILER_CXX_SPECIALIZE_HANDLE_HASHER(hsa_signal_t)
ROCPROFILER_CXX_SPECIALIZE_HANDLE_HASHER(hsa_executable_t)
ROCPROFILER_CXX_SPECIALIZE_HANDLE_HASHER(hsa_region_t)
ROCPROFILER_CXX_SPECIALIZE_HANDLE_HASHER(hsa_amd_memory_pool_t)
#undef ROCPROFILER_CXX_SPECIALIZE_HANDLE_HASHER
} // namespace std
+116
ファイルの表示
@@ -0,0 +1,116 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
//
#pragma once
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/cxx/details/mpl.hpp>
#include <string>
#include <string_view>
#include <type_traits>
#include <vector>
namespace rocprofiler
{
namespace sdk
{
namespace utility
{
template <typename EnumT, typename ValueT = std::string_view>
struct name_info_impl
{
using support_type = mpl::string_support<ValueT>;
using enum_type = EnumT;
using value_type = ValueT;
using return_type = typename support_type::return_type;
using item_type = std::pair<rocprofiler_tracing_operation_t, const value_type*>;
using item_array_t = std::vector<item_type>;
static_assert(support_type::value,
"value_type must be supported by rocprofiler::sdk::mpl::string_support");
return_type operator()() const { return name; }
return_type operator()(size_t idx) const { return operations.at(idx); }
return_type operator[](size_t idx) const { return operations.at(idx); }
item_array_t items() const;
EnumT value = static_cast<EnumT>(0);
value_type name = {};
std::vector<value_type> operations = {};
};
template <typename EnumT, typename ValueT = std::string_view>
struct name_info
{
using value_type = name_info_impl<EnumT, ValueT>;
using enum_type = EnumT;
using support_type = typename value_type::support_type;
using return_type = typename value_type::return_type;
using item_type = const value_type*;
using item_array_t = std::vector<item_type>;
void emplace(EnumT idx, const char* name);
void emplace(EnumT idx, rocprofiler_tracing_operation_t opidx, const char* name);
return_type at(EnumT idx) const;
return_type at(EnumT idx, rocprofiler_tracing_operation_t opidx) const;
item_array_t items() const;
decltype(auto) size() const { return impl.size(); }
decltype(auto) begin() { return impl.begin(); }
decltype(auto) begin() const { return impl.begin(); }
decltype(auto) end() { return impl.end(); }
decltype(auto) end() const { return impl.end(); }
value_type& operator[](size_t idx) { return impl.at(idx); }
const value_type& operator[](size_t idx) const { return impl.at(idx); }
private:
std::vector<value_type> impl = {};
};
} // namespace utility
template <typename Tp = std::string_view>
using callback_name_info_t = utility::name_info<rocprofiler_callback_tracing_kind_t, Tp>;
template <typename Tp = std::string_view>
using buffer_name_info_t = utility::name_info<rocprofiler_buffer_tracing_kind_t, Tp>;
using callback_name_info = callback_name_info_t<std::string_view>;
using buffer_name_info = buffer_name_info_t<std::string_view>;
template <typename Tp = std::string_view>
callback_name_info_t<Tp>
get_callback_tracing_names();
template <typename Tp = std::string_view>
buffer_name_info_t<Tp>
get_buffer_tracing_names();
} // namespace sdk
} // namespace rocprofiler
#define ROCPROFILER_SDK_CXX_NAME_INFO_HPP_ 1
#include <rocprofiler-sdk/cxx/details/name_info.hpp>
+343
ファイルの表示
@@ -0,0 +1,343 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
//
#pragma once
#include <rocprofiler-sdk/agent.h>
#include <rocprofiler-sdk/counters.h>
#include <rocprofiler-sdk/defines.h>
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/hsa.h>
#include <rocprofiler-sdk/internal_threading.h>
#include "rocprofiler-sdk/cxx/details/mpl.hpp"
#include <string_view>
#include <tuple>
#define ROCPROFILER_CXX_DECLARE_OPERATORS(TYPE) \
bool operator==(TYPE lhs, TYPE rhs) ROCPROFILER_ATTRIBUTE(pure); \
bool operator!=(TYPE lhs, TYPE rhs) ROCPROFILER_ATTRIBUTE(pure); \
bool operator<(TYPE lhs, TYPE rhs) ROCPROFILER_ATTRIBUTE(pure); \
bool operator>(TYPE lhs, TYPE rhs) ROCPROFILER_ATTRIBUTE(pure); \
bool operator<=(TYPE lhs, TYPE rhs) ROCPROFILER_ATTRIBUTE(pure); \
bool operator>=(TYPE lhs, TYPE rhs) ROCPROFILER_ATTRIBUTE(pure);
#define ROCPROFILER_CXX_DEFINE_NE_OPERATOR(TYPE) \
inline bool operator!=(TYPE lhs, TYPE rhs) { return !(lhs == rhs); }
#define ROCPROFILER_CXX_DEFINE_EQ_HANDLE_OPERATOR(TYPE) \
inline bool operator==(TYPE lhs, TYPE rhs) \
{ \
return ::rocprofiler::sdk::operators::equal(lhs, rhs); \
}
#define ROCPROFILER_CXX_DEFINE_LT_HANDLE_OPERATOR(TYPE) \
inline bool operator<(TYPE lhs, TYPE rhs) \
{ \
return ::rocprofiler::sdk::operators::less(lhs, rhs); \
}
#define ROCPROFILER_CXX_DEFINE_COMPARE_OPERATORS(TYPE) \
inline bool operator>(TYPE lhs, TYPE rhs) { return !(lhs == rhs || lhs < rhs); } \
inline bool operator<=(TYPE lhs, TYPE rhs) { return (lhs == rhs || lhs < rhs); } \
inline bool operator>=(TYPE lhs, TYPE rhs) { return !(lhs < rhs); }
namespace rocprofiler
{
namespace sdk
{
namespace operators
{
template <typename Tp>
bool
equal(Tp lhs, Tp rhs) ROCPROFILER_ATTRIBUTE(pure);
template <typename Tp>
bool
less(Tp lhs, Tp rhs) ROCPROFILER_ATTRIBUTE(pure);
template <typename Tp>
bool
equal(Tp lhs, Tp rhs)
{
static_assert(sizeof(Tp) == sizeof(uint64_t), "error! only for opaque handle types");
return lhs.handle == rhs.handle;
}
template <typename Tp>
bool
less(Tp lhs, Tp rhs)
{
static_assert(sizeof(Tp) == sizeof(uint64_t), "error! only for opaque handle types");
return lhs.handle < rhs.handle;
}
namespace detail
{
template <typename Tp>
struct sv_trait
{
static constexpr auto is_string_type() noexcept
{
return mpl::is_string_type<mpl::unqualified_identity_t<Tp>>::value;
}
using type = std::conditional_t<is_string_type(), std::string_view, Tp&>;
constexpr type operator()(Tp& v) noexcept
{
if constexpr(is_string_type())
return std::string_view{v};
else
return v;
}
};
} // namespace detail
// tie_sv(): deduce each Tp from your lvalues, then build tuple<...> out of
// either Tp& or std::string_view, calling operator() on each.
template <typename... Tp>
constexpr auto
tie_sv(Tp&... vs) noexcept
{
return std::make_tuple(detail::sv_trait<Tp>{}(vs)...);
}
} // namespace operators
} // namespace sdk
} // namespace rocprofiler
// declaration of operator== and operator!=
ROCPROFILER_CXX_DECLARE_OPERATORS(rocprofiler_context_id_t)
ROCPROFILER_CXX_DECLARE_OPERATORS(rocprofiler_address_t)
ROCPROFILER_CXX_DECLARE_OPERATORS(rocprofiler_agent_id_t)
ROCPROFILER_CXX_DECLARE_OPERATORS(rocprofiler_queue_id_t)
ROCPROFILER_CXX_DECLARE_OPERATORS(rocprofiler_stream_id_t)
ROCPROFILER_CXX_DECLARE_OPERATORS(rocprofiler_buffer_id_t)
ROCPROFILER_CXX_DECLARE_OPERATORS(rocprofiler_counter_id_t)
ROCPROFILER_CXX_DECLARE_OPERATORS(rocprofiler_counter_config_id_t)
ROCPROFILER_CXX_DECLARE_OPERATORS(rocprofiler_callback_thread_t)
ROCPROFILER_CXX_DECLARE_OPERATORS(hsa_agent_t)
ROCPROFILER_CXX_DECLARE_OPERATORS(hsa_signal_t)
ROCPROFILER_CXX_DECLARE_OPERATORS(hsa_executable_t)
ROCPROFILER_CXX_DECLARE_OPERATORS(const rocprofiler_agent_v0_t&)
ROCPROFILER_CXX_DECLARE_OPERATORS(rocprofiler_dim3_t)
ROCPROFILER_CXX_DECLARE_OPERATORS(hsa_region_t)
ROCPROFILER_CXX_DECLARE_OPERATORS(hsa_amd_memory_pool_t)
ROCPROFILER_CXX_DECLARE_OPERATORS(const rocprofiler_counter_record_dimension_info_t&)
ROCPROFILER_CXX_DECLARE_OPERATORS(const rocprofiler_counter_record_dimension_instance_info_t&)
ROCPROFILER_CXX_DECLARE_OPERATORS(const rocprofiler_counter_dimension_info_t&)
ROCPROFILER_CXX_DECLARE_OPERATORS(rocprofiler_version_triplet_t)
// definitions of operator==
ROCPROFILER_CXX_DEFINE_EQ_HANDLE_OPERATOR(rocprofiler_context_id_t)
ROCPROFILER_CXX_DEFINE_EQ_HANDLE_OPERATOR(rocprofiler_address_t)
ROCPROFILER_CXX_DEFINE_EQ_HANDLE_OPERATOR(rocprofiler_agent_id_t)
ROCPROFILER_CXX_DEFINE_EQ_HANDLE_OPERATOR(rocprofiler_queue_id_t)
ROCPROFILER_CXX_DEFINE_EQ_HANDLE_OPERATOR(rocprofiler_stream_id_t)
ROCPROFILER_CXX_DEFINE_EQ_HANDLE_OPERATOR(rocprofiler_buffer_id_t)
ROCPROFILER_CXX_DEFINE_EQ_HANDLE_OPERATOR(rocprofiler_counter_id_t)
ROCPROFILER_CXX_DEFINE_EQ_HANDLE_OPERATOR(rocprofiler_counter_config_id_t)
ROCPROFILER_CXX_DEFINE_EQ_HANDLE_OPERATOR(rocprofiler_callback_thread_t)
ROCPROFILER_CXX_DEFINE_EQ_HANDLE_OPERATOR(hsa_agent_t)
ROCPROFILER_CXX_DEFINE_EQ_HANDLE_OPERATOR(hsa_signal_t)
ROCPROFILER_CXX_DEFINE_EQ_HANDLE_OPERATOR(hsa_executable_t)
ROCPROFILER_CXX_DEFINE_EQ_HANDLE_OPERATOR(hsa_region_t)
ROCPROFILER_CXX_DEFINE_EQ_HANDLE_OPERATOR(hsa_amd_memory_pool_t)
inline bool
operator==(const rocprofiler_agent_v0_t& lhs, const rocprofiler_agent_v0_t& rhs)
{
return (lhs.id == rhs.id);
}
inline bool
operator==(rocprofiler_dim3_t lhs, rocprofiler_dim3_t rhs)
{
return std::tie(lhs.x, lhs.y, lhs.z) == std::tie(rhs.x, rhs.y, rhs.z);
}
inline bool
operator==(const rocprofiler_counter_record_dimension_info_t& lhs,
const rocprofiler_counter_record_dimension_info_t& rhs)
{
namespace op = ::rocprofiler::sdk::operators;
return op::tie_sv(lhs.id, lhs.instance_size, lhs.name) ==
op::tie_sv(rhs.id, rhs.instance_size, rhs.name);
}
inline bool
operator==(const rocprofiler_counter_dimension_info_t& lhs,
const rocprofiler_counter_dimension_info_t& rhs)
{
namespace op = ::rocprofiler::sdk::operators;
return op::tie_sv(lhs.dimension_name, lhs.index, lhs.size) ==
op::tie_sv(rhs.dimension_name, rhs.index, rhs.size);
}
inline bool
operator==(const rocprofiler_counter_record_dimension_instance_info_t& lhs,
const rocprofiler_counter_record_dimension_instance_info_t& rhs)
{
if(std::tie(lhs.instance_id, lhs.counter_id, lhs.dimensions_count) !=
std::tie(rhs.instance_id, rhs.counter_id, rhs.dimensions_count))
{
return false;
}
for(uint64_t i = 0; i < lhs.dimensions_count; ++i)
{
if(lhs.dimensions[i] == nullptr && rhs.dimensions[i] == nullptr) continue;
if(!lhs.dimensions[i] || !rhs.dimensions[i] || *lhs.dimensions[i] != *rhs.dimensions[i])
{
return false;
}
}
return true;
}
inline bool
operator==(rocprofiler_version_triplet_t lhs, rocprofiler_version_triplet_t rhs)
{
return std::tie(lhs.major, lhs.minor, lhs.patch) == std::tie(rhs.major, rhs.minor, rhs.patch);
}
// definitions of operator!=
ROCPROFILER_CXX_DEFINE_NE_OPERATOR(rocprofiler_context_id_t)
ROCPROFILER_CXX_DEFINE_NE_OPERATOR(rocprofiler_address_t)
ROCPROFILER_CXX_DEFINE_NE_OPERATOR(rocprofiler_agent_id_t)
ROCPROFILER_CXX_DEFINE_NE_OPERATOR(rocprofiler_queue_id_t)
ROCPROFILER_CXX_DEFINE_NE_OPERATOR(rocprofiler_stream_id_t)
ROCPROFILER_CXX_DEFINE_NE_OPERATOR(rocprofiler_buffer_id_t)
ROCPROFILER_CXX_DEFINE_NE_OPERATOR(rocprofiler_counter_id_t)
ROCPROFILER_CXX_DEFINE_NE_OPERATOR(rocprofiler_counter_config_id_t)
ROCPROFILER_CXX_DEFINE_NE_OPERATOR(rocprofiler_callback_thread_t)
ROCPROFILER_CXX_DEFINE_NE_OPERATOR(hsa_agent_t)
ROCPROFILER_CXX_DEFINE_NE_OPERATOR(hsa_signal_t)
ROCPROFILER_CXX_DEFINE_NE_OPERATOR(hsa_executable_t)
ROCPROFILER_CXX_DEFINE_NE_OPERATOR(const rocprofiler_agent_v0_t&)
ROCPROFILER_CXX_DEFINE_NE_OPERATOR(rocprofiler_dim3_t)
ROCPROFILER_CXX_DEFINE_NE_OPERATOR(hsa_region_t)
ROCPROFILER_CXX_DEFINE_NE_OPERATOR(hsa_amd_memory_pool_t)
ROCPROFILER_CXX_DEFINE_NE_OPERATOR(rocprofiler_version_triplet_t)
// definitions of operator<
ROCPROFILER_CXX_DEFINE_LT_HANDLE_OPERATOR(rocprofiler_context_id_t)
ROCPROFILER_CXX_DEFINE_LT_HANDLE_OPERATOR(rocprofiler_address_t)
ROCPROFILER_CXX_DEFINE_LT_HANDLE_OPERATOR(rocprofiler_agent_id_t)
ROCPROFILER_CXX_DEFINE_LT_HANDLE_OPERATOR(rocprofiler_queue_id_t)
ROCPROFILER_CXX_DEFINE_LT_HANDLE_OPERATOR(rocprofiler_stream_id_t)
ROCPROFILER_CXX_DEFINE_LT_HANDLE_OPERATOR(rocprofiler_buffer_id_t)
ROCPROFILER_CXX_DEFINE_LT_HANDLE_OPERATOR(rocprofiler_counter_id_t)
ROCPROFILER_CXX_DEFINE_LT_HANDLE_OPERATOR(rocprofiler_counter_config_id_t)
ROCPROFILER_CXX_DEFINE_LT_HANDLE_OPERATOR(rocprofiler_callback_thread_t)
ROCPROFILER_CXX_DEFINE_LT_HANDLE_OPERATOR(hsa_agent_t)
ROCPROFILER_CXX_DEFINE_LT_HANDLE_OPERATOR(hsa_signal_t)
ROCPROFILER_CXX_DEFINE_LT_HANDLE_OPERATOR(hsa_executable_t)
ROCPROFILER_CXX_DEFINE_LT_HANDLE_OPERATOR(hsa_region_t)
ROCPROFILER_CXX_DEFINE_LT_HANDLE_OPERATOR(hsa_amd_memory_pool_t)
inline bool
operator<(const rocprofiler_counter_record_dimension_info_t& lhs,
const rocprofiler_counter_record_dimension_info_t& rhs)
{
namespace op = ::rocprofiler::sdk::operators;
return op::tie_sv(lhs.id, lhs.instance_size, lhs.name) <
op::tie_sv(rhs.id, rhs.instance_size, rhs.name);
}
inline bool
operator<(const rocprofiler_counter_dimension_info_t& lhs,
const rocprofiler_counter_dimension_info_t& rhs)
{
namespace op = ::rocprofiler::sdk::operators;
return op::tie_sv(lhs.dimension_name, lhs.index, lhs.size) <
op::tie_sv(rhs.dimension_name, rhs.index, rhs.size);
}
inline bool
operator<(const rocprofiler_counter_record_dimension_instance_info_t& lhs,
const rocprofiler_counter_record_dimension_instance_info_t& rhs)
{
if(lhs.instance_id != rhs.instance_id) return lhs.instance_id < rhs.instance_id;
if(lhs.counter_id != rhs.counter_id) return lhs.counter_id < rhs.counter_id;
if(lhs.dimensions_count != rhs.dimensions_count)
return lhs.dimensions_count < rhs.dimensions_count;
for(uint64_t i = 0; i < lhs.dimensions_count; ++i)
{
if(!lhs.dimensions[i] || !rhs.dimensions[i]) return *lhs.dimensions[i] < *rhs.dimensions[i];
}
return false;
}
inline bool
operator<(const rocprofiler_agent_v0_t& lhs, const rocprofiler_agent_v0_t& rhs)
{
return (lhs.id < rhs.id);
}
inline bool
operator<(rocprofiler_dim3_t lhs, rocprofiler_dim3_t rhs)
{
const auto magnitude = [](rocprofiler_dim3_t dim_v) { return dim_v.x * dim_v.y * dim_v.z; };
auto lhs_m = magnitude(lhs);
auto rhs_m = magnitude(rhs);
return (lhs_m == rhs_m) ? std::tie(lhs.x, lhs.y, lhs.z) < std::tie(rhs.x, rhs.y, rhs.z)
: (lhs_m < rhs_m);
}
inline bool
operator<(rocprofiler_version_triplet_t lhs, rocprofiler_version_triplet_t rhs)
{
return std::tie(lhs.major, lhs.minor, lhs.patch) < std::tie(rhs.major, rhs.minor, rhs.patch);
}
// definitions of operator>, operator<=, operator>=
ROCPROFILER_CXX_DEFINE_COMPARE_OPERATORS(rocprofiler_context_id_t)
ROCPROFILER_CXX_DEFINE_COMPARE_OPERATORS(rocprofiler_address_t)
ROCPROFILER_CXX_DEFINE_COMPARE_OPERATORS(rocprofiler_agent_id_t)
ROCPROFILER_CXX_DEFINE_COMPARE_OPERATORS(rocprofiler_queue_id_t)
ROCPROFILER_CXX_DEFINE_COMPARE_OPERATORS(rocprofiler_stream_id_t)
ROCPROFILER_CXX_DEFINE_COMPARE_OPERATORS(rocprofiler_buffer_id_t)
ROCPROFILER_CXX_DEFINE_COMPARE_OPERATORS(rocprofiler_counter_id_t)
ROCPROFILER_CXX_DEFINE_COMPARE_OPERATORS(rocprofiler_counter_config_id_t)
ROCPROFILER_CXX_DEFINE_COMPARE_OPERATORS(rocprofiler_callback_thread_t)
ROCPROFILER_CXX_DEFINE_COMPARE_OPERATORS(hsa_agent_t)
ROCPROFILER_CXX_DEFINE_COMPARE_OPERATORS(hsa_signal_t)
ROCPROFILER_CXX_DEFINE_COMPARE_OPERATORS(hsa_executable_t)
ROCPROFILER_CXX_DEFINE_COMPARE_OPERATORS(const rocprofiler_agent_v0_t&)
ROCPROFILER_CXX_DEFINE_COMPARE_OPERATORS(rocprofiler_dim3_t)
ROCPROFILER_CXX_DEFINE_COMPARE_OPERATORS(hsa_region_t)
ROCPROFILER_CXX_DEFINE_COMPARE_OPERATORS(hsa_amd_memory_pool_t)
ROCPROFILER_CXX_DEFINE_COMPARE_OPERATORS(rocprofiler_version_triplet_t)
// cleanup defines
#undef ROCPROFILER_CXX_DECLARE_OPERATORS
#undef ROCPROFILER_CXX_DEFINE_NE_OPERATOR
#undef ROCPROFILER_CXX_DEFINE_EQ_HANDLE_OPERATOR
#undef ROCPROFILER_CXX_DEFINE_LT_HANDLE_OPERATOR
#undef ROCPROFILER_CXX_DEFINE_COMPARE_OPERATORS
+306
ファイルの表示
@@ -0,0 +1,306 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/cxx/details/mpl.hpp>
#include <cstddef>
#include <ostream>
#include <sstream>
#include <string>
#include <string_view>
#include <type_traits>
#include <utility>
#define ROCPROFILER_DEFINE_PERFETTO_CATEGORY(NAME, DESC, ...) \
namespace rocprofiler \
{ \
namespace sdk \
{ \
template <> \
struct perfetto_category<__VA_ARGS__> \
{ \
static constexpr auto name = NAME; \
static constexpr auto description = DESC; \
}; \
} \
}
#define ROCPROFILER_DEFINE_CATEGORY(NS, VALUE, DESC) \
namespace rocprofiler \
{ \
namespace sdk \
{ \
namespace NS \
{ \
struct VALUE \
{}; \
} \
} \
} \
ROCPROFILER_DEFINE_PERFETTO_CATEGORY(#VALUE, DESC, NS::VALUE)
#define ROCPROFILER_PERFETTO_CATEGORY(TYPE) \
::perfetto::Category(::rocprofiler::sdk::perfetto_category<::rocprofiler::sdk::TYPE>::name) \
.SetDescription( \
::rocprofiler::sdk::perfetto_category<::rocprofiler::sdk::TYPE>::description)
#define ROCPROFILER_PERFETTO_TRACING_CATEGORY(KIND, PREFIX, CODE, CATEGORY) \
template <> \
struct rocprofiler_tracing_perfetto_category<KIND, PREFIX##CODE> \
{ \
static constexpr auto name = \
::rocprofiler::sdk::perfetto_category<::rocprofiler::sdk::category::CATEGORY>::name; \
};
#define ROCPROFILER_PERFETTO_BUFFER_TRACING_CATEGORY(...) \
ROCPROFILER_PERFETTO_TRACING_CATEGORY( \
rocprofiler_buffer_tracing_kind_t, ROCPROFILER_BUFFER_TRACING_, __VA_ARGS__)
#define ROCPROFILER_PERFETTO_CALLBACK_TRACING_CATEGORY(...) \
ROCPROFILER_PERFETTO_TRACING_CATEGORY( \
rocprofiler_callback_tracing_kind_t, ROCPROFILER_CALLBACK_TRACING_, __VA_ARGS__)
namespace rocprofiler
{
namespace sdk
{
template <typename Tp>
struct perfetto_category;
} // namespace sdk
} // namespace rocprofiler
ROCPROFILER_DEFINE_CATEGORY(category, hsa_api, "HSA API function")
ROCPROFILER_DEFINE_CATEGORY(category, hip_api, "HIP API function")
ROCPROFILER_DEFINE_CATEGORY(category, marker_api, "Marker API region")
ROCPROFILER_DEFINE_CATEGORY(category, rccl_api, "RCCL API function")
ROCPROFILER_DEFINE_CATEGORY(category, openmp, "OpenMP")
ROCPROFILER_DEFINE_CATEGORY(category, kernel_dispatch, "GPU kernel dispatch")
ROCPROFILER_DEFINE_CATEGORY(category, memory_copy, "Async memory copy")
ROCPROFILER_DEFINE_CATEGORY(category, memory_allocation, "Memory Allocation")
ROCPROFILER_DEFINE_CATEGORY(category, rocdecode_api, "rocDecode API function")
ROCPROFILER_DEFINE_CATEGORY(category, rocjpeg_api, "rocJPEG API function")
ROCPROFILER_DEFINE_CATEGORY(category, counter_collection, "Counter Collection")
ROCPROFILER_DEFINE_CATEGORY(category, kfd_events, "KFD events collection")
ROCPROFILER_DEFINE_CATEGORY(category, scratch_memory, "Scratch Memory Allocation")
ROCPROFILER_DEFINE_CATEGORY(category, none, "Unknown category")
#define ROCPROFILER_PERFETTO_CATEGORIES \
ROCPROFILER_PERFETTO_CATEGORY(category::hsa_api), \
ROCPROFILER_PERFETTO_CATEGORY(category::hip_api), \
ROCPROFILER_PERFETTO_CATEGORY(category::marker_api), \
ROCPROFILER_PERFETTO_CATEGORY(category::rccl_api), \
ROCPROFILER_PERFETTO_CATEGORY(category::openmp), \
ROCPROFILER_PERFETTO_CATEGORY(category::kernel_dispatch), \
ROCPROFILER_PERFETTO_CATEGORY(category::memory_copy), \
ROCPROFILER_PERFETTO_CATEGORY(category::counter_collection), \
ROCPROFILER_PERFETTO_CATEGORY(category::memory_allocation), \
ROCPROFILER_PERFETTO_CATEGORY(category::rocdecode_api), \
ROCPROFILER_PERFETTO_CATEGORY(category::rocjpeg_api), \
ROCPROFILER_PERFETTO_CATEGORY(category::scratch_memory), \
ROCPROFILER_PERFETTO_CATEGORY(category::none)
#include <perfetto.h>
PERFETTO_DEFINE_CATEGORIES(ROCPROFILER_PERFETTO_CATEGORIES);
namespace rocprofiler
{
namespace sdk
{
using perfetto_event_context_t = ::perfetto::EventContext;
template <typename Np, typename Tp>
auto
add_perfetto_annotation(perfetto_event_context_t& ctx, Np&& _name, Tp&& _val)
{
namespace mpl = ::rocprofiler::sdk::mpl;
using named_type = mpl::unqualified_identity_t<Np>;
using value_type = mpl::unqualified_identity_t<Tp>;
static_assert(mpl::is_string_type<named_type>::value, "Error! name is not a string type");
auto _get_dbg = [&]() {
auto* _dbg = ctx.event()->add_debug_annotations();
_dbg->set_name(std::string_view{std::forward<Np>(_name)}.data());
return _dbg;
};
if constexpr(std::is_same<value_type, std::string_view>::value)
{
_get_dbg()->set_string_value(_val.data());
}
else if constexpr(mpl::is_string_type<value_type>::value)
{
_get_dbg()->set_string_value(std::forward<Tp>(_val));
}
else if constexpr(std::is_same<value_type, bool>::value)
{
_get_dbg()->set_bool_value(_val);
}
else if constexpr(std::is_enum<value_type>::value)
{
_get_dbg()->set_int_value(static_cast<int64_t>(_val));
}
else if constexpr(std::is_floating_point<value_type>::value)
{
_get_dbg()->set_double_value(static_cast<double>(_val));
}
else if constexpr(std::is_integral<value_type>::value)
{
if constexpr(std::is_unsigned<value_type>::value)
{
_get_dbg()->set_uint_value(_val);
}
else
{
_get_dbg()->set_int_value(_val);
}
}
else if constexpr(std::is_pointer<value_type>::value)
{
_get_dbg()->set_pointer_value(reinterpret_cast<uint64_t>(_val));
}
else if constexpr(mpl::can_stringify<value_type>::value)
{
auto _ss = std::stringstream{};
_ss << std::forward<Tp>(_val);
_get_dbg()->set_string_value(_ss.str());
}
else
{
static_assert(std::is_empty<value_type>::value, "Error! unsupported data type");
}
}
} // namespace sdk
} // namespace rocprofiler
#include <rocprofiler-sdk/fwd.h>
namespace rocprofiler
{
namespace sdk
{
template <typename KindT, size_t Idx>
struct rocprofiler_tracing_perfetto_category;
ROCPROFILER_PERFETTO_BUFFER_TRACING_CATEGORY(NONE, none)
ROCPROFILER_PERFETTO_BUFFER_TRACING_CATEGORY(HSA_CORE_API, hsa_api)
ROCPROFILER_PERFETTO_BUFFER_TRACING_CATEGORY(HSA_AMD_EXT_API, hsa_api)
ROCPROFILER_PERFETTO_BUFFER_TRACING_CATEGORY(HSA_IMAGE_EXT_API, hsa_api)
ROCPROFILER_PERFETTO_BUFFER_TRACING_CATEGORY(HSA_FINALIZE_EXT_API, hsa_api)
ROCPROFILER_PERFETTO_BUFFER_TRACING_CATEGORY(HIP_RUNTIME_API, hip_api)
ROCPROFILER_PERFETTO_BUFFER_TRACING_CATEGORY(HIP_COMPILER_API, hip_api)
ROCPROFILER_PERFETTO_BUFFER_TRACING_CATEGORY(MARKER_CORE_API, marker_api)
ROCPROFILER_PERFETTO_BUFFER_TRACING_CATEGORY(MARKER_CORE_RANGE_API, marker_api)
ROCPROFILER_PERFETTO_BUFFER_TRACING_CATEGORY(MARKER_CONTROL_API, marker_api)
ROCPROFILER_PERFETTO_BUFFER_TRACING_CATEGORY(MARKER_NAME_API, marker_api)
ROCPROFILER_PERFETTO_BUFFER_TRACING_CATEGORY(MEMORY_COPY, memory_copy)
ROCPROFILER_PERFETTO_BUFFER_TRACING_CATEGORY(MEMORY_ALLOCATION, memory_allocation)
ROCPROFILER_PERFETTO_BUFFER_TRACING_CATEGORY(KERNEL_DISPATCH, kernel_dispatch)
ROCPROFILER_PERFETTO_BUFFER_TRACING_CATEGORY(SCRATCH_MEMORY, scratch_memory)
ROCPROFILER_PERFETTO_BUFFER_TRACING_CATEGORY(CORRELATION_ID_RETIREMENT, none)
ROCPROFILER_PERFETTO_BUFFER_TRACING_CATEGORY(RCCL_API, rccl_api)
ROCPROFILER_PERFETTO_BUFFER_TRACING_CATEGORY(OMPT, openmp)
ROCPROFILER_PERFETTO_BUFFER_TRACING_CATEGORY(RUNTIME_INITIALIZATION, none)
ROCPROFILER_PERFETTO_BUFFER_TRACING_CATEGORY(ROCDECODE_API, rocdecode_api)
ROCPROFILER_PERFETTO_BUFFER_TRACING_CATEGORY(ROCJPEG_API, rocjpeg_api)
ROCPROFILER_PERFETTO_BUFFER_TRACING_CATEGORY(HIP_STREAM, hip_api)
ROCPROFILER_PERFETTO_BUFFER_TRACING_CATEGORY(HIP_RUNTIME_API_EXT, hip_api)
ROCPROFILER_PERFETTO_BUFFER_TRACING_CATEGORY(HIP_COMPILER_API_EXT, hip_api)
ROCPROFILER_PERFETTO_BUFFER_TRACING_CATEGORY(ROCDECODE_API_EXT, rocdecode_api)
ROCPROFILER_PERFETTO_BUFFER_TRACING_CATEGORY(KFD_EVENT_PAGE_MIGRATE, kfd_events)
ROCPROFILER_PERFETTO_BUFFER_TRACING_CATEGORY(KFD_EVENT_PAGE_FAULT, kfd_events)
ROCPROFILER_PERFETTO_BUFFER_TRACING_CATEGORY(KFD_EVENT_QUEUE, kfd_events)
ROCPROFILER_PERFETTO_BUFFER_TRACING_CATEGORY(KFD_EVENT_UNMAP_FROM_GPU, kfd_events)
ROCPROFILER_PERFETTO_BUFFER_TRACING_CATEGORY(KFD_EVENT_DROPPED_EVENTS, kfd_events)
ROCPROFILER_PERFETTO_BUFFER_TRACING_CATEGORY(KFD_PAGE_MIGRATE, kfd_events)
ROCPROFILER_PERFETTO_BUFFER_TRACING_CATEGORY(KFD_PAGE_FAULT, kfd_events)
ROCPROFILER_PERFETTO_BUFFER_TRACING_CATEGORY(KFD_QUEUE, kfd_events)
ROCPROFILER_PERFETTO_CALLBACK_TRACING_CATEGORY(NONE, none)
ROCPROFILER_PERFETTO_CALLBACK_TRACING_CATEGORY(HSA_CORE_API, hsa_api)
ROCPROFILER_PERFETTO_CALLBACK_TRACING_CATEGORY(HSA_AMD_EXT_API, hsa_api)
ROCPROFILER_PERFETTO_CALLBACK_TRACING_CATEGORY(HSA_IMAGE_EXT_API, hsa_api)
ROCPROFILER_PERFETTO_CALLBACK_TRACING_CATEGORY(HSA_FINALIZE_EXT_API, hsa_api)
ROCPROFILER_PERFETTO_CALLBACK_TRACING_CATEGORY(HIP_RUNTIME_API, hip_api)
ROCPROFILER_PERFETTO_CALLBACK_TRACING_CATEGORY(HIP_COMPILER_API, hip_api)
ROCPROFILER_PERFETTO_CALLBACK_TRACING_CATEGORY(MARKER_CORE_API, marker_api)
ROCPROFILER_PERFETTO_CALLBACK_TRACING_CATEGORY(MARKER_CORE_RANGE_API, marker_api)
ROCPROFILER_PERFETTO_CALLBACK_TRACING_CATEGORY(MARKER_CONTROL_API, marker_api)
ROCPROFILER_PERFETTO_CALLBACK_TRACING_CATEGORY(MARKER_NAME_API, marker_api)
ROCPROFILER_PERFETTO_CALLBACK_TRACING_CATEGORY(CODE_OBJECT, none)
ROCPROFILER_PERFETTO_CALLBACK_TRACING_CATEGORY(SCRATCH_MEMORY, scratch_memory)
ROCPROFILER_PERFETTO_CALLBACK_TRACING_CATEGORY(KERNEL_DISPATCH, kernel_dispatch)
ROCPROFILER_PERFETTO_CALLBACK_TRACING_CATEGORY(MEMORY_COPY, memory_copy)
ROCPROFILER_PERFETTO_CALLBACK_TRACING_CATEGORY(MEMORY_ALLOCATION, memory_allocation)
ROCPROFILER_PERFETTO_CALLBACK_TRACING_CATEGORY(RCCL_API, rccl_api)
ROCPROFILER_PERFETTO_CALLBACK_TRACING_CATEGORY(OMPT, openmp)
ROCPROFILER_PERFETTO_CALLBACK_TRACING_CATEGORY(RUNTIME_INITIALIZATION, none)
ROCPROFILER_PERFETTO_CALLBACK_TRACING_CATEGORY(ROCDECODE_API, rocdecode_api)
ROCPROFILER_PERFETTO_CALLBACK_TRACING_CATEGORY(ROCJPEG_API, rocjpeg_api)
ROCPROFILER_PERFETTO_CALLBACK_TRACING_CATEGORY(HIP_STREAM, hip_api)
template <typename KindT, size_t Idx, size_t... Tail>
const char*
get_perfetto_category(KindT kind, std::index_sequence<Idx, Tail...>)
{
if(kind == Idx) return rocprofiler_tracing_perfetto_category<KindT, Idx>::name;
// recursion until tail empty
if constexpr(sizeof...(Tail) > 0)
return get_perfetto_category(kind, std::index_sequence<Tail...>{});
return nullptr;
}
template <typename KindT>
const char*
get_perfetto_category(KindT kind)
{
if constexpr(std::is_same<KindT, rocprofiler_buffer_tracing_kind_t>::value)
{
return get_perfetto_category<KindT>(
kind, std::make_index_sequence<ROCPROFILER_BUFFER_TRACING_LAST>{});
}
else if constexpr(std::is_same<KindT, rocprofiler_callback_tracing_kind_t>::value)
{
return get_perfetto_category<KindT>(
kind, std::make_index_sequence<ROCPROFILER_CALLBACK_TRACING_LAST>{});
}
else
{
static_assert(rocprofiler::sdk::mpl::assert_false<KindT>::value, "Unsupported data type");
}
return nullptr;
}
} // namespace sdk
} // namespace rocprofiler
#undef ROCPROFILER_DEFINE_PERFETTO_CATEGORY
#undef ROCPROFILER_DEFINE_CATEGORY
#undef ROCPROFILER_PERFETTO_CATEGORY
#undef ROCPROFILER_PERFETTO_CATEGORIES
#undef ROCPROFILER_PERFETTO_TRACING_CATEGORY
#undef ROCPROFILER_PERFETTO_BUFFER_TRACING_CATEGORY
#undef ROCPROFILER_PERFETTO_CALLBACK_TRACING_CATEGORY
+27
ファイルの表示
@@ -0,0 +1,27 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
//
#pragma once
#include <rocprofiler-sdk/cxx/serialization/load.hpp>
#include <rocprofiler-sdk/cxx/serialization/save.hpp>
@@ -0,0 +1,11 @@
#
#
# Installation of public C++ headers (implementations)
#
#
set(ROCPROFILER_CXX_SERIALIZATION_HEADER_FILES save.hpp load.hpp)
install(
FILES ${ROCPROFILER_CXX_SERIALIZATION_HEADER_FILES}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocprofiler-sdk/cxx/serialization
COMPONENT development)
+380
ファイルの表示
@@ -0,0 +1,380 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
//
#pragma once
#include <rocprofiler-sdk/buffer.h>
#include <rocprofiler-sdk/callback_tracing.h>
#include <rocprofiler-sdk/external_correlation.h>
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/internal_threading.h>
#include <rocprofiler-sdk/rocprofiler.h>
#include <rocprofiler-sdk/cxx/name_info.hpp>
#include <rocprofiler-sdk/cxx/utility.hpp>
#include <cereal/archives/binary.hpp>
#include <cereal/archives/json.hpp>
#include <cereal/archives/portable_binary.hpp>
#include <cereal/cereal.hpp>
#include <cereal/types/array.hpp>
#include <cereal/types/atomic.hpp>
#include <cereal/types/bitset.hpp>
#include <cereal/types/chrono.hpp>
#include <cereal/types/common.hpp>
#include <cereal/types/complex.hpp>
#include <cereal/types/deque.hpp>
#include <cereal/types/functional.hpp>
#include <cereal/types/list.hpp>
#include <cereal/types/map.hpp>
#include <cereal/types/optional.hpp>
#include <cereal/types/queue.hpp>
#include <cereal/types/set.hpp>
#include <cereal/types/stack.hpp>
#include <cereal/types/string.hpp>
#include <cereal/types/unordered_map.hpp>
#include <cereal/types/unordered_set.hpp>
#include <cereal/types/utility.hpp>
#include <cereal/types/variant.hpp>
#include <cereal/types/vector.hpp>
#include <string>
#include <string_view>
#include <type_traits>
#include <utility>
#include <vector>
#if defined(ROCPROFILER_SDK_CXX_SERIALIZATION_LOAD_DEBUG) && \
ROCPROFILER_SDK_CXX_SERIALIZATION_LOAD_DEBUG > 0
# define ROCP_SDK_LOAD_MESSAGE(NAME) \
std::clog << "[" << __PRETTY_FUNCTION__ << "] loading JSON field " << NAME << "...\n" \
<< std::flush
#else
# define ROCP_SDK_LOAD_MESSAGE(NAME)
#endif
#define ROCP_SDK_LOAD_DATA_FIELD(FIELD) \
ROCP_SDK_LOAD_MESSAGE(#FIELD); \
ar(make_nvp(#FIELD, data.FIELD))
#define ROCP_SDK_LOAD_DATA_VALUE(NAME, VALUE) \
ROCP_SDK_LOAD_MESSAGE(NAME); \
ar(make_nvp(NAME, data.VALUE))
#define ROCP_SDK_LOAD_VALUE(NAME, VALUE) \
ROCP_SDK_LOAD_MESSAGE(NAME); \
ar(make_nvp(NAME, VALUE))
#define ROCP_SDK_LOAD_DATA_CSTR(FIELD) \
{ \
ROCP_SDK_LOAD_MESSAGE(#FIELD); \
auto _val = new std::string{}; \
ar(make_nvp(#FIELD, *_val)); \
data.FIELD = _val->c_str(); \
}
#define ROCP_SDK_LOAD_DATA_BITFIELD(NAME, VALUE) \
{ \
ROCP_SDK_LOAD_MESSAGE(NAME); \
auto _val = data.VALUE; \
ar(make_nvp(NAME, _val)); \
data.VALUE = _val; \
}
#if !defined(ROCPROFILER_SDK_CEREAL_NAMESPACE_BEGIN)
# define ROCPROFILER_SDK_CEREAL_NAMESPACE_BEGIN \
namespace cereal \
{
#endif
#if !defined(ROCPROFILER_SDK_CEREAL_NAMESPACE_END)
# define ROCPROFILER_SDK_CEREAL_NAMESPACE_END } // namespace cereal
#endif
ROCPROFILER_SDK_CEREAL_NAMESPACE_BEGIN
template <typename ArchiveT>
void
load(ArchiveT& ar, rocprofiler_agent_id_t& data)
{
ROCP_SDK_LOAD_DATA_FIELD(handle);
}
template <typename ArchiveT>
void
load(ArchiveT& ar, HsaCacheType& data)
{
ROCP_SDK_LOAD_DATA_BITFIELD("Data", ui32.Data);
ROCP_SDK_LOAD_DATA_BITFIELD("Instruction", ui32.Instruction);
ROCP_SDK_LOAD_DATA_BITFIELD("CPU", ui32.CPU);
ROCP_SDK_LOAD_DATA_BITFIELD("HSACU", ui32.HSACU);
}
template <typename ArchiveT>
void
load(ArchiveT& ar, HSA_LINKPROPERTY& data)
{
ROCP_SDK_LOAD_DATA_BITFIELD("Override", ui32.Override);
ROCP_SDK_LOAD_DATA_BITFIELD("NonCoherent", ui32.NonCoherent);
ROCP_SDK_LOAD_DATA_BITFIELD("NoAtomics32bit", ui32.NoAtomics32bit);
ROCP_SDK_LOAD_DATA_BITFIELD("NoAtomics64bit", ui32.NoAtomics64bit);
ROCP_SDK_LOAD_DATA_BITFIELD("NoPeerToPeerDMA", ui32.NoPeerToPeerDMA);
}
template <typename ArchiveT>
void
load(ArchiveT& ar, HSA_CAPABILITY& data)
{
ROCP_SDK_LOAD_DATA_BITFIELD("HotPluggable", ui32.HotPluggable);
ROCP_SDK_LOAD_DATA_BITFIELD("HSAMMUPresent", ui32.HSAMMUPresent);
ROCP_SDK_LOAD_DATA_BITFIELD("SharedWithGraphics", ui32.SharedWithGraphics);
ROCP_SDK_LOAD_DATA_BITFIELD("QueueSizePowerOfTwo", ui32.QueueSizePowerOfTwo);
ROCP_SDK_LOAD_DATA_BITFIELD("QueueSize32bit", ui32.QueueSize32bit);
ROCP_SDK_LOAD_DATA_BITFIELD("QueueIdleEvent", ui32.QueueIdleEvent);
ROCP_SDK_LOAD_DATA_BITFIELD("VALimit", ui32.VALimit);
ROCP_SDK_LOAD_DATA_BITFIELD("WatchPointsSupported", ui32.WatchPointsSupported);
ROCP_SDK_LOAD_DATA_BITFIELD("WatchPointsTotalBits", ui32.WatchPointsTotalBits);
ROCP_SDK_LOAD_DATA_BITFIELD("DoorbellType", ui32.DoorbellType);
ROCP_SDK_LOAD_DATA_BITFIELD("AQLQueueDoubleMap", ui32.AQLQueueDoubleMap);
ROCP_SDK_LOAD_DATA_BITFIELD("DebugTrapSupported", ui32.DebugTrapSupported);
ROCP_SDK_LOAD_DATA_BITFIELD("WaveLaunchTrapOverrideSupported",
ui32.WaveLaunchTrapOverrideSupported);
ROCP_SDK_LOAD_DATA_BITFIELD("WaveLaunchModeSupported", ui32.WaveLaunchModeSupported);
ROCP_SDK_LOAD_DATA_BITFIELD("PreciseMemoryOperationsSupported",
ui32.PreciseMemoryOperationsSupported);
ROCP_SDK_LOAD_DATA_BITFIELD("DEPRECATED_SRAM_EDCSupport", ui32.DEPRECATED_SRAM_EDCSupport);
ROCP_SDK_LOAD_DATA_BITFIELD("Mem_EDCSupport", ui32.Mem_EDCSupport);
ROCP_SDK_LOAD_DATA_BITFIELD("RASEventNotify", ui32.RASEventNotify);
ROCP_SDK_LOAD_DATA_BITFIELD("ASICRevision", ui32.ASICRevision);
ROCP_SDK_LOAD_DATA_BITFIELD("SRAM_EDCSupport", ui32.SRAM_EDCSupport);
ROCP_SDK_LOAD_DATA_BITFIELD("SVMAPISupported", ui32.SVMAPISupported);
ROCP_SDK_LOAD_DATA_BITFIELD("CoherentHostAccess", ui32.CoherentHostAccess);
ROCP_SDK_LOAD_DATA_BITFIELD("DebugSupportedFirmware", ui32.DebugSupportedFirmware);
}
template <typename ArchiveT>
void
load(ArchiveT& ar, rocprofiler_dim3_t& data)
{
ROCP_SDK_LOAD_DATA_FIELD(x);
ROCP_SDK_LOAD_DATA_FIELD(y);
ROCP_SDK_LOAD_DATA_FIELD(z);
}
template <typename ArchiveT>
void
load(ArchiveT& ar, HSA_MEMORYPROPERTY& data)
{
ROCP_SDK_LOAD_DATA_BITFIELD("HotPluggable", ui32.HotPluggable);
ROCP_SDK_LOAD_DATA_BITFIELD("NonVolatile", ui32.NonVolatile);
}
template <typename ArchiveT>
void
load(ArchiveT& ar, HSA_ENGINE_VERSION& data)
{
ROCP_SDK_LOAD_DATA_BITFIELD("uCodeSDMA", uCodeSDMA);
ROCP_SDK_LOAD_DATA_BITFIELD("uCodeRes", uCodeRes);
}
template <typename ArchiveT>
void
load(ArchiveT& ar, HSA_ENGINE_ID& data)
{
ROCP_SDK_LOAD_DATA_BITFIELD("uCode", ui32.uCode);
ROCP_SDK_LOAD_DATA_BITFIELD("Major", ui32.Major);
ROCP_SDK_LOAD_DATA_BITFIELD("Minor", ui32.Minor);
ROCP_SDK_LOAD_DATA_BITFIELD("Stepping", ui32.Stepping);
}
template <typename ArchiveT>
void
load(ArchiveT& ar, rocprofiler_agent_cache_t& data)
{
ROCP_SDK_LOAD_DATA_FIELD(processor_id_low);
ROCP_SDK_LOAD_DATA_FIELD(size);
ROCP_SDK_LOAD_DATA_FIELD(level);
ROCP_SDK_LOAD_DATA_FIELD(cache_line_size);
ROCP_SDK_LOAD_DATA_FIELD(cache_lines_per_tag);
ROCP_SDK_LOAD_DATA_FIELD(association);
ROCP_SDK_LOAD_DATA_FIELD(latency);
ROCP_SDK_LOAD_DATA_FIELD(type);
}
template <typename ArchiveT>
void
load(ArchiveT& ar, rocprofiler_agent_io_link_t& data)
{
ROCP_SDK_LOAD_DATA_FIELD(type);
ROCP_SDK_LOAD_DATA_FIELD(version_major);
ROCP_SDK_LOAD_DATA_FIELD(version_minor);
ROCP_SDK_LOAD_DATA_FIELD(node_from);
ROCP_SDK_LOAD_DATA_FIELD(node_to);
ROCP_SDK_LOAD_DATA_FIELD(weight);
ROCP_SDK_LOAD_DATA_FIELD(min_latency);
ROCP_SDK_LOAD_DATA_FIELD(max_latency);
ROCP_SDK_LOAD_DATA_FIELD(min_bandwidth);
ROCP_SDK_LOAD_DATA_FIELD(max_bandwidth);
ROCP_SDK_LOAD_DATA_FIELD(recommended_transfer_size);
ROCP_SDK_LOAD_DATA_FIELD(flags);
}
template <typename ArchiveT>
void
load(ArchiveT& ar, rocprofiler_agent_mem_bank_t& data)
{
ROCP_SDK_LOAD_DATA_FIELD(heap_type);
ROCP_SDK_LOAD_DATA_FIELD(flags);
ROCP_SDK_LOAD_DATA_FIELD(width);
ROCP_SDK_LOAD_DATA_FIELD(mem_clk_max);
ROCP_SDK_LOAD_DATA_FIELD(size_in_bytes);
}
template <typename ArchiveT>
void
load(ArchiveT& ar, rocprofiler_agent_v0_t& data)
{
ROCP_SDK_LOAD_DATA_FIELD(size);
ROCP_SDK_LOAD_DATA_FIELD(id);
ROCP_SDK_LOAD_DATA_FIELD(type);
ROCP_SDK_LOAD_DATA_FIELD(cpu_cores_count);
ROCP_SDK_LOAD_DATA_FIELD(simd_count);
ROCP_SDK_LOAD_DATA_FIELD(mem_banks_count);
ROCP_SDK_LOAD_DATA_FIELD(caches_count);
ROCP_SDK_LOAD_DATA_FIELD(io_links_count);
ROCP_SDK_LOAD_DATA_FIELD(cpu_core_id_base);
ROCP_SDK_LOAD_DATA_FIELD(simd_id_base);
ROCP_SDK_LOAD_DATA_FIELD(max_waves_per_simd);
ROCP_SDK_LOAD_DATA_FIELD(lds_size_in_kb);
ROCP_SDK_LOAD_DATA_FIELD(gds_size_in_kb);
ROCP_SDK_LOAD_DATA_FIELD(num_gws);
ROCP_SDK_LOAD_DATA_FIELD(wave_front_size);
ROCP_SDK_LOAD_DATA_FIELD(num_xcc);
ROCP_SDK_LOAD_DATA_FIELD(cu_count);
ROCP_SDK_LOAD_DATA_FIELD(array_count);
ROCP_SDK_LOAD_DATA_FIELD(num_shader_banks);
ROCP_SDK_LOAD_DATA_FIELD(simd_arrays_per_engine);
ROCP_SDK_LOAD_DATA_FIELD(cu_per_simd_array);
ROCP_SDK_LOAD_DATA_FIELD(simd_per_cu);
ROCP_SDK_LOAD_DATA_FIELD(max_slots_scratch_cu);
ROCP_SDK_LOAD_DATA_FIELD(gfx_target_version);
ROCP_SDK_LOAD_DATA_FIELD(vendor_id);
ROCP_SDK_LOAD_DATA_FIELD(device_id);
ROCP_SDK_LOAD_DATA_FIELD(location_id);
ROCP_SDK_LOAD_DATA_FIELD(domain);
ROCP_SDK_LOAD_DATA_FIELD(drm_render_minor);
ROCP_SDK_LOAD_DATA_FIELD(num_sdma_engines);
ROCP_SDK_LOAD_DATA_FIELD(num_sdma_xgmi_engines);
ROCP_SDK_LOAD_DATA_FIELD(num_sdma_queues_per_engine);
ROCP_SDK_LOAD_DATA_FIELD(num_cp_queues);
ROCP_SDK_LOAD_DATA_FIELD(max_engine_clk_ccompute);
ROCP_SDK_LOAD_DATA_FIELD(max_engine_clk_fcompute);
ROCP_SDK_LOAD_DATA_FIELD(sdma_fw_version);
ROCP_SDK_LOAD_DATA_FIELD(fw_version);
ROCP_SDK_LOAD_DATA_FIELD(capability);
ROCP_SDK_LOAD_DATA_FIELD(cu_per_engine);
ROCP_SDK_LOAD_DATA_FIELD(max_waves_per_cu);
ROCP_SDK_LOAD_DATA_FIELD(family_id);
ROCP_SDK_LOAD_DATA_FIELD(workgroup_max_size);
ROCP_SDK_LOAD_DATA_FIELD(grid_max_size);
ROCP_SDK_LOAD_DATA_FIELD(local_mem_size);
ROCP_SDK_LOAD_DATA_FIELD(hive_id);
ROCP_SDK_LOAD_DATA_FIELD(gpu_id);
ROCP_SDK_LOAD_DATA_FIELD(workgroup_max_dim);
ROCP_SDK_LOAD_DATA_FIELD(grid_max_dim);
ROCP_SDK_LOAD_DATA_CSTR(name);
ROCP_SDK_LOAD_DATA_CSTR(vendor_name);
ROCP_SDK_LOAD_DATA_CSTR(product_name);
ROCP_SDK_LOAD_DATA_CSTR(model_name);
ROCP_SDK_LOAD_DATA_FIELD(node_id);
ROCP_SDK_LOAD_DATA_FIELD(logical_node_id);
ROCP_SDK_LOAD_DATA_FIELD(logical_node_type_id);
auto generate = [&](auto name, const auto*& value, auto& size) {
using value_type =
std::remove_const_t<std::remove_pointer_t<std::remove_reference_t<decltype(value)>>>;
auto vec = std::vector<value_type>{};
ar(make_nvp(name, vec));
size = vec.size();
auto* value_m = new value_type[size];
for(uint64_t i = 0; i < size; ++i)
value_m[i] = vec.at(i);
value = value_m;
};
generate("mem_banks", data.mem_banks, data.mem_banks_count);
generate("caches", data.caches, data.caches_count);
generate("io_links", data.io_links, data.io_links_count);
}
template <typename ArchiveT>
void
load(ArchiveT& ar, rocprofiler_address_t& data)
{
ROCP_SDK_LOAD_DATA_FIELD(handle);
}
template <typename ArchiveT>
void
load(ArchiveT& ar, rocprofiler_callback_tracing_code_object_load_data_t& data)
{
ROCP_SDK_LOAD_DATA_FIELD(size);
ROCP_SDK_LOAD_DATA_FIELD(code_object_id);
ROCP_SDK_LOAD_DATA_FIELD(agent_id);
ROCP_SDK_LOAD_DATA_CSTR(uri);
ROCP_SDK_LOAD_DATA_FIELD(load_base);
ROCP_SDK_LOAD_DATA_FIELD(load_size);
ROCP_SDK_LOAD_DATA_FIELD(load_delta);
ROCP_SDK_LOAD_DATA_FIELD(storage_type);
if(data.storage_type == ROCPROFILER_CODE_OBJECT_STORAGE_TYPE_FILE)
{
ROCP_SDK_LOAD_DATA_FIELD(storage_file);
}
else if(data.storage_type == ROCPROFILER_CODE_OBJECT_STORAGE_TYPE_MEMORY)
{
ROCP_SDK_LOAD_DATA_FIELD(memory_base);
ROCP_SDK_LOAD_DATA_FIELD(memory_size);
}
}
template <typename ArchiveT>
void
load(ArchiveT& ar, rocprofiler_callback_tracing_code_object_kernel_symbol_register_data_t& data)
{
ROCP_SDK_LOAD_DATA_FIELD(size);
ROCP_SDK_LOAD_DATA_FIELD(kernel_id);
ROCP_SDK_LOAD_DATA_FIELD(code_object_id);
ROCP_SDK_LOAD_DATA_CSTR(kernel_name);
ROCP_SDK_LOAD_DATA_FIELD(kernel_object);
ROCP_SDK_LOAD_DATA_FIELD(kernarg_segment_size);
ROCP_SDK_LOAD_DATA_FIELD(kernarg_segment_alignment);
ROCP_SDK_LOAD_DATA_FIELD(group_segment_size);
ROCP_SDK_LOAD_DATA_FIELD(private_segment_size);
ROCP_SDK_LOAD_DATA_FIELD(sgpr_count);
ROCP_SDK_LOAD_DATA_FIELD(arch_vgpr_count);
ROCP_SDK_LOAD_DATA_FIELD(accum_vgpr_count);
ROCP_SDK_LOAD_DATA_FIELD(kernel_code_entry_byte_offset);
ROCP_SDK_LOAD_DATA_FIELD(kernel_address);
}
ROCPROFILER_SDK_CEREAL_NAMESPACE_END
#undef ROCP_SDK_LOAD_DATA_FIELD
#undef ROCP_SDK_LOAD_DATA_VALUE
#undef ROCP_SDK_LOAD_DATA_CSTR
#undef ROCP_SDK_LOAD_DATA_BITFIELD
ファイル差分が大きすぎるため表示されません。 差分を読み込み
+52
ファイルの表示
@@ -0,0 +1,52 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
//
#pragma once
#include <cstdint>
#include <iomanip>
#include <sstream>
namespace rocprofiler
{
namespace sdk
{
namespace utility
{
template <typename Tp>
auto
as_hex(Tp val, size_t width = 0)
{
uintptr_t _uintp_val = 0;
if constexpr(std::is_pointer<Tp>::value)
_uintp_val = reinterpret_cast<uintptr_t>(val);
else
_uintp_val = val;
auto ss = std::stringstream{};
ss << "0x" << std::hex << std::setfill('0') << std::setw(width) << _uintp_val;
return ss.str();
}
} // namespace utility
} // namespace sdk
} // namespace rocprofiler
+59
ファイルの表示
@@ -0,0 +1,59 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
//
#pragma once
#include <rocprofiler-sdk/fwd.h>
#include <cstdint>
namespace rocprofiler
{
namespace sdk
{
namespace version
{
/**
* @brief This function extracts the `<major>.<minor>.<patch>` from a single integer which encodes
* this triplet by a factor of `N`. E.g. version 3.2.1 using N=100 is represented by the value of
* 30201; version 3.2.1 using N=1000 is represented by the value of 3002001.
*
* For a given factor `N`, the major version can be extracted by
* dividing the version value by (N * N); the minor version can be extracted via
* computing the modulus of (N * N) and then divided by N; the patch version is simply the modulus
* of N.
*/
template <uint64_t FactorV = 100>
constexpr rocprofiler_version_triplet_t
compute_version_triplet(uint64_t version)
{
constexpr auto factor = FactorV;
return rocprofiler_version_triplet_t{
.major = static_cast<uint32_t>(version / (factor * factor)),
.minor = static_cast<uint32_t>((version % (factor * factor)) / factor),
.patch = static_cast<uint32_t>(version % factor)};
}
} // namespace version
} // namespace sdk
} // namespace rocprofiler
+244
ファイルの表示
@@ -0,0 +1,244 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <stdint.h>
/**
* @defgroup SYMBOL_VERSIONING_GROUP Symbol Versions
*
* @brief The names used for the shared library versioned symbols.
*
* Every function is annotated with one of the version macros defined in this
* section. Each macro specifies a corresponding symbol version string. After
* dynamically loading the shared library with @p dlopen, the address of each
* function can be obtained using @p dlsym with the name of the function and
* its corresponding symbol version string. An error will be reported by @p
* dlvsym if the installed library does not support the version for the
* function specified in this version of the interface.
*
* @{
*/
/**
* @brief The function was introduced in version 0.0 of the interface and has the
* symbol version string of ``"ROCPROFILER_SDK_0.0"``.
*/
#define ROCPROFILER_SDK_VERSION_0_0
/** @} */
/**
* @def ROCPROFILER_SDK_BETA_COMPAT
* @brief rocprofiler-sdk clients (i.e. tool using rocprofiler-sdk) should set this definition to 1
* before including any rocprofiler-sdk header if it wants rocprofiler-sdk to provide preprocessor
* definitions to help with compilation support for tools prior to v1.0.0 release. Note: for v1.0.0
* release, rocprofiler-sdk sets the ppdef to 1 by default. Eventually, rocprofiler-sdk will remove
* defining this value and it will be up to the tools to define this value.
*
* For example in version 0.6.0, there was a function `rocprofiler_create_profile_config` and, prior
* to the 1.0.0 release, this function was renamed to `rocprofiler_create_counter_config`.
* @addtogroup VERSIONING_GROUP
*
* @def ROCPROFILER_SDK_BETA_COMPAT_SUPPORTED
* @brief rocprofiler-sdk will set this preprocessor definition to 1 if it can honor
* ::ROCPROFILER_SDK_BETA_COMPAT set to 1. Once backwards compatibility with the beta
* rocprofiler-sdk can no longer be supported, this will always be set to 0.
* @addtogroup VERSIONING_GROUP
*
* @def ROCPROFILER_SDK_DEPRECATED_WARNINGS
* @brief Set this preprocessor definition to 0 to silent compiler warnings when using features that
* are marked as deprecated. By default, rocprofiler-sdk defines this to equal to 1.
* @addtogroup VERSIONING_GROUP
*
* @def ROCPROFILER_SDK_EXPERIMENTAL_WARNINGS
* @brief Set this preprocessor definition to 1 to enable compiler warnings when using experimental
* features. @see ::ROCPROFILER_SDK_EXPERIMENTAL
* @addtogroup VERSIONING_GROUP
*
* @def ROCPROFILER_SDK_EXPERIMENTAL
* @brief When this attribute is added to a type, object, expression, etc., the developer should be
* aware that the API and/or ABI is subject to change in subsequent releases.
* @addtogroup VERSIONING_GROUP
*
* @def ROCPROFILER_SDK_COMPUTE_VERSION_VALUE
* @param[in] MAX_VERSION_VALUE set to +1 of the maximum value for a given version, e.g. a value of
* 100 means that the max value of the major/minor/patch version is 99
* @param[in] MAJOR_VERSION major version of library (integral)
* @param[in] MINOR_VERSION minor version of library (integral)
* @param[in] PATCH_VERSION patch version of library (integral)
* @brief Helper macro calculating a generate versioning integer for a library
* @addtogroup VERSIONING_GROUP
*
* @def ROCPROFILER_SDK_COMPUTE_VERSION
* @param[in] MAJOR_VERSION major version of library (integral)
* @param[in] MINOR_VERSION minor version of library (integral)
* @param[in] PATCH_VERSION patch version of library (integral)
* @brief Helper macro for users to generate versioning int expected by
* rocprofiler-sdk when the library maintains a major, minor, and patch version numbers
* @addtogroup VERSIONING_GROUP
*/
#if !defined(ROCPROFILER_ATTRIBUTE)
# if defined(_MSC_VER)
# define ROCPROFILER_ATTRIBUTE(...) __declspec(__VA_ARGS__)
# else
# define ROCPROFILER_ATTRIBUTE(...) __attribute__((__VA_ARGS__))
# endif
#endif
#if !defined(ROCPROFILER_PUBLIC_API)
# if defined(_MSC_VER)
# define ROCPROFILER_PUBLIC_API ROCPROFILER_ATTRIBUTE(dllexport)
# else
# define ROCPROFILER_PUBLIC_API ROCPROFILER_ATTRIBUTE(visibility("default"))
# endif
#endif
#if !defined(ROCPROFILER_HIDDEN_API)
# if defined(_MSC_VER)
# define ROCPROFILER_HIDDEN_API
# else
# define ROCPROFILER_HIDDEN_API ROCPROFILER_ATTRIBUTE(visibility("hidden"))
# endif
#endif
#if !defined(ROCPROFILER_EXPORT_DECORATOR)
# define ROCPROFILER_EXPORT_DECORATOR ROCPROFILER_PUBLIC_API
#endif
#if !defined(ROCPROFILER_IMPORT_DECORATOR)
# if defined(_MSC_VER)
# define ROCPROFILER_IMPORT_DECORATOR ROCPROFILER_ATTRIBUTE(dllimport)
# else
# define ROCPROFILER_IMPORT_DECORATOR
# endif
#endif
#define ROCPROFILER_EXPORT ROCPROFILER_EXPORT_DECORATOR
#define ROCPROFILER_IMPORT ROCPROFILER_IMPORT_DECORATOR
#if !defined(ROCPROFILER_API)
# if defined(rocprofiler_EXPORTS)
# define ROCPROFILER_API ROCPROFILER_EXPORT
# else
# define ROCPROFILER_API ROCPROFILER_IMPORT
# endif
#endif
#if defined(__has_attribute)
# if __has_attribute(nonnull)
# define ROCPROFILER_NONNULL(...) __attribute__((nonnull(__VA_ARGS__)))
# else
# define ROCPROFILER_NONNULL(...)
# endif
#else
# if defined(__GNUC__)
# define ROCPROFILER_NONNULL(...) __attribute__((nonnull(__VA_ARGS__)))
# else
# define ROCPROFILER_NONNULL(...)
# endif
#endif
#if __cplusplus >= 201103L // C++11
/* c++11 allows extended initializer lists. */
# define ROCPROFILER_HANDLE_LITERAL(type, value) (type{value})
#elif __STDC_VERSION__ >= 199901L
/* c99 allows compound literals. */
# define ROCPROFILER_HANDLE_LITERAL(type, value) ((type){value})
#else
# define ROCPROFILER_HANDLE_LITERAL(type, value) \
{ \
value \
}
#endif
#ifdef __cplusplus
# define ROCPROFILER_EXTERN_C_INIT extern "C" {
# define ROCPROFILER_EXTERN_C_FINI }
# define ROCPROFILER_CXX_CODE(...) __VA_ARGS__
#else
# define ROCPROFILER_EXTERN_C_INIT
# define ROCPROFILER_EXTERN_C_FINI
# define ROCPROFILER_CXX_CODE(...)
#endif
#if __cplusplus
# define ROCPROFILER_UINT64_C(value) uint64_t(value)
#else
# define ROCPROFILER_UINT64_C(value) UINT64_C(value)
#endif
#if defined(__cplusplus) && __cplusplus >= 201402L
# define ROCPROFILER_SDK_DEPRECATED_MESSAGE(...) [[deprecated(__VA_ARGS__)]]
#elif !defined(__cplusplus) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
# define ROCPROFILER_SDK_DEPRECATED_MESSAGE(...) [[deprecated(__VA_ARGS__)]]
#else
# define ROCPROFILER_SDK_DEPRECATED_MESSAGE(...) ROCPROFILER_ATTRIBUTE(deprecated)
#endif
// TODO(jomadsen): uncomment below code before v1.0.0
#if !defined(ROCPROFILER_SDK_DEPRECATED_WARNINGS)
# define ROCPROFILER_SDK_DEPRECATED_WARNINGS 0
#endif
#if !defined(ROCPROFILER_SDK_EXPERIMENTAL_WARNINGS)
# define ROCPROFILER_SDK_EXPERIMENTAL_WARNINGS 0
#endif
#if defined(ROCPROFILER_SDK_DEPRECATED_WARNINGS) && ROCPROFILER_SDK_DEPRECATED_WARNINGS > 0
# define ROCPROFILER_SDK_DEPRECATED(...) ROCPROFILER_SDK_DEPRECATED_MESSAGE(__VA_ARGS__)
#else
# define ROCPROFILER_SDK_DEPRECATED(...)
#endif
#define ROCPROFILER_SDK_EXPERIMENTAL_MESSAGE \
ROCPROFILER_SDK_DEPRECATED_MESSAGE( \
"Note: this feature has been marked as experimental. Define " \
"ROCPROFILER_SDK_EXPERIMENTAL_WARNINGS=0 to silence this message.")
#if defined(ROCPROFILER_SDK_EXPERIMENTAL_WARNINGS) && ROCPROFILER_SDK_EXPERIMENTAL_WARNINGS > 0
# define ROCPROFILER_SDK_EXPERIMENTAL ROCPROFILER_SDK_EXPERIMENTAL_MESSAGE
#else
# define ROCPROFILER_SDK_EXPERIMENTAL
#endif
//
// if ROCPROFILER_SDK_BETA_COMPAT is > 0, provide some macros to help with compatibility.
// For 1.0.0 release, we define this by default
//
#if !defined(ROCPROFILER_SDK_BETA_COMPAT)
# define ROCPROFILER_SDK_BETA_COMPAT 1
#endif
// rocprofiler-sdk will set ROCPROFILER_SDK_BETA_COMPAT_SUPPORTED to 1 if it can support
// compatibility with rocprofiler-sdk < v1.0.0
#if defined(ROCPROFILER_SDK_BETA_COMPAT) && ROCPROFILER_SDK_BETA_COMPAT > 0
# define ROCPROFILER_SDK_BETA_COMPAT_SUPPORTED 1
#endif
#define ROCPROFILER_SDK_COMPUTE_VERSION_VALUE(MAX_VERSION_VALUE, MAJOR, MINOR, PATCH) \
(((MAX_VERSION_VALUE * MAX_VERSION_VALUE) * MAJOR) + (MAX_VERSION_VALUE * MINOR) + (PATCH))
#define ROCPROFILER_SDK_COMPUTE_VERSION(MAJOR, MINOR, PATCH) \
ROCPROFILER_SDK_COMPUTE_VERSION_VALUE(100, MAJOR, MINOR, PATCH)
+31
ファイルの表示
@@ -0,0 +1,31 @@
# MIT License
#
# Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# 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.
#
# headers containing deprecated functions, types, etc.
#
set(ROCPROFILER_DEPRECATED_HEADER_FILES counters.h profile_config.h)
install(
FILES ${ROCPROFILER_DEPRECATED_HEADER_FILES}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocprofiler-sdk/deprecated
COMPONENT development)
+86
ファイルの表示
@@ -0,0 +1,86 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/agent.h>
#include <rocprofiler-sdk/defines.h>
#include <rocprofiler-sdk/fwd.h>
ROCPROFILER_EXTERN_C_INIT
/**
* @brief (deprecated) Callback that gives a list of available dimensions for a counter
*
* @param [in] id Counter id the dimension data is for
* @param [in] dim_info An array of dimensions for the counter
* ::rocprofiler_iterate_counter_dimensions was called on.
* @param [in] num_dims Number of dimensions
* @param [in] user_data User data supplied by
* ::rocprofiler_iterate_agent_supported_counters
*/
ROCPROFILER_SDK_DEPRECATED(
"Function using this alias has been deprecated. See rocprofiler_iterate_counter_dimensions")
typedef rocprofiler_status_t (*rocprofiler_available_dimensions_cb_t)(
rocprofiler_counter_id_t id,
const rocprofiler_counter_record_dimension_info_t* dim_info,
size_t num_dims,
void* user_data);
/**
* @brief (deprecated) Return information about the dimensions that exists for a specific counter
* and the extent of each dimension.
*
* @param [in] id counter id to query dimension info for.
* @param [in] info_cb Callback to return dimension information for counter
* @param [in] user_data data to pass into the callback
* @return ::rocprofiler_status_t
* @retval ROCPROFILER_STATUS_SUCCESS if dimension exists
* @retval ROCPROFILER_STATUS_ERROR_COUNTER_NOT_FOUND if counter is not found
* @retval ROCPROFILER_STATUS_ERROR_DIM_NOT_FOUND if counter does not have this dimension
*/
ROCPROFILER_SDK_DEPRECATED("Information now available in rocprofiler_counter_info_v1_t. "
"This function will be removed in the future.")
rocprofiler_status_t
rocprofiler_iterate_counter_dimensions(rocprofiler_counter_id_t id,
rocprofiler_available_dimensions_cb_t info_cb,
void* user_data) ROCPROFILER_API;
/**
* @brief (deprecated) This call returns the number of instances specific counter contains.
*
* @param [in] agent_id rocprofiler agent identifier
* @param [in] counter_id counter id (obtained from iterate_agent_supported_counters)
* @param [out] instance_count number of instances the counter has
* @return ::rocprofiler_status_t
* @retval ROCPROFILER_STATUS_SUCCESS if counter found
* @retval ROCPROFILER_STATUS_ERROR_COUNTER_NOT_FOUND if counter not found
*/
ROCPROFILER_SDK_DEPRECATED("Information now available in rocprofiler_counter_info_v1_t. "
"This function will be removed in the future.")
rocprofiler_status_t
rocprofiler_query_counter_instance_count(rocprofiler_agent_id_t agent_id,
rocprofiler_counter_id_t counter_id,
size_t* instance_count) ROCPROFILER_API
ROCPROFILER_NONNULL(3);
ROCPROFILER_EXTERN_C_FINI
+56
ファイルの表示
@@ -0,0 +1,56 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/counter_config.h>
#include <rocprofiler-sdk/defines.h>
#include <rocprofiler-sdk/fwd.h>
ROCPROFILER_EXTERN_C_INIT
/**
* @brief (deprecated) Replaced by ::rocprofiler_create_counter_config.
*
*/
ROCPROFILER_SDK_DEPRECATED("profile_config renamed to counter_config")
static inline rocprofiler_status_t
rocprofiler_create_profile_config(rocprofiler_agent_id_t agent_id,
rocprofiler_counter_id_t* counters_list,
size_t counters_count,
rocprofiler_profile_config_id_t* config_id)
{
return rocprofiler_create_counter_config(agent_id, counters_list, counters_count, config_id);
}
/**
* @brief (deprecated) Replaced by ::rocprofiler_destroy_counter_config.
*
*/
ROCPROFILER_SDK_DEPRECATED("profile_config renamed to counter_config")
static inline rocprofiler_status_t
rocprofiler_destroy_profile_config(rocprofiler_profile_config_id_t config_id)
{
return rocprofiler_destroy_counter_config(config_id);
}
ROCPROFILER_EXTERN_C_FINI
+150
ファイルの表示
@@ -0,0 +1,150 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/defines.h>
#include <rocprofiler-sdk/fwd.h>
ROCPROFILER_EXTERN_C_INIT
/**
* @defgroup device_counting_service Agent Profile Counting Service
* @brief needs brief description
*
* @{
*/
/**
* @brief (experimental) Callback to set the profile config for the agent.
*
* @param [in] context_id context id
* @param [in] config_id Profile config detailing the counters to collect for this kernel
* @return ::rocprofiler_status_t
* @retval ::ROCPROFILER_STATUS_ERROR_PROFILE_NOT_FOUND Returned if the config_id is not found
* @retval ::ROCPROFILER_STATUS_ERROR_CONTEXT_INVALID Returned if the ctx is not valid
* @retval ::ROCPROFILER_STATUS_ERROR_CONFIGURATION_LOCKED Returned if attempting to make this
* call outside of context startup.
* @retval ::ROCPROFILER_STATUS_ERROR_AGENT_MISMATCH Agent of profile does not match agent of the
* context.
* @retval ::ROCPROFILER_STATUS_SUCCESS Returned if succesfully configured
*/
ROCPROFILER_SDK_EXPERIMENTAL
typedef rocprofiler_status_t (*rocprofiler_device_counting_agent_cb_t)(
rocprofiler_context_id_t context_id,
rocprofiler_counter_config_id_t config_id);
/**
* @brief (experimental) Configure Profile Counting Service for agent. Called when the context is
* started. Selects the counters to be used for agent profiling.
*
* @param [in] context_id context id
* @param [in] agent_id agent id
* @param [in] set_config Function to call to set the profile config (see
* rocprofiler_device_counting_agent_cb_t)
* @param [in] user_data Data supplied to rocprofiler_configure_device_counting_service
*/
ROCPROFILER_SDK_EXPERIMENTAL
typedef void (*rocprofiler_device_counting_service_cb_t)(
rocprofiler_context_id_t context_id,
rocprofiler_agent_id_t agent_id,
rocprofiler_device_counting_agent_cb_t set_config,
void* user_data);
/**
* @brief (experimental) Configure Device Counting Service for agent. There may only be one counting
* service configured per agent in a context and can be only one active context that is profiling a
* single agent at a time. Multiple agent contexts can be started at the same time if they are
* profiling different agents.
*
* @param [in] context_id context id
* @param [in] buffer_id id of the buffer to use for the counting service. When
* rocprofiler_sample_device_counting_service is called, counter data will be written
* to this buffer. If the input buffer id is null (i.e. `rocprofiler_buffer_id_t{.handle = 0}`), the
* counter data will not be written to a buffer and will only be returned in the output_records of
* rocprofiler_sample_device_counting_service
* @param [in] agent_id agent to configure profiling on.
* @param [in] cb Callback called when the context is started for the tool to specify what
* counters to collect (rocprofiler_counter_config_id_t).
* @param [in] user_data User supplied data to be passed to the callback cb when triggered
* @return ::rocprofiler_status_t
* @retval ::ROCPROFILER_STATUS_ERROR_CONTEXT_INVALID Returned if the context does not exist.
* @retval ::ROCPROFILER_STATUS_ERROR_BUFFER_NOT_FOUND Returned if the buffer is not found.
* @retval ::ROCPROFILER_STATUS_ERROR_INVALID_ARGUMENT Returned if context already has agent
* profiling configured for agent_id.
* @retval ::ROCPROFILER_STATUS_SUCCESS Returned if succesfully configured
*/
ROCPROFILER_SDK_EXPERIMENTAL
rocprofiler_status_t
rocprofiler_configure_device_counting_service(rocprofiler_context_id_t context_id,
rocprofiler_buffer_id_t buffer_id,
rocprofiler_agent_id_t agent_id,
rocprofiler_device_counting_service_cb_t cb,
void* user_data)
ROCPROFILER_NONNULL(4) ROCPROFILER_API;
/**
* @brief (experimental) Trigger a read of the counter data for the agent profile. The counter data
* will be written to the buffer specified in rocprofiler_configure_device_counting_service. The
* data in rocprofiler_user_data_t will be written to the buffer along with the counter data. flags
* can be used to specify if this call should be performed asynchronously (default is synchronous).
*
* @param [in] context_id context id
* @param [in] user_data User supplied data, included in records outputted to buffer.
* @param [in] flags Flags to specify how the counter data should be collected (defaults to sync).
* @param [in] output_records (Optional) Provides the values immediately instead of outputting to
* buffer. Must be allocated by caller.
* @param [in] rec_count (Optional) On entry, this is the maximum number of records rocprof can
* store in output_records. On exit, contains the number of actual records.
* @return ::rocprofiler_status_t
* @retval ::ROCPROFILER_STATUS_ERROR_CONTEXT_INVALID Returned if the context does not exist or
* the context is not configured for agent profiling.
* @retval ::ROCPROFILER_STATUS_ERROR_CONTEXT_ERROR Returned if another operation is in progress (
* start/stop ctx or another read).
* @retval ::ROCPROFILER_STATUS_ERROR Returned if HSA has not been initialized yet.
* @retval ::ROCPROFILER_STATUS_ERROR_OUT_OF_RESOURCES Returned output_records is set but size is
* too small to store results
* @retval ::ROCPROFILER_STATUS_SUCCESS Returned if read request was successful.
* @retval ::ROCPROFILER_STATUS_ERROR_INVALID_ARGUMENT Returned If ASYNC is being used while
* output_records is not null.
*/
ROCPROFILER_SDK_EXPERIMENTAL
rocprofiler_status_t
rocprofiler_sample_device_counting_service(rocprofiler_context_id_t context_id,
rocprofiler_user_data_t user_data,
rocprofiler_counter_flag_t flags,
rocprofiler_counter_record_t* output_records,
size_t* rec_count) ROCPROFILER_API;
#if defined(ROCPROFILER_SDK_BETA_COMPAT) && ROCPROFILER_SDK_BETA_COMPAT > 0
// "rocprofiler_agent_set_profile_callback_t" renamed to
// "rocprofiler_device_counting_agent_cb_t"
ROCPROFILER_SDK_DEPRECATED(
"rocprofiler_agent_set_profile_callback_t renamed to rocprofiler_device_counting_agent_cb_t")
typedef rocprofiler_device_counting_agent_cb_t rocprofiler_agent_set_profile_callback_t;
#endif
/** @} */
ROCPROFILER_EXTERN_C_FINI
+164
ファイルの表示
@@ -0,0 +1,164 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/agent.h>
#include <rocprofiler-sdk/counter_config.h>
#include <rocprofiler-sdk/defines.h>
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/hsa.h>
ROCPROFILER_EXTERN_C_INIT
/**
* @defgroup dispatch_counting_service Dispatch Profile Counting Service
* @brief Per-dispatch hardware counter collection service
*
* @{
*/
/**
* @brief (experimental) Kernel dispatch data for profile counting callbacks.
*
*/
typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_dispatch_counting_service_data_t
{
uint64_t size; ///< Size of this struct
rocprofiler_async_correlation_id_t correlation_id; ///< Correlation ID for this dispatch
rocprofiler_timestamp_t start_timestamp; ///< start time in nanoseconds
rocprofiler_timestamp_t end_timestamp; ///< end time in nanoseconds
rocprofiler_kernel_dispatch_info_t dispatch_info; ///< Dispatch info
} rocprofiler_dispatch_counting_service_data_t;
/**
* @brief (experimental) ROCProfiler Profile Counting Counter Record Header Information
*
* This is buffer equivalent of ::rocprofiler_dispatch_counting_service_data_t
*/
typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_dispatch_counting_service_record_t
{
uint64_t size; ///< Size of this struct
uint64_t num_records; ///< number of ::rocprofiler_counter_record_t records
rocprofiler_async_correlation_id_t correlation_id; ///< Correlation ID for this dispatch
rocprofiler_timestamp_t start_timestamp; ///< start time in nanoseconds
rocprofiler_timestamp_t end_timestamp; ///< end time in nanoseconds
rocprofiler_kernel_dispatch_info_t dispatch_info; ///< Contains the `dispatch_id`
} rocprofiler_dispatch_counting_service_record_t;
/**
* @brief (experimental) Kernel Dispatch Callback. This is a callback that is invoked before the
* kernel is enqueued into the HSA queue. What counters to collect for a kernel are set via passing
* back a profile config (config) in this callback. These counters will be collected and emplaced in
* the buffer with ::rocprofiler_buffer_id_t used when setting up this callback.
*
* @param [in] dispatch_data @see ::rocprofiler_dispatch_counting_service_data_t
* @param [out] config Profile config detailing the counters to collect for this kernel
* @param [out] user_data User data unique to this dispatch. Returned in record callback
* @param [in] callback_data_args Callback supplied via buffered_dispatch_counting_service
*/
ROCPROFILER_SDK_EXPERIMENTAL
typedef void (*rocprofiler_dispatch_counting_service_cb_t)(
rocprofiler_dispatch_counting_service_data_t dispatch_data,
rocprofiler_counter_config_id_t* config,
rocprofiler_user_data_t* user_data,
void* callback_data_args);
/**
* @brief (experimental) Counting record callback. This is a callback is invoked when the kernel
* execution is complete and contains the counter profile data requested in
* ::rocprofiler_dispatch_counting_service_cb_t. Only used with
* ::rocprofiler_configure_callback_dispatch_counting_service.
*
* @param [in] dispatch_data @see ::rocprofiler_dispatch_counting_service_data_t
* @param [in] record_data Counter record data.
* @param [in] record_count Number of counter records.
* @param [in] user_data User data instance from dispatch callback
* @param [in] callback_data_args Callback supplied via buffered_dispatch_counting_service
*/
ROCPROFILER_SDK_EXPERIMENTAL
typedef void (*rocprofiler_dispatch_counting_record_cb_t)(
rocprofiler_dispatch_counting_service_data_t dispatch_data,
rocprofiler_counter_record_t* record_data,
size_t record_count,
rocprofiler_user_data_t user_data,
void* callback_data_args);
/**
* @brief (experimental) Configure buffered dispatch profile Counting Service.
* Collects the counters in dispatch packets and stores them
* in a buffer with @p buffer_id. The buffer may contain packets from more than
* one dispatch (denoted by correlation id). Will trigger the
* callback based on the parameters setup in buffer_id_t.
*
* NOTE: Interface is up for comment as to whether restrictions
* on agent should be made here (limiting the CB based on agent)
* or if the restriction should be performed by the tool in
* ::rocprofiler_dispatch_counting_service_cb_t (i.e.
* tool code checking the agent param to see if they want to profile
* it).
*
* Interface is up for comment as to whether restrictions
* on agent should be made here (limiting the CB based on agent)
* or if the restriction should be performed by the tool in
* ::rocprofiler_dispatch_counting_service_cb_t (i.e.
* tool code checking the agent param to see if they want to profile
* it).
*
* @param [in] context_id context id
* @param [in] buffer_id id of the buffer to use for the counting service
* @param [in] callback callback to perform when dispatch is enqueued
* @param [in] callback_data_args callback data
* @return ::rocprofiler_status_t
*/
ROCPROFILER_SDK_EXPERIMENTAL
rocprofiler_status_t
rocprofiler_configure_buffer_dispatch_counting_service(
rocprofiler_context_id_t context_id,
rocprofiler_buffer_id_t buffer_id,
rocprofiler_dispatch_counting_service_cb_t callback,
void* callback_data_args) ROCPROFILER_API;
/**
* @brief (experimental) Configure buffered dispatch profile Counting Service.
* Collects the counters in dispatch packets and calls a callback
* with the counters collected during that dispatch.
*
* @param [in] context_id context id
* @param [in] dispatch_callback callback to perform when dispatch is enqueued
* @param [in] dispatch_callback_args callback data for dispatch callback
* @param [in] record_callback Record callback for completed profile data
* @param [in] record_callback_args Callback args for record callback
* @return ::rocprofiler_status_t
*/
ROCPROFILER_SDK_EXPERIMENTAL
rocprofiler_status_t
rocprofiler_configure_callback_dispatch_counting_service(
rocprofiler_context_id_t context_id,
rocprofiler_dispatch_counting_service_cb_t dispatch_callback,
void* dispatch_callback_args,
rocprofiler_dispatch_counting_record_cb_t record_callback,
void* record_callback_args) ROCPROFILER_API;
/** @} */
ROCPROFILER_EXTERN_C_FINI
@@ -0,0 +1,8 @@
set(ROCPROFILER_EXPERIMENTAL_HEADER_FILES counters.h thread_trace.h)
install(
FILES ${ROCPROFILER_EXPERIMENTAL_HEADER_FILES}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocprofiler-sdk/experimental
COMPONENT development)
add_subdirectory(thread-trace)
+49
ファイルの表示
@@ -0,0 +1,49 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/agent.h>
#include <rocprofiler-sdk/defines.h>
#include <rocprofiler-sdk/fwd.h>
ROCPROFILER_EXTERN_C_INIT
/**
* @brief (experimental) Apply a custom counter definition (YAML). This function must be called
* before counter iteration functions like ::rocprofiler_iterate_agent_supported_counters if
* custom counter definitions are to be used. This function will return an error if the definition
* has already been loaded.
* @param [in] yaml YAML string containing counter definitions
* @param [in] size Size of the YAML string
* @param [in] flags Flags to apply to the counter definition
* @return ::rocprofiler_status_t
* @retval ROCPROFILER_STATUS_SUCCESS if counter definition applied
* @retval ROCPROFILER_STATUS_ERROR if counter definition already loaded
*/
ROCPROFILER_SDK_EXPERIMENTAL
rocprofiler_status_t
rocprofiler_load_counter_definition(const char* yaml,
size_t size,
rocprofiler_counter_flag_t flags) ROCPROFILER_API;
ROCPROFILER_EXTERN_C_FINI
@@ -0,0 +1,7 @@
set(ROCPROFILER_EXPERIMENTAL_THREAD_TRACE_HEADER_FILES
core.h agent.h dispatch.h trace_decoder_types.h trace_decoder.h)
install(
FILES ${ROCPROFILER_EXPERIMENTAL_THREAD_TRACE_HEADER_FILES}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocprofiler-sdk/experimental/thread-trace
COMPONENT development)
@@ -0,0 +1,71 @@
// MIT License
//
// Copyright (c) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/agent.h>
#include <rocprofiler-sdk/defines.h>
#include <rocprofiler-sdk/experimental/thread-trace/core.h>
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/hsa.h>
ROCPROFILER_EXTERN_C_INIT
/**
* @defgroup THREAD_TRACE Thread Trace Service
* @brief Provides API calls to enable and handle thread trace data
*
* @{
*/
/**
* @brief Configure Thread Trace Service for agent. There may only be one agent profile
* configured per context and can be only one active context that is profiling a single agent
* at a time. Multiple agent contexts can be started at the same time if they are profiling
* different agents.
*
* @param [in] context_id context id
* @param [in] parameters List of ATT-specific parameters.
* @param [in] num_parameters Number of parameters. Zero is allowed.
* @param [in] agent_id agent to configure profiling on.
* @param [in] shader_callback Callback fn where the collected data will be sent to.
* @param [in] callback_userdata Passed back to user in shader_callback.
* @return ::rocprofiler_status_t
* @retval ROCPROFILER_STATUS_SUCCESS on success
* @retval ROCPROFILER_STATUS_ERROR_CONFIGURATION_LOCKED for configuration locked
* @retval ROCPROFILER_STATUS_ERROR_CONTEXT_INVALID for conflicting configurations in the same ctx
* @retval ROCPROFILER_STATUS_ERROR_CONTEXT_NOT_FOUND for invalid context id
* @retval ROCPROFILER_STATUS_ERROR_INVALID_ARGUMENT for invalid
* rocprofiler_thread_trace_parameter_t
*/
rocprofiler_status_t
rocprofiler_configure_device_thread_trace_service(
rocprofiler_context_id_t context_id,
rocprofiler_agent_id_t agent_id,
rocprofiler_thread_trace_parameter_t* parameters,
size_t num_parameters,
rocprofiler_thread_trace_shader_data_callback_t shader_callback,
rocprofiler_user_data_t callback_userdata) ROCPROFILER_API;
/** @} */
ROCPROFILER_EXTERN_C_FINI
@@ -0,0 +1,90 @@
// MIT License
//
// Copyright (c) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/agent.h>
#include <rocprofiler-sdk/defines.h>
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/hsa.h>
ROCPROFILER_EXTERN_C_INIT
/**
* @defgroup THREAD_TRACE Thread Trace Service
* @brief Provides API calls to enable and handle thread trace data
*
* @{
*/
/**
* @brief Types of Thread Trace parameters
*
*/
typedef enum rocprofiler_thread_trace_parameter_type_t
{
ROCPROFILER_THREAD_TRACE_PARAMETER_TARGET_CU = 0, ///< Select the Target CU or WGP
ROCPROFILER_THREAD_TRACE_PARAMETER_SHADER_ENGINE_MASK, ///< Bitmask of shader engines.
ROCPROFILER_THREAD_TRACE_PARAMETER_BUFFER_SIZE, ///< Size of combined GPU buffer for ATT
ROCPROFILER_THREAD_TRACE_PARAMETER_SIMD_SELECT, ///< Bitmask (GFX9) or ID (Navi) of SIMDs
ROCPROFILER_THREAD_TRACE_PARAMETER_PERFCOUNTERS_CTRL, ///< Period [1,32] or disable (0) perfmon
ROCPROFILER_THREAD_TRACE_PARAMETER_PERFCOUNTER, ///< Perfmon ID and SIMD mask
ROCPROFILER_THREAD_TRACE_PARAMETER_SERIALIZE_ALL, ///< Serializes kernels not under thread
///< trace
ROCPROFILER_THREAD_TRACE_PARAMETER_LAST
} rocprofiler_thread_trace_parameter_type_t;
/**
* @brief Thread Trace parameter specification
*
*/
typedef struct rocprofiler_thread_trace_parameter_t
{
rocprofiler_thread_trace_parameter_type_t type;
union
{
uint64_t value;
struct
{
rocprofiler_counter_id_t counter_id;
uint64_t simd_mask : 4;
};
};
} rocprofiler_thread_trace_parameter_t;
/**
* @brief Callback to be triggered every time some ATT data is generated by the device
* @param [in] agent Identifier for the target agent (@see ::rocprofiler_agent_id_t)
* @param [in] shader_engine_id ID of shader engine, as enabled by SE_MASK
* @param [in] data Pointer to the buffer containing the ATT data
* @param [in] data_size Number of bytes in "data"
* @param [in] userdata Passed back to user from rocprofiler_thread_trace_dispatch_callback_t()
*/
typedef void (*rocprofiler_thread_trace_shader_data_callback_t)(rocprofiler_agent_id_t agent,
int64_t shader_engine_id,
void* data,
size_t data_size,
rocprofiler_user_data_t userdata);
/** @} */
ROCPROFILER_EXTERN_C_FINI
@@ -0,0 +1,98 @@
// MIT License
//
// Copyright (c) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/agent.h>
#include <rocprofiler-sdk/defines.h>
#include <rocprofiler-sdk/experimental/thread-trace/core.h>
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/hsa.h>
ROCPROFILER_EXTERN_C_INIT
/**
* @defgroup THREAD_TRACE Thread Trace Service
* @brief Provides API calls to enable and handle thread trace data
*
* @{
*/
typedef enum rocprofiler_thread_trace_control_flags_t
{
ROCPROFILER_THREAD_TRACE_CONTROL_NONE = 0,
ROCPROFILER_THREAD_TRACE_CONTROL_START_AND_STOP = 3
} rocprofiler_thread_trace_control_flags_t;
/**
* @brief Callback to be triggered every kernel dispatch, indicating to start and/or stop ATT
* @param [in] agent_id agent_id.
* @param [in] queue_id queue_id.
* @param [in] correlation_id internal correlation id.
* @param [in] kernel_id kernel_id.
* @param [in] dispatch_id dispatch_id.
* @param [in] userdata_config Userdata passed back from
* rocprofiler_configure_dispatch_thread_trace_service.
* @param [out] userdata_shader Userdata to be passed in shader_callback
*/
typedef rocprofiler_thread_trace_control_flags_t (*rocprofiler_thread_trace_dispatch_callback_t)(
rocprofiler_agent_id_t agent_id,
rocprofiler_queue_id_t queue_id,
rocprofiler_async_correlation_id_t correlation_id,
rocprofiler_kernel_id_t kernel_id,
rocprofiler_dispatch_id_t dispatch_id,
void* userdata_config,
rocprofiler_user_data_t* userdata_shader);
/**
* @brief Enables the thread trace service for dispatch-based tracing.
* The tool has an option to enable/disable thread trace on every dispatch callback.
* This service serializes all traced kernels, and optionally all non-traced kernels.
* @param [in] context_id id of the context used for start/stop thread_trace.
* @param [in] agent_id rocprofiler_agent_id_t to configure thread trace.
* @param [in] parameters List of ATT-specific parameters.
* @param [in] num_parameters Number of parameters. Zero is allowed.
* @param [in] dispatch_callback Control fn which decides when TT starts/stop collecting.
* @param [in] shader_callback Callback fn where the collected data will be sent to.
* @param [in] callback_userdata Passed back to user in dispatch_callback.
* @return ::rocprofiler_status_t
* @retval ROCPROFILER_STATUS_SUCCESS on success
* @retval ROCPROFILER_STATUS_ERROR_CONFIGURATION_LOCKED for configuration locked
* @retval ROCPROFILER_STATUS_ERROR_CONTEXT_INVALID for conflicting configurations in the same ctx
* @retval ROCPROFILER_STATUS_ERROR_CONTEXT_NOT_FOUND for invalid context id
* @retval ROCPROFILER_STATUS_ERROR_INVALID_ARGUMENT for invalid
* rocprofiler_thread_trace_parameter_t
* @retval ROCPROFILER_STATUS_ERROR_SERVICE_ALREADY_CONFIGURED if already configured
*/
rocprofiler_status_t
rocprofiler_configure_dispatch_thread_trace_service(
rocprofiler_context_id_t context_id,
rocprofiler_agent_id_t agent_id,
rocprofiler_thread_trace_parameter_t* parameters,
size_t num_parameters,
rocprofiler_thread_trace_dispatch_callback_t dispatch_callback,
rocprofiler_thread_trace_shader_data_callback_t shader_callback,
void* callback_userdata) ROCPROFILER_API;
/** @} */
ROCPROFILER_EXTERN_C_FINI
@@ -0,0 +1,157 @@
// MIT License
//
// Copyright (c) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/experimental/thread-trace/trace_decoder_types.h>
#include <rocprofiler-sdk/fwd.h>
ROCPROFILER_EXTERN_C_INIT
/**
* @defgroup THREAD_TRACE Thread Trace Service
* @brief ROCprof-trace-decoder wrapper. Provides API calls to decode thread trace shader data.
* @{
*/
/**
* @brief Handle containing a loaded rocprof-trace-decoder and a decoder state.
*/
typedef struct rocprofiler_thread_trace_decoder_handle_t
{
uint64_t handle;
} rocprofiler_thread_trace_decoder_handle_t;
/**
* @brief Initializes Trace Decoder library with a library search path
* @param[out] handle Handle to created decoder instance.
* @param[in] path Path to trace decoder library location (e.g. /opt/rocm/lib).
* @return ::rocprofiler_status_t
* @retval ::ROCPROFILER_STATUS_ERROR_NOT_AVAILABLE Library not found
* @retval ::ROCPROFILER_STATUS_ERROR_INCOMPATIBLE_ABI Library found but version not supported
* @retval ::ROCPROFILER_STATUS_SUCCESS Handle created
*/
rocprofiler_status_t
rocprofiler_thread_trace_decoder_create(rocprofiler_thread_trace_decoder_handle_t* handle,
const char* path) ROCPROFILER_API ROCPROFILER_NONNULL(1, 2);
/**
* @brief Deletes handle created by ::rocprofiler_thread_trace_decoder_create
* @param[in] handle Handle to destroy
*/
void
rocprofiler_thread_trace_decoder_destroy(rocprofiler_thread_trace_decoder_handle_t handle)
ROCPROFILER_API;
/**
* @brief Loads a code object binary to match with Thread Trace.
* The size, data and load_* are reported by rocprofiler-sdk's code object tracing service.
* Used for the decoder library to know what code objects to look into when decoding shader data.
* Not all application code objects are required to be reported here, only the ones containing code
* executed at the time the shader data was collected by thread_trace services.
* If a code object not reported here is encountered while decoding shader data, a record of type
* INFO_STITCH_INCOMPLETE will be generated and instructions will not be reported with a PC address.
*
* @param[in] handle Handle to decoder instance.
* @param[in] load_id Code object load ID.
* @param[in] load_addr Code object load address.
* @param[in] load_size Code object load size.
* @param[in] data Code object binary data.
* @param[in] size Code object binary data size.
* @return ::rocprofiler_status_t
* @retval ::ROCPROFILER_STATUS_ERROR Unable to load code object.
* @retval ::ROCPROFILER_STATUS_ERROR_INVALID_ARGUMENT Invalid handle
* @retval ::ROCPROFILER_STATUS_SUCCESS Code object loaded
*/
rocprofiler_status_t
rocprofiler_thread_trace_decoder_codeobj_load(rocprofiler_thread_trace_decoder_handle_t handle,
uint64_t load_id,
uint64_t load_addr,
uint64_t load_size,
const void* data,
uint64_t size) ROCPROFILER_API ROCPROFILER_NONNULL(5);
/**
* @brief Unloads a code object binary.
* @param[in] handle Handle to decoder instance.
* @param[in] load_id Code object load ID to remove.
* @return ::rocprofiler_status_t
* @retval ::ROCPROFILER_STATUS_ERROR Code object not loaded.
* @retval ::ROCPROFILER_STATUS_ERROR_INVALID_ARGUMENT Invalid handle
* @retval ::ROCPROFILER_STATUS_SUCCESS Code object unloaded
*/
rocprofiler_status_t
rocprofiler_thread_trace_decoder_codeobj_unload(rocprofiler_thread_trace_decoder_handle_t handle,
uint64_t load_id) ROCPROFILER_API;
/**
* @brief Callback for rocprof-trace-decoder to return decoder traces back to user.
* @param[in] record_type_id One of ::rocprofiler_thread_trace_decoder_record_type_t
* @param[in] trace_events A pointer to sequence of events, of size trace_size.
* @param[in] trace_size The number of events in the trace.
* @param[in] userdata Arbitrary data pointer to be sent back to the user via callback.
*/
typedef void (*rocprofiler_thread_trace_decoder_callback_t)(
rocprofiler_thread_trace_decoder_record_type_t record_type_id,
void* trace_events,
uint64_t trace_size,
void* userdata);
/**
* @brief Decodes shader data returned by ::rocprofiler_thread_trace_shader_data_callback_t.
* Use ::rocprofiler_thread_trace_decoder_codeobj_load to add references to loaded code objects
* during the trace.
* A ::rocprofiler_thread_trace_decoder_callback_t returns decoded data back to user. The first
* record is always of type ::ROCPROFILER_THREAD_TRACE_DECODER_RECORD_GFXIP.
*
* @param[in] handle Decoder handle
* @param[in] callback Decoded trace data returned to user.
* @param[in] data Thread trace binary data.
* @param[in] size Thread trace binary size.
* @param[in] userdata Userdata passed back to caller via callback.
* @return ::rocprofiler_status_t
* @retval ::ROCPROFILER_STATUS_ERROR_INVALID_ARGUMENT invalid argument
* @retval ::ROCPROFILER_STATUS_ERROR_AGENT_ARCH_NOT_SUPPORTED arch not supported
* @retval ::ROCPROFILER_STATUS_ERROR generic error
* @retval ::ROCPROFILER_STATUS_SUCCESS on success
*/
rocprofiler_status_t
rocprofiler_trace_decode(rocprofiler_thread_trace_decoder_handle_t handle,
rocprofiler_thread_trace_decoder_callback_t callback,
void* data,
uint64_t size,
void* userdata) ROCPROFILER_API ROCPROFILER_NONNULL(2, 3);
/**
* @brief Returns the string description of a ::rocprofiler_thread_trace_decoder_info_t record.
* @param[in] handle Decoder handle
* @param[in] info The decoder info received
* @retval null terminated string as description of "info".
*/
const char*
rocprofiler_thread_trace_decoder_info_string(rocprofiler_thread_trace_decoder_handle_t handle,
rocprofiler_thread_trace_decoder_info_t info)
ROCPROFILER_API;
/** @} */
ROCPROFILER_EXTERN_C_FINI
@@ -0,0 +1,185 @@
// MIT License
//
// Copyright (c) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <stddef.h>
#include <stdint.h>
/**
* @defgroup THREAD_TRACE Thread Trace Service
* @brief ROCprof-trace-decoder defined types. All timestamp values are in shader clock units.
*
* @{
*/
/**
* @brief Describes the type of info received.
*/
typedef enum rocprofiler_thread_trace_decoder_info_t
{
ROCPROFILER_THREAD_TRACE_DECODER_INFO_NONE = 0,
ROCPROFILER_THREAD_TRACE_DECODER_INFO_DATA_LOST,
ROCPROFILER_THREAD_TRACE_DECODER_INFO_STITCH_INCOMPLETE,
ROCPROFILER_THREAD_TRACE_DECODER_INFO_LAST
} rocprofiler_thread_trace_decoder_info_t;
/**
* @brief Describes a PC address.
*/
typedef struct rocprofiler_thread_trace_decoder_pc_t
{
size_t addr; ///< Memory address (marker_id == 0), or ELF vaddr (marker_id != 0).
size_t marker_id; ///< Code object load ID. Zero if no code object was found.
} rocprofiler_thread_trace_decoder_pc_t;
/**
* @brief Describes four performance counter values.
*/
typedef struct rocprofiler_thread_trace_decoder_perfevent_t
{
int64_t time; ///< Shader clock timestamp in which these counters were read.
uint16_t events0; ///< Counter0 (bank==0) or Counter4 (bank==1).
uint16_t events1; ///< Counter1 (bank==0) or Counter5 (bank==1).
uint16_t events2; ///< Counter2 (bank==0) or Counter6 (bank==1).
uint16_t events3; ///< Counter3 (bank==0) or Counter7 (bank==1).
uint8_t CU; ///< Shader compute unit ID these counters were collected from.
uint8_t bank; ///< Selects counter group [0,3] or [4,7]
} rocprofiler_thread_trace_decoder_perfevent_t;
/**
* @brief Describes an occupancy event (wave started or wave ended).
*/
typedef struct rocprofiler_thread_trace_decoder_occupancy_t
{
rocprofiler_thread_trace_decoder_pc_t pc; ///< Wave start address (kernel entry point)
uint64_t time; ///< Timestamp of event
uint8_t reserved; ///< Reserved
uint8_t cu; ///< Compute unit ID (gfx9) or WGP ID (gfx10+).
uint8_t simd; ///< SIMD ID [0,3] within compute unit
uint8_t slot; ///< Wave slot ID within SIMD
uint32_t start : 1; ///< 1 if wave_start, 0 if a wave_end
uint32_t _rsvd : 31;
} rocprofiler_thread_trace_decoder_occupancy_t;
/**
* @brief Wave state type.
*/
typedef enum rocprofiler_thread_trace_decoder_wstate_type_t
{
ROCPROFILER_THREAD_TRACE_DECODER_WSTATE_EMPTY = 0,
ROCPROFILER_THREAD_TRACE_DECODER_WSTATE_IDLE,
ROCPROFILER_THREAD_TRACE_DECODER_WSTATE_EXEC,
ROCPROFILER_THREAD_TRACE_DECODER_WSTATE_WAIT,
ROCPROFILER_THREAD_TRACE_DECODER_WSTATE_STALL,
ROCPROFILER_THREAD_TRACE_DECODER_WSTATE_LAST,
} rocprofiler_thread_trace_decoder_wstate_type_t;
/**
* @brief A wave state change event.
*/
typedef struct rocprofiler_thread_trace_decoder_wave_state_t
{
int32_t type; ///< one of rocprofiler_thread_trace_decoder_waveslot_state_type_t
int32_t duration; ///< state duration in cycles
} rocprofiler_thread_trace_decoder_wave_state_t;
/**
* @brief Instruction type.
*/
typedef enum rocprofiler_thread_trace_decoder_inst_category_t
{
ROCPROFILER_THREAD_TRACE_DECODER_INST_NONE = 0,
ROCPROFILER_THREAD_TRACE_DECODER_INST_SMEM, ///< Scalar memory op
ROCPROFILER_THREAD_TRACE_DECODER_INST_SALU, ///< Scalar ALU op
ROCPROFILER_THREAD_TRACE_DECODER_INST_VMEM, ///< Vector memory op
ROCPROFILER_THREAD_TRACE_DECODER_INST_FLAT, ///< Flat addressing vmem or lds
ROCPROFILER_THREAD_TRACE_DECODER_INST_LDS, ///< Local Data Share op
ROCPROFILER_THREAD_TRACE_DECODER_INST_VALU, ///< Vector ALU op
ROCPROFILER_THREAD_TRACE_DECODER_INST_JUMP, ///< Branch taken
ROCPROFILER_THREAD_TRACE_DECODER_INST_NEXT, ///< Branch not taken
ROCPROFILER_THREAD_TRACE_DECODER_INST_IMMED, ///< Internal operation
ROCPROFILER_THREAD_TRACE_DECODER_INST_CONTEXT, ///< Wave context switch
ROCPROFILER_THREAD_TRACE_DECODER_INST_MESSAGE, ///< MSG types
ROCPROFILER_THREAD_TRACE_DECODER_INST_BVH, ///< Raytrace op
ROCPROFILER_THREAD_TRACE_DECODER_INST_LAST
} rocprofiler_thread_trace_decoder_inst_category_t;
/**
* @brief Describes an instruction execution event.
*
* The duration is measured as stall+issue time (gfx9) or stall+execution time (gfx10+).
* Time + duration marks the issue (gfx9) or execution (gfx10+) completion time.
* Time + stall marks the successful issue time.
* Duration - stall is the issue time (gfx9) or execution time (gfx10+).
*/
typedef struct rocprofiler_thread_trace_decoder_inst_t
{
uint32_t category : 8; ///< One of rocprofiler_thread_trace_decoder_inst_category_t
uint32_t stall : 24; ///< Stall duration, in clock cycles.
int32_t duration; ///< Total instruction duration, in clock cycles.
int64_t time; ///< When the wave first attempted to execute this instruction.
rocprofiler_thread_trace_decoder_pc_t pc;
} rocprofiler_thread_trace_decoder_inst_t;
/**
* @brief Struct describing a wave during it's lifetime.
* This record is only generated for waves executing in the target_cu and target_simd, selected by
* ROCPROFILER_THREAD_TRACE_PARAMETER_TARGET_CU and ROCPROFILER_THREAD_TRACE_PARAMETER_SIMD_SELECT
*
* instructions_array contains a time-ordered list of all (traced) instructions by the wave.
*/
typedef struct rocprofiler_thread_trace_decoder_wave_t
{
uint8_t cu; ///< CU id (gfx9) or wgp id (gfx10+). This is always the target_cu.
uint8_t simd; ///< SIMD ID [0,3].
uint8_t wave_id; ///< Wave slot ID within SIMD.
uint8_t contexts; ///< Counts how many CWSR events have occured during the wave lifetime.
uint32_t _rsvd1;
uint32_t _rsvd2;
uint32_t _rsvd3;
int64_t begin_time; ///< Wave begin time. Should match occupancy event wave start.
int64_t end_time; ///< Wave end time. Should match occupancy event wave end.
size_t timeline_size; ///< timeline_array size
size_t instructions_size; ///< instructions_array size
rocprofiler_thread_trace_decoder_wave_state_t* timeline_array; ///< wave state change events
rocprofiler_thread_trace_decoder_inst_t* instructions_array; ///< Instructions executed
} rocprofiler_thread_trace_decoder_wave_t;
/**
* @brief Defines the type of payload received by rocprofiler_thread_trace_decoder_callback_t
*/
typedef enum rocprofiler_thread_trace_decoder_record_type_t
{
ROCPROFILER_THREAD_TRACE_DECODER_RECORD_GFXIP = 0, ///< Record is gfxip_major, type size_t
ROCPROFILER_THREAD_TRACE_DECODER_RECORD_OCCUPANCY, ///< rocprofiler_thread_trace_decoder_occupancy_t*
ROCPROFILER_THREAD_TRACE_DECODER_RECORD_PERFEVENT, ///< rocprofiler_thread_trace_decoder_perfevent_t*
ROCPROFILER_THREAD_TRACE_DECODER_RECORD_WAVE, ///< rocprofiler_thread_trace_decoder_wave_t*
ROCPROFILER_THREAD_TRACE_DECODER_RECORD_INFO, ///< rocprofiler_thread_trace_decoder_info_t*
ROCPROFILER_THREAD_TRACE_DECODER_RECORD_DEBUG, ///< Debug
ROCPROFILER_THREAD_TRACE_DECODER_RECORD_LAST
} rocprofiler_thread_trace_decoder_record_type_t;
/** @} */
+28
ファイルの表示
@@ -0,0 +1,28 @@
// MIT License
//
// Copyright (c) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/experimental/thread-trace/agent.h>
#include <rocprofiler-sdk/experimental/thread-trace/core.h>
#include <rocprofiler-sdk/experimental/thread-trace/dispatch.h>
#include <rocprofiler-sdk/experimental/thread-trace/trace_decoder.h>
+55
ファイルの表示
@@ -0,0 +1,55 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
/**
* @file rocprofiler-sdk/ext_version.h
* @brief Defines versions for external dependencies
*
*/
// clang-format off
#define ROCPROFILER_HSA_RUNTIME_VERSION_MAJOR @HSA_RUNTIME_VERSION_MAJOR@
#define ROCPROFILER_HSA_RUNTIME_VERSION_MINOR @HSA_RUNTIME_VERSION_MINOR@
#cmakedefine ROCPROFILER_HSA_API_TABLE_MAJOR_VERSION @ROCPROFILER_HSA_API_TABLE_MAJOR_VERSION@
#cmakedefine ROCPROFILER_HSA_CORE_API_TABLE_MAJOR_VERSION @ROCPROFILER_HSA_CORE_API_TABLE_MAJOR_VERSION@
#cmakedefine ROCPROFILER_HSA_AMD_EXT_API_TABLE_MAJOR_VERSION @ROCPROFILER_HSA_AMD_EXT_API_TABLE_MAJOR_VERSION@
#cmakedefine ROCPROFILER_HSA_FINALIZER_API_TABLE_MAJOR_VERSION @ROCPROFILER_HSA_FINALIZER_API_TABLE_MAJOR_VERSION@
#cmakedefine ROCPROFILER_HSA_IMAGE_API_TABLE_MAJOR_VERSION @ROCPROFILER_HSA_IMAGE_API_TABLE_MAJOR_VERSION@
#cmakedefine ROCPROFILER_HSA_AQLPROFILE_API_TABLE_MAJOR_VERSION @ROCPROFILER_HSA_AQLPROFILE_API_TABLE_MAJOR_VERSION@
#cmakedefine ROCPROFILER_HSA_TOOLS_API_TABLE_MAJOR_VERSION @ROCPROFILER_HSA_TOOLS_API_TABLE_MAJOR_VERSION@
#cmakedefine ROCPROFILER_HSA_API_TABLE_STEP_VERSION @ROCPROFILER_HSA_API_TABLE_STEP_VERSION@
#cmakedefine ROCPROFILER_HSA_CORE_API_TABLE_STEP_VERSION @ROCPROFILER_HSA_CORE_API_TABLE_STEP_VERSION@
#cmakedefine ROCPROFILER_HSA_AMD_EXT_API_TABLE_STEP_VERSION @ROCPROFILER_HSA_AMD_EXT_API_TABLE_STEP_VERSION@
#cmakedefine ROCPROFILER_HSA_FINALIZER_API_TABLE_STEP_VERSION @ROCPROFILER_HSA_FINALIZER_API_TABLE_STEP_VERSION@
#cmakedefine ROCPROFILER_HSA_IMAGE_API_TABLE_STEP_VERSION @ROCPROFILER_HSA_IMAGE_API_TABLE_STEP_VERSION@
#cmakedefine ROCPROFILER_HSA_AQLPROFILE_API_TABLE_STEP_VERSION @ROCPROFILER_HSA_AQLPROFILE_API_TABLE_STEP_VERSION@
#cmakedefine ROCPROFILER_HSA_TOOLS_API_TABLE_STEP_VERSION @ROCPROFILER_HSA_TOOLS_API_TABLE_STEP_VERSION@
// clang-format on
// latest hsa-runtime version supported
#define ROCPROFILER_HSA_RUNTIME_VERSION \
((10000 * ROCPROFILER_HSA_RUNTIME_VERSION_MAJOR) + \
(100 * ROCPROFILER_HSA_RUNTIME_VERSION_MINOR))
+204
ファイルの表示
@@ -0,0 +1,204 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/defines.h>
#include <rocprofiler-sdk/fwd.h>
ROCPROFILER_EXTERN_C_INIT
/**
* @defgroup EXTERNAL_CORRELATION External Correlation IDs
* @brief User-defined correlation identifiers to supplement rocprofiler generated correlation ids
*
* @{
*/
/**
* @brief (experimental) ROCProfiler External Correlation ID Operations.
*
* These kinds correspond to callback and buffered tracing kinds (@see
* ::rocprofiler_callback_tracing_kind_t and ::rocprofiler_buffer_tracing_kind_t) which generate
* correlation IDs. Typically, rocprofiler-sdk uses the most recent external correlation ID on the
* current thread set via ::rocprofiler_push_external_correlation_id; however, this approach can be
* problematic if a new external correlation ID should be set before the
* ::ROCPROFILER_CALLBACK_PHASE_ENTER callback or if relevant external correlation IDs are desired
* when the buffered tracing is used. Thus, rocprofiler-sdk provides a way for tools to get a
* callback whenever an external correlation ID is needed. However, this can add significant
* overhead for those who only need these callbacks for, say, kernel dispatches while the HSA API is
* being traced (i.e. lots of callbacks for HSA API functions). The enumeration below is provided to
* ensure that tools can default to using the external correlation IDs set via the push/pop methods
* where the external correlation ID value is not important while also getting a request for an
* external correlation ID for other tracing kinds.
*/
// NOLINTNEXTLINE(performance-enum-size)
typedef enum ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_external_correlation_id_request_kind_t
{
ROCPROFILER_EXTERNAL_CORRELATION_REQUEST_NONE = 0, ///< Unknown kind
ROCPROFILER_EXTERNAL_CORRELATION_REQUEST_HSA_CORE_API, ///<
ROCPROFILER_EXTERNAL_CORRELATION_REQUEST_HSA_AMD_EXT_API, ///<
ROCPROFILER_EXTERNAL_CORRELATION_REQUEST_HSA_IMAGE_EXT_API, ///<
ROCPROFILER_EXTERNAL_CORRELATION_REQUEST_HSA_FINALIZE_EXT_API, ///<
ROCPROFILER_EXTERNAL_CORRELATION_REQUEST_HIP_RUNTIME_API, ///<
ROCPROFILER_EXTERNAL_CORRELATION_REQUEST_HIP_COMPILER_API, ///<
ROCPROFILER_EXTERNAL_CORRELATION_REQUEST_MARKER_CORE_API, ///<
ROCPROFILER_EXTERNAL_CORRELATION_REQUEST_MARKER_CONTROL_API, ///<
ROCPROFILER_EXTERNAL_CORRELATION_REQUEST_MARKER_NAME_API, ///<
ROCPROFILER_EXTERNAL_CORRELATION_REQUEST_MEMORY_COPY, ///<
ROCPROFILER_EXTERNAL_CORRELATION_REQUEST_KERNEL_DISPATCH, ///<
ROCPROFILER_EXTERNAL_CORRELATION_REQUEST_SCRATCH_MEMORY, ///<
ROCPROFILER_EXTERNAL_CORRELATION_REQUEST_RCCL_API, ///<
ROCPROFILER_EXTERNAL_CORRELATION_REQUEST_OMPT, ///<
ROCPROFILER_EXTERNAL_CORRELATION_REQUEST_MEMORY_ALLOCATION, ///<
ROCPROFILER_EXTERNAL_CORRELATION_REQUEST_ROCDECODE_API, ///<
ROCPROFILER_EXTERNAL_CORRELATION_REQUEST_ROCJPEG_API, ///<
ROCPROFILER_EXTERNAL_CORRELATION_REQUEST_MARKER_CORE_RANGE_API, ///<
ROCPROFILER_EXTERNAL_CORRELATION_REQUEST_LAST,
} rocprofiler_external_correlation_id_request_kind_t;
/**
* @brief (experimental) Callback requesting a value for the external correlation id.
*
* @param [in] thread_id Id of the thread making the request
* @param [in] context_id Id of the context making the request
* @param [in] kind Origin of the external correlation id request
* @param [in] operation Regardless of whether callback or buffer tracing is being used, the
* operation value will be the same, i.e., regardless of whether callback kind is
* ::ROCPROFILER_CALLBACK_TRACING_HSA_CORE_API or the buffer record kind is
* ::ROCPROFILER_BUFFER_TRACING_HSA_CORE_API, the data/record for `hsa_init` will have an operation
* value of ::ROCPROFILER_HSA_CORE_API_ID_hsa_init.
* @param [in] internal_corr_id_value Current internal correlation ID value for the request
* @param [out] external_corr_id_value Set this value to the desired external correlation ID value
* @param [in] data The `callback_args` value passed to
* ::rocprofiler_configure_external_correlation_id_request_service.
* @returns int
* @retval 0 Used to indicate the tool had zero issues setting the external correlation ID field
* @retval 1 (or any other non-zero number) Used to indicate the callback did not set an external
* correlation ID value and the thread-local value for the most recently pushed external correlation
* ID should be used instead
*/
ROCPROFILER_SDK_EXPERIMENTAL
typedef int (*rocprofiler_external_correlation_id_request_cb_t)(
rocprofiler_thread_id_t thread_id,
rocprofiler_context_id_t context_id,
rocprofiler_external_correlation_id_request_kind_t kind,
rocprofiler_tracing_operation_t operation,
uint64_t internal_corr_id_value,
rocprofiler_user_data_t* external_corr_id_value,
void* data);
/**
* @brief (experimental) Configure External Correlation ID Request Service.
*
* @param [in] context_id Context to associate the service with
* @param [in] kinds Array of ::rocprofiler_external_correlation_id_request_kind_t values. If
* this parameter is null, all tracing operations will invoke the callback to request an external
* correlation ID.
* @param [in] kinds_count If the kinds array is non-null, set this to the size of the
* array.
* @param [in] callback The function to invoke for an external correlation ID request
* @param [in] callback_args Data provided to every invocation of the callback function
* @return ::rocprofiler_status_t
* @retval ::ROCPROFILER_STATUS_ERROR_CONFIGURATION_LOCKED Invoked outside of the initialization
* function in ::rocprofiler_tool_configure_result_t provided to rocprofiler via
* ::rocprofiler_configure function
* @retval ::ROCPROFILER_STATUS_ERROR_CONTEXT_NOT_FOUND The provided context is not valid/registered
* @retval ::ROCPROFILER_STATUS_ERROR_SERVICE_ALREADY_CONFIGURED if the same
* ::rocprofiler_callback_tracing_kind_t value is provided more than once (per context) -- in other
* words, we do not support overriding or combining the kinds in separate function calls.
*/
ROCPROFILER_SDK_EXPERIMENTAL
rocprofiler_status_t
rocprofiler_configure_external_correlation_id_request_service(
rocprofiler_context_id_t context_id,
const rocprofiler_external_correlation_id_request_kind_t* kinds,
size_t kinds_count,
rocprofiler_external_correlation_id_request_cb_t callback,
void* callback_args) ROCPROFILER_API ROCPROFILER_NONNULL(4);
/**
* @brief Query the name of the external correlation request kind. The name retrieved from this
* function is a string literal that is encoded in the read-only section of the binary (i.e. it is
* always "allocated" and never "deallocated").
*
* @param [in] kind External correlation id request domain
* @param [out] name If non-null and the name is a constant string that does not require dynamic
* allocation, this paramter will be set to the address of the string literal, otherwise it will
* be set to nullptr
* @param [out] name_len If non-null, this will be assigned the length of the name (regardless of
* the name is a constant string or requires dynamic allocation)
* @return ::rocprofiler_status_t
* @retval ::ROCPROFILER_STATUS_ERROR_KIND_NOT_FOUND Returned if the domain id is not valid
* @retval ::ROCPROFILER_STATUS_SUCCESS Returned if a valid domain, regardless if there is a
* constant string or not.
*/
ROCPROFILER_SDK_EXPERIMENTAL
rocprofiler_status_t
rocprofiler_query_external_correlation_id_request_kind_name(
rocprofiler_external_correlation_id_request_kind_t kind,
const char** name,
uint64_t* name_len) ROCPROFILER_API;
/**
* @brief Push default value for `external` field in ::rocprofiler_correlation_id_t onto stack.
*
* External correlation ids are thread-local values. However, if rocprofiler internally requests an
* external correlation id on a non-main thread and an external correlation id has not been pushed
* for this thread, the external correlation ID will default to the latest external correlation id
* on the main thread -- this allows tools to push an external correlation id once on the main
* thread for, say, the MPI rank or process-wide UUID and this value will be used by all subsequent
* child threads.
*
* @param [in] context Associated context
* @param [in] tid thread identifier. @see rocprofiler_get_thread_id
* @param [in] external_correlation_id User data to place in external field in
* ::rocprofiler_correlation_id_t
* @return ::rocprofiler_status_t
* @retval ::ROCPROFILER_STATUS_ERROR_CONTEXT_NOT_FOUND Context does not exist
* @retval ::ROCPROFILER_STATUS_ERROR_INVALID_ARGUMENT Thread id is not valid
*/
rocprofiler_status_t
rocprofiler_push_external_correlation_id(rocprofiler_context_id_t context,
rocprofiler_thread_id_t tid,
rocprofiler_user_data_t external_correlation_id)
ROCPROFILER_API;
/**
* @brief Pop default value for `external` field in ::rocprofiler_correlation_id_t off of stack.
*
* @param [in] context Associated context
* @param [in] tid thread identifier. @see rocprofiler_get_thread_id
* @param [out] external_correlation_id Correlation id data popped off the stack
* @return ::rocprofiler_status_t
* @retval ::ROCPROFILER_STATUS_ERROR_CONTEXT_NOT_FOUND Context does not exist
* @retval ::ROCPROFILER_STATUS_ERROR_INVALID_ARGUMENT Thread id is not valid
*/
rocprofiler_status_t
rocprofiler_pop_external_correlation_id(rocprofiler_context_id_t context,
rocprofiler_thread_id_t tid,
rocprofiler_user_data_t* external_correlation_id)
ROCPROFILER_API;
/** @} */
ROCPROFILER_EXTERN_C_FINI
+871
ファイルの表示
@@ -0,0 +1,871 @@
// MIT License
//
// Copyright (c) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/defines.h>
#include <stddef.h>
#include <stdint.h>
ROCPROFILER_EXTERN_C_INIT
//--------------------------------------------------------------------------------------//
//
// ENUMERATIONS
//
//--------------------------------------------------------------------------------------//
/**
* @defgroup BASIC_DATA_TYPES Basic data types
* @brief Basic data types and typedefs
*
* @{
*/
/**
* @brief Status codes.
*/
typedef enum rocprofiler_status_t // NOLINT(performance-enum-size)
{
ROCPROFILER_STATUS_SUCCESS = 0, ///< No error occurred
ROCPROFILER_STATUS_ERROR, ///< Generalized error
ROCPROFILER_STATUS_ERROR_CONTEXT_NOT_FOUND, ///< No valid context for given context id
ROCPROFILER_STATUS_ERROR_BUFFER_NOT_FOUND, ///< No valid buffer for given buffer id
ROCPROFILER_STATUS_ERROR_KIND_NOT_FOUND, ///< Kind identifier is invalid
ROCPROFILER_STATUS_ERROR_OPERATION_NOT_FOUND, ///< Operation identifier is invalid for domain
ROCPROFILER_STATUS_ERROR_THREAD_NOT_FOUND, ///< No valid thread for given thread id
ROCPROFILER_STATUS_ERROR_AGENT_NOT_FOUND, ///< Agent identifier not found
ROCPROFILER_STATUS_ERROR_COUNTER_NOT_FOUND, ///< Counter identifier does not exist
ROCPROFILER_STATUS_ERROR_CONTEXT_ERROR, ///< Generalized context error
ROCPROFILER_STATUS_ERROR_CONTEXT_INVALID, ///< Context configuration is not valid
ROCPROFILER_STATUS_ERROR_CONTEXT_NOT_STARTED, ///< Context was not started (e.g., atomic swap
///< into active array failed)
ROCPROFILER_STATUS_ERROR_CONTEXT_CONFLICT, ///< Context operation failed due to a conflict with
///< another context
ROCPROFILER_STATUS_ERROR_CONTEXT_ID_NOT_ZERO, ///< Context ID is not initialized to zero
ROCPROFILER_STATUS_ERROR_BUFFER_BUSY, ///< buffer operation failed because it currently busy
///< handling another request (e.g. flushing)
ROCPROFILER_STATUS_ERROR_SERVICE_ALREADY_CONFIGURED, ///< service has already been configured
///< in context
ROCPROFILER_STATUS_ERROR_CONFIGURATION_LOCKED, ///< Function call is not valid outside of
///< rocprofiler configuration (i.e.
///< function called post-initialization)
ROCPROFILER_STATUS_ERROR_NOT_IMPLEMENTED, ///< Function is not implemented
ROCPROFILER_STATUS_ERROR_INCOMPATIBLE_ABI, ///< Data structure provided by user is incompatible
///< with current version of rocprofiler
ROCPROFILER_STATUS_ERROR_INVALID_ARGUMENT, ///< Function invoked with one or more invalid
///< arguments
ROCPROFILER_STATUS_ERROR_METRIC_NOT_VALID_FOR_AGENT, ///< Invalid metric supplied to agent.
ROCPROFILER_STATUS_ERROR_FINALIZED, ///< invalid because rocprofiler has been finalized
ROCPROFILER_STATUS_ERROR_HSA_NOT_LOADED, ///< Call requires HSA to be loaded before performed
ROCPROFILER_STATUS_ERROR_DIM_NOT_FOUND, ///< Dimension is not found for counter
ROCPROFILER_STATUS_ERROR_PROFILE_COUNTER_NOT_FOUND, ///< Profile could not find counter for GPU
///< agent
ROCPROFILER_STATUS_ERROR_AST_GENERATION_FAILED, ///< AST could not be generated correctly
ROCPROFILER_STATUS_ERROR_AST_NOT_FOUND, ///< AST was not found
ROCPROFILER_STATUS_ERROR_AQL_NO_EVENT_COORD, ///< Event coordinate was not found by AQL profile
ROCPROFILER_STATUS_ERROR_INCOMPATIBLE_KERNEL, ///< A service depends on a newer version of KFD
///< (amdgpu kernel driver). Check logs for
///< service that report incompatibility
ROCPROFILER_STATUS_ERROR_OUT_OF_RESOURCES, ///< The given resources are
///< insufficient to complete operation
ROCPROFILER_STATUS_ERROR_PROFILE_NOT_FOUND, ///< Could not find the counter profile
ROCPROFILER_STATUS_ERROR_AGENT_DISPATCH_CONFLICT, ///< Cannot enable both agent and dispatch
///< counting in the same context.
ROCPROFILER_STATUS_INTERNAL_NO_AGENT_CONTEXT, ///< No agent context found, may not be an error
ROCPROFILER_STATUS_ERROR_SAMPLE_RATE_EXCEEDED, ///< Sample rate exceeded
ROCPROFILER_STATUS_ERROR_NO_PROFILE_QUEUE, ///< Profile queue creation failed
ROCPROFILER_STATUS_ERROR_NO_HARDWARE_COUNTERS, ///< No hardware counters were specified
ROCPROFILER_STATUS_ERROR_AGENT_MISMATCH, ///< Agent mismatch between profile and context.
ROCPROFILER_STATUS_ERROR_NOT_AVAILABLE, ///< The service is not available.
///< Please refer to API functions that return this
///< status code for more information.
ROCPROFILER_STATUS_ERROR_EXCEEDS_HW_LIMIT, ///< Exceeds hardware limits for collection.
ROCPROFILER_STATUS_ERROR_AGENT_ARCH_NOT_SUPPORTED, ///< Agent HW architecture not supported.
ROCPROFILER_STATUS_ERROR_PERMISSION_DENIED, ///< Permission denied.
ROCPROFILER_STATUS_LAST,
} rocprofiler_status_t;
/**
* @brief Buffer record categories. This enumeration type is encoded in
* ::rocprofiler_record_header_t category field
*/
typedef enum rocprofiler_buffer_category_t // NOLINT(performance-enum-size)
{
ROCPROFILER_BUFFER_CATEGORY_NONE = 0,
ROCPROFILER_BUFFER_CATEGORY_TRACING,
ROCPROFILER_BUFFER_CATEGORY_PC_SAMPLING,
ROCPROFILER_BUFFER_CATEGORY_COUNTERS,
ROCPROFILER_BUFFER_CATEGORY_LAST,
} rocprofiler_buffer_category_t;
/**
* @brief Agent type.
*/
typedef enum rocprofiler_agent_type_t // NOLINT(performance-enum-size)
{
ROCPROFILER_AGENT_TYPE_NONE = 0, ///< Agent type is unknown
ROCPROFILER_AGENT_TYPE_CPU, ///< Agent type is a CPU
ROCPROFILER_AGENT_TYPE_GPU, ///< Agent type is a GPU
ROCPROFILER_AGENT_TYPE_LAST,
} rocprofiler_agent_type_t;
/**
* @brief Service Callback Phase.
*/
typedef enum rocprofiler_callback_phase_t // NOLINT(performance-enum-size)
{
ROCPROFILER_CALLBACK_PHASE_NONE = 0, ///< Callback has no phase
ROCPROFILER_CALLBACK_PHASE_ENTER, ///< Callback invoked prior to function execution
ROCPROFILER_CALLBACK_PHASE_LOAD =
ROCPROFILER_CALLBACK_PHASE_ENTER, ///< Callback invoked prior to code object loading
ROCPROFILER_CALLBACK_PHASE_EXIT, ///< Callback invoked after to function execution
ROCPROFILER_CALLBACK_PHASE_UNLOAD =
ROCPROFILER_CALLBACK_PHASE_EXIT, ///< Callback invoked prior to code object unloading
ROCPROFILER_CALLBACK_PHASE_LAST,
} rocprofiler_callback_phase_t;
/**
* @brief Service Callback Tracing Kind. @see rocprofiler_configure_callback_tracing_service.
*/
typedef enum rocprofiler_callback_tracing_kind_t // NOLINT(performance-enum-size)
{
ROCPROFILER_CALLBACK_TRACING_NONE = 0,
ROCPROFILER_CALLBACK_TRACING_HSA_CORE_API, ///< @see ::rocprofiler_hsa_core_api_id_t
ROCPROFILER_CALLBACK_TRACING_HSA_AMD_EXT_API, ///< @see ::rocprofiler_hsa_amd_ext_api_id_t
ROCPROFILER_CALLBACK_TRACING_HSA_IMAGE_EXT_API, ///< @see ::rocprofiler_hsa_image_ext_api_id_t
ROCPROFILER_CALLBACK_TRACING_HSA_FINALIZE_EXT_API, ///< @see
///< ::rocprofiler_hsa_finalize_ext_api_id_t
ROCPROFILER_CALLBACK_TRACING_HIP_RUNTIME_API, ///< @see ::rocprofiler_hip_runtime_api_id_t
ROCPROFILER_CALLBACK_TRACING_HIP_COMPILER_API, ///< @see ::rocprofiler_hip_compiler_api_id_t
ROCPROFILER_CALLBACK_TRACING_MARKER_CORE_API, ///< @see ::rocprofiler_marker_core_api_id_t
ROCPROFILER_CALLBACK_TRACING_MARKER_CONTROL_API, ///< @see
///< ::rocprofiler_marker_control_api_id_t
ROCPROFILER_CALLBACK_TRACING_MARKER_NAME_API, ///< @see ::rocprofiler_marker_name_api_id_t
ROCPROFILER_CALLBACK_TRACING_CODE_OBJECT, ///< @see ::rocprofiler_code_object_operation_t
ROCPROFILER_CALLBACK_TRACING_SCRATCH_MEMORY, ///< @see ::rocprofiler_scratch_memory_operation_t
ROCPROFILER_CALLBACK_TRACING_KERNEL_DISPATCH, ///< Callbacks for kernel dispatches
ROCPROFILER_CALLBACK_TRACING_MEMORY_COPY, ///< @see ::rocprofiler_memory_copy_operation_t
ROCPROFILER_CALLBACK_TRACING_RCCL_API, ///< RCCL tracing
ROCPROFILER_CALLBACK_TRACING_OMPT, ///< @see ::rocprofiler_ompt_operation_t
ROCPROFILER_CALLBACK_TRACING_MEMORY_ALLOCATION, ///< @see
///< ::rocprofiler_memory_allocation_operation_t
ROCPROFILER_CALLBACK_TRACING_RUNTIME_INITIALIZATION, ///< Callback notifying that a runtime
///< library has been initialized
ROCPROFILER_CALLBACK_TRACING_ROCDECODE_API, ///< rocDecode API Tracing
ROCPROFILER_CALLBACK_TRACING_ROCJPEG_API, ///< rocJPEG API Tracing
ROCPROFILER_CALLBACK_TRACING_HIP_STREAM, ///< @see ::rocprofiler_hip_stream_operation_t
ROCPROFILER_CALLBACK_TRACING_MARKER_CORE_RANGE_API, ///< @see
///< ::rocprofiler_marker_core_range_api_id_t
ROCPROFILER_CALLBACK_TRACING_LAST,
} rocprofiler_callback_tracing_kind_t;
/**
* @brief Service Buffer Tracing Kind. @see rocprofiler_configure_buffer_tracing_service.
*/
typedef enum rocprofiler_buffer_tracing_kind_t // NOLINT(performance-enum-size)
{
ROCPROFILER_BUFFER_TRACING_NONE = 0,
ROCPROFILER_BUFFER_TRACING_HSA_CORE_API, ///< @see ::rocprofiler_hsa_core_api_id_t
ROCPROFILER_BUFFER_TRACING_HSA_AMD_EXT_API, ///< @see ::rocprofiler_hsa_amd_ext_api_id_t
ROCPROFILER_BUFFER_TRACING_HSA_IMAGE_EXT_API, ///< @see ::rocprofiler_hsa_image_ext_api_id_t
ROCPROFILER_BUFFER_TRACING_HSA_FINALIZE_EXT_API, ///< @see
///< ::rocprofiler_hsa_finalize_ext_api_id_t
ROCPROFILER_BUFFER_TRACING_HIP_RUNTIME_API, ///< @see ::rocprofiler_hip_runtime_api_id_t
ROCPROFILER_BUFFER_TRACING_HIP_COMPILER_API, ///< @see ::rocprofiler_hip_compiler_api_id_t
ROCPROFILER_BUFFER_TRACING_MARKER_CORE_API, ///< @see ::rocprofiler_marker_core_api_id_t
ROCPROFILER_BUFFER_TRACING_MARKER_CONTROL_API, ///< @see ::rocprofiler_marker_control_api_id_t
ROCPROFILER_BUFFER_TRACING_MARKER_NAME_API, ///< @see ::rocprofiler_marker_name_api_id_t
ROCPROFILER_BUFFER_TRACING_MEMORY_COPY, ///< @see ::rocprofiler_memory_copy_operation_t
ROCPROFILER_BUFFER_TRACING_KERNEL_DISPATCH, ///< Buffer kernel dispatch info
ROCPROFILER_BUFFER_TRACING_SCRATCH_MEMORY, ///< Buffer scratch memory reclaimation info
ROCPROFILER_BUFFER_TRACING_CORRELATION_ID_RETIREMENT, ///< Correlation ID in no longer in use
ROCPROFILER_BUFFER_TRACING_RCCL_API, ///< RCCL tracing
ROCPROFILER_BUFFER_TRACING_OMPT, ///< @see ::rocprofiler_ompt_operation_t
ROCPROFILER_BUFFER_TRACING_MEMORY_ALLOCATION, ///< @see
///< ::rocprofiler_memory_allocation_operation_t
ROCPROFILER_BUFFER_TRACING_RUNTIME_INITIALIZATION, ///< Record indicating a runtime library has
///< been initialized. @see
///< ::rocprofiler_runtime_initialization_operation_t
ROCPROFILER_BUFFER_TRACING_ROCDECODE_API, ///< rocDecode tracing
ROCPROFILER_BUFFER_TRACING_ROCJPEG_API, ///< rocJPEG tracing
ROCPROFILER_BUFFER_TRACING_HIP_STREAM, ///< @see ::rocprofiler_hip_stream_operation_t
ROCPROFILER_BUFFER_TRACING_HIP_RUNTIME_API_EXT,
ROCPROFILER_BUFFER_TRACING_HIP_COMPILER_API_EXT,
ROCPROFILER_BUFFER_TRACING_ROCDECODE_API_EXT,
ROCPROFILER_BUFFER_TRACING_KFD_EVENT_PAGE_MIGRATE, ///< @see
///< rocprofiler_kfd_event_page_migrate_operation_t
ROCPROFILER_BUFFER_TRACING_KFD_EVENT_PAGE_FAULT, ///< @see
///< rocprofiler_kfd_event_page_fault_operation_t
ROCPROFILER_BUFFER_TRACING_KFD_EVENT_QUEUE, ///< @see rocprofiler_kfd_event_queue_operation_t
ROCPROFILER_BUFFER_TRACING_KFD_EVENT_UNMAP_FROM_GPU, ///< @see
///< rocprofiler_kfd_event_unmap_from_gpu_operation_t
ROCPROFILER_BUFFER_TRACING_KFD_EVENT_DROPPED_EVENTS, ///< @see
///< rocprofiler_kfd_event_dropped_events_operation_t
ROCPROFILER_BUFFER_TRACING_KFD_PAGE_MIGRATE, ///< @see rocprofiler_kfd_page_migrate_operation_t
ROCPROFILER_BUFFER_TRACING_KFD_PAGE_FAULT, ///< @see rocprofiler_kfd_page_fault_operation_t
ROCPROFILER_BUFFER_TRACING_KFD_QUEUE, ///< @see rocprofiler_kfd_queue_operation_t
ROCPROFILER_BUFFER_TRACING_MARKER_CORE_RANGE_API, ///< @see
///< ::rocprofiler_marker_core_range_api_id_t
ROCPROFILER_BUFFER_TRACING_LAST,
/// @var ROCPROFILER_BUFFER_TRACING_HIP_RUNTIME_API_EXT
/// @brief Similar to ROCPROFILER_BUFFER_TRACING_HIP_RUNTIME_API except the buffer record
/// contains the function argument(s) and return value
/// @var ROCPROFILER_BUFFER_TRACING_HIP_COMPILER_API_EXT
/// @brief Similar to ROCPROFILER_BUFFER_TRACING_HIP_COMPILER_API except the buffer record
/// contains the function argument(s) and return value
/// @var ROCPROFILER_BUFFER_TRACING_ROCDECODE_API_EXT
/// @brief Similar to ROCPROFILER_BUFFER_TRACING_ROCDECODE_API except the buffer record
/// contains the function argument(s) and return value
} rocprofiler_buffer_tracing_kind_t;
/**
* @brief ROCProfiler Code Object Tracer Operations.
*/
typedef enum rocprofiler_code_object_operation_t // NOLINT(performance-enum-size)
{
ROCPROFILER_CODE_OBJECT_NONE = 0, ///< Unknown code object operation
ROCPROFILER_CODE_OBJECT_LOAD, ///< Code object containing kernel symbols
ROCPROFILER_CODE_OBJECT_DEVICE_KERNEL_SYMBOL_REGISTER, ///< Kernel symbols - Device
ROCPROFILER_CODE_OBJECT_HOST_KERNEL_SYMBOL_REGISTER, ///< Kernel symbols - Host
ROCPROFILER_CODE_OBJECT_LAST,
} rocprofiler_code_object_operation_t;
/**
* @brief ROCProfiler HIP Stream Operations. These operations can be used to associate subsequent
* information with a HIP stream
*/
typedef enum rocprofiler_hip_stream_operation_t // NOLINT(performance-enum-size)
{
ROCPROFILER_HIP_STREAM_NONE = 0, ///< Unknown stream handle operation
ROCPROFILER_HIP_STREAM_CREATE, ///< A stream handle is created
ROCPROFILER_HIP_STREAM_DESTROY, ///< A stream handle is destroyed
ROCPROFILER_HIP_STREAM_SET,
ROCPROFILER_HIP_STREAM_LAST,
/// @var ROCPROFILER_HIP_STREAM_SET
/// @brief Invokes callbacks before and after a HIP API, kernel dispatch, or memory copy
/// operation that has a stream handle associated with it. HIP API calls will always have a
/// stream, but kernel dispatches and memory copy operations may or may not.
} rocprofiler_hip_stream_operation_t;
/**
* @brief Memory Copy Operations.
*/
typedef enum rocprofiler_memory_copy_operation_t // NOLINT(performance-enum-size)
{
ROCPROFILER_MEMORY_COPY_NONE = 0, ///< Unknown memory copy direction
ROCPROFILER_MEMORY_COPY_HOST_TO_HOST, ///< Memory copy from host to host
ROCPROFILER_MEMORY_COPY_HOST_TO_DEVICE, ///< Memory copy from host to device
ROCPROFILER_MEMORY_COPY_DEVICE_TO_HOST, ///< Memory copy from device to host
ROCPROFILER_MEMORY_COPY_DEVICE_TO_DEVICE, ///< Memory copy from device to device
ROCPROFILER_MEMORY_COPY_LAST,
} rocprofiler_memory_copy_operation_t;
/**
* @brief Memory Allocation Operation.
*/
typedef enum rocprofiler_memory_allocation_operation_t // NOLINT(performance-enum-size)
{
ROCPROFILER_MEMORY_ALLOCATION_NONE = 0, ///< Unknown memory allocation function
ROCPROFILER_MEMORY_ALLOCATION_ALLOCATE, ///< Allocate memory function
ROCPROFILER_MEMORY_ALLOCATION_VMEM_ALLOCATE, ///< Allocate vmem memory handle
ROCPROFILER_MEMORY_ALLOCATION_FREE, ///< Free memory function
ROCPROFILER_MEMORY_ALLOCATION_VMEM_FREE, ///< Release vmem memory handle
ROCPROFILER_MEMORY_ALLOCATION_LAST,
} rocprofiler_memory_allocation_operation_t;
/**
* @brief ROCProfiler Kernel Dispatch Tracing Operation Types.
*/
typedef enum rocprofiler_kernel_dispatch_operation_t // NOLINT(performance-enum-size)
{
ROCPROFILER_KERNEL_DISPATCH_NONE = 0, ///< Unknown kernel dispatch operation
ROCPROFILER_KERNEL_DISPATCH_ENQUEUE = 1,
ROCPROFILER_KERNEL_DISPATCH_COMPLETE,
ROCPROFILER_KERNEL_DISPATCH_LAST,
/// @var ROCPROFILER_KERNEL_DISPATCH_ENQUEUE
/// @brief Invoke callback prior to a kernel being enqueued and after the kernel has been
/// enqueued. When the phase is ::ROCPROFILER_CALLBACK_PHASE_ENTER, this is an opportunity to
/// push an external correlation id and/or modify the active contexts before a kernel is
/// launched. Any active contexts containing services related to a kernel dispatch (kernel
/// tracing, counter collection, etc.) will be captured after this callback and attached to the
/// kernel. These captured contexts will be considered "active" when the kernel completes even
/// if the context was stopped before the kernel completes -- this contract is designed to
/// ensure that tools do not have to delay stopping a context because of an async operation in
/// order to get the data they requested when the async operation was started. When the phase is
/// ::ROCPROFILER_CALLBACK_PHASE_EXIT, the active contexts for the kernel dispatch have been
/// captured and it is safe to disable those contexts without affecting the delivery of the
/// requested data when the kernel completes. It is important to note that, even if the context
/// associated with the kernel dispatch callback tracing service is disabled in between the
/// enter and exit phase, the exit phase callback is still delievered but that context will not
/// be captured when the kernel is enqueued and therefore will not provide a
/// ::ROCPROFILER_KERNEL_DISPATCH_COMPLETE callback. Furthermore, it should be
/// noted that if a tool encodes information into the `::rocprofiler_user_data_t` output
/// parameter in ::rocprofiler_callback_tracing_cb_t, that same value will be delivered in the
/// exit phase and in the ::ROCPROFILER_KERNEL_DISPATCH_COMPLETE callback. In
/// other words, any modifications to that user data value in the exit phase will not be
/// reflected in the ::ROCPROFILER_KERNEL_DISPATCH_COMPLETE callback because a
/// copy of that user data struct is attached to the kernel, not a reference to the user data
/// struct.
///
/// @var ROCPROFILER_KERNEL_DISPATCH_COMPLETE
/// @brief Invoke callback after a kernel has completed and the HSA runtime has processed the
/// signal indicating that the kernel has completed. The latter half of this statement is
/// important. There is no guarantee that these callbacks are invoked in any order related to
/// when the kernels were dispatched, i.e. even if kernel A is launched and fully executed
/// before kernel B is launched, it is entirely possible that the HSA runtime ends up processing
/// the signal associated with kernel B before processing the signal associated with kernel A --
/// resulting in rocprofiler-sdk invoking this operation callback for kernel B before invoking
/// the callback for kernel A.
} rocprofiler_kernel_dispatch_operation_t;
/**
* @brief PC Sampling Method.
*/
typedef enum rocprofiler_pc_sampling_method_t // NOLINT(performance-enum-size)
{
ROCPROFILER_PC_SAMPLING_METHOD_NONE = 0, ///< Unknown sampling type
ROCPROFILER_PC_SAMPLING_METHOD_STOCHASTIC, ///< Stochastic sampling (MI300+)
ROCPROFILER_PC_SAMPLING_METHOD_HOST_TRAP, ///< Interval sampling (MI200+)
ROCPROFILER_PC_SAMPLING_METHOD_LAST,
} rocprofiler_pc_sampling_method_t;
/**
* @brief PC Sampling Unit.
*/
typedef enum rocprofiler_pc_sampling_unit_t // NOLINT(performance-enum-size)
{
ROCPROFILER_PC_SAMPLING_UNIT_NONE = 0, ///< Sample interval has unspecified units
ROCPROFILER_PC_SAMPLING_UNIT_INSTRUCTIONS, ///< Sample interval is in instructions
ROCPROFILER_PC_SAMPLING_UNIT_CYCLES, ///< Sample interval is in cycles
ROCPROFILER_PC_SAMPLING_UNIT_TIME, ///< Sample internval is in nanoseconds
ROCPROFILER_PC_SAMPLING_UNIT_LAST,
} rocprofiler_pc_sampling_unit_t;
/**
* @brief Actions when Buffer is full.
*/
typedef enum rocprofiler_buffer_policy_t // NOLINT(performance-enum-size)
{
ROCPROFILER_BUFFER_POLICY_NONE = 0, ///< No policy has been set
ROCPROFILER_BUFFER_POLICY_DISCARD, ///< Drop records when buffer is full
ROCPROFILER_BUFFER_POLICY_LOSSLESS, ///< Block when buffer is full
ROCPROFILER_BUFFER_POLICY_LAST,
} rocprofiler_buffer_policy_t;
/**
* @brief Scratch event kind
*/
typedef enum rocprofiler_scratch_memory_operation_t
{
ROCPROFILER_SCRATCH_MEMORY_NONE = 0, ///< Unknown scratch operation
ROCPROFILER_SCRATCH_MEMORY_ALLOC, ///< Scratch memory allocation event
ROCPROFILER_SCRATCH_MEMORY_FREE, ///< Scratch memory free event
ROCPROFILER_SCRATCH_MEMORY_ASYNC_RECLAIM, ///< Scratch memory asynchronously reclaimed
ROCPROFILER_SCRATCH_MEMORY_LAST,
} rocprofiler_scratch_memory_operation_t;
/**
* @brief Enumeration for specifying runtime libraries supported by rocprofiler. This enumeration is
* used for thread creation callbacks. @see INTERNAL_THREADING.
*/
typedef enum rocprofiler_runtime_library_t
{
ROCPROFILER_LIBRARY = (1 << 0),
ROCPROFILER_HSA_LIBRARY = (1 << 1),
ROCPROFILER_HIP_LIBRARY = (1 << 2),
ROCPROFILER_MARKER_LIBRARY = (1 << 3),
ROCPROFILER_RCCL_LIBRARY = (1 << 4),
ROCPROFILER_ROCDECODE_LIBRARY = (1 << 5),
ROCPROFILER_ROCJPEG_LIBRARY = (1 << 6),
ROCPROFILER_LIBRARY_LAST = ROCPROFILER_ROCJPEG_LIBRARY,
} rocprofiler_runtime_library_t;
/**
* @brief Enumeration for specifying intercept tables supported by rocprofiler. This enumeration is
* used for intercept tables. @see INTERCEPT_TABLE.
*/
typedef enum rocprofiler_intercept_table_t
{
ROCPROFILER_HSA_TABLE = (1 << 0),
ROCPROFILER_HIP_RUNTIME_TABLE = (1 << 1),
ROCPROFILER_HIP_COMPILER_TABLE = (1 << 2),
ROCPROFILER_MARKER_CORE_TABLE = (1 << 3),
ROCPROFILER_MARKER_CONTROL_TABLE = (1 << 4),
ROCPROFILER_MARKER_NAME_TABLE = (1 << 5),
ROCPROFILER_RCCL_TABLE = (1 << 6),
ROCPROFILER_ROCDECODE_TABLE = (1 << 7),
ROCPROFILER_ROCJPEG_TABLE = (1 << 8),
ROCPROFILER_TABLE_LAST = ROCPROFILER_ROCJPEG_TABLE,
} rocprofiler_intercept_table_t;
/**
* @brief ROCProfiler Runtime Initialization Tracer Operations.
*/
typedef enum rocprofiler_runtime_initialization_operation_t // NOLINT(performance-enum-size)
{
ROCPROFILER_RUNTIME_INITIALIZATION_NONE = 0, ///< Unknown runtime initialization
ROCPROFILER_RUNTIME_INITIALIZATION_HSA, ///< Application loaded HSA runtime
ROCPROFILER_RUNTIME_INITIALIZATION_HIP, ///< Application loaded HIP runtime
ROCPROFILER_RUNTIME_INITIALIZATION_MARKER, ///< Application loaded Marker (ROCTx) runtime
ROCPROFILER_RUNTIME_INITIALIZATION_RCCL, ///< Application loaded RCCL runtime
ROCPROFILER_RUNTIME_INITIALIZATION_ROCDECODE, ///< Application loaded rocDecoder runtime
ROCPROFILER_RUNTIME_INITIALIZATION_ROCJPEG, ///< Application loaded rocJPEG runtime
ROCPROFILER_RUNTIME_INITIALIZATION_LAST,
} rocprofiler_runtime_initialization_operation_t;
/**
* @brief Enumeration for specifying the counter info struct version you want.
*/
typedef enum rocprofiler_counter_info_version_id_t
{
ROCPROFILER_COUNTER_INFO_VERSION_NONE,
ROCPROFILER_COUNTER_INFO_VERSION_0, ///< @see ::rocprofiler_counter_info_v0_t
ROCPROFILER_COUNTER_INFO_VERSION_1, ///< @see ::rocprofiler_counter_info_v1_t
ROCPROFILER_COUNTER_INFO_VERSION_LAST,
} rocprofiler_counter_info_version_id_t;
/**
* @brief Enumeration for distinguishing different buffer record kinds within the
* ::ROCPROFILER_BUFFER_CATEGORY_COUNTERS category
*/
typedef enum rocprofiler_counter_record_kind_t
{
ROCPROFILER_COUNTER_RECORD_NONE = 0,
ROCPROFILER_COUNTER_RECORD_PROFILE_COUNTING_DISPATCH_HEADER, ///< ::rocprofiler_dispatch_counting_service_record_t
ROCPROFILER_COUNTER_RECORD_VALUE,
ROCPROFILER_COUNTER_RECORD_LAST,
/// @var ROCPROFILER_COUNTER_RECORD_KIND_DISPATCH_PROFILE_HEADER
/// @brief Indicates the payload type is of type
/// ::rocprofiler_dispatch_counting_service_record_t
} rocprofiler_counter_record_kind_t;
/**
* @brief Enumeration of flags that can be used with some counter api calls
*/
typedef enum rocprofiler_counter_flag_t
{
ROCPROFILER_COUNTER_FLAG_NONE = 0,
ROCPROFILER_COUNTER_FLAG_ASYNC, ///< Do not wait for completion before returning.
ROCPROFILER_COUNTER_FLAG_APPEND_DEFINITION, ///< Append the counter definition to the system
///< provided counter definition file.
ROCPROFILER_COUNTER_FLAG_LAST,
} rocprofiler_counter_flag_t;
/**
* @brief Enumeration for distinguishing different buffer record kinds within the
* ::ROCPROFILER_BUFFER_CATEGORY_PC_SAMPLING category
*/
typedef enum rocprofiler_pc_sampling_record_kind_t
{
ROCPROFILER_PC_SAMPLING_RECORD_NONE = 0,
ROCPROFILER_PC_SAMPLING_RECORD_INVALID_SAMPLE, ///< ::rocprofiler_pc_sampling_record_invalid_t
ROCPROFILER_PC_SAMPLING_RECORD_HOST_TRAP_V0_SAMPLE, ///< ::rocprofiler_pc_sampling_record_host_trap_v0_t
ROCPROFILER_PC_SAMPLING_RECORD_STOCHASTIC_V0_SAMPLE, ///< ::rocprofiler_pc_sampling_record_stochastic_v0_t
ROCPROFILER_PC_SAMPLING_RECORD_LAST,
} rocprofiler_pc_sampling_record_kind_t;
//--------------------------------------------------------------------------------------//
//
// ALIASES
//
//--------------------------------------------------------------------------------------//
/**
* @brief ROCProfiler Timestamp.
*/
typedef uint64_t rocprofiler_timestamp_t;
/**
* @brief Thread ID. Value will be equivalent to `syscall(__NR_gettid)`
*/
typedef uint64_t rocprofiler_thread_id_t;
/**
* @brief Tracing Operation ID. Depending on the kind, operations can be determined.
* If the value is equal to zero that means all operations will be considered
* for tracing. Detailed API tracing operations can be found at associated header file
* for that partiular operation. i.e: For ROCProfiler enumeration of HSA AMD Extended API tracing
* operations, look at source/include/rocprofiler-sdk/hsa/amd_ext_api_id.h
*/
typedef int32_t rocprofiler_tracing_operation_t;
/**
* @brief Kernel identifier type
*
*/
typedef uint64_t rocprofiler_kernel_id_t;
// /**
// * @brief Sequence identifier type
// *
// */
typedef uint64_t rocprofiler_dispatch_id_t;
/**
* @brief Unique record id encoding both the counter
* and dimensional values (positions) for the record.
*/
typedef uint64_t rocprofiler_counter_instance_id_t;
/**
* @brief A dimension for counter instances. Some example
* dimensions include XCC, SM (Shader), etc. This
* value represents the dimension beind described
* or queried about.
*/
typedef uint64_t rocprofiler_counter_dimension_id_t;
//--------------------------------------------------------------------------------------//
//
// UNIONS
//
//--------------------------------------------------------------------------------------//
/**
* @brief User-assignable data type
*
*/
typedef union rocprofiler_user_data_t
{
uint64_t value; ///< usage example: set to process id, thread id, etc.
void* ptr; ///< usage example: set to address of data allocation
} rocprofiler_user_data_t;
/**
* @brief Stores memory address for profiling
*
*/
typedef union rocprofiler_address_t
{
uint64_t handle; ///< compatability
uint64_t value; ///< usage example: store address in uint64_t format
const void* ptr; ///< usage example: generic form of address
} rocprofiler_address_t;
/**
* @brief Stores UUID for devices.
*
*/
typedef struct rocprofiler_uuid_t
{
uint8_t bytes[16]; // numerical value
} rocprofiler_uuid_t;
//--------------------------------------------------------------------------------------//
//
// STRUCTS
//
//--------------------------------------------------------------------------------------//
/**
* @brief Versioning info.
*/
typedef struct rocprofiler_version_triplet_t
{
uint32_t major;
uint32_t minor;
uint32_t patch;
} rocprofiler_version_triplet_t;
/**
* @brief Context ID.
*/
typedef struct rocprofiler_context_id_t
{
uint64_t handle;
} rocprofiler_context_id_t;
/**
* @brief Queue ID.
*/
typedef struct rocprofiler_queue_id_t
{
uint64_t handle;
} rocprofiler_queue_id_t;
/**
* @brief Stream ID.
*/
typedef struct rocprofiler_stream_id_t
{
uint64_t handle;
} rocprofiler_stream_id_t;
/**
* @brief ROCProfiler Record Correlation ID.
*/
typedef struct rocprofiler_correlation_id_t
{
uint64_t internal;
rocprofiler_user_data_t external;
uint64_t ancestor;
/// @var internal
/// @brief A unique ID created by rocprofiler-sdk when an API call is invoked.
/// @var external
/// @brief An ID specified by tools to associate external events.
/// See include/rocprofiler-sdk/external_correlation.h
/// @var ancestor
/// @brief Stores the @ref internal value of the API call that generated this
/// API call.
} rocprofiler_correlation_id_t;
/**
* @brief ROCProfiler Correlation ID record for async activity.
*/
typedef struct rocprofiler_async_correlation_id_t
{
uint64_t internal;
rocprofiler_user_data_t external;
/// @var internal
/// @brief A unique ID created by rocprofiler-sdk when an API call is invoked.
/// @var external
/// @brief An ID specified by tools to associate external events.
/// See include/rocprofiler-sdk/external_correlation.h
} rocprofiler_async_correlation_id_t;
/**
* @brief The NULL value of an internal correlation ID.
*/
#define ROCPROFILER_CORRELATION_ID_INTERNAL_NONE ROCPROFILER_UINT64_C(0)
/**
* @brief The NULL value of an ancestor correlation ID.
*/
#define ROCPROFILER_CORRELATION_ID_ANCESTOR_NONE ROCPROFILER_UINT64_C(0)
/**
* @struct rocprofiler_buffer_id_t
* @brief Buffer ID.
*/
typedef struct rocprofiler_buffer_id_t
{
uint64_t handle;
} rocprofiler_buffer_id_t;
/**
* @brief Agent Identifier
*/
typedef struct rocprofiler_agent_id_t
{
uint64_t handle;
} rocprofiler_agent_id_t;
/**
* @brief Counter ID.
*/
typedef struct rocprofiler_counter_id_t
{
uint64_t handle;
} rocprofiler_counter_id_t;
/**
* @brief Profile Configurations
* @see rocprofiler_create_counter_config for how to create.
*/
typedef struct rocprofiler_counter_config_id_t
{
uint64_t handle; ///< Opaque handle
} rocprofiler_counter_config_id_t;
/**
* @brief Multi-dimensional struct of data used to describe GPU workgroup and grid sizes
*/
typedef struct rocprofiler_dim3_t
{
uint32_t x;
uint32_t y;
uint32_t z;
} rocprofiler_dim3_t;
/**
* @brief Tracing record
*
*/
typedef struct rocprofiler_callback_tracing_record_t
{
rocprofiler_context_id_t context_id;
rocprofiler_thread_id_t thread_id;
rocprofiler_correlation_id_t correlation_id;
rocprofiler_callback_tracing_kind_t kind;
rocprofiler_tracing_operation_t operation;
rocprofiler_callback_phase_t phase;
void* payload;
} rocprofiler_callback_tracing_record_t;
/**
* @brief Generic record with type identifier(s) and a pointer to data. This data type is used with
* buffered data.
*
* @code{.cpp}
* void
* tool_tracing_callback(rocprofiler_record_header_t** headers,
* size_t num_headers)
* {
* for(size_t i = 0; i < num_headers; ++i)
* {
* rocprofiler_record_header_t* header = headers[i];
*
* if(header->category == ROCPROFILER_BUFFER_CATEGORY_TRACING &&
* header->kind == ROCPROFILER_BUFFER_TRACING_HSA_API)
* {
* // cast to rocprofiler_buffer_tracing_hsa_api_record_t which
* // is type associated with this category + kind
* auto* record =
* static_cast<rocprofiler_buffer_tracing_hsa_api_record_t*>(header->payload);
*
* // trivial test
* assert(record->start_timestamp <= record->end_timestamp);
* }
* }
* }
*
* @endcode
*/
typedef struct rocprofiler_record_header_t
{
union
{
struct
{
/** @brief ::rocprofiler_buffer_category_t */
uint32_t category;
/** @brief domain */
uint32_t kind;
};
/** @brief generic identifier. You can compute this via: `uint64_t hash = category |
* ((uint64_t)(kind) << 32)` */
uint64_t hash;
};
/** @brief Pointer to data. Should be casted to data type based on category + kind */
void* payload;
} rocprofiler_record_header_t;
/**
* @brief Function for computing the unsigned 64-bit hash value in ::rocprofiler_record_header_t
* from a category and kind (two unsigned 32-bit values)
*
* @param [in] category a value from ::rocprofiler_buffer_category_t
* @param [in] kind depending on the category, this is the domain value, e.g.,
* ::rocprofiler_buffer_tracing_kind_t value
* @return uint64_t hash value of category and kind
*/
static inline uint64_t
rocprofiler_record_header_compute_hash(uint32_t category, uint32_t kind)
{
uint64_t value = category;
value |= ((uint64_t)(kind)) << 32;
return value;
}
/**
* @brief ROCProfiler kernel dispatch information
*
*/
typedef struct rocprofiler_kernel_dispatch_info_t
{
uint64_t size; ///< Size of this struct (minus reserved padding)
rocprofiler_agent_id_t agent_id; ///< Agent ID where kernel is launched
rocprofiler_queue_id_t queue_id; ///< Queue ID where kernel packet is enqueued
rocprofiler_kernel_id_t kernel_id; ///< Kernel identifier
rocprofiler_dispatch_id_t dispatch_id; ///< unique id for each dispatch
uint32_t private_segment_size;
uint32_t group_segment_size;
rocprofiler_dim3_t workgroup_size; ///< runtime workgroup size (grid * threads)
rocprofiler_dim3_t grid_size; ///< runtime grid size
uint8_t reserved_padding[56]; // reserved for extensions w/o ABI break
/// @var group_segment_size
/// @brief Runtime group memory segment size. Size of group segment memory (static + runtime)
/// required by the kernel (per work-group), in bytes. AKA: LDS size
///
/// @var private_segment_size
/// @brief Runtime private memory segment size. Size of private, spill, and arg segment memory
/// (static + runtime) required by this kernel (per work-item), in bytes. AKA: scratch size
} rocprofiler_kernel_dispatch_info_t;
/**
* @brief (experimental) Details for the dimension, including its size, for a counter record.
*/
typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_counter_record_dimension_info_t
{
const char* name;
size_t instance_size;
rocprofiler_counter_dimension_id_t id;
/// @var id
/// @brief Id for this dimension used by ::rocprofiler_query_record_dimension_position
} rocprofiler_counter_record_dimension_info_t;
ROCPROFILER_SDK_DEPRECATED("rocprofiler_counter_record_dimension_info_t was renamed to "
"rocprofiler_counter_record_dimension_info_t")
typedef rocprofiler_counter_record_dimension_info_t rocprofiler_record_dimension_info_t;
/**
* @brief (experimental) ROCProfiler Profile Counting Counter Record per instance.
*/
typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_counter_record_t
{
rocprofiler_counter_instance_id_t id; ///< counter identifier
double counter_value; ///< counter value
rocprofiler_dispatch_id_t dispatch_id;
rocprofiler_user_data_t user_data;
rocprofiler_agent_id_t agent_id;
/// @var dispatch_id
/// @brief A value greater than zero indicates that this counter record is associated with a
/// specific dispatch.
///
/// This value can be mapped to a dispatch via the `dispatch_info` field (@see
/// ::rocprofiler_kernel_dispatch_info_t) of a ::rocprofiler_dispatch_counting_service_data_t
/// instance (provided during callback for profile config) or a
/// ::rocprofiler_dispatch_counting_service_record_t records (which will be insert into the
/// buffer prior to the associated ::rocprofiler_counter_record_t records).
} rocprofiler_counter_record_t;
ROCPROFILER_SDK_DEPRECATED(
"rocprofiler_record_counter_t was renamed to rocprofiler_counter_record_t")
typedef rocprofiler_counter_record_t rocprofiler_record_counter_t;
#if defined(ROCPROFILER_SDK_BETA_COMPAT) && ROCPROFILER_SDK_BETA_COMPAT > 0
// "profile_config" renamed to "counter_config"
ROCPROFILER_SDK_DEPRECATED("profile_config renamed to counter_config")
typedef rocprofiler_counter_config_id_t rocprofiler_profile_config_id_t;
#endif
/** @} */
ROCPROFILER_EXTERN_C_FINI
ROCPROFILER_CXX_CODE(
static_assert(sizeof(rocprofiler_kernel_dispatch_info_t) == 128,
"Increasing the size of the kernel dispatch info is not permitted");)
+27
ファイルの表示
@@ -0,0 +1,27 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/hip/api_args.h>
#include <rocprofiler-sdk/hip/api_id.h>
#include <rocprofiler-sdk/hip/table_id.h>
+12
ファイルの表示
@@ -0,0 +1,12 @@
#
#
# Installation of public HIP headers
#
#
set(ROCPROFILER_HIP_HEADER_FILES api_args.h api_id.h compiler_api_id.h runtime_api_id.h
table_id.h)
install(
FILES ${ROCPROFILER_HIP_HEADER_FILES}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocprofiler-sdk/hip
COMPONENT development)
ファイル差分が大きすぎるため表示されません。 差分を読み込み
+26
ファイルの表示
@@ -0,0 +1,26 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include "compiler_api_id.h"
#include "runtime_api_id.h"
+43
ファイルの表示
@@ -0,0 +1,43 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <hip/amd_detail/hip_api_trace.hpp>
/**
* @brief ROCProfiler enumeration of HIP Compiler API tracing operations
*/
typedef enum rocprofiler_hip_compiler_api_id_t // NOLINT(performance-enum-size)
{
ROCPROFILER_HIP_COMPILER_API_ID_NONE = -1,
ROCPROFILER_HIP_COMPILER_API_ID___hipPopCallConfiguration = 0,
ROCPROFILER_HIP_COMPILER_API_ID___hipPushCallConfiguration,
ROCPROFILER_HIP_COMPILER_API_ID___hipRegisterFatBinary,
ROCPROFILER_HIP_COMPILER_API_ID___hipRegisterFunction,
ROCPROFILER_HIP_COMPILER_API_ID___hipRegisterManagedVar,
ROCPROFILER_HIP_COMPILER_API_ID___hipRegisterSurface,
ROCPROFILER_HIP_COMPILER_API_ID___hipRegisterTexture,
ROCPROFILER_HIP_COMPILER_API_ID___hipRegisterVar,
ROCPROFILER_HIP_COMPILER_API_ID___hipUnregisterFatBinary,
ROCPROFILER_HIP_COMPILER_API_ID_LAST,
} rocprofiler_hip_compiler_api_id_t;
+535
ファイルの表示
@@ -0,0 +1,535 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <hip/amd_detail/hip_api_trace.hpp>
/**
* @brief ROCProfiler enumeration of HIP runtime API tracing operations
*/
typedef enum rocprofiler_hip_runtime_api_id_t // NOLINT(performance-enum-size)
{
ROCPROFILER_HIP_RUNTIME_API_ID_NONE = -1,
ROCPROFILER_HIP_RUNTIME_API_ID_hipApiName = 0,
ROCPROFILER_HIP_RUNTIME_API_ID_hipArray3DCreate,
ROCPROFILER_HIP_RUNTIME_API_ID_hipArray3DGetDescriptor,
ROCPROFILER_HIP_RUNTIME_API_ID_hipArrayCreate,
ROCPROFILER_HIP_RUNTIME_API_ID_hipArrayDestroy,
ROCPROFILER_HIP_RUNTIME_API_ID_hipArrayGetDescriptor,
ROCPROFILER_HIP_RUNTIME_API_ID_hipArrayGetInfo,
ROCPROFILER_HIP_RUNTIME_API_ID_hipBindTexture, ///< deprecated or removed
ROCPROFILER_HIP_RUNTIME_API_ID_hipBindTexture2D, ///< deprecated or removed
ROCPROFILER_HIP_RUNTIME_API_ID_hipBindTextureToArray, ///< deprecated or removed
ROCPROFILER_HIP_RUNTIME_API_ID_hipBindTextureToMipmappedArray, ///< deprecated or removed
ROCPROFILER_HIP_RUNTIME_API_ID_hipChooseDevice,
ROCPROFILER_HIP_RUNTIME_API_ID_hipChooseDeviceR0000,
ROCPROFILER_HIP_RUNTIME_API_ID_hipConfigureCall,
ROCPROFILER_HIP_RUNTIME_API_ID_hipCreateSurfaceObject,
ROCPROFILER_HIP_RUNTIME_API_ID_hipCreateTextureObject, ///< deprecated or removed
ROCPROFILER_HIP_RUNTIME_API_ID_hipCtxCreate,
ROCPROFILER_HIP_RUNTIME_API_ID_hipCtxDestroy,
ROCPROFILER_HIP_RUNTIME_API_ID_hipCtxDisablePeerAccess,
ROCPROFILER_HIP_RUNTIME_API_ID_hipCtxEnablePeerAccess,
ROCPROFILER_HIP_RUNTIME_API_ID_hipCtxGetApiVersion,
ROCPROFILER_HIP_RUNTIME_API_ID_hipCtxGetCacheConfig,
ROCPROFILER_HIP_RUNTIME_API_ID_hipCtxGetCurrent,
ROCPROFILER_HIP_RUNTIME_API_ID_hipCtxGetDevice,
ROCPROFILER_HIP_RUNTIME_API_ID_hipCtxGetFlags,
ROCPROFILER_HIP_RUNTIME_API_ID_hipCtxGetSharedMemConfig,
ROCPROFILER_HIP_RUNTIME_API_ID_hipCtxPopCurrent,
ROCPROFILER_HIP_RUNTIME_API_ID_hipCtxPushCurrent,
ROCPROFILER_HIP_RUNTIME_API_ID_hipCtxSetCacheConfig,
ROCPROFILER_HIP_RUNTIME_API_ID_hipCtxSetCurrent,
ROCPROFILER_HIP_RUNTIME_API_ID_hipCtxSetSharedMemConfig,
ROCPROFILER_HIP_RUNTIME_API_ID_hipCtxSynchronize,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDestroyExternalMemory,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDestroyExternalSemaphore,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDestroySurfaceObject,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDestroyTextureObject, ///< deprecated or removed
ROCPROFILER_HIP_RUNTIME_API_ID_hipDeviceCanAccessPeer,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDeviceComputeCapability,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDeviceDisablePeerAccess,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDeviceEnablePeerAccess,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDeviceGet,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDeviceGetAttribute,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDeviceGetByPCIBusId,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDeviceGetCacheConfig,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDeviceGetDefaultMemPool,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDeviceGetGraphMemAttribute,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDeviceGetLimit,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDeviceGetMemPool,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDeviceGetName,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDeviceGetP2PAttribute,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDeviceGetPCIBusId,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDeviceGetSharedMemConfig,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDeviceGetStreamPriorityRange,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDeviceGetUuid,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDeviceGraphMemTrim,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDevicePrimaryCtxGetState,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDevicePrimaryCtxRelease,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDevicePrimaryCtxReset,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDevicePrimaryCtxRetain,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDevicePrimaryCtxSetFlags,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDeviceReset,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDeviceSetCacheConfig,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDeviceSetGraphMemAttribute,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDeviceSetLimit,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDeviceSetMemPool,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDeviceSetSharedMemConfig,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDeviceSynchronize,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDeviceTotalMem,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDriverGetVersion,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDrvGetErrorName,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDrvGetErrorString,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDrvGraphAddMemcpyNode,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDrvMemcpy2DUnaligned,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDrvMemcpy3D,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDrvMemcpy3DAsync,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDrvPointerGetAttributes,
ROCPROFILER_HIP_RUNTIME_API_ID_hipEventCreate,
ROCPROFILER_HIP_RUNTIME_API_ID_hipEventCreateWithFlags,
ROCPROFILER_HIP_RUNTIME_API_ID_hipEventDestroy,
ROCPROFILER_HIP_RUNTIME_API_ID_hipEventElapsedTime,
ROCPROFILER_HIP_RUNTIME_API_ID_hipEventQuery,
ROCPROFILER_HIP_RUNTIME_API_ID_hipEventRecord,
ROCPROFILER_HIP_RUNTIME_API_ID_hipEventSynchronize,
ROCPROFILER_HIP_RUNTIME_API_ID_hipExtGetLinkTypeAndHopCount,
ROCPROFILER_HIP_RUNTIME_API_ID_hipExtLaunchKernel,
ROCPROFILER_HIP_RUNTIME_API_ID_hipExtLaunchMultiKernelMultiDevice,
ROCPROFILER_HIP_RUNTIME_API_ID_hipExtMallocWithFlags,
ROCPROFILER_HIP_RUNTIME_API_ID_hipExtStreamCreateWithCUMask,
ROCPROFILER_HIP_RUNTIME_API_ID_hipExtStreamGetCUMask,
ROCPROFILER_HIP_RUNTIME_API_ID_hipExternalMemoryGetMappedBuffer,
ROCPROFILER_HIP_RUNTIME_API_ID_hipFree,
ROCPROFILER_HIP_RUNTIME_API_ID_hipFreeArray,
ROCPROFILER_HIP_RUNTIME_API_ID_hipFreeAsync,
ROCPROFILER_HIP_RUNTIME_API_ID_hipFreeHost,
ROCPROFILER_HIP_RUNTIME_API_ID_hipFreeMipmappedArray,
ROCPROFILER_HIP_RUNTIME_API_ID_hipFuncGetAttribute,
ROCPROFILER_HIP_RUNTIME_API_ID_hipFuncGetAttributes,
ROCPROFILER_HIP_RUNTIME_API_ID_hipFuncSetAttribute,
ROCPROFILER_HIP_RUNTIME_API_ID_hipFuncSetCacheConfig,
ROCPROFILER_HIP_RUNTIME_API_ID_hipFuncSetSharedMemConfig,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGLGetDevices,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGetChannelDesc,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGetDevice,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGetDeviceCount,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGetDeviceFlags,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGetDevicePropertiesR0600,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGetDevicePropertiesR0000,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGetErrorName,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGetErrorString,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGetLastError,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGetMipmappedArrayLevel,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGetSymbolAddress,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGetSymbolSize,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGetTextureAlignmentOffset, ///< deprecated or removed
ROCPROFILER_HIP_RUNTIME_API_ID_hipGetTextureObjectResourceDesc, ///< deprecated or removed
ROCPROFILER_HIP_RUNTIME_API_ID_hipGetTextureObjectResourceViewDesc, ///< deprecated or removed
ROCPROFILER_HIP_RUNTIME_API_ID_hipGetTextureObjectTextureDesc, ///< deprecated or removed
ROCPROFILER_HIP_RUNTIME_API_ID_hipGetTextureReference, ///< deprecated or removed
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphAddChildGraphNode,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphAddDependencies,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphAddEmptyNode,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphAddEventRecordNode,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphAddEventWaitNode,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphAddHostNode,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphAddKernelNode,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphAddMemAllocNode,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphAddMemFreeNode,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphAddMemcpyNode,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphAddMemcpyNode1D,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphAddMemcpyNodeFromSymbol,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphAddMemcpyNodeToSymbol,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphAddMemsetNode,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphChildGraphNodeGetGraph,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphClone,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphCreate,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphDebugDotPrint,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphDestroy,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphDestroyNode,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphEventRecordNodeGetEvent,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphEventRecordNodeSetEvent,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphEventWaitNodeGetEvent,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphEventWaitNodeSetEvent,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphExecChildGraphNodeSetParams,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphExecDestroy,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphExecEventRecordNodeSetEvent,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphExecEventWaitNodeSetEvent,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphExecHostNodeSetParams,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphExecKernelNodeSetParams,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphExecMemcpyNodeSetParams,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphExecMemcpyNodeSetParams1D,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphExecMemcpyNodeSetParamsFromSymbol,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphExecMemcpyNodeSetParamsToSymbol,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphExecMemsetNodeSetParams,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphExecUpdate,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphGetEdges,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphGetNodes,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphGetRootNodes,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphHostNodeGetParams,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphHostNodeSetParams,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphInstantiate,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphInstantiateWithFlags,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphKernelNodeCopyAttributes,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphKernelNodeGetAttribute,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphKernelNodeGetParams,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphKernelNodeSetAttribute,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphKernelNodeSetParams,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphLaunch,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphMemAllocNodeGetParams,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphMemFreeNodeGetParams,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphMemcpyNodeGetParams,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphMemcpyNodeSetParams,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphMemcpyNodeSetParams1D,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphMemcpyNodeSetParamsFromSymbol,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphMemcpyNodeSetParamsToSymbol,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphMemsetNodeGetParams,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphMemsetNodeSetParams,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphNodeFindInClone,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphNodeGetDependencies,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphNodeGetDependentNodes,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphNodeGetEnabled,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphNodeGetType,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphNodeSetEnabled,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphReleaseUserObject,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphRemoveDependencies,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphRetainUserObject,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphUpload,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphicsGLRegisterBuffer,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphicsGLRegisterImage,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphicsMapResources,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphicsResourceGetMappedPointer,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphicsSubResourceGetMappedArray,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphicsUnmapResources,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphicsUnregisterResource,
ROCPROFILER_HIP_RUNTIME_API_ID_hipHostAlloc,
ROCPROFILER_HIP_RUNTIME_API_ID_hipHostFree,
ROCPROFILER_HIP_RUNTIME_API_ID_hipHostGetDevicePointer,
ROCPROFILER_HIP_RUNTIME_API_ID_hipHostGetFlags,
ROCPROFILER_HIP_RUNTIME_API_ID_hipHostMalloc,
ROCPROFILER_HIP_RUNTIME_API_ID_hipHostRegister,
ROCPROFILER_HIP_RUNTIME_API_ID_hipHostUnregister,
ROCPROFILER_HIP_RUNTIME_API_ID_hipImportExternalMemory,
ROCPROFILER_HIP_RUNTIME_API_ID_hipImportExternalSemaphore,
ROCPROFILER_HIP_RUNTIME_API_ID_hipInit,
ROCPROFILER_HIP_RUNTIME_API_ID_hipIpcCloseMemHandle,
ROCPROFILER_HIP_RUNTIME_API_ID_hipIpcGetEventHandle,
ROCPROFILER_HIP_RUNTIME_API_ID_hipIpcGetMemHandle,
ROCPROFILER_HIP_RUNTIME_API_ID_hipIpcOpenEventHandle,
ROCPROFILER_HIP_RUNTIME_API_ID_hipIpcOpenMemHandle,
ROCPROFILER_HIP_RUNTIME_API_ID_hipKernelNameRef,
ROCPROFILER_HIP_RUNTIME_API_ID_hipKernelNameRefByPtr,
ROCPROFILER_HIP_RUNTIME_API_ID_hipLaunchByPtr,
ROCPROFILER_HIP_RUNTIME_API_ID_hipLaunchCooperativeKernel,
ROCPROFILER_HIP_RUNTIME_API_ID_hipLaunchCooperativeKernelMultiDevice,
ROCPROFILER_HIP_RUNTIME_API_ID_hipLaunchHostFunc,
ROCPROFILER_HIP_RUNTIME_API_ID_hipLaunchKernel,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMalloc,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMalloc3D,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMalloc3DArray,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMallocArray,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMallocAsync,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMallocFromPoolAsync,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMallocHost,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMallocManaged,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMallocMipmappedArray,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMallocPitch,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemAddressFree,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemAddressReserve,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemAdvise,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemAllocHost,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemAllocPitch,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemCreate,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemExportToShareableHandle,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemGetAccess,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemGetAddressRange,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemGetAllocationGranularity,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemGetAllocationPropertiesFromHandle,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemGetInfo,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemImportFromShareableHandle,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemMap,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemMapArrayAsync,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemPoolCreate,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemPoolDestroy,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemPoolExportPointer,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemPoolExportToShareableHandle,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemPoolGetAccess,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemPoolGetAttribute,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemPoolImportFromShareableHandle,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemPoolImportPointer,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemPoolSetAccess,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemPoolSetAttribute,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemPoolTrimTo,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemPrefetchAsync,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemPtrGetInfo,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemRangeGetAttribute,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemRangeGetAttributes,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemRelease,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemRetainAllocationHandle,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemSetAccess,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemUnmap,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpy,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpy2D,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpy2DAsync,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpy2DFromArray,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpy2DFromArrayAsync,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpy2DToArray,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpy2DToArrayAsync,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpy3D,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpy3DAsync,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpyAsync,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpyAtoH,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpyDtoD,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpyDtoDAsync,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpyDtoH,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpyDtoHAsync,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpyFromArray,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpyFromSymbol,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpyFromSymbolAsync,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpyHtoA,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpyHtoD,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpyHtoDAsync,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpyParam2D,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpyParam2DAsync,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpyPeer,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpyPeerAsync,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpyToArray,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpyToSymbol,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpyToSymbolAsync,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpyWithStream,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemset,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemset2D,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemset2DAsync,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemset3D,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemset3DAsync,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemsetAsync,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemsetD16,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemsetD16Async,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemsetD32,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemsetD32Async,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemsetD8,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemsetD8Async,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMipmappedArrayCreate,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMipmappedArrayDestroy,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMipmappedArrayGetLevel,
ROCPROFILER_HIP_RUNTIME_API_ID_hipModuleGetFunction,
ROCPROFILER_HIP_RUNTIME_API_ID_hipModuleGetGlobal,
ROCPROFILER_HIP_RUNTIME_API_ID_hipModuleGetTexRef,
ROCPROFILER_HIP_RUNTIME_API_ID_hipModuleLaunchCooperativeKernel,
ROCPROFILER_HIP_RUNTIME_API_ID_hipModuleLaunchCooperativeKernelMultiDevice,
ROCPROFILER_HIP_RUNTIME_API_ID_hipModuleLaunchKernel,
ROCPROFILER_HIP_RUNTIME_API_ID_hipModuleLoad,
ROCPROFILER_HIP_RUNTIME_API_ID_hipModuleLoadData,
ROCPROFILER_HIP_RUNTIME_API_ID_hipModuleLoadDataEx,
ROCPROFILER_HIP_RUNTIME_API_ID_hipModuleOccupancyMaxActiveBlocksPerMultiprocessor,
ROCPROFILER_HIP_RUNTIME_API_ID_hipModuleOccupancyMaxActiveBlocksPerMultiprocessorWithFlags,
ROCPROFILER_HIP_RUNTIME_API_ID_hipModuleOccupancyMaxPotentialBlockSize,
ROCPROFILER_HIP_RUNTIME_API_ID_hipModuleOccupancyMaxPotentialBlockSizeWithFlags,
ROCPROFILER_HIP_RUNTIME_API_ID_hipModuleUnload,
ROCPROFILER_HIP_RUNTIME_API_ID_hipOccupancyMaxActiveBlocksPerMultiprocessor,
ROCPROFILER_HIP_RUNTIME_API_ID_hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags,
ROCPROFILER_HIP_RUNTIME_API_ID_hipOccupancyMaxPotentialBlockSize,
ROCPROFILER_HIP_RUNTIME_API_ID_hipPeekAtLastError,
ROCPROFILER_HIP_RUNTIME_API_ID_hipPointerGetAttribute,
ROCPROFILER_HIP_RUNTIME_API_ID_hipPointerGetAttributes,
ROCPROFILER_HIP_RUNTIME_API_ID_hipPointerSetAttribute,
ROCPROFILER_HIP_RUNTIME_API_ID_hipProfilerStart,
ROCPROFILER_HIP_RUNTIME_API_ID_hipProfilerStop,
ROCPROFILER_HIP_RUNTIME_API_ID_hipRuntimeGetVersion,
ROCPROFILER_HIP_RUNTIME_API_ID_hipSetDevice,
ROCPROFILER_HIP_RUNTIME_API_ID_hipSetDeviceFlags,
ROCPROFILER_HIP_RUNTIME_API_ID_hipSetupArgument,
ROCPROFILER_HIP_RUNTIME_API_ID_hipSignalExternalSemaphoresAsync,
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamAddCallback,
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamAttachMemAsync,
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamBeginCapture,
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamCreate,
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamCreateWithFlags,
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamCreateWithPriority,
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamDestroy,
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamEndCapture,
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamGetCaptureInfo,
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamGetCaptureInfo_v2,
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamGetDevice,
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamGetFlags,
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamGetPriority,
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamIsCapturing,
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamQuery,
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamSynchronize,
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamUpdateCaptureDependencies,
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamWaitEvent,
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamWaitValue32,
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamWaitValue64,
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamWriteValue32,
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamWriteValue64,
ROCPROFILER_HIP_RUNTIME_API_ID_hipTexObjectCreate, ///< deprecated or removed
ROCPROFILER_HIP_RUNTIME_API_ID_hipTexObjectDestroy, ///< deprecated or removed
ROCPROFILER_HIP_RUNTIME_API_ID_hipTexObjectGetResourceDesc, ///< deprecated or removed
ROCPROFILER_HIP_RUNTIME_API_ID_hipTexObjectGetResourceViewDesc, ///< deprecated or removed
ROCPROFILER_HIP_RUNTIME_API_ID_hipTexObjectGetTextureDesc, ///< deprecated or removed
ROCPROFILER_HIP_RUNTIME_API_ID_hipTexRefGetAddress,
ROCPROFILER_HIP_RUNTIME_API_ID_hipTexRefGetAddressMode, ///< deprecated or removed
ROCPROFILER_HIP_RUNTIME_API_ID_hipTexRefGetFilterMode, ///< deprecated or removed
ROCPROFILER_HIP_RUNTIME_API_ID_hipTexRefGetFlags,
ROCPROFILER_HIP_RUNTIME_API_ID_hipTexRefGetFormat,
ROCPROFILER_HIP_RUNTIME_API_ID_hipTexRefGetMaxAnisotropy,
ROCPROFILER_HIP_RUNTIME_API_ID_hipTexRefGetMipMappedArray,
ROCPROFILER_HIP_RUNTIME_API_ID_hipTexRefGetMipmapFilterMode, ///< deprecated or removed
ROCPROFILER_HIP_RUNTIME_API_ID_hipTexRefGetMipmapLevelBias,
ROCPROFILER_HIP_RUNTIME_API_ID_hipTexRefGetMipmapLevelClamp,
ROCPROFILER_HIP_RUNTIME_API_ID_hipTexRefSetAddress,
ROCPROFILER_HIP_RUNTIME_API_ID_hipTexRefSetAddress2D,
ROCPROFILER_HIP_RUNTIME_API_ID_hipTexRefSetAddressMode, ///< deprecated or removed
ROCPROFILER_HIP_RUNTIME_API_ID_hipTexRefSetArray,
ROCPROFILER_HIP_RUNTIME_API_ID_hipTexRefSetBorderColor,
ROCPROFILER_HIP_RUNTIME_API_ID_hipTexRefSetFilterMode, ///< deprecated or removed
ROCPROFILER_HIP_RUNTIME_API_ID_hipTexRefSetFlags,
ROCPROFILER_HIP_RUNTIME_API_ID_hipTexRefSetFormat,
ROCPROFILER_HIP_RUNTIME_API_ID_hipTexRefSetMaxAnisotropy,
ROCPROFILER_HIP_RUNTIME_API_ID_hipTexRefSetMipmapFilterMode, ///< deprecated or removed
ROCPROFILER_HIP_RUNTIME_API_ID_hipTexRefSetMipmapLevelBias,
ROCPROFILER_HIP_RUNTIME_API_ID_hipTexRefSetMipmapLevelClamp,
ROCPROFILER_HIP_RUNTIME_API_ID_hipTexRefSetMipmappedArray,
ROCPROFILER_HIP_RUNTIME_API_ID_hipThreadExchangeStreamCaptureMode,
ROCPROFILER_HIP_RUNTIME_API_ID_hipUnbindTexture, ///< deprecated or removed
ROCPROFILER_HIP_RUNTIME_API_ID_hipUserObjectCreate,
ROCPROFILER_HIP_RUNTIME_API_ID_hipUserObjectRelease,
ROCPROFILER_HIP_RUNTIME_API_ID_hipUserObjectRetain,
ROCPROFILER_HIP_RUNTIME_API_ID_hipWaitExternalSemaphoresAsync,
ROCPROFILER_HIP_RUNTIME_API_ID_hipCreateChannelDesc,
ROCPROFILER_HIP_RUNTIME_API_ID_hipExtModuleLaunchKernel,
ROCPROFILER_HIP_RUNTIME_API_ID_hipHccModuleLaunchKernel,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpy_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpyToSymbol_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpyFromSymbol_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpy2D_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpy2DFromArray_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpy3D_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemset_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemsetAsync_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemset2D_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemset2DAsync_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemset3DAsync_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemset3D_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpyAsync_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpy3DAsync_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpy2DAsync_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpyFromSymbolAsync_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpyToSymbolAsync_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpyFromArray_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpy2DToArray_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpy2DFromArrayAsync_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpy2DToArrayAsync_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamQuery_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamSynchronize_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamGetPriority_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamWaitEvent_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamGetFlags_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamAddCallback_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipEventRecord_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipLaunchCooperativeKernel_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipLaunchKernel_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphLaunch_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamBeginCapture_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamEndCapture_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamIsCapturing_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamGetCaptureInfo_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamGetCaptureInfo_v2_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipLaunchHostFunc_spt,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGetStreamDeviceId,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDrvGraphAddMemsetNode,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphAddExternalSemaphoresWaitNode,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphAddExternalSemaphoresSignalNode,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphExternalSemaphoresSignalNodeSetParams,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphExternalSemaphoresWaitNodeSetParams,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphExternalSemaphoresSignalNodeGetParams,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphExternalSemaphoresWaitNodeGetParams,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphExecExternalSemaphoresSignalNodeSetParams,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphExecExternalSemaphoresWaitNodeSetParams,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphAddNode,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphInstantiateWithParams,
ROCPROFILER_HIP_RUNTIME_API_ID_hipExtGetLastError,
ROCPROFILER_HIP_RUNTIME_API_ID_hipTexRefGetBorderColor,
ROCPROFILER_HIP_RUNTIME_API_ID_hipTexRefGetArray,
#if HIP_RUNTIME_API_TABLE_STEP_VERSION >= 1
ROCPROFILER_HIP_RUNTIME_API_ID_hipGetProcAddress,
#endif
#if HIP_RUNTIME_API_TABLE_STEP_VERSION >= 2
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamBeginCaptureToGraph,
#endif
#if HIP_RUNTIME_API_TABLE_STEP_VERSION >= 3
ROCPROFILER_HIP_RUNTIME_API_ID_hipGetFuncBySymbol,
ROCPROFILER_HIP_RUNTIME_API_ID_hipSetValidDevices,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpyAtoD,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpyDtoA,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpyAtoA,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpyAtoHAsync,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpyHtoAAsync,
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpy2DArrayToArray,
#endif
#if HIP_RUNTIME_API_TABLE_STEP_VERSION >= 4
ROCPROFILER_HIP_RUNTIME_API_ID_hipDrvGraphAddMemFreeNode,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDrvGraphExecMemcpyNodeSetParams,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDrvGraphExecMemsetNodeSetParams,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphExecGetFlags,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphNodeSetParams,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphExecNodeSetParams,
ROCPROFILER_HIP_RUNTIME_API_ID_hipExternalMemoryGetMappedMipmappedArray,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDrvGraphMemcpyNodeGetParams,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDrvGraphMemcpyNodeSetParams,
#endif
#if HIP_RUNTIME_API_TABLE_STEP_VERSION >= 5
ROCPROFILER_HIP_RUNTIME_API_ID_hipExtHostAlloc,
#endif
#if HIP_RUNTIME_API_TABLE_STEP_VERSION >= 6
ROCPROFILER_HIP_RUNTIME_API_ID_hipDeviceGetTexture1DLinearMaxWidth,
#endif
#if HIP_RUNTIME_API_TABLE_STEP_VERSION >= 7
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamBatchMemOp,
#endif
#if HIP_RUNTIME_API_TABLE_STEP_VERSION >= 8
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphAddBatchMemOpNode,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphBatchMemOpNodeGetParams,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphBatchMemOpNodeSetParams,
ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphExecBatchMemOpNodeSetParams,
#endif
#if HIP_RUNTIME_API_TABLE_STEP_VERSION >= 9
ROCPROFILER_HIP_RUNTIME_API_ID_hipLinkAddData,
ROCPROFILER_HIP_RUNTIME_API_ID_hipLinkAddFile,
ROCPROFILER_HIP_RUNTIME_API_ID_hipLinkComplete,
ROCPROFILER_HIP_RUNTIME_API_ID_hipLinkCreate,
ROCPROFILER_HIP_RUNTIME_API_ID_hipLinkDestroy,
#endif
#if HIP_RUNTIME_API_TABLE_STEP_VERSION >= 10
ROCPROFILER_HIP_RUNTIME_API_ID_hipEventRecordWithFlags,
#endif
#if HIP_RUNTIME_API_TABLE_STEP_VERSION >= 11
ROCPROFILER_HIP_RUNTIME_API_ID_hipLaunchKernelExC,
ROCPROFILER_HIP_RUNTIME_API_ID_hipDrvLaunchKernelEx,
#endif
#if HIP_RUNTIME_API_TABLE_STEP_VERSION >= 12
ROCPROFILER_HIP_RUNTIME_API_ID_hipMemGetHandleForAddressRange,
#endif
ROCPROFILER_HIP_RUNTIME_API_ID_LAST,
} rocprofiler_hip_runtime_api_id_t;
+32
ファイルの表示
@@ -0,0 +1,32 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
// NOLINTNEXTLINE(performance-enum-size)
typedef enum rocprofiler_hip_table_id_t
{
ROCPROFILER_HIP_TABLE_ID_NONE = -1,
ROCPROFILER_HIP_TABLE_ID_Compiler = 0,
ROCPROFILER_HIP_TABLE_ID_Runtime,
ROCPROFILER_HIP_TABLE_ID_LAST,
} rocprofiler_hip_table_id_t;
+47
ファイルの表示
@@ -0,0 +1,47 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
// without AMD_INTERNAL_BUILD defined, including the hsa/hsa.h looks for headers in inc/ folder
// so we always want it defined but we set ROCPROFILER_DEFINED_AMD_INTERNAL_BUILD to 1 to tell
// us that after this include, we should undefine it
#ifndef AMD_INTERNAL_BUILD
# define AMD_INTERNAL_BUILD
# ifndef ROCPROFILER_DEFINED_AMD_INTERNAL_BUILD
# define ROCPROFILER_DEFINED_AMD_INTERNAL_BUILD 1
# endif
#endif
#include <hsa/hsa.h>
#include <rocprofiler-sdk/hsa/api_trace_version.h>
#include <rocprofiler-sdk/hsa/api_args.h>
#include <rocprofiler-sdk/hsa/api_id.h>
#include <rocprofiler-sdk/hsa/scratch_memory_args.h>
#include <rocprofiler-sdk/hsa/scratch_memory_id.h>
#include <rocprofiler-sdk/hsa/table_id.h>
#if defined(ROCPROFILER_DEFINED_AMD_INTERNAL_BUILD) && ROCPROFILER_DEFINED_AMD_INTERNAL_BUILD > 0
# undef AMD_INTERNAL_BUILD
#endif
+21
ファイルの表示
@@ -0,0 +1,21 @@
#
#
# Installation of public HSA headers
#
#
set(ROCPROFILER_HSA_HEADER_FILES
amd_ext_api_id.h
api_args.h
api_id.h
api_trace_version.h
core_api_id.h
finalize_ext_api_id.h
image_ext_api_id.h
scratch_memory_args.h
scratch_memory_id.h
table_id.h)
install(
FILES ${ROCPROFILER_HSA_HEADER_FILES}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocprofiler-sdk/hsa
COMPONENT development)
+127
ファイルの表示
@@ -0,0 +1,127 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/ext_version.h>
#include <rocprofiler-sdk/hsa/api_trace_version.h>
/**
* @brief ROCProfiler enumeration of HSA AMD Extended API tracing operations
*/
typedef enum rocprofiler_hsa_amd_ext_api_id_t // NOLINT(performance-enum-size)
{
ROCPROFILER_HSA_AMD_EXT_API_ID_NONE = -1,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_coherency_get_type,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_coherency_set_type,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_profiling_set_profiler_enabled,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_profiling_async_copy_enable,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_profiling_get_dispatch_time,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_profiling_get_async_copy_time,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_profiling_convert_tick_to_system_domain,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_signal_async_handler,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_async_function,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_signal_wait_any,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_queue_cu_set_mask,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_memory_pool_get_info,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_agent_iterate_memory_pools,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_memory_pool_allocate,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_memory_pool_free,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_memory_async_copy,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_memory_async_copy_on_engine,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_memory_copy_engine_status,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_agent_memory_pool_get_info,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_agents_allow_access,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_memory_pool_can_migrate,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_memory_migrate,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_memory_lock,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_memory_unlock,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_memory_fill,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_interop_map_buffer,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_interop_unmap_buffer,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_image_create,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_pointer_info,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_pointer_info_set_userdata,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_ipc_memory_create,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_ipc_memory_attach,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_ipc_memory_detach,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_signal_create,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_ipc_signal_create,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_ipc_signal_attach,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_register_system_event_handler,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_queue_intercept_create,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_queue_intercept_register,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_queue_set_priority,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_memory_async_copy_rect,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_runtime_queue_create_register,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_memory_lock_to_pool,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_register_deallocation_callback,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_deregister_deallocation_callback,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_signal_value_pointer,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_svm_attributes_set,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_svm_attributes_get,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_svm_prefetch_async,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_spm_acquire,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_spm_release,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_spm_set_dest_buffer,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_queue_cu_get_mask,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_portable_export_dmabuf,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_portable_close_dmabuf,
#if HSA_AMD_EXT_API_TABLE_MAJOR_VERSION >= 0x02
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_vmem_address_reserve,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_vmem_address_free,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_vmem_handle_create,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_vmem_handle_release,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_vmem_map,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_vmem_unmap,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_vmem_set_access,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_vmem_get_access,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_vmem_export_shareable_handle,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_vmem_import_shareable_handle,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_vmem_retain_alloc_handle,
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_vmem_get_alloc_properties_from_handle,
# if HSA_AMD_EXT_API_TABLE_STEP_VERSION >= 0x01
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_agent_set_async_scratch_limit,
# endif
# if HSA_AMD_EXT_API_TABLE_STEP_VERSION >= 0x02
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_queue_get_info,
# endif
# if HSA_AMD_EXT_API_TABLE_STEP_VERSION >= 0x03
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_vmem_address_reserve_align,
# endif
# if HSA_AMD_EXT_API_TABLE_STEP_VERSION >= 0x04
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_enable_logging,
# endif
# if HSA_AMD_EXT_API_TABLE_STEP_VERSION >= 0x05
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_signal_wait_all,
# endif
# if HSA_AMD_EXT_API_TABLE_STEP_VERSION >= 0x06
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_memory_get_preferred_copy_engine,
# endif
# if HSA_AMD_EXT_API_TABLE_STEP_VERSION >= 0x07
ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_portable_export_dmabuf_v2,
# endif
#endif
ROCPROFILER_HSA_AMD_EXT_API_ID_LAST,
} rocprofiler_hsa_amd_ext_api_id_t;
ファイル差分が大きすぎるため表示されません。 差分を読み込み
+28
ファイルの表示
@@ -0,0 +1,28 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include "amd_ext_api_id.h"
#include "core_api_id.h"
#include "finalize_ext_api_id.h"
#include "image_ext_api_id.h"
+121
ファイルの表示
@@ -0,0 +1,121 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/ext_version.h>
#if defined(__cplusplus)
# include <hsa/hsa_api_trace.h> // safe to include from C++
#elif defined(__has_include)
# if __has_include(<hsa/hsa_api_trace_version.h>)
# include <hsa/hsa_api_trace_version.h>
# endif
#endif
#ifndef HSA_API_TABLE_MAJOR_VERSION
# ifdef ROCPROFILER_HSA_API_TABLE_MAJOR_VERSION
# define HSA_API_TABLE_MAJOR_VERSION ROCPROFILER_HSA_API_TABLE_MAJOR_VERSION
# endif
#endif
#ifndef HSA_CORE_API_TABLE_MAJOR_VERSION
# ifdef ROCPROFILER_HSA_CORE_API_TABLE_MAJOR_VERSION
# define HSA_CORE_API_TABLE_MAJOR_VERSION ROCPROFILER_HSA_CORE_API_TABLE_MAJOR_VERSION
# endif
#endif
#ifndef HSA_AMD_EXT_API_TABLE_MAJOR_VERSION
# ifdef ROCPROFILER_HSA_AMD_EXT_API_TABLE_MAJOR_VERSION
# define HSA_AMD_EXT_API_TABLE_MAJOR_VERSION ROCPROFILER_HSA_AMD_EXT_API_TABLE_MAJOR_VERSION
# endif
#endif
#ifndef HSA_FINALIZER_API_TABLE_MAJOR_VERSION
# ifdef ROCPROFILER_HSA_FINALIZER_API_TABLE_MAJOR_VERSION
# define HSA_FINALIZER_API_TABLE_MAJOR_VERSION \
ROCPROFILER_HSA_FINALIZER_API_TABLE_MAJOR_VERSION
# endif
#endif
#ifndef HSA_IMAGE_API_TABLE_MAJOR_VERSION
# ifdef ROCPROFILER_HSA_IMAGE_API_TABLE_MAJOR_VERSION
# define HSA_IMAGE_API_TABLE_MAJOR_VERSION ROCPROFILER_HSA_IMAGE_API_TABLE_MAJOR_VERSION
# endif
#endif
#ifndef HSA_AQLPROFILE_API_TABLE_MAJOR_VERSION
# ifdef ROCPROFILER_HSA_AQLPROFILE_API_TABLE_MAJOR_VERSION
# define HSA_AQLPROFILE_API_TABLE_MAJOR_VERSION \
ROCPROFILER_HSA_AQLPROFILE_API_TABLE_MAJOR_VERSION
# endif
#endif
#ifndef HSA_TOOLS_API_TABLE_MAJOR_VERSION
# ifdef ROCPROFILER_HSA_TOOLS_API_TABLE_MAJOR_VERSION
# define HSA_TOOLS_API_TABLE_MAJOR_VERSION ROCPROFILER_HSA_TOOLS_API_TABLE_MAJOR_VERSION
# endif
#endif
#ifndef HSA_API_TABLE_STEP_VERSION
# ifdef ROCPROFILER_HSA_API_TABLE_STEP_VERSION
# define HSA_API_TABLE_STEP_VERSION ROCPROFILER_HSA_API_TABLE_STEP_VERSION
# endif
#endif
#ifndef HSA_CORE_API_TABLE_STEP_VERSION
# ifdef ROCPROFILER_HSA_CORE_API_TABLE_STEP_VERSION
# define HSA_CORE_API_TABLE_STEP_VERSION ROCPROFILER_HSA_CORE_API_TABLE_STEP_VERSION
# endif
#endif
#ifndef HSA_AMD_EXT_API_TABLE_STEP_VERSION
# ifdef ROCPROFILER_HSA_AMD_EXT_API_TABLE_STEP_VERSION
# define HSA_AMD_EXT_API_TABLE_STEP_VERSION ROCPROFILER_HSA_AMD_EXT_API_TABLE_STEP_VERSION
# endif
#endif
#ifndef HSA_FINALIZER_API_TABLE_STEP_VERSION
# ifdef ROCPROFILER_HSA_FINALIZER_API_TABLE_STEP_VERSION
# define HSA_FINALIZER_API_TABLE_STEP_VERSION \
ROCPROFILER_HSA_FINALIZER_API_TABLE_STEP_VERSION
# endif
#endif
#ifndef HSA_IMAGE_API_TABLE_STEP_VERSION
# ifdef ROCPROFILER_HSA_IMAGE_API_TABLE_STEP_VERSION
# define HSA_IMAGE_API_TABLE_STEP_VERSION ROCPROFILER_HSA_IMAGE_API_TABLE_STEP_VERSION
# endif
#endif
#ifndef HSA_AQLPROFILE_API_TABLE_STEP_VERSION
# ifdef ROCPROFILER_HSA_AQLPROFILE_API_TABLE_STEP_VERSION
# define HSA_AQLPROFILE_API_TABLE_STEP_VERSION \
ROCPROFILER_HSA_AQLPROFILE_API_TABLE_STEP_VERSION
# endif
#endif
#ifndef HSA_TOOLS_API_TABLE_STEP_VERSION
# ifdef ROCPROFILER_HSA_TOOLS_API_TABLE_STEP_VERSION
# define HSA_TOOLS_API_TABLE_STEP_VERSION ROCPROFILER_HSA_TOOLS_API_TABLE_STEP_VERSION
# endif
#endif
+160
ファイルの表示
@@ -0,0 +1,160 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/ext_version.h>
/**
* @brief ROCProfiler enumeration of HSA Core API tracing operations
*/
typedef enum rocprofiler_hsa_core_api_id_t // NOLINT(performance-enum-size)
{
ROCPROFILER_HSA_CORE_API_ID_NONE = -1,
ROCPROFILER_HSA_CORE_API_ID_hsa_init = 0,
ROCPROFILER_HSA_CORE_API_ID_hsa_shut_down,
ROCPROFILER_HSA_CORE_API_ID_hsa_system_get_info,
ROCPROFILER_HSA_CORE_API_ID_hsa_system_extension_supported,
ROCPROFILER_HSA_CORE_API_ID_hsa_system_get_extension_table,
ROCPROFILER_HSA_CORE_API_ID_hsa_iterate_agents,
ROCPROFILER_HSA_CORE_API_ID_hsa_agent_get_info,
ROCPROFILER_HSA_CORE_API_ID_hsa_queue_create,
ROCPROFILER_HSA_CORE_API_ID_hsa_soft_queue_create,
ROCPROFILER_HSA_CORE_API_ID_hsa_queue_destroy,
ROCPROFILER_HSA_CORE_API_ID_hsa_queue_inactivate,
ROCPROFILER_HSA_CORE_API_ID_hsa_queue_load_read_index_scacquire,
ROCPROFILER_HSA_CORE_API_ID_hsa_queue_load_read_index_relaxed,
ROCPROFILER_HSA_CORE_API_ID_hsa_queue_load_write_index_scacquire,
ROCPROFILER_HSA_CORE_API_ID_hsa_queue_load_write_index_relaxed,
ROCPROFILER_HSA_CORE_API_ID_hsa_queue_store_write_index_relaxed,
ROCPROFILER_HSA_CORE_API_ID_hsa_queue_store_write_index_screlease,
ROCPROFILER_HSA_CORE_API_ID_hsa_queue_cas_write_index_scacq_screl,
ROCPROFILER_HSA_CORE_API_ID_hsa_queue_cas_write_index_scacquire,
ROCPROFILER_HSA_CORE_API_ID_hsa_queue_cas_write_index_relaxed,
ROCPROFILER_HSA_CORE_API_ID_hsa_queue_cas_write_index_screlease,
ROCPROFILER_HSA_CORE_API_ID_hsa_queue_add_write_index_scacq_screl,
ROCPROFILER_HSA_CORE_API_ID_hsa_queue_add_write_index_scacquire,
ROCPROFILER_HSA_CORE_API_ID_hsa_queue_add_write_index_relaxed,
ROCPROFILER_HSA_CORE_API_ID_hsa_queue_add_write_index_screlease,
ROCPROFILER_HSA_CORE_API_ID_hsa_queue_store_read_index_relaxed,
ROCPROFILER_HSA_CORE_API_ID_hsa_queue_store_read_index_screlease,
ROCPROFILER_HSA_CORE_API_ID_hsa_agent_iterate_regions,
ROCPROFILER_HSA_CORE_API_ID_hsa_region_get_info,
ROCPROFILER_HSA_CORE_API_ID_hsa_agent_get_exception_policies,
ROCPROFILER_HSA_CORE_API_ID_hsa_agent_extension_supported,
ROCPROFILER_HSA_CORE_API_ID_hsa_memory_register,
ROCPROFILER_HSA_CORE_API_ID_hsa_memory_deregister,
ROCPROFILER_HSA_CORE_API_ID_hsa_memory_allocate,
ROCPROFILER_HSA_CORE_API_ID_hsa_memory_free,
ROCPROFILER_HSA_CORE_API_ID_hsa_memory_copy,
ROCPROFILER_HSA_CORE_API_ID_hsa_memory_assign_agent,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_create,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_destroy,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_load_relaxed,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_load_scacquire,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_store_relaxed,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_store_screlease,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_wait_relaxed,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_wait_scacquire,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_and_relaxed,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_and_scacquire,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_and_screlease,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_and_scacq_screl,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_or_relaxed,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_or_scacquire,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_or_screlease,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_or_scacq_screl,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_xor_relaxed,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_xor_scacquire,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_xor_screlease,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_xor_scacq_screl,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_exchange_relaxed,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_exchange_scacquire,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_exchange_screlease,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_exchange_scacq_screl,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_add_relaxed,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_add_scacquire,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_add_screlease,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_add_scacq_screl,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_subtract_relaxed,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_subtract_scacquire,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_subtract_screlease,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_subtract_scacq_screl,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_cas_relaxed,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_cas_scacquire,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_cas_screlease,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_cas_scacq_screl,
ROCPROFILER_HSA_CORE_API_ID_hsa_isa_from_name,
ROCPROFILER_HSA_CORE_API_ID_hsa_isa_get_info,
ROCPROFILER_HSA_CORE_API_ID_hsa_isa_compatible,
ROCPROFILER_HSA_CORE_API_ID_hsa_code_object_serialize,
ROCPROFILER_HSA_CORE_API_ID_hsa_code_object_deserialize,
ROCPROFILER_HSA_CORE_API_ID_hsa_code_object_destroy,
ROCPROFILER_HSA_CORE_API_ID_hsa_code_object_get_info,
ROCPROFILER_HSA_CORE_API_ID_hsa_code_object_get_symbol,
ROCPROFILER_HSA_CORE_API_ID_hsa_code_symbol_get_info,
ROCPROFILER_HSA_CORE_API_ID_hsa_code_object_iterate_symbols,
ROCPROFILER_HSA_CORE_API_ID_hsa_executable_create,
ROCPROFILER_HSA_CORE_API_ID_hsa_executable_destroy,
ROCPROFILER_HSA_CORE_API_ID_hsa_executable_load_code_object,
ROCPROFILER_HSA_CORE_API_ID_hsa_executable_freeze,
ROCPROFILER_HSA_CORE_API_ID_hsa_executable_get_info,
ROCPROFILER_HSA_CORE_API_ID_hsa_executable_global_variable_define,
ROCPROFILER_HSA_CORE_API_ID_hsa_executable_agent_global_variable_define,
ROCPROFILER_HSA_CORE_API_ID_hsa_executable_readonly_variable_define,
ROCPROFILER_HSA_CORE_API_ID_hsa_executable_validate,
ROCPROFILER_HSA_CORE_API_ID_hsa_executable_get_symbol,
ROCPROFILER_HSA_CORE_API_ID_hsa_executable_symbol_get_info,
ROCPROFILER_HSA_CORE_API_ID_hsa_executable_iterate_symbols,
ROCPROFILER_HSA_CORE_API_ID_hsa_status_string,
ROCPROFILER_HSA_CORE_API_ID_hsa_extension_get_name,
ROCPROFILER_HSA_CORE_API_ID_hsa_system_major_extension_supported,
ROCPROFILER_HSA_CORE_API_ID_hsa_system_get_major_extension_table,
ROCPROFILER_HSA_CORE_API_ID_hsa_agent_major_extension_supported,
ROCPROFILER_HSA_CORE_API_ID_hsa_cache_get_info,
ROCPROFILER_HSA_CORE_API_ID_hsa_agent_iterate_caches,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_silent_store_relaxed,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_silent_store_screlease,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_group_create,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_group_destroy,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_group_wait_any_scacquire,
ROCPROFILER_HSA_CORE_API_ID_hsa_signal_group_wait_any_relaxed,
ROCPROFILER_HSA_CORE_API_ID_hsa_agent_iterate_isas,
ROCPROFILER_HSA_CORE_API_ID_hsa_isa_get_info_alt,
ROCPROFILER_HSA_CORE_API_ID_hsa_isa_get_exception_policies,
ROCPROFILER_HSA_CORE_API_ID_hsa_isa_get_round_method,
ROCPROFILER_HSA_CORE_API_ID_hsa_wavefront_get_info,
ROCPROFILER_HSA_CORE_API_ID_hsa_isa_iterate_wavefronts,
ROCPROFILER_HSA_CORE_API_ID_hsa_code_object_get_symbol_from_name,
ROCPROFILER_HSA_CORE_API_ID_hsa_code_object_reader_create_from_file,
ROCPROFILER_HSA_CORE_API_ID_hsa_code_object_reader_create_from_memory,
ROCPROFILER_HSA_CORE_API_ID_hsa_code_object_reader_destroy,
ROCPROFILER_HSA_CORE_API_ID_hsa_executable_create_alt,
ROCPROFILER_HSA_CORE_API_ID_hsa_executable_load_program_code_object,
ROCPROFILER_HSA_CORE_API_ID_hsa_executable_load_agent_code_object,
ROCPROFILER_HSA_CORE_API_ID_hsa_executable_validate_alt,
ROCPROFILER_HSA_CORE_API_ID_hsa_executable_get_symbol_by_name,
ROCPROFILER_HSA_CORE_API_ID_hsa_executable_iterate_agent_symbols,
ROCPROFILER_HSA_CORE_API_ID_hsa_executable_iterate_program_symbols,
ROCPROFILER_HSA_CORE_API_ID_LAST,
} rocprofiler_hsa_core_api_id_t;
+40
ファイルの表示
@@ -0,0 +1,40 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/ext_version.h>
/**
* @brief ROCProfiler enumeration of HSA Image Extended API tracing operations
*/
typedef enum rocprofiler_hsa_finalize_ext_api_id_t // NOLINT(performance-enum-size)
{
ROCPROFILER_HSA_FINALIZE_EXT_API_ID_NONE = -1,
ROCPROFILER_HSA_FINALIZE_EXT_API_ID_hsa_ext_program_create = 0,
ROCPROFILER_HSA_FINALIZE_EXT_API_ID_hsa_ext_program_destroy,
ROCPROFILER_HSA_FINALIZE_EXT_API_ID_hsa_ext_program_add_module,
ROCPROFILER_HSA_FINALIZE_EXT_API_ID_hsa_ext_program_iterate_modules,
ROCPROFILER_HSA_FINALIZE_EXT_API_ID_hsa_ext_program_get_info,
ROCPROFILER_HSA_FINALIZE_EXT_API_ID_hsa_ext_program_finalize,
ROCPROFILER_HSA_FINALIZE_EXT_API_ID_LAST,
} rocprofiler_hsa_finalize_ext_api_id_t;
+47
ファイルの表示
@@ -0,0 +1,47 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/ext_version.h>
/**
* @brief ROCProfiler enumeration of HSA Image Extended API tracing operations
*/
typedef enum rocprofiler_hsa_image_ext_api_id_t // NOLINT(performance-enum-size)
{
ROCPROFILER_HSA_IMAGE_EXT_API_ID_NONE = -1,
ROCPROFILER_HSA_IMAGE_EXT_API_ID_hsa_ext_image_get_capability,
ROCPROFILER_HSA_IMAGE_EXT_API_ID_hsa_ext_image_data_get_info,
ROCPROFILER_HSA_IMAGE_EXT_API_ID_hsa_ext_image_create,
ROCPROFILER_HSA_IMAGE_EXT_API_ID_hsa_ext_image_import,
ROCPROFILER_HSA_IMAGE_EXT_API_ID_hsa_ext_image_export,
ROCPROFILER_HSA_IMAGE_EXT_API_ID_hsa_ext_image_copy,
ROCPROFILER_HSA_IMAGE_EXT_API_ID_hsa_ext_image_clear,
ROCPROFILER_HSA_IMAGE_EXT_API_ID_hsa_ext_image_destroy,
ROCPROFILER_HSA_IMAGE_EXT_API_ID_hsa_ext_sampler_create,
ROCPROFILER_HSA_IMAGE_EXT_API_ID_hsa_ext_sampler_destroy,
ROCPROFILER_HSA_IMAGE_EXT_API_ID_hsa_ext_image_get_capability_with_layout,
ROCPROFILER_HSA_IMAGE_EXT_API_ID_hsa_ext_image_data_get_info_with_layout,
ROCPROFILER_HSA_IMAGE_EXT_API_ID_hsa_ext_image_create_with_layout,
ROCPROFILER_HSA_IMAGE_EXT_API_ID_LAST,
} rocprofiler_hsa_image_ext_api_id_t;
+70
ファイルの表示
@@ -0,0 +1,70 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/defines.h>
#include <stddef.h>
#include <stdint.h>
ROCPROFILER_EXTERN_C_INIT
// Empty struct has a size of 0 in C but size of 1 in C++.
// This struct is added to the union members which represent
// functions with no arguments to ensure ABI compatibility
typedef struct rocprofiler_scratch_memory_no_args
{
char empty;
} rocprofiler_scratch_memory_no_args;
typedef union rocprofiler_scratch_memory_args_t
{
struct
{
uint64_t dispatch_id;
} alloc_start;
struct
{
uint64_t dispatch_id;
size_t size;
size_t num_slots;
} alloc_end;
struct
{
rocprofiler_scratch_memory_no_args no_args;
} free_start;
struct
{
rocprofiler_scratch_memory_no_args no_args;
} free_end;
struct
{
rocprofiler_scratch_memory_no_args no_args;
} async_reclaim_start;
struct
{
rocprofiler_scratch_memory_no_args no_args;
} async_reclaim_end;
} rocprofiler_scratch_memory_args_t;
ROCPROFILER_EXTERN_C_FINI
+39
ファイルの表示
@@ -0,0 +1,39 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <hsa/hsa_amd_tool.h>
/**
* @brief Allocation flags for @see rocprofiler_buffer_tracing_scratch_memory_record_t
*/
// NOLINTNEXTLINE(performance-enum-size)
typedef enum rocprofiler_scratch_alloc_flag_t
{
ROCPROFILER_SCRATCH_ALLOC_FLAG_NONE = 0,
ROCPROFILER_SCRATCH_ALLOC_FLAG_USE_ONCE =
HSA_AMD_EVENT_SCRATCH_ALLOC_FLAG_USE_ONCE, ///< This scratch allocation is only valid for 1
///< dispatch.
ROCPROFILER_SCRATCH_ALLOC_FLAG_ALT =
HSA_AMD_EVENT_SCRATCH_ALLOC_FLAG_ALT, ///< Used alternate scratch instead of main scratch
} rocprofiler_scratch_alloc_flag_t;
+36
ファイルの表示
@@ -0,0 +1,36 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
// NOLINTNEXTLINE(performance-enum-size)
typedef enum rocprofiler_hsa_table_id_t
{
ROCPROFILER_HSA_TABLE_ID_NONE = -1,
ROCPROFILER_HSA_TABLE_ID_Core = 0,
ROCPROFILER_HSA_TABLE_ID_AmdExt,
ROCPROFILER_HSA_TABLE_ID_ImageExt,
ROCPROFILER_HSA_TABLE_ID_FinalizeExt,
ROCPROFILER_HSA_TABLE_ID_AmdTool,
ROCPROFILER_HSA_TABLE_ID_PcSamplingExt,
ROCPROFILER_HSA_TABLE_ID_LAST,
} rocprofiler_hsa_table_id_t;
+248
ファイルの表示
@@ -0,0 +1,248 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/defines.h>
#include <rocprofiler-sdk/fwd.h>
ROCPROFILER_EXTERN_C_INIT
/**
* @defgroup INTERCEPT_TABLE Intercept table for runtime libraries
* @brief Enable tools to wrap the runtime API function calls of HIP, HSA, and ROCTx before and
* after the "real" implementation is called.
*
* When an application invokes the public function from the HIP, HSA, and ROCTx libraries, these
* functions invoke a function pointer which, when properly chained, allow tools to wrap these
* function calls to collect information. When this capability is used alongside the rocprofiler API
* tracing, tools will wrap the rocprofiler wrappers of the API function, e.g. if the tool installs
* a wrapper around the `hsa_init` function called `tool_hsa_init`, and rocprofiler installs a
* wrapper around the `hsa_init` function called `rocp_hsa_init`, and within the HSA runtime
* library, the "real" implementation of the `hsa_init` invokes a function called `real_hsa_init`,
* the invocation chain (starting from within the user application) will be: `<application>` ->
* `hsa_init` -> `tool_hsa_init` -> `rocp_hsa_init` -> `real_hsa_init`. The return sequence will be
* the inverse of invocation chain: `real_hsa_init` -> `rocp_hsa_init` -> `tool_hsa_init` ->
* `<application>`. Thus, it is important for tools that use this feature to (A) call the next
* function in the chain and (B) properly handle the return value.
*
* @{
*/
/**
* @brief (experimental) Callback type when a new runtime library is loaded. @see
* rocprofiler_at_intercept_table_registration
* @param [in] type Type of API table
* @param [in] lib_version Major, minor, and patch version of library encoded into single number
* similar to ::ROCPROFILER_VERSION
* @param [in] lib_instance The number of times this runtime library has been registered previously
* @param [in] tables An array of pointers to the API tables
* @param [in] num_tables The size of the array of pointers to the API tables
* @param [in] user_data The pointer to the data provided to
* ::rocprofiler_at_intercept_table_registration
*/
ROCPROFILER_SDK_EXPERIMENTAL
typedef void (*rocprofiler_intercept_library_cb_t)(rocprofiler_intercept_table_t type,
uint64_t lib_version,
uint64_t lib_instance,
void** tables,
uint64_t num_tables,
void* user_data);
/**
* @brief (experimental) Query the name of the intercept table. The name retrieved from this
* function is a string literal that is encoded in the read-only section of the binary (i.e. it is
* always "allocated" and never "deallocated").
*
* @param [in] kind Intercept table kind
* @param [out] name If non-null and the name is a constant string that does not require dynamic
* allocation, this paramter will be set to the address of the string literal, otherwise it will
* be set to nullptr
* @param [out] name_len If non-null, this will be assigned the length of the name (regardless of
* the name is a constant string or requires dynamic allocation)
* @return ::rocprofiler_status_t
* @retval ::ROCPROFILER_STATUS_ERROR_KIND_NOT_FOUND Returned if the domain id is not valid
* @retval ::ROCPROFILER_STATUS_SUCCESS Returned if a valid domain, regardless if there is a
* constant string or not.
*/
ROCPROFILER_SDK_EXPERIMENTAL
rocprofiler_status_t
rocprofiler_query_intercept_table_name(rocprofiler_intercept_table_t kind,
const char** name,
uint64_t* name_len) ROCPROFILER_API;
/**
* @brief (experimental) Invoke this function to receive callbacks when a ROCm library registers its
* API intercept table with rocprofiler. Use the ::rocprofiler_intercept_table_t enumeration for
* specifying which raw API tables the tool would like to have access to. E.g. including
* ::ROCPROFILER_HSA_TABLE in the ::rocprofiler_at_intercept_table_registration function call
* communicates to rocprofiler that, when rocprofiler receives a `HsaApiTable` instance, the tool
* would like rocprofiler to provide it access too.
*
* When the HIP, HSA, and ROCTx libraries are initialized (either explicitly or on the first
* invocation of one of their public API functions), these runtimes will provide a table of function
* pointers to the rocprofiler library via the rocprofiler-register library if the
* `rocprofiler_configure` symbol is visible in the application's symbol table. The vast majority of
* tools will want to use the @ref CALLBACK_TRACING_SERVICE to trace these runtime APIs, however,
* some tools may want or require installing their own intercept functions in lieu of receiving
* these callbacks and those tools should use the ::rocprofiler_at_intercept_table_registration
* to install their intercept functions. There are no restrictions to where or how early this
* function can be invoked but it will return ::ROCPROFILER_STATUS_ERROR_CONFIGURATION_LOCKED if it
* is invoked after rocprofiler has requested all the tool configurations. Thus, it is highly
* recommended to invoke this function within the ::rocprofiler_configure function or the
* callback passed to the ::rocprofiler_force_configure function -- the reason for this
* recommendation is that if ::rocprofiler_at_intercept_table_registration is invoked in one of
* these locations, rocprofiler can guarantee that the tool will be passed the API table because, at
* the first instance of a runtime registering it's API table, rocprofiler will ensure that, in the
* case of the former, rocprofiler will invoke all of the ::rocprofiler_configure symbols that
* are visible before checking the list of tools which want to receive the API tables and, in the
* case of the latter, ::rocprofiler_force_configure will fail with error code
* ::ROCPROFILER_STATUS_ERROR_CONFIGURATION_LOCKED if a runtime has already been registered (and,
* therefore, already scanned and invoked the visible ::rocprofiler_configure symbols and
* completed the tool initialization). If ::rocprofiler_at_intercept_table_registration is
* invoked outside of these recommended places, even if it is done before the `main` function starts
* (e.g. in a library init/constructor function), it is possible that another library, such as
* ROCm-aware MPI, caused the HIP and HSA runtime libraries to be initialized when that library was
* loaded. In this aforementioned scenario, if the ROCm-aware MPI library library init/constructor
* function runs before your library init/constructor function, rocprofiler will have already
* processed the API table and will not provide the API table to the tool due to the fact that the
* API may already be in use and, thus, any modifications to the table might result in thread-safety
* violations or more disastrous consequences.
*
* @param [in] callback Callback to tool invoked when a runtime registers their API table with
* rocprofiler
* @param [in] libs Bitwise-or of libraries, e.g. `ROCPROFILER_HSA_TABLE |
* ROCPROFILER_HIP_RUNTIME_TABLE | ROCPROFILER_MARKER_CORE_TABLE` means the callbacks will be
* invoked whenever the HSA, HIP runtime, and ROCTx core API tables register their intercept
* table(s).
* @param [in] data Data to provide to callback(s)
* @return ::rocprofiler_status_t
* @retval ::ROCPROFILER_STATUS_SUCCESS Callback was registered for specified runtime(s)
* @retval ::ROCPROFILER_STATUS_ERROR_CONFIGURATION_LOCKED rocprofiler has already initialized
* @retval ::ROCPROFILER_STATUS_ERROR_INVALID_ARGUMENT this error code is returned if
* `ROCPROFILER_TABLE` is included in bitwise-or of the libs
* @retval ::ROCPROFILER_STATUS_ERROR_NOT_IMPLEMENTED this error code is returned if one of the
* specified libraries does not have support for API intercept tables (which should not be the case
* by the time this code is publicly released)
*
* @code{.cpp}
* namespace
* {
* // this function generates a wrapper around the original function that
* // prints out the function name and then invokes the original function
* template <size_t Idx, typename RetT, typename... Args>
* auto
* generate_wrapper(const char* name, RetT (*func)(Args...))
* {
* using functor_type = RetT (*)(Args...);
*
* // save function name, "real function"
* static const auto* func_name = name;
* static functor_type underlying_func = func;
* static functor_type wrapped_func = [](Args... args) -> RetT {
* std::cout << "Wrapping " << func_name << "..." << std::endl;
* if(underlying_func) return underlying_func(args...);
* if constexpr(!std::is_void<RetT>::value) return RetT{};
* };
*
* return wrapped_func;
* }
*
*
* // this macro installs the wrapper in place of the original function
* #define GENERATE_WRAPPER(TABLE, FUNC) \
* TABLE->FUNC##_fn = generate_wrapper<__COUNTER__>(#FUNC, TABLE->FUNC##_fn)
*
*
* // this is the function that gets called when the HSA runtime
* // intercept table is registered with rocprofiler
* void
* api_registration_callback(rocprofiler_intercept_table_t type,
* uint64_t lib_version,
* uint64_t lib_instance,
* void** tables,
* uint64_t num_tables,
* void* user_data)
* {
* if(type != ROCPROFILER_HSA_TABLE)
* throw std::runtime_error{"unexpected library type: " +
* std::to_string(static_cast<int>(type))};
* if(lib_instance != 0) throw std::runtime_error{"multiple instances of HSA runtime library"};
* if(num_tables != 1) throw std::runtime_error{"expected only one table of type HsaApiTable"};
*
* auto* hsa_api_table = static_cast<HsaApiTable*>(tables[0]);
* GENERATE_WRAPPER(hsa_api_table->core_, hsa_agent_get_info);
* GENERATE_WRAPPER(hsa_api_table->core_, hsa_agent_iterate_isas);
* GENERATE_WRAPPER(hsa_api_table->core_, hsa_code_object_reader_create_from_memory);
* GENERATE_WRAPPER(hsa_api_table->core_, hsa_executable_create_alt);
* GENERATE_WRAPPER(hsa_api_table->core_, hsa_executable_freeze);
* GENERATE_WRAPPER(hsa_api_table->core_, hsa_executable_get_symbol_by_name);
* GENERATE_WRAPPER(hsa_api_table->core_, hsa_executable_iterate_symbols);
* GENERATE_WRAPPER(hsa_api_table->core_, hsa_executable_load_agent_code_object);
* GENERATE_WRAPPER(hsa_api_table->core_, hsa_executable_symbol_get_info);
* GENERATE_WRAPPER(hsa_api_table->core_, hsa_isa_get_info_alt);
* GENERATE_WRAPPER(hsa_api_table->core_, hsa_iterate_agents);
* GENERATE_WRAPPER(hsa_api_table->core_, hsa_queue_add_write_index_screlease);
* GENERATE_WRAPPER(hsa_api_table->core_, hsa_queue_create);
* GENERATE_WRAPPER(hsa_api_table->core_, hsa_queue_load_read_index_relaxed);
* GENERATE_WRAPPER(hsa_api_table->core_, hsa_queue_load_read_index_scacquire);
* GENERATE_WRAPPER(hsa_api_table->core_, hsa_signal_create);
* GENERATE_WRAPPER(hsa_api_table->core_, hsa_signal_destroy);
* GENERATE_WRAPPER(hsa_api_table->core_, hsa_signal_load_relaxed);
* GENERATE_WRAPPER(hsa_api_table->core_, hsa_signal_silent_store_relaxed);
* GENERATE_WRAPPER(hsa_api_table->core_, hsa_signal_store_screlease);
* GENERATE_WRAPPER(hsa_api_table->core_, hsa_signal_wait_scacquire);
* GENERATE_WRAPPER(hsa_api_table->core_, hsa_system_get_info);
* GENERATE_WRAPPER(hsa_api_table->core_, hsa_system_get_major_extension_table);
* }
* } // namespace
*
*
* extern "C" rocprofiler_tool_configure_result_t*
* rocprofiler_configure(uint32_t version,
* const char* runtime_version,
* uint32_t priority,
* rocprofiler_client_id_t* id)
* {
* // set the client name
* id->name = "ExampleTool";
*
* // specify that we only want to intercept the HSA library
* rocprofiler_at_intercept_table_registration(api_registration_callback,
* ROCPROFILER_HSA_TABLE, nullptr);
*
* return nullptr;
* }
* @endcode
*
* @example intercept_table/client.cpp
* Example demonstrating ::rocprofiler_at_intercept_table_registration usage
*/
ROCPROFILER_SDK_EXPERIMENTAL
rocprofiler_status_t
rocprofiler_at_intercept_table_registration(rocprofiler_intercept_library_cb_t callback,
int libs,
void* data) ROCPROFILER_API;
/** @} */
ROCPROFILER_EXTERN_C_FINI
+138
ファイルの表示
@@ -0,0 +1,138 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/defines.h>
#include <rocprofiler-sdk/fwd.h>
ROCPROFILER_EXTERN_C_INIT
/**
* @defgroup INTERNAL_THREADING Internal Thread Handling
* @brief Callbacks before and after threads created internally by libraries
*
* @{
* @example api_buffered_tracing/client.cpp
* Example demonstrating @ref BUFFER_TRACING_SERVICE that includes usage of
* ::rocprofiler_at_internal_thread_create, ::rocprofiler_create_callback_thread, and
* ::rocprofiler_assign_callback_thread.
*/
/**
* @brief (experimental) Callback type before and after internal thread creation. @see
* rocprofiler_at_internal_thread_create
*
*/
ROCPROFILER_SDK_EXPERIMENTAL
typedef void (*rocprofiler_internal_thread_library_cb_t)(rocprofiler_runtime_library_t, void*);
/**
* @brief (experimental) Invoke this function to receive callbacks before and after the creation of
* an internal thread by a library which as invoked on the thread which is creating the internal
* thread(s).
*
* Use the ::rocprofiler_runtime_library_t enumeration for specifying which libraries you want
* callbacks before and after the library creates an internal thread. These callbacks will be
* invoked on the thread that is about to create the new thread (not on the newly created thread).
* In thread-aware tools that wrap pthread_create, this can be used to disable the wrapper before
* the pthread_create invocation and re-enable the wrapper afterwards. In many cases, tools will
* want to ignore the thread(s) created by rocprofiler since these threads do not exist in the
* normal application execution, whereas the internal threads for HSA, HIP, etc. are created in
* normal application execution; however, the HIP, HSA, etc. internal threads are typically
* background threads which just monitor kernel completion and are unlikely to contribute to any
* performance issues. Please note that the postcreate callback is guaranteed to be invoked after
* the underlying system call to create a new thread but it does not guarantee that the new thread
* has been started. Please note, that once these callbacks are registered, they cannot be removed
* so the caller is responsible for ignoring these callbacks if they want to ignore them beyond a
* certain point in the application.
*
* @param [in] precreate Callback invoked immediately before a new internal thread is created
* @param [in] postcreate Callback invoked immediately after a new internal thread is created
* @param [in] libs Bitwise-or of libraries, e.g. `ROCPROFILER_LIBRARY | ROCPROFILER_MARKER_LIBRARY`
* means the callbacks will be invoked whenever rocprofiler and/or the marker library create
* internal threads but not when the HSA or HIP libraries create internal threads.
* @param [in] data Data shared between callbacks
* @return ::rocprofiler_status_t
* @retval ::ROCPROFILER_STATUS_SUCCESS There are currently no conditions which result in any other
* value, even if internal threads have already been created
*/
ROCPROFILER_SDK_EXPERIMENTAL
rocprofiler_status_t
rocprofiler_at_internal_thread_create(rocprofiler_internal_thread_library_cb_t precreate,
rocprofiler_internal_thread_library_cb_t postcreate,
int libs,
void* data) ROCPROFILER_API;
/**
* @brief (experimental) opaque handle to an internal thread identifier which delivers callbacks for
* buffers
* @see rocprofiler_create_callback_thread
*/
typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_callback_thread_t
{
uint64_t handle;
} rocprofiler_callback_thread_t;
/**
* @brief (experimental) Create a handle to a unique thread (created by rocprofiler) which, when
* associated with a particular buffer, will guarantee those buffered results always get delivered
* on the same thread. This is useful to prevent/control thread-safety issues and/or enable
* multithreaded processing of buffers with non-overlapping data
*
* @param [in] cb_thread_id User-provided pointer to a ::rocprofiler_callback_thread_t
* @return ::rocprofiler_status_t
* @retval ::ROCPROFILER_STATUS_SUCCESS Successful thread creation
* @retval ::ROCPROFILER_STATUS_ERROR_CONFIGURATION_LOCKED Thread creation is no longer available
* post-initialization
* @retval ::ROCPROFILER_STATUS_ERROR Failed to create thread
*/
ROCPROFILER_SDK_EXPERIMENTAL
rocprofiler_status_t
rocprofiler_create_callback_thread(rocprofiler_callback_thread_t* cb_thread_id) ROCPROFILER_API
ROCPROFILER_NONNULL(1);
/**
* @brief (experimental) By default, all buffered results are delivered on the same thread. Using
* ::rocprofiler_create_callback_thread, one or more buffers can be assigned to deliever their
* results on a unique, dedicated thread.
*
* @param [in] buffer_id Buffer identifier
* @param [in] cb_thread_id Callback thread identifier via ::rocprofiler_create_callback_thread
* @return ::rocprofiler_status_t
* @retval ::ROCPROFILER_STATUS_SUCCESS Successful assignment of the delivery thread for the given
* buffer
* @retval ::ROCPROFILER_STATUS_ERROR_CONFIGURATION_LOCKED Thread assignment is no longer available
* post-initialization
* @retval ::ROCPROFILER_STATUS_ERROR_THREAD_NOT_FOUND Thread identifier did not match any of the
* threads created by rocprofiler
* @retval ::ROCPROFILER_STATUS_ERROR_BUFFER_NOT_FOUND Buffer identifier did not match any of the
* buffers registered with rocprofiler
*/
ROCPROFILER_SDK_EXPERIMENTAL
rocprofiler_status_t
rocprofiler_assign_callback_thread(rocprofiler_buffer_id_t buffer_id,
rocprofiler_callback_thread_t cb_thread_id) ROCPROFILER_API;
/** @} */
ROCPROFILER_EXTERN_C_FINI
+11
ファイルの表示
@@ -0,0 +1,11 @@
#
#
# Installation of public KFD headers
#
#
set(ROCPROFILER_KFD_HEADER_FILES kfd_id.h)
install(
FILES ${ROCPROFILER_KFD_HEADER_FILES}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocprofiler-sdk/kfd
COMPONENT development)
+159
ファイルの表示
@@ -0,0 +1,159 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/defines.h>
#include <rocprofiler-sdk/hsa.h>
#include <rocprofiler-sdk/hsa/api_trace_version.h>
#include <rocprofiler-sdk/version.h>
#include <stdint.h>
ROCPROFILER_EXTERN_C_INIT
/**
* @brief Page migration event operations. @see
* rocprofiler_buffer_tracing_kfd_event_page_migrate_record_t
*/
typedef enum rocprofiler_kfd_event_page_migrate_operation_t
{
ROCPROFILER_KFD_EVENT_PAGE_MIGRATE_NONE = -1,
ROCPROFILER_KFD_EVENT_PAGE_MIGRATE_PREFETCH, ///< Migration triggered by a prefetch
ROCPROFILER_KFD_EVENT_PAGE_MIGRATE_PAGEFAULT_GPU, ///< Migration triggered by a page fault on
///< the GPU
ROCPROFILER_KFD_EVENT_PAGE_MIGRATE_PAGEFAULT_CPU, ///< Migration triggered by a page fault on
///< the CPU
ROCPROFILER_KFD_EVENT_PAGE_MIGRATE_TTM_EVICTION, ///< Page evicted by linux TTM (Translation
///< Table Manager)
ROCPROFILER_KFD_EVENT_PAGE_MIGRATE_END,
ROCPROFILER_KFD_EVENT_PAGE_MIGRATE_LAST,
} rocprofiler_kfd_event_page_migrate_operation_t;
/**
* @brief Page fault event operations. @see rocprofiler_buffer_tracing_kfd_event_page_fault_record_t
*/
typedef enum rocprofiler_kfd_event_page_fault_operation_t
{
ROCPROFILER_KFD_EVENT_PAGE_FAULT_NONE = -1,
ROCPROFILER_KFD_EVENT_PAGE_FAULT_START,
ROCPROFILER_KFD_EVENT_PAGE_FAULT_START_READ_FAULT, ///< Page fault was due to a read operation
ROCPROFILER_KFD_EVENT_PAGE_FAULT_START_WRITE_FAULT, ///< Page fault was due to a write
///< operation
ROCPROFILER_KFD_EVENT_PAGE_FAULT_END_PAGE_MIGRATED, ///< Fault resolved through a migration
ROCPROFILER_KFD_EVENT_PAGE_FAULT_END_PAGE_UPDATED, ///< Fault resolved through an update
ROCPROFILER_KFD_EVENT_PAGE_FAULT_LAST,
} rocprofiler_kfd_event_page_fault_operation_t;
/**
* @brief Queue evict/restore event operations. @see
* rocprofiler_buffer_tracing_kfd_event_queue_record_t
*/
typedef enum rocprofiler_kfd_event_queue_operation_t
{
ROCPROFILER_KFD_EVENT_QUEUE_NONE = -1,
ROCPROFILER_KFD_EVENT_QUEUE_EVICT_SVM, ///< SVM Buffer migration
ROCPROFILER_KFD_EVENT_QUEUE_EVICT_USERPTR, ///< userptr movement
ROCPROFILER_KFD_EVENT_QUEUE_EVICT_TTM, ///< TTM move buffer
ROCPROFILER_KFD_EVENT_QUEUE_EVICT_SUSPEND, ///< GPU suspend
ROCPROFILER_KFD_EVENT_QUEUE_EVICT_CRIU_CHECKPOINT, ///< Queues evicted due to process
///< checkpoint by CRIU
ROCPROFILER_KFD_EVENT_QUEUE_EVICT_CRIU_RESTORE, ///< Queues restored during process restore by
///< CRIU
ROCPROFILER_KFD_EVENT_QUEUE_RESTORE_RESCHEDULED, ///< Queue was not restored; will be restored
///< later
ROCPROFILER_KFD_EVENT_QUEUE_RESTORE, ///< Queue was restored
ROCPROFILER_KFD_EVENT_QUEUE_LAST,
} rocprofiler_kfd_event_queue_operation_t;
/**
* @brief Memory unmap from GPU event operations. @see
* rocprofiler_buffer_tracing_kfd_event_unmap_from_gpu_record_t
*/
typedef enum rocprofiler_kfd_event_unmap_from_gpu_operation_t
{
ROCPROFILER_KFD_EVENT_UNMAP_FROM_GPU_NONE = -1,
ROCPROFILER_KFD_EVENT_UNMAP_FROM_GPU_MMU_NOTIFY, ///< MMU notifier CPU buffer movement
ROCPROFILER_KFD_EVENT_UNMAP_FROM_GPU_MMU_NOTIFY_MIGRATE, ///< MMU notifier page migration
ROCPROFILER_KFD_EVENT_UNMAP_FROM_GPU_UNMAP_FROM_CPU, ///< Unmap to free the buffer
ROCPROFILER_KFD_EVENT_UNMAP_FROM_GPU_LAST,
} rocprofiler_kfd_event_unmap_from_gpu_operation_t;
/**
* @brief KFD dropped event operations. @see
* rocprofiler_buffer_tracing_kfd_event_dropped_events_record_t
*/
typedef enum rocprofiler_kfd_event_dropped_events_operation_t
{
ROCPROFILER_KFD_EVENT_DROPPED_EVENTS_NONE = -1,
ROCPROFILER_KFD_EVENT_DROPPED_EVENTS,
ROCPROFILER_KFD_EVENT_DROPPED_EVENTS_LAST,
} rocprofiler_kfd_event_dropped_events_operation_t;
/**
* @brief Operation kinds for @see rocprofiler_buffer_tracing_kfd_page_migrate_record_t
*/
typedef enum rocprofiler_kfd_page_migrate_operation_t
{
ROCPROFILER_KFD_PAGE_MIGRATE_NONE = -1,
ROCPROFILER_KFD_PAGE_MIGRATE_PREFETCH, ///< Migration triggered by a prefetch
ROCPROFILER_KFD_PAGE_MIGRATE_PAGEFAULT_GPU, ///< Migration triggered by a page fault on the
///< GPU
ROCPROFILER_KFD_PAGE_MIGRATE_PAGEFAULT_CPU, ///< Migration triggered by a page fault on the
///< CPU
ROCPROFILER_KFD_PAGE_MIGRATE_TTM_EVICTION, ///< Page evicted by linux TTM (Translation Table
///< Manager)
ROCPROFILER_KFD_PAGE_MIGRATE_LAST,
} rocprofiler_kfd_page_migrate_operation_t;
/**
* @brief Operation kinds for @see rocprofiler_buffer_tracing_kfd_page_fault_record_t
*/
typedef enum rocprofiler_kfd_page_fault_operation_t
{
ROCPROFILER_KFD_PAGE_FAULT_NONE = -1,
ROCPROFILER_KFD_PAGE_FAULT_READ_FAULT_MIGRATED, ///< read fault resolved with a migrate
ROCPROFILER_KFD_PAGE_FAULT_READ_FAULT_UPDATED, ///< read fault resolved with an update
ROCPROFILER_KFD_PAGE_FAULT_WRITE_FAULT_MIGRATED, ///< write fault resolved with an migrate
ROCPROFILER_KFD_PAGE_FAULT_WRITE_FAULT_UPDATED, ///< write fault resolved with an update
ROCPROFILER_KFD_PAGE_FAULT_LAST,
} rocprofiler_kfd_page_fault_operation_t;
/**
* @brief Operation kinds for @see rocprofiler_buffer_tracing_kfd_queue_record_t
*/
typedef enum rocprofiler_kfd_queue_operation_t
{
ROCPROFILER_KFD_QUEUE_NONE = -1,
ROCPROFILER_KFD_QUEUE_EVICT_SVM, ///< SVM Buffer migration
ROCPROFILER_KFD_QUEUE_EVICT_USERPTR, ///< userptr movement
ROCPROFILER_KFD_QUEUE_EVICT_TTM, ///< TTM move buffer
ROCPROFILER_KFD_QUEUE_EVICT_SUSPEND, ///< GPU suspend
ROCPROFILER_KFD_QUEUE_EVICT_CRIU_CHECKPOINT, ///< Queues evicted due to process checkpoint by
///< CRIU
ROCPROFILER_KFD_QUEUE_EVICT_CRIU_RESTORE, ///< Queues restored during process restore by CRIU
ROCPROFILER_KFD_QUEUE_LAST,
} rocprofiler_kfd_queue_operation_t;
ROCPROFILER_EXTERN_C_FINI
+27
ファイルの表示
@@ -0,0 +1,27 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/marker/api_args.h>
#include <rocprofiler-sdk/marker/api_id.h>
#include <rocprofiler-sdk/marker/table_id.h>
+11
ファイルの表示
@@ -0,0 +1,11 @@
#
#
# Installation of public HSA headers
#
#
set(ROCPROFILER_MARKER_HEADER_FILES api_args.h api_id.h table_id.h)
install(
FILES ${ROCPROFILER_MARKER_HEADER_FILES}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocprofiler-sdk/marker
COMPONENT development)
+115
ファイルの表示
@@ -0,0 +1,115 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/defines.h>
#include <rocprofiler-sdk-roctx/api_trace.h>
#include <rocprofiler-sdk-roctx/types.h>
#include <stdint.h>
ROCPROFILER_EXTERN_C_INIT
// Empty struct has a size of 0 in C but size of 1 in C++.
// This struct is added to the union members which represent
// functions with no arguments to ensure ABI compatibility
typedef struct rocprofiler_marker_api_no_args
{
char empty;
} rocprofiler_marker_api_no_args;
typedef union rocprofiler_marker_api_retval_t
{
int32_t int32_t_retval;
int64_t int64_t_retval;
roctx_range_id_t roctx_range_id_t_retval;
} rocprofiler_marker_api_retval_t;
typedef union rocprofiler_marker_api_args_t
{
struct
{
const char* message;
} roctxMarkA;
struct
{
const char* message;
} roctxRangePushA;
struct
{
// Empty struct has a size of 0 in C but size of 1 in C++.
// Add the rocprofiler_marker_api_no_args struct to fix this
rocprofiler_marker_api_no_args no_args;
} roctxRangePop;
struct
{
const char* message;
} roctxRangeStartA;
struct
{
roctx_range_id_t id;
} roctxRangeStop;
struct
{
roctx_thread_id_t* tid;
} roctxGetThreadId;
struct
{
roctx_thread_id_t tid;
} roctxProfilerPause;
struct
{
roctx_thread_id_t tid;
} roctxProfilerResume;
struct
{
const char* name;
} roctxNameOsThread;
struct
{
const char* name;
const struct hsa_agent_s* agent;
} roctxNameHsaAgent;
struct
{
const char* name;
int device_id;
} roctxNameHipDevice;
struct
{
const char* name;
const struct ihipStream_t* stream;
} roctxNameHipStream;
struct
{
const char* message;
} roctxThreadRangeA;
struct
{
const char* message;
// roctx_range_id_t id; // only set when range ends in callback tracing
} roctxProcessRangeA;
} rocprofiler_marker_api_args_t;
ROCPROFILER_EXTERN_C_FINI
+66
ファイルの表示
@@ -0,0 +1,66 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
/**
* @brief ROCProfiler enumeration of Marker (ROCTx) API tracing operations
*/
typedef enum rocprofiler_marker_core_api_id_t // NOLINT(performance-enum-size)
{
ROCPROFILER_MARKER_CORE_API_ID_NONE = -1,
ROCPROFILER_MARKER_CORE_API_ID_roctxMarkA = 0,
ROCPROFILER_MARKER_CORE_API_ID_roctxRangePushA,
ROCPROFILER_MARKER_CORE_API_ID_roctxRangePop,
ROCPROFILER_MARKER_CORE_API_ID_roctxRangeStartA,
ROCPROFILER_MARKER_CORE_API_ID_roctxRangeStop,
ROCPROFILER_MARKER_CORE_API_ID_roctxGetThreadId,
ROCPROFILER_MARKER_CORE_API_ID_LAST,
} rocprofiler_marker_core_api_id_t;
typedef enum rocprofiler_marker_control_api_id_t // NOLINT(performance-enum-size)
{
ROCPROFILER_MARKER_CONTROL_API_ID_NONE = -1,
ROCPROFILER_MARKER_CONTROL_API_ID_roctxProfilerPause = 0,
ROCPROFILER_MARKER_CONTROL_API_ID_roctxProfilerResume,
ROCPROFILER_MARKER_CONTROL_API_ID_LAST,
} rocprofiler_marker_control_api_id_t;
typedef enum rocprofiler_marker_name_api_id_t // NOLINT(performance-enum-size)
{
ROCPROFILER_MARKER_NAME_API_ID_NONE = -1,
ROCPROFILER_MARKER_NAME_API_ID_roctxNameOsThread = 0,
ROCPROFILER_MARKER_NAME_API_ID_roctxNameHsaAgent,
ROCPROFILER_MARKER_NAME_API_ID_roctxNameHipDevice,
ROCPROFILER_MARKER_NAME_API_ID_roctxNameHipStream,
ROCPROFILER_MARKER_NAME_API_ID_LAST,
} rocprofiler_marker_name_api_id_t;
typedef enum rocprofiler_marker_core_range_api_id_t // NOLINT(performance-enum-size)
{
ROCPROFILER_MARKER_CORE_RANGE_API_ID_NONE = -1,
ROCPROFILER_MARKER_CORE_RANGE_API_ID_roctxMarkA = 0,
ROCPROFILER_MARKER_CORE_RANGE_API_ID_roctxThreadRangeA,
ROCPROFILER_MARKER_CORE_RANGE_API_ID_roctxProcessRangeA,
ROCPROFILER_MARKER_CORE_RANGE_API_ID_roctxGetThreadId,
ROCPROFILER_MARKER_CORE_RANGE_API_ID_LAST,
} rocprofiler_marker_core_range_api_id_t;
+34
ファイルの表示
@@ -0,0 +1,34 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
// NOLINTNEXTLINE(performance-enum-size)
typedef enum rocprofiler_marker_table_id_t
{
ROCPROFILER_MARKER_TABLE_ID_NONE = -1,
ROCPROFILER_MARKER_TABLE_ID_RoctxCore = 0,
ROCPROFILER_MARKER_TABLE_ID_RoctxControl,
ROCPROFILER_MARKER_TABLE_ID_RoctxName,
ROCPROFILER_MARKER_TABLE_ID_RoctxCoreRange,
ROCPROFILER_MARKER_TABLE_ID_LAST,
} rocprofiler_marker_table_id_t;
+81
ファイルの表示
@@ -0,0 +1,81 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/defines.h>
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/ompt/api_args.h>
#include <rocprofiler-sdk/ompt/api_id.h>
#include <rocprofiler-sdk/ompt/omp-tools.h>
/**
* @defgroup OMPT_REGISTRATION Tool registration for OpenMP Tools
*
* Functions for enabling OMPT support in tools which provide their own ompt_start_tool symbol but
* want to defer to rocprofiler-sdk for OMPT.
*
* @{
*/
ROCPROFILER_EXTERN_C_INIT
/**
* @brief (experimental) Query whether rocprofiler-sdk OMPT implementation has been initialized by
* OpenMP runtime.
*
* @param [out] status Set to 0 if rocprofiler OMPT has not been initialized. Otherwise, set to 1.
* @return ::rocprofiler_status_t
* @retval ::ROCPROFILER_STATUS_SUCCESS Always returns this value
*/
ROCPROFILER_SDK_EXPERIMENTAL
rocprofiler_status_t
rocprofiler_ompt_is_initialized(int* status) ROCPROFILER_API ROCPROFILER_NONNULL(1);
/**
* @brief (experimental) Query whether rocprofiler-sdk OMPT implementation has invoked ompt_finalize
* function.
*
* @param [out] status Set to 0 if rocprofiler OMPT has not been finalized. Otherwise, set to 1.
* @return ::rocprofiler_status_t
* @retval ::ROCPROFILER_STATUS_SUCCESS Always returns this value
*/
ROCPROFILER_SDK_EXPERIMENTAL
rocprofiler_status_t
rocprofiler_ompt_is_finalized(int* status) ROCPROFILER_API ROCPROFILER_NONNULL(1);
/**
* @brief (experimental) If a tool which contains a "ompt_start_tool" function which is invoked by
* the OpenMP runtime but the tool wishes to defer to rocprofiler-sdk to be the OMPT tool, it should
* invoke this function from it's `ompt_start_tool` implementation.
*
* @param [in] omp_version Refer to OpenMP OMPT docs for more information
* @param [in] runtime_version Refer to OpenMP OMPT docs for more information
* @return ompt_start_tool_result_t*
*/
ROCPROFILER_SDK_EXPERIMENTAL
ompt_start_tool_result_t*
rocprofiler_ompt_start_tool(unsigned int omp_version, const char* runtime_version) ROCPROFILER_API;
ROCPROFILER_EXTERN_C_FINI
/** @} */
+11
ファイルの表示
@@ -0,0 +1,11 @@
#
#
# Installation of public OMPT headers
#
#
set(ROCPROFILER_OMPT_HEADER_FILES api_args.h api_id.h omp-tools.h)
install(
FILES ${ROCPROFILER_OMPT_HEADER_FILES}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocprofiler-sdk/ompt
COMPONENT development)
+339
ファイルの表示
@@ -0,0 +1,339 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/defines.h>
#include <rocprofiler-sdk/ompt/omp-tools.h>
#include <stdint.h>
ROCPROFILER_EXTERN_C_INIT
// all the available callback interface runtime entry points
typedef struct rocprofiler_ompt_callback_functions_t
{
ompt_enumerate_states_t ompt_enumerate_states;
ompt_enumerate_mutex_impls_t ompt_enumerate_mutex_impls;
ompt_get_thread_data_t ompt_get_thread_data;
ompt_get_num_places_t ompt_get_num_places;
ompt_get_place_proc_ids_t ompt_get_place_proc_ids;
ompt_get_place_num_t ompt_get_place_num;
ompt_get_partition_place_nums_t ompt_get_partition_place_nums;
ompt_get_proc_id_t ompt_get_proc_id;
ompt_get_state_t ompt_get_state;
ompt_get_parallel_info_t ompt_get_parallel_info;
ompt_get_task_info_t ompt_get_task_info;
ompt_get_task_memory_t ompt_get_task_memory;
ompt_get_num_devices_t ompt_get_num_devices;
ompt_get_num_procs_t ompt_get_num_procs;
ompt_get_target_info_t ompt_get_target_info;
ompt_get_unique_id_t ompt_get_unique_id;
} rocprofiler_ompt_callback_functions_t;
// Empty struct has a size of 0 in C but size of 1 in C++.
// This struct is added to the union members which represent
// functions with no arguments to ensure ABI compatibility
typedef struct rocprofiler_ompt_no_args
{
char empty;
} rocprofiler_ompt_no_args;
typedef union rocprofiler_ompt_args_t
{
// The ompt_data_t* values passed to the client tool are proxies.
// This allows the client tool to use them as it would in their own
// OMPT tool.
// We keepa a map from the address of the ompt_data_t passed to the SDK's
// callback to the proxy object and keep it in sync when a callback is done
// to the client tool.
struct
{
ompt_thread_t thread_type;
ompt_data_t* thread_data;
} thread_begin;
struct
{
ompt_data_t* thread_data;
} thread_end;
struct
{
ompt_data_t* encountering_task_data;
const ompt_frame_t* encountering_task_frame;
ompt_data_t* parallel_data;
unsigned int requested_parallelism;
int flags;
const void* codeptr_ra;
} parallel_begin;
struct
{
ompt_data_t* parallel_data;
ompt_data_t* encountering_task_data;
int flags;
const void* codeptr_ra;
} parallel_end;
struct
{
ompt_data_t* encountering_task_data;
const ompt_frame_t* encountering_task_frame;
ompt_data_t* new_task_data;
int flags;
int has_dependences;
const void* codeptr_ra;
} task_create;
struct
{
ompt_data_t* prior_task_data;
ompt_task_status_t prior_task_status;
ompt_data_t* next_task_data;
} task_schedule;
struct
{
ompt_scope_endpoint_t endpoint;
ompt_data_t* parallel_data;
ompt_data_t* task_data;
unsigned int actual_parallelism;
unsigned int index;
int flags;
} implicit_task;
struct
{
int device_num;
const char* type;
ompt_device_t* device;
ompt_function_lookup_t lookup;
const char* documentation;
} device_initialize;
struct
{
int device_num;
} device_finalize;
struct
{
int device_num;
const char* filename;
int64_t offset_in_file;
void* vma_in_file;
size_t bytes;
void* host_addr;
void* device_addr;
uint64_t module_id;
} device_load;
// struct
// {
// int device_num;
// uint64_t module_id;
// } device_unload;
struct
{
ompt_sync_region_t kind;
ompt_scope_endpoint_t endpoint;
ompt_data_t* parallel_data;
ompt_data_t* task_data;
const void* codeptr_ra;
} sync_region_wait;
struct
{
ompt_mutex_t kind;
ompt_wait_id_t wait_id;
const void* codeptr_ra;
} mutex_released;
struct
{
ompt_data_t* task_data;
const ompt_dependence_t* deps;
int ndeps;
} dependences;
struct
{
ompt_data_t* src_task_data;
ompt_data_t* sink_task_data;
} task_dependence;
struct
{
ompt_work_t work_type;
ompt_scope_endpoint_t endpoint;
ompt_data_t* parallel_data;
ompt_data_t* task_data;
uint64_t count;
const void* codeptr_ra;
} work;
struct
{
ompt_scope_endpoint_t endpoint;
ompt_data_t* parallel_data;
ompt_data_t* task_data;
const void* codeptr_ra;
} masked;
struct
{
ompt_sync_region_t kind;
ompt_scope_endpoint_t endpoint;
ompt_data_t* parallel_data;
ompt_data_t* task_data;
const void* codeptr_ra;
} sync_region;
struct
{
ompt_mutex_t kind;
unsigned int hint;
unsigned int impl;
ompt_wait_id_t wait_id;
const void* codeptr_ra;
} lock_init;
struct
{
ompt_mutex_t kind;
ompt_wait_id_t wait_id;
const void* codeptr_ra;
} lock_destroy;
struct
{
ompt_mutex_t kind;
unsigned int hint;
unsigned int impl;
ompt_wait_id_t wait_id;
const void* codeptr_ra;
} mutex_acquire;
struct
{
ompt_mutex_t kind;
ompt_wait_id_t wait_id;
const void* codeptr_ra;
} mutex_acquired;
struct
{
ompt_scope_endpoint_t endpoint;
ompt_wait_id_t wait_id;
const void* codeptr_ra;
} nest_lock;
struct
{
ompt_data_t* thread_data;
const void* codeptr_ra;
} flush;
struct
{
ompt_data_t* task_data;
int flags;
const void* codeptr_ra;
} cancel;
struct
{
ompt_sync_region_t kind;
ompt_scope_endpoint_t endpoint;
ompt_data_t* parallel_data;
ompt_data_t* task_data;
const void* codeptr_ra;
} reduction;
struct
{
ompt_data_t* parallel_data;
ompt_data_t* task_data;
ompt_dispatch_t kind;
ompt_data_t instance;
} dispatch;
struct
{
ompt_target_t kind;
ompt_scope_endpoint_t endpoint;
int device_num;
ompt_data_t* task_data;
ompt_data_t* target_task_data;
ompt_data_t* target_data;
const void* codeptr_ra;
} target_emi;
struct
{
ompt_scope_endpoint_t endpoint;
ompt_data_t* target_task_data;
ompt_data_t* target_data;
ompt_data_t* host_op_id;
ompt_target_data_op_t optype;
void* src_address;
int src_device_num;
void* dst_address;
int dst_device_num;
size_t bytes;
const void* codeptr_ra;
} target_data_op_emi;
struct
{
ompt_scope_endpoint_t endpoint;
ompt_data_t* target_data;
ompt_data_t* host_op_id;
unsigned int requested_num_teams;
} target_submit_emi;
// struct
// {
// unsigned int nitems;
// void** host_addr;
// void** device_addr;
// size_t* bytes;
// unsigned int* mapping_flags;
// const void* codeptr_ra;
// } target_map_emi;
struct
{
ompt_severity_t severity;
const char* message;
size_t length;
const void* codeptr_ra;
} error;
rocprofiler_ompt_callback_functions_t callback_functions;
} rocprofiler_ompt_args_t;
ROCPROFILER_EXTERN_C_FINI
+67
ファイルの表示
@@ -0,0 +1,67 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
/**
* @brief ROCProfiler enumeration of OMPT (OpenMP tools) tracing operations
* NOTE: These are callbacks into the ROCProfiler SDK from the vendor-provided OMPT implementation
*/
typedef enum rocprofiler_ompt_operation_t // NOLINT(performance-enum-size)
{
ROCPROFILER_OMPT_ID_NONE = -1,
ROCPROFILER_OMPT_ID_thread_begin = 0,
ROCPROFILER_OMPT_ID_thread_end,
ROCPROFILER_OMPT_ID_parallel_begin,
ROCPROFILER_OMPT_ID_parallel_end,
ROCPROFILER_OMPT_ID_task_create,
ROCPROFILER_OMPT_ID_task_schedule,
ROCPROFILER_OMPT_ID_implicit_task,
ROCPROFILER_OMPT_ID_device_initialize,
ROCPROFILER_OMPT_ID_device_finalize,
ROCPROFILER_OMPT_ID_device_load,
// ROCPROFILER_OMPT_ID_device_unload,
ROCPROFILER_OMPT_ID_sync_region_wait,
ROCPROFILER_OMPT_ID_mutex_released,
ROCPROFILER_OMPT_ID_dependences,
ROCPROFILER_OMPT_ID_task_dependence,
ROCPROFILER_OMPT_ID_work,
ROCPROFILER_OMPT_ID_masked,
ROCPROFILER_OMPT_ID_sync_region,
ROCPROFILER_OMPT_ID_lock_init,
ROCPROFILER_OMPT_ID_lock_destroy,
ROCPROFILER_OMPT_ID_mutex_acquire,
ROCPROFILER_OMPT_ID_mutex_acquired,
ROCPROFILER_OMPT_ID_nest_lock,
ROCPROFILER_OMPT_ID_flush,
ROCPROFILER_OMPT_ID_cancel,
ROCPROFILER_OMPT_ID_reduction,
ROCPROFILER_OMPT_ID_dispatch,
ROCPROFILER_OMPT_ID_target_emi,
ROCPROFILER_OMPT_ID_target_data_op_emi,
ROCPROFILER_OMPT_ID_target_submit_emi,
// ROCPROFILER_OMPT_ID_target_map_emi,
ROCPROFILER_OMPT_ID_error,
ROCPROFILER_OMPT_ID_callback_functions, // fake to return struct of ompt callback function
// pointers
ROCPROFILER_OMPT_ID_LAST
} rocprofiler_ompt_operation_t;
ファイル差分が大きすぎるため表示されません。 差分を読み込み
+521
ファイルの表示
@@ -0,0 +1,521 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/agent.h>
#include <rocprofiler-sdk/defines.h>
#include <rocprofiler-sdk/fwd.h>
ROCPROFILER_EXTERN_C_INIT
/**
* @defgroup PC_SAMPLING_SERVICE PC Sampling
* @brief Enabling PC (Program Counter) Sampling for GPU Activity
* @{
*/
/**
* @brief (experimental) Function used to configure the PC sampling service on the GPU agent with @p
* agent_id.
*
* Prerequisites are the following:
* - The client must create a context and supply its @p context_id. By using this context,
* the client can start/stop PC sampling on the agent. For more information,
* please @see rocprofiler_start_context/rocprofiler_stop_context.
* - The user must create a buffer and supply its @p buffer_id. Rocprofiler-SDK uses the buffer
* to deliver the PC samples to the client. For more information about the data delivery,
* please @see rocprofiler_create_buffer and @see rocprofiler_buffer_tracing_cb_t.
*
* Before calling this function, we recommend querying PC sampling configurations
* supported by the GPU agent via the @see rocprofiler_query_pc_sampling_agent_configurations.
* The client chooses the @p method, @p unit, and @p interval to match one of the
* available configurations. Note that the @p interval must belong to the range of values
* [available_config.min_interval, available_config.max_interval],
* where available_config is the instance of the @see rocprofiler_pc_sampling_configuration_s
* supported/available at the moment.
*
* Rocprofiler-SDK checks whether the requsted configuration is actually supported
* at the moment of calling this function. If the answer is yes, it returns
* the @see ROCPROFILER_STATUS_SUCCESS. Otherwise, it notifies the client about the
* rejection reason via the returned status code. For more information
* about the status codes, please @see rocprofiler_status_t.
*
* There are a few constraints a client's code needs to be aware of.
*
* Constraint1: A GPU agent can be configured to support at most one running PC sampling
* configuration at any time, which implies some of the consequences described below.
* After the tool configures the PC sampling with one of the available configurations,
* rocprofiler-SDK guarantees that this configuration will be valid for the tool's
* lifetime. The tool can start and stop the configured PC sampling service whenever convenient.
*
* Constraint2: Since the same GPU agent can be used by multiple processes concurrently,
* Rocprofiler-SDK cannot guarantee the exclusive access to the PC sampling capability.
* The consequence is the following scenario. The tool TA that belongs to the process PA,
* calls the @see rocprofiler_query_pc_sampling_agent_configurations that returns the
* two supported configurations CA and CB by the agent. Then the tool TB of the process PB,
* configures the PC sampling on the same agent by using the configuration CB.
* Subsequently, the TA tries configuring the CA on the agent, and it fails.
* To point out that this case happened, we introduce a special status code
* @see ROCPROFILER_STATUS_ERROR_NOT_AVAILABLE.
* When this status code is observed by the tool TA, it queries all available configurations again
* by calling @see rocprofiler_query_pc_sampling_agent_configurations,
* that returns only CB this time. The tool TA can choose CB, so that both
* TA and TB use the PC sampling capability in the separate processes.
* Both TA and TB receives samples generated by the kernels launched by the
* corresponding processes PA and PB, respectively.
*
* Constraint3: Rocprofiler-SDK allows only one context to contain the configured PC sampling
* service within the process, that implies that at most one of the loaded tools can use PC
* sampling. One context can contains multiple PC sampling services configured for different GPU
* agents.
*
* Constraint4: PC sampling feature is not available within the ROCgdb.
*
* Constraint5: PC sampling service cannot be used simultaneously with
* counter collection service.
*
* @param [in] context_id - id of the context used for starting/stopping PC sampling service
* @param [in] agent_id - id of the agent on which caller tries using PC sampling capability
* @param [in] method - the type of PC sampling the caller tries to use on the agent.
* @param [in] unit - The unit appropriate to the PC sampling type/method.
* @param [in] interval - frequency at which PC samples are generated
* @param [in] buffer_id - id of the buffer used for delivering PC samples
* @param [in] flags - for future use
* @return ::rocprofiler_status_t
* @retval ::ROCPROFILER_STATUS_SUCCESS PC sampling service configured successfully
* @retval ::ROCPROFILER_STATUS_ERROR_NOT_AVAILABLE One of the scenarios is present:
* 1. PC sampling is already configured with configuration different than requested,
* 2. PC sampling is requested from a process that runs within the ROCgdb.
* 3. HSA runtime does not support PC sampling.
* 4. GPU device does not support requested PC sampling method.
* @retval ::ROCPROFILER_STATUS_ERROR_INCOMPATIBLE_KERNEL the amdgpu driver installed on the system
* does not support the PC sampling feature
* @retval ::ROCPROFILER_STATUS_ERROR a general error caused by the amdgpu driver
* @retval ::ROCPROFILER_STATUS_ERROR_CONTEXT_CONFLICT counter collection service already
* setup in the context
* @retval ::ROCPROFILER_STATUS_ERROR_INVALID_ARGUMENT function invoked with an invalid argument
*/
ROCPROFILER_SDK_EXPERIMENTAL
rocprofiler_status_t
rocprofiler_configure_pc_sampling_service(rocprofiler_context_id_t context_id,
rocprofiler_agent_id_t agent_id,
rocprofiler_pc_sampling_method_t method,
rocprofiler_pc_sampling_unit_t unit,
uint64_t interval,
rocprofiler_buffer_id_t buffer_id,
int flags) ROCPROFILER_API;
/**
* @brief (experimental) Enumeration describing values of flags of
* ::rocprofiler_pc_sampling_configuration_t.
*/
typedef enum ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_pc_sampling_configuration_flags_t
{
ROCPROFILER_PC_SAMPLING_CONFIGURATION_FLAGS_NONE = 0,
ROCPROFILER_PC_SAMPLING_CONFIGURATION_FLAGS_INTERVAL_POW2,
ROCPROFILER_PC_SAMPLING_CONFIGURATION_FLAGS_LAST
/// @var ROCPROFILER_PC_SAMPLING_CONFIGURATION_FLAGS_INTERVAL_POW2
/// @brief The interval value must be a power of 2.
} rocprofiler_pc_sampling_configuration_flags_t;
/**
* @brief (experimental) PC sampling configuration supported by a GPU agent.
*/
typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_pc_sampling_configuration_t
{
uint64_t size; ///< Size of this struct
rocprofiler_pc_sampling_method_t method;
rocprofiler_pc_sampling_unit_t unit;
size_t min_interval;
size_t max_interval;
uint64_t flags; ///< take values from ::rocprofiler_pc_sampling_configuration_flags_t
/// @var method
/// @brief Sampling method supported by the GPU agent.
/// Currently, it can take one of the following two values:
/// - ::ROCPROFILER_PC_SAMPLING_METHOD_HOST_TRAP: a background host kernel thread
/// periodically interrupts waves execution on the GPU to generate PC samples
/// - ::ROCPROFILER_PC_SAMPLING_METHOD_STOCHASTIC: performance monitoring hardware
/// on the GPU periodically interrupts waves to generate PC samples.
/// @var unit
/// @brief A unit used to specify the interval of the @ref method for samples generation.
/// @var min_interval
/// @brief the highest possible frequencey for generating samples using @ref method.
/// @var max_interval
/// @brief the lowest possible frequency for generating samples using @ref method
} rocprofiler_pc_sampling_configuration_t;
/**
* @brief (experimental) Rocprofiler SDK's callback function to deliver the list of available PC
* sampling configurations upon the call to the
* ::rocprofiler_query_pc_sampling_agent_configurations.
*
* @param[out] configs - The array of PC sampling configurations supported by the agent
* at the moment of invoking ::rocprofiler_query_pc_sampling_agent_configurations.
* @param[out] num_config - The number of configurations contained in the underlying array
* @p configs.
* In case the GPU agent does not support PC sampling, the value is 0.
* @param[in] user_data - client's private data passed via
* ::rocprofiler_query_pc_sampling_agent_configurations
* @return ::rocprofiler_status_t
*/
ROCPROFILER_SDK_EXPERIMENTAL
typedef rocprofiler_status_t (*rocprofiler_available_pc_sampling_configurations_cb_t)(
const rocprofiler_pc_sampling_configuration_t* configs,
size_t num_config,
void* user_data);
/**
* @brief (experimental) Query PC Sampling Configuration.
*
* Lists PC sampling configurations a GPU agent with @p agent_id supports at the moment
* of invoking the function. Delivers configurations via @p cb.
* In case the PC sampling is configured on the GPU agent, the @p cb delivers information
* about the active PC sampling configuration.
* In case the GPU agent does not support PC sampling capability,
* the @p cb delivers none PC sampling configurations.
*
* @param [in] agent_id - id of the agent for which available configurations will be listed
* @param [in] cb - User callback that delivers the available PC sampling configurations
* @param [in] user_data - passed to the @p cb
* @return ::rocprofiler_status_t
* @retval ::ROCPROFILER_STATUS_ERROR_NOT_AVAILABLE One of the scenarios is present:
* 1. PC sampling is requested from a process that runs within the ROCgdb.
* 2. HSA runtime does not support PC sampling.
* @retval ::ROCPROFILER_STATUS_ERROR_INCOMPATIBLE_KERNEL the amdgpu driver installed on the system
* does not support the PC sampling feature.
* @retval ::ROCPROFILER_STATUS_ERROR a general error caused by the amdgpu driver
* @retval ::ROCPROFILER_STATUS_SUCCESS @p cb successfully finished
*/
ROCPROFILER_SDK_EXPERIMENTAL
rocprofiler_status_t
rocprofiler_query_pc_sampling_agent_configurations(
rocprofiler_agent_id_t agent_id,
rocprofiler_available_pc_sampling_configurations_cb_t cb,
void* user_data) ROCPROFILER_API ROCPROFILER_NONNULL(2, 3);
/**
* @brief (experimental) Information about the GPU part where wave was executing
* at the moment of sampling.
*/
typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_pc_sampling_hw_id_v0_t
{
uint64_t chiplet : 6; ///< chiplet index (3 bits allocated by the ROCr runtime)
uint64_t wave_id : 7; ///< wave slot index
uint64_t simd_id : 2; ///< SIMD index
uint64_t pipe_id : 4; ///< pipe index
uint64_t cu_or_wgp_id : 4;
uint64_t shader_array_id : 1; ///< Shared array index
uint64_t shader_engine_id : 5; ///< shared engine index
uint64_t workgroup_id : 7; ///< thread_group index on GFX9, and workgroup index on GFX10+
uint64_t vm_id : 6; ///< virtual memory ID
uint64_t queue_id : 4; ///< queue id
uint64_t microengine_id : 2; ///< ACE (microengine) index
uint64_t reserved0 : 16; ///< Reserved for the future use
/// @var cu_or_wgp_id
/// @brief Compute unit index on GFX9 or workgroup processor index on GFX10+.
} rocprofiler_pc_sampling_hw_id_v0_t;
/**
* @brief (experimental) Sampled program counter.
*/
typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_pc_t
{
uint64_t code_object_id;
uint64_t code_object_offset;
/// @var code_object_id
/// @brief id of the loaded code object instance that contains sampled PC.
/// This fields holds the value ::ROCPROFILER_CODE_OBJECT_ID_NONE
/// if the code object cannot be determined
/// (e.g., sampled PC belongs to code generated by self modifying code).
/// @var code_object_offset
/// @brief If @ref code_object_id is different than ::ROCPROFILER_CODE_OBJECT_ID_NONE,
/// then this field contains the offset of the sampled PC relative to the
/// ::rocprofiler_callback_tracing_code_object_load_data_t.load_base
/// of the code object instance with @ref code_object_id.
/// To calculate the original virtual address of the sampled PC, one can add the value
/// of this field to the ::rocprofiler_callback_tracing_code_object_load_data_t.load_base.
/// The value of @ref code_object_offset matches
/// the virtual address of the sampled instruction (PC), only if the
/// @ref code_object_id is equal to the ::ROCPROFILER_CODE_OBJECT_ID_NONE.
} rocprofiler_pc_t;
/**
* @brief (experimental) ROCProfiler Host-Trap PC Sampling Record.
*/
typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_pc_sampling_record_host_trap_v0_t
{
uint64_t size; ///< Size of this struct
rocprofiler_pc_sampling_hw_id_v0_t hw_id; ///< @see ::rocprofiler_pc_sampling_hw_id_v0_t
rocprofiler_pc_t pc; ///< information about sampled program counter
uint64_t exec_mask; ///< active SIMD lanes when sampled
uint64_t timestamp; ///< timestamp when sample is generated
uint64_t dispatch_id; ///< originating kernel dispatch ID
rocprofiler_async_correlation_id_t correlation_id;
rocprofiler_dim3_t workgroup_id; ///< wave coordinates within the workgroup
uint32_t wave_in_group : 8; ///< wave position within the workgroup (0-31)
uint32_t reserved0 : 24; ///< wave position within the workgroup (0-31)
/// @var correlation_id
/// @brief API launch call id that matches dispatch ID
} rocprofiler_pc_sampling_record_host_trap_v0_t;
/**
* @brief (experimental) The header of the ::rocprofiler_pc_sampling_record_stochastic_v0_t,
* indicating what fields of the ::rocprofiler_pc_sampling_record_stochastic_v0_t instance are
* meaningful for the sample.
*/
typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_pc_sampling_record_stochastic_header_t
{
uint8_t has_memory_counter : 1; ///< pc sample provides memory counters information
///< via ::rocprofiler_pc_sampling_memory_counters_t
uint8_t reserved_type : 7;
} rocprofiler_pc_sampling_record_stochastic_header_t;
/**
* @brief (experimental) Enumeration describing type of sampled issued instruction.
*/
typedef enum ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_pc_sampling_instruction_type_t
{
ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_NONE = 0,
ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_VALU, ///< vector ALU instruction
ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_MATRIX, ///< matrix instruction
ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_SCALAR, ///< scalar (memory) instruction
ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_TEX, ///< texture memory instruction
ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_LDS, ///< LDS memory instruction
ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_LDS_DIRECT, ///< LDS direct memory instruction
ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_FLAT, ///< flat memory instruction
ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_EXPORT, ///< export instruction
ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_MESSAGE, ///< message instruction
ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_BARRIER, ///< barrier instruction
ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_BRANCH_NOT_TAKEN,
ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_BRANCH_TAKEN,
ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_JUMP, ///< jump instruction
ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_OTHER, ///< other types of instruction
ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_NO_INST, ///< no instruction issued
ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_DUAL_VALU, /// dual VALU instruction
ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_LAST
/// @var ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_BRANCH_NOT_TAKEN
/// @brief Instruction representing a branch not being taken.
/// @var ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_BRANCH_TAKEN
/// @brief Instruction representing a taken branch.
} rocprofiler_pc_sampling_instruction_type_t;
/**
* @brief (experimental) Enumeration describing reason for not issuing an instruction.
*/
typedef enum ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_pc_sampling_instruction_not_issued_reason_t
{
ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED_REASON_NONE = 0,
ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED_REASON_NO_INSTRUCTION_AVAILABLE,
ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED_REASON_ALU_DEPENDENCY,
ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED_REASON_WAITCNT, ///< waitcnt dependency
ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED_REASON_INTERNAL_INSTRUCTION,
ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED_REASON_BARRIER_WAIT, ///< waiting on a barrier
ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED_REASON_ARBITER_NOT_WIN,
ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED_REASON_ARBITER_WIN_EX_STALL,
ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED_REASON_OTHER_WAIT,
ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED_REASON_SLEEP_WAIT, ///< wave was sleeping
ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED_REASON_LAST
/// @var ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED_REASON_NO_INSTRUCTION_AVAILABLE
/// @brief No instruction available in the instruction cache.
/// @var ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED_REASON_ALU_DEPENDENCY
/// @brief ALU dependency not resolved.
/// @var ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED_REASON_INTERNAL_INSTRUCTION
/// @brief Wave executes an internal instruction.
/// @var ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED_REASON_ARBITER_NOT_WIN
/// @brief The instruction did not win the arbiter.
/// @var ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED_REASON_ARBITER_WIN_EX_STALL
/// @brief Arbiter issued an instruction, but the execution pipe pushed it back from execution.
/// @var ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED_REASON_OTHER_WAIT
/// @brief Other types of wait (e.g., wait for XNACK acknowledgment).
} rocprofiler_pc_sampling_instruction_not_issued_reason_t;
/**
* @brief (experimental) Data provided by stochastic sampling hardware.
*
*/
typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_pc_sampling_snapshot_v0_t
{
uint32_t reason_not_issued : 4;
uint32_t reserved0 : 1; ///< reserved for future use
uint32_t arb_state_issue_valu : 1; ///< arbiter issued a VALU instruction
uint32_t arb_state_issue_matrix : 1; ///< arbiter issued a matrix instruction
uint32_t arb_state_issue_lds : 1; ///< arbiter issued a LDS instruction
uint32_t arb_state_issue_lds_direct : 1; ///< arbiter issued a LDS direct instruction
uint32_t arb_state_issue_scalar : 1; ///< arbiter issued a scalar (SALU/SMEM) instruction
uint32_t arb_state_issue_vmem_tex : 1; ///< arbiter issued a texture instruction
uint32_t arb_state_issue_flat : 1; ///< arbiter issued a FLAT instruction
uint32_t arb_state_issue_exp : 1; ///< arbiter issued a export instruction
uint32_t arb_state_issue_misc : 1; ///< arbiter issued a miscellaneous instruction
uint32_t arb_state_issue_brmsg : 1; ///< arbiter issued a branch/message instruction
uint32_t arb_state_issue_reserved : 1; ///< reserved for the future use
uint32_t arb_state_stall_valu : 1;
uint32_t arb_state_stall_matrix : 1; ///< matrix instruction was stalled
uint32_t arb_state_stall_lds : 1; ///< LDS instruction was stalled
uint32_t arb_state_stall_lds_direct : 1; ///< LDS direct instruction was stalled
uint32_t arb_state_stall_scalar : 1; ///< Scalar (SALU/SMEM) instruction was stalled
uint32_t arb_state_stall_vmem_tex : 1; ///< texture instruction was stalled
uint32_t arb_state_stall_flat : 1; ///< flat instruction was stalled
uint32_t arb_state_stall_exp : 1; ///< export instruction was stalled
uint32_t arb_state_stall_misc : 1; ///< miscellaneous instruction was stalled
uint32_t arb_state_stall_brmsg : 1; ///< branch/message instruction was stalled
uint32_t arb_state_state_reserved : 1; ///< reserved for the future use
// We have two reserved bits
uint32_t dual_issue_valu : 1;
uint32_t reserved1 : 1; ///< reserved for the future use
uint32_t reserved2 : 3; ///< reserved for the future use
/// @var reason_not_issued
/// @brief The reason for not issuing an instruction. The field takes one of the value defined
/// in ::rocprofiler_pc_sampling_instruction_not_issued_reason_t
/// @var arb_state_stall_valu
/// @brief VALU instruction was stalled when a sample was generated
/// @var dual_issue_valu
/// @brief Two VALU instructions were issued for coexecution (MI3xx specific)
} rocprofiler_pc_sampling_snapshot_v0_t;
/**
* @brief (experimental) Counters of issued but not yet completed instructions.
*/
typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_pc_sampling_memory_counters_t
{
uint32_t load_cnt : 6;
uint32_t store_cnt : 6;
uint32_t bvh_cnt : 3;
uint32_t sample_cnt : 6;
uint32_t ds_cnt : 6;
uint32_t km_cnt : 5;
/// @var load_cnt
/// @brief Counts the number of VMEM load instructions issued but not yet completed.
/// @var store_cnt
/// @brief Counts the number of VMEM store instructions issued but not yet completed.
/// @var bvh_cnt
/// @brief Counts the number of VMEM BVH instructions issued but not yet completed.
/// @var sample_cnt
/// @brief Counts the number of VMEM sample instructions issued but not yet completed.
/// @var ds_cnt
/// @brief Counts the number of LDS instructions issued but not yet completed.
/// @var km_cnt
/// @brief Counts the number of scalar memory reads and memory instructions issued but not yet
/// completed.
} rocprofiler_pc_sampling_memory_counters_t;
/**
* @brief (experimental) ROCProfiler Stochastic PC Sampling Record.
*/
typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_pc_sampling_record_stochastic_v0_t
{
uint64_t size; ///< Size of this struct
rocprofiler_pc_sampling_record_stochastic_header_t flags;
uint8_t wave_in_group;
uint8_t wave_issued : 1;
uint8_t inst_type : 5;
uint8_t reserved : 2;
rocprofiler_pc_sampling_hw_id_v0_t hw_id;
rocprofiler_pc_t pc;
uint64_t exec_mask;
rocprofiler_dim3_t workgroup_id;
uint32_t wave_count;
uint64_t timestamp;
uint64_t dispatch_id;
rocprofiler_async_correlation_id_t correlation_id;
rocprofiler_pc_sampling_snapshot_v0_t snapshot;
rocprofiler_pc_sampling_memory_counters_t memory_counters;
/// @var flags
/// @brief Defines what fields are meaningful for the sample.
/// @var wave_in_group
/// @brief wave position within the workgroup (0-15)
/// @var wave_issued
/// @brief wave issued the instruction represented with the PC
/// @var inst_type
/// @brief instruction type, takes a value defined in @ref
/// ::rocprofiler_pc_sampling_instruction_type_t
/// @var reserved
/// @brief reserved 2 bits must be zero
/// @var hw_id
/// @brief @see ::rocprofiler_pc_sampling_hw_id_v0_t
/// @var pc
/// @brief information about sampled program counter
/// @var exec_mask
/// @brief active SIMD lanes at the moment of sampling
/// @var workgroup_id
/// @brief wave coordinates within the workgroup
/// @var wave_count
/// @brief active waves on the CU at the moment of sampling
/// @var timestamp
/// @brief timestamp when sample is generated
/// @var dispatch_id
/// @brief originating kernel dispatch ID
/// @var correlation_id
/// @brief API launch call id that matches dispatch ID
/// @var snapshot
/// @brief Data provided by stochastic sampling hardware. @see
/// ::rocprofiler_pc_sampling_snapshot_v0_t
/// @var memory_counters
/// @brief Counters of issued but not yet completed instructions. @see
/// ::rocprofiler_pc_sampling_memory_counters_t
} rocprofiler_pc_sampling_record_stochastic_v0_t;
/**
* @brief (experimental) Record representing an invalid PC Sampling Record.
*/
typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_pc_sampling_record_invalid_t
{
uint64_t size; ///< Size of the struct
} rocprofiler_pc_sampling_record_invalid_t;
/**
* @brief (experimental) Return the string encoding of ::rocprofiler_pc_sampling_instruction_type_t
* value
* @param [in] instruction_type instruction type enum value
* @return Will return a nullptr if invalid/unsupported ::rocprofiler_pc_sampling_instruction_type_t
* value is provided.
*/
ROCPROFILER_SDK_EXPERIMENTAL
const char*
rocprofiler_get_pc_sampling_instruction_type_name(
rocprofiler_pc_sampling_instruction_type_t instruction_type) ROCPROFILER_API;
/**
* @brief (experimental) Return the string encoding of
* ::rocprofiler_pc_sampling_instruction_not_issued_reason_t value
* @param [in] not_issued_reason no issue reason enum value
* @return Will return a nullptr if invalid/unsupported
* ::rocprofiler_pc_sampling_instruction_not_issued_reason_t value is provided.
*/
ROCPROFILER_SDK_EXPERIMENTAL const char*
rocprofiler_get_pc_sampling_instruction_not_issued_reason_name(
rocprofiler_pc_sampling_instruction_not_issued_reason_t not_issued_reason) ROCPROFILER_API;
/** @} */
ROCPROFILER_EXTERN_C_FINI
+27
ファイルの表示
@@ -0,0 +1,27 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/rccl/api_args.h>
#include <rocprofiler-sdk/rccl/api_id.h>
#include <rocprofiler-sdk/rccl/table_id.h>
+13
ファイルの表示
@@ -0,0 +1,13 @@
#
#
# Installation of public RCCL headers
#
#
set(ROCPROFILER_RCCL_HEADER_FILES api_args.h api_id.h table_id.h)
install(
FILES ${ROCPROFILER_RCCL_HEADER_FILES}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocprofiler-sdk/rccl
COMPONENT development)
add_subdirectory(details)
+323
ファイルの表示
@@ -0,0 +1,323 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
#include <rocprofiler-sdk/defines.h>
#if !defined(ROCPROFILER_SDK_USE_SYSTEM_RCCL)
# if defined __has_include
# if __has_include(<rccl/rccl.h>)
# define ROCPROFILER_SDK_USE_SYSTEM_RCCL 1
# else
# define ROCPROFILER_SDK_USE_SYSTEM_RCCL 0
# endif
# else
# define ROCPROFILER_SDK_USE_SYSTEM_RCCL 0
# endif
#endif
#if ROCPROFILER_SDK_USE_SYSTEM_RCCL > 0
# include <rccl/rccl.h>
#else
# include <rocprofiler-sdk/rccl/details/rccl.h>
#endif
#include <stdint.h>
ROCPROFILER_EXTERN_C_INIT
// Empty struct has a size of 0 in C but size of 1 in C++.
// This struct is added to the union members which represent
// functions with no arguments to ensure ABI compatibility
typedef struct rocprofiler_rccl_api_no_args
{
char empty;
} rocprofiler_rccl_api_no_args;
typedef union rocprofiler_rccl_api_retval_t
{
int32_t ncclResult_t_retval;
const char* const_charp_retval;
} rocprofiler_rccl_api_retval_t;
typedef union rocprofiler_rccl_api_args_t
{
struct
{
const void* sendbuff;
void* recvbuff;
size_t sendcount;
ncclDataType_t datatype;
ncclComm_t comm;
hipStream_t stream;
} ncclAllGather;
struct
{
const void* sendbuff;
void* recvbuff;
size_t count;
ncclDataType_t datatype;
ncclRedOp_t op;
struct ncclComm* comm;
hipStream_t stream;
} ncclAllReduce;
struct
{
const void* sendbuff;
void* recvbuff;
size_t count;
ncclDataType_t datatype;
ncclComm_t comm;
hipStream_t stream;
} ncclAllToAll;
struct
{
const void* sendbuff;
const size_t* sendcounts;
const size_t* sdispls;
void* recvbuff;
const size_t* recvcounts;
const size_t* rdispls;
ncclDataType_t datatype;
ncclComm_t comm;
hipStream_t stream;
} ncclAllToAllv;
struct
{
const void* sendbuff;
void* recvbuff;
size_t count;
ncclDataType_t datatype;
int root;
ncclComm_t comm;
hipStream_t stream;
} ncclBroadcast;
struct
{
const void* sendbuff;
void* recvbuff;
size_t sendcount;
ncclDataType_t datatype;
int root;
ncclComm_t comm;
hipStream_t stream;
} ncclGather;
struct
{
const void* sendbuff;
void* recvbuff;
size_t count;
ncclDataType_t datatype;
ncclRedOp_t op;
int root;
ncclComm_t comm;
hipStream_t stream;
} ncclReduce;
struct
{
const void* sendbuff;
void* recvbuff;
size_t recvcount;
ncclDataType_t datatype;
ncclRedOp_t op;
struct ncclComm* comm;
hipStream_t stream;
} ncclReduceScatter;
struct
{
const void* sendbuff;
void* recvbuff;
size_t recvcount;
ncclDataType_t datatype;
int root;
ncclComm_t comm;
hipStream_t stream;
} ncclScatter;
struct
{
const void* sendbuff;
size_t count;
ncclDataType_t datatype;
int peer;
ncclComm_t comm;
hipStream_t stream;
} ncclSend;
struct
{
void* recvbuff;
size_t count;
ncclDataType_t datatype;
int peer;
ncclComm_t comm;
hipStream_t stream;
} ncclRecv;
struct
{
ncclRedOp_t* op;
void* scalar;
ncclDataType_t datatype;
ncclScalarResidence_t residence;
ncclComm_t comm;
} ncclRedOpCreatePreMulSum;
struct
{
ncclRedOp_t op;
ncclComm_t comm;
} ncclRedOpDestroy;
struct
{
rocprofiler_rccl_api_no_args no_args;
} ncclGroupStart;
struct
{
rocprofiler_rccl_api_no_args no_args;
} ncclGroupEnd;
struct
{
int* version;
} ncclGetVersion;
struct
{
ncclUniqueId* out;
} ncclGetUniqueId;
struct
{
ncclComm_t* newcomm;
int nranks;
ncclUniqueId commId;
int myrank;
} ncclCommInitRank;
struct
{
ncclComm_t* comms;
int ndev;
const int* devlist;
} ncclCommInitAll;
struct
{
ncclComm_t* comm;
int nranks;
ncclUniqueId commId;
int myrank;
ncclConfig_t* config;
} ncclCommInitRankConfig;
struct
{
ncclComm_t comm;
} ncclCommFinalize;
struct
{
ncclComm_t comm;
} ncclCommDestroy;
struct
{
ncclComm_t comm;
} ncclCommAbort;
struct
{
ncclComm_t comm;
int color;
int key;
ncclComm_t* newcomm;
ncclConfig_t* config;
} ncclCommSplit;
struct
{
ncclResult_t code;
} ncclGetErrorString;
struct
{
ncclComm_t comm;
} ncclGetLastError;
struct
{
ncclComm_t comm;
ncclResult_t* asyncError;
} ncclCommGetAsyncError;
struct
{
ncclComm_t comm;
int* count;
} ncclCommCount;
struct
{
ncclComm_t comm;
int* devid;
} ncclCommCuDevice;
struct
{
ncclComm_t comm;
int* rank;
} ncclCommUserRank;
struct
{
void** ptr;
size_t size;
} ncclMemAlloc;
struct
{
void* ptr;
} ncclMemFree;
struct
{
const char* mscclAlgoFilePath;
mscclAlgoHandle_t* mscclAlgoHandle;
int rank;
} mscclLoadAlgo;
struct
{
const void* sendBuff;
const size_t* sendCounts;
const size_t* sDisPls;
void* recvBuff;
const size_t* recvCounts;
const size_t* rDisPls;
size_t count;
ncclDataType_t dataType;
int root;
int peer;
ncclRedOp_t op;
mscclAlgoHandle_t mscclAlgoHandle;
ncclComm_t comm;
hipStream_t stream;
} mscclRunAlgo;
struct
{
mscclAlgoHandle_t mscclAlgoHandle;
} mscclUnloadAlgo;
struct
{
ncclComm_t comm;
void* buff;
size_t size;
void** handle;
} ncclCommRegister;
struct
{
ncclComm_t comm;
void* handle;
} ncclCommDeregister;
} rocprofiler_rccl_api_args_t;
ROCPROFILER_EXTERN_C_FINI
+73
ファイルの表示
@@ -0,0 +1,73 @@
// MIT License
//
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
//
// 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.
#pragma once
/**
* @brief ROCProfiler enumeration of RCCL API tracing operations
*/
typedef enum rocprofiler_rccl_api_id_t // NOLINT(performance-enum-size)
{
ROCPROFILER_RCCL_API_ID_NONE = -1,
ROCPROFILER_RCCL_API_ID_ncclAllGather = 0,
ROCPROFILER_RCCL_API_ID_ncclAllReduce,
ROCPROFILER_RCCL_API_ID_ncclAllToAll,
ROCPROFILER_RCCL_API_ID_ncclAllToAllv,
ROCPROFILER_RCCL_API_ID_ncclBroadcast,
ROCPROFILER_RCCL_API_ID_ncclGather,
ROCPROFILER_RCCL_API_ID_ncclReduce,
ROCPROFILER_RCCL_API_ID_ncclReduceScatter,
ROCPROFILER_RCCL_API_ID_ncclScatter,
ROCPROFILER_RCCL_API_ID_ncclSend,
ROCPROFILER_RCCL_API_ID_ncclRecv,
ROCPROFILER_RCCL_API_ID_ncclRedOpCreatePreMulSum,
ROCPROFILER_RCCL_API_ID_ncclRedOpDestroy,
ROCPROFILER_RCCL_API_ID_ncclGroupStart,
ROCPROFILER_RCCL_API_ID_ncclGroupEnd,
ROCPROFILER_RCCL_API_ID_ncclGetVersion,
ROCPROFILER_RCCL_API_ID_ncclGetUniqueId,
ROCPROFILER_RCCL_API_ID_ncclCommInitRank,
ROCPROFILER_RCCL_API_ID_ncclCommInitAll,
ROCPROFILER_RCCL_API_ID_ncclCommInitRankConfig,
ROCPROFILER_RCCL_API_ID_ncclCommFinalize,
ROCPROFILER_RCCL_API_ID_ncclCommDestroy,
ROCPROFILER_RCCL_API_ID_ncclCommAbort,
ROCPROFILER_RCCL_API_ID_ncclCommSplit,
ROCPROFILER_RCCL_API_ID_ncclGetErrorString,
ROCPROFILER_RCCL_API_ID_ncclGetLastError,
ROCPROFILER_RCCL_API_ID_ncclCommGetAsyncError,
ROCPROFILER_RCCL_API_ID_ncclCommCount,
ROCPROFILER_RCCL_API_ID_ncclCommCuDevice,
ROCPROFILER_RCCL_API_ID_ncclCommUserRank,
ROCPROFILER_RCCL_API_ID_ncclMemAlloc,
ROCPROFILER_RCCL_API_ID_ncclMemFree,
ROCPROFILER_RCCL_API_ID_mscclLoadAlgo,
ROCPROFILER_RCCL_API_ID_mscclRunAlgo,
ROCPROFILER_RCCL_API_ID_mscclUnloadAlgo,
ROCPROFILER_RCCL_API_ID_ncclCommRegister,
ROCPROFILER_RCCL_API_ID_ncclCommDeregister,
ROCPROFILER_RCCL_API_ID_LAST,
} rocprofiler_rccl_api_id_t;
1272ファイル中100ファイルを読み込みました。 変更されたファイルが多すぎるため、それ以降のファイルは表示していません。 さらに表示