Initial Implementation: include (#10)
* Initial Implementation: include * Initial Implementation: lib details (#11) * Initial Implementation: lib details * Initial Implementation: lib (#12) * Initial Implementation: lib * Initial Implementation: source (#13) * Initial Implementation: source * Initial Implementation: samples (#14) * Initial Implementation: samples * Initial Implementation: tests (#15) * Initial Implementation: tests * Initial Implementation: scripts (#16) * Initial Implementation: scripts * Initial Implementation: cmake (#17) * Initial Implementation: cmake * Initial Implementation: top-level files (#18) * Initial Implementation: top-level files - clang-format - clang-tidy - cmake-format - ignore build and cache directories - main CMakeLists.txt - pyproject.toml (python formatting) - VERSION file * Initial Implementation: workflow (#19) * Fix unused variable - rocprofiler_register_warn_level
This commit is contained in:
committed by
GitHub
parent
53a9547670
commit
fa4295db6b
@@ -0,0 +1,4 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
add_subdirectory(rocprofiler-register)
|
||||
@@ -0,0 +1,13 @@
|
||||
#
|
||||
#
|
||||
# Installation of public headers
|
||||
#
|
||||
#
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/version.h @ONLY)
|
||||
|
||||
set(ROCPROFILER_REGISTER_INCLUDE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/rocprofiler-register.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/version.h)
|
||||
|
||||
install(FILES ${ROCPROFILER_REGISTER_INCLUDE_FILES}
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocprofiler-register)
|
||||
@@ -0,0 +1,188 @@
|
||||
// Copyright (c) 2023 Advanced Micro Devices, Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <rocprofiler-register/version.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef int (*rocprofiler_configure_callback_t)(void*);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
rocprofiler_configure_callback_t initialize;
|
||||
rocprofiler_configure_callback_t finalize;
|
||||
void* user_data;
|
||||
} rocprofiler_configure_result_t;
|
||||
|
||||
typedef uint32_t (*rocprofiler_register_import_func_t)(void);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint64_t handle;
|
||||
} rocprofiler_register_library_indentifier_t;
|
||||
|
||||
/// @enum rocprofiler_register_error_code_t
|
||||
/// @brief enumeration of error codes
|
||||
///
|
||||
/// @var ROCP_REG_SUCCESS
|
||||
/// @brief Successful call to rocprofiler-register
|
||||
///
|
||||
/// @var ROCP_REG_NO_TOOLS
|
||||
/// @brief API table was not passed to rocprofiler because no rocprofiler tool
|
||||
/// configuration symbols were requested
|
||||
///
|
||||
/// @var ROCP_REG_DEADLOCK
|
||||
/// @brief The thread that is currently communicating the API tables to rocprofiler
|
||||
/// re-entered \ref rocprofiler_register_library_api_table
|
||||
///
|
||||
/// @var ROCP_REG_BAD_API_TABLE_LENGTH
|
||||
/// @brief Library provided an invalid API table length (likely zero)
|
||||
///
|
||||
/// @var ROCP_REG_UNSUPPORTED_API
|
||||
/// @brief Library is providing an API table name that is not supported
|
||||
///
|
||||
/// @var ROCP_REG_ROCPROFILER_ERROR
|
||||
/// @brief Rocprofiler returned an error when passing the API tables
|
||||
///
|
||||
/// @var ROCP_REG_EXCESS_API_INSTANCES
|
||||
/// @brief The same API has been registered too many times
|
||||
///
|
||||
typedef enum rocprofiler_register_error_code_t // NOLINT(performance-enum-size)
|
||||
{
|
||||
ROCP_REG_SUCCESS = 0,
|
||||
ROCP_REG_NO_TOOLS,
|
||||
ROCP_REG_DEADLOCK,
|
||||
ROCP_REG_BAD_API_TABLE_LENGTH,
|
||||
ROCP_REG_UNSUPPORTED_API,
|
||||
ROCP_REG_INVALID_API_ADDRESS,
|
||||
ROCP_REG_ROCPROFILER_ERROR,
|
||||
ROCP_REG_EXCESS_API_INSTANCES,
|
||||
ROCP_REG_ERROR_CODE_END,
|
||||
} rocprofiler_register_error_code_t;
|
||||
|
||||
/// @fn rocprofiler_register_error_code_t rocprofiler_register_library_api_table(
|
||||
/// const char* lib_name,
|
||||
/// rocprofiler_register_import_func_t import_func,
|
||||
/// uint32_t lib_version,
|
||||
/// void* api_tables,
|
||||
/// uint64_t api_table_length,
|
||||
/// rocprofiler_register_library_indentifier_t* register_id)
|
||||
/// @param[in] lib_name string identifier for the library registering the API table
|
||||
/// @param[in] import_func function pointer to rocprofiler_register_import_<lib_name>
|
||||
/// symbol
|
||||
/// @param[in] lib_version lib version in form of (10000 * major ) + (100 * minor) + patch
|
||||
/// @param[in] api_tables pointer to one or more API table pointers
|
||||
/// @param[in] api_table_length number of API tables that are being passed in. Must be > 0
|
||||
/// @param[out] register_id a unique identifier for this library encoding the API category
|
||||
/// and the priority in the event that multiple libraries register with the same name
|
||||
/// @returns value of type @ref rocprofiler_register_error_code_t
|
||||
///
|
||||
/// @brief primary function call that needs to be performed when the API table of the
|
||||
/// library is initialized.
|
||||
///
|
||||
rocprofiler_register_error_code_t
|
||||
rocprofiler_register_library_api_table(
|
||||
const char* lib_name,
|
||||
rocprofiler_register_import_func_t import_func,
|
||||
uint32_t lib_version,
|
||||
void** api_tables,
|
||||
uint64_t api_table_length,
|
||||
rocprofiler_register_library_indentifier_t* register_id)
|
||||
ROCPROFILER_REGISTER_ATTRIBUTE(nonnull(4, 6)) ROCPROFILER_REGISTER_PUBLIC_API;
|
||||
|
||||
const char* rocprofiler_register_error_string(rocprofiler_register_error_code_t)
|
||||
ROCPROFILER_REGISTER_PUBLIC_API;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/// @def ROCPROFILER_REGISTER_COMPUTE_VERSION_1
|
||||
/// @param[in] MAJOR_VERSION major version of library (integral)
|
||||
/// @brief Helper macro for users to generate versioning int expected by
|
||||
/// rocprofiler-register when the library only maintains a major version number
|
||||
#define ROCPROFILER_REGISTER_COMPUTE_VERSION_1(MAJOR_VERSION) (10000 * MAJOR_VERSION)
|
||||
|
||||
/// @def ROCPROFILER_REGISTER_COMPUTE_VERSION_
|
||||
/// @param[in] MAJOR_VERSION major version of library (integral)
|
||||
/// @param[in] MINOR_VERSION minor version of library (integral)
|
||||
/// @brief Helper macro for users to generate versioning int expected by
|
||||
/// rocprofiler-register when the library only maintains a major and minor version number
|
||||
#define ROCPROFILER_REGISTER_COMPUTE_VERSION_2(MAJOR_VERSION, MINOR_VERSION) \
|
||||
(ROCPROFILER_REGISTER_COMPUTE_VERSION_1(MAJOR_VERSION) + (100 * MINOR_VERSION))
|
||||
|
||||
/// @def ROCPROFILER_REGISTER_COMPUTE_VERSION_3
|
||||
/// @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-register when the library maintains a major, minor, and patch version
|
||||
/// numbers
|
||||
#define ROCPROFILER_REGISTER_COMPUTE_VERSION_3( \
|
||||
MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION) \
|
||||
(ROCPROFILER_REGISTER_COMPUTE_VERSION_2(MAJOR_VERSION, MINOR_VERSION) + \
|
||||
(PATCH_VERSION))
|
||||
|
||||
/// @def ROCPROFILER_REGISTER_COMPUTE_VERSION_4
|
||||
/// @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)
|
||||
/// @param[in] TWEAK_VERSION tweak version of library which will be ignored
|
||||
/// @brief Helper macro for users to generate versioning int expected by
|
||||
/// rocprofiler-register when the library maintains a major, minor, patch, and tweak
|
||||
/// version numbers
|
||||
#define ROCPROFILER_REGISTER_COMPUTE_VERSION_3( \
|
||||
MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION) \
|
||||
(ROCPROFILER_REGISTER_COMPUTE_VERSION_2(MAJOR_VERSION, MINOR_VERSION) + \
|
||||
(PATCH_VERSION))
|
||||
|
||||
/// @def ROCPROFILER_REGISTER_IMPORT_FUNC(NAME)
|
||||
/// @param[in] NAME the string identifier for the library
|
||||
/// @brief Helper macro for retrieving the name of the import function which is used by
|
||||
/// rocprofiler-register to identify the location and priority of the registering library
|
||||
#define ROCPROFILER_REGISTER_IMPORT_FUNC(NAME) \
|
||||
ROCPROFILER_REGISTER_PP_COMBINE(rocprofiler_register_import_, NAME)
|
||||
|
||||
/// @def ROCPROFILER_REGISTER_DEFINE_IMPORT(NAME, VERSION)
|
||||
/// @param[in] NAME the unquoted string identifier for the library, e.g. hip
|
||||
/// @brief Helper macro for declaring a visible import symbol for rocprofiler-register
|
||||
/// which returns the version.
|
||||
///
|
||||
#ifdef __cplusplus
|
||||
# define ROCPROFILER_REGISTER_DEFINE_IMPORT(NAME, VERSION) \
|
||||
extern "C" { \
|
||||
uint32_t ROCPROFILER_REGISTER_IMPORT_FUNC(NAME)() \
|
||||
ROCPROFILER_REGISTER_ATTRIBUTE(visibility("default")); \
|
||||
\
|
||||
uint32_t ROCPROFILER_REGISTER_IMPORT_FUNC(NAME)() { return VERSION; } \
|
||||
}
|
||||
#else
|
||||
# define ROCPROFILER_REGISTER_DEFINE_IMPORT(NAME, VERSION) \
|
||||
uint32_t ROCPROFILER_REGISTER_IMPORT_FUNC(NAME)(void) \
|
||||
ROCPROFILER_REGISTER_ATTRIBUTE(visibility("default")); \
|
||||
\
|
||||
uint32_t ROCPROFILER_REGISTER_IMPORT_FUNC(NAME)(void) { return VERSION; }
|
||||
#endif
|
||||
@@ -0,0 +1,103 @@
|
||||
// MIT License
|
||||
//
|
||||
// Copyright (c) 2022 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
|
||||
|
||||
// clang-format off
|
||||
#define ROCPROFILER_REGISTER_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
|
||||
#define ROCPROFILER_REGISTER_VERSION_MINOR @PROJECT_VERSION_MINOR@
|
||||
#define ROCPROFILER_REGISTER_VERSION_PATCH @PROJECT_VERSION_PATCH@
|
||||
#define ROCPROFILER_REGISTER_VERSION_STRING "@FULL_VERSION_STRING@"
|
||||
#define ROCPROFILER_REGISTER_SOVERSION "@PROJECT_VERSION_MAJOR@"
|
||||
#define ROCPROFILER_REGISTER_GIT_DESCRIBE "@ROCPROFILER_REGISTER_GIT_DESCRIBE@"
|
||||
#define ROCPROFILER_REGISTER_GIT_REVISION "@ROCPROFILER_REGISTER_GIT_REVISION@"
|
||||
|
||||
// system info during compilation
|
||||
#define ROCPROFILER_REGISTER_LIBRARY_ARCH "@CMAKE_LIBRARY_ARCHITECTURE@"
|
||||
#define ROCPROFILER_REGISTER_SYSTEM_NAME "@CMAKE_SYSTEM_NAME@"
|
||||
#define ROCPROFILER_REGISTER_SYSTEM_PROCESSOR "@CMAKE_SYSTEM_PROCESSOR@"
|
||||
#define ROCPROFILER_REGISTER_SYSTEM_VERSION "@CMAKE_SYSTEM_VERSION@"
|
||||
|
||||
// compiler information
|
||||
#define ROCPROFILER_REGISTER_COMPILER_ID "@CMAKE_CXX_COMPILER_ID@"
|
||||
#define ROCPROFILER_REGISTER_COMPILER_VERSION "@CMAKE_CXX_COMPILER_VERSION@"
|
||||
#define ROCPROFILER_REGISTER_COMPILER_STRING ROCPROFILER_REGISTER_COMPILER_ID " v" ROCPROFILER_REGISTER_COMPILER_VERSION
|
||||
// clang-format on
|
||||
|
||||
#define ROCPROFILER_REGISTER_VERSION \
|
||||
((10000 * ROCPROFILER_REGISTER_VERSION_MAJOR) + \
|
||||
(100 * ROCPROFILER_REGISTER_VERSION_MINOR) + ROCPROFILER_REGISTER_VERSION_PATCH)
|
||||
|
||||
#define ROCPROFILER_REGISTER_ATTRIBUTE(...) __attribute__((__VA_ARGS__))
|
||||
#define ROCPROFILER_REGISTER_PP_COMBINE(X, Y) X##Y
|
||||
|
||||
#if defined(rocprofiler_register_EXPORTS)
|
||||
// only defined in build tree
|
||||
# define ROCPROFILER_REGISTER_VISIBILITY(MODE) \
|
||||
ROCPROFILER_REGISTER_ATTRIBUTE(visibility(MODE))
|
||||
# define ROCPROFILER_REGISTER_PUBLIC_API ROCPROFILER_REGISTER_VISIBILITY("default")
|
||||
# define ROCPROFILER_REGISTER_HIDDEN_API ROCPROFILER_REGISTER_VISIBILITY("hidden")
|
||||
# define ROCPROFILER_REGISTER_INTERNAL_API ROCPROFILER_REGISTER_VISIBILITY("internal")
|
||||
# define ROCPROFILER_REGISTER_INLINE \
|
||||
ROCPROFILER_REGISTER_ATTRIBUTE(always_inline) inline
|
||||
# define ROCPROFILER_REGISTER_NOINLINE ROCPROFILER_REGISTER_ATTRIBUTE(noinline)
|
||||
# define ROCPROFILER_REGISTER_HOT ROCPROFILER_REGISTER_ATTRIBUTE(hot)
|
||||
# define ROCPROFILER_REGISTER_COLD ROCPROFILER_REGISTER_ATTRIBUTE(cold)
|
||||
# define ROCPROFILER_REGISTER_CONST ROCPROFILER_REGISTER_ATTRIBUTE(const)
|
||||
# define ROCPROFILER_REGISTER_PURE ROCPROFILER_REGISTER_ATTRIBUTE(pure)
|
||||
# define ROCPROFILER_REGISTER_WEAK ROCPROFILER_REGISTER_ATTRIBUTE(weak)
|
||||
# define ROCPROFILER_REGISTER_PACKED ROCPROFILER_REGISTER_ATTRIBUTE(__packed__)
|
||||
# define ROCPROFILER_REGISTER_PACKED_ALIGN(VAL) \
|
||||
ROCPROFILER_REGISTER_PACKED ROCPROFILER_REGISTER_ATTRIBUTE(__aligned__(VAL))
|
||||
# define ROCPROFILER_REGISTER_LIKELY(...) __builtin_expect((__VA_ARGS__), 1)
|
||||
# define ROCPROFILER_REGISTER_UNLIKELY(...) __builtin_expect((__VA_ARGS__), 0)
|
||||
|
||||
# if defined(ROCPROFILER_REGISTER_CI) && ROCPROFILER_REGISTER_CI > 0
|
||||
# if defined(NDEBUG)
|
||||
# undef NDEBUG
|
||||
# endif
|
||||
# if !defined(DEBUG)
|
||||
# define DEBUG 1
|
||||
# endif
|
||||
# if defined(__cplusplus)
|
||||
# include <cassert> // NOLINT
|
||||
# else
|
||||
# include <assert.h>
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# define ROCPROFILER_REGISTER_STRINGIZE(X) ROCPROFILER_REGISTER_STRINGIZE2(X)
|
||||
# define ROCPROFILER_REGISTER_STRINGIZE2(X) # X
|
||||
# define ROCPROFILER_REGISTER_LINESTR ROCPROFILER_REGISTER_STRINGIZE(__LINE__)
|
||||
# define ROCPROFILER_REGISTER_ESC(...) __VA_ARGS__
|
||||
|
||||
# if defined(__cplusplus)
|
||||
# if !defined(ROCPROFILER_REGISTER_FOLD_EXPRESSION)
|
||||
# define ROCPROFILER_REGISTER_FOLD_EXPRESSION(...) ((__VA_ARGS__), ...)
|
||||
# endif
|
||||
# endif
|
||||
#else
|
||||
# define ROCPROFILER_REGISTER_VISIBILITY(MODE)
|
||||
# define ROCPROFILER_REGISTER_PUBLIC_API
|
||||
# define ROCPROFILER_REGISTER_HIDDEN_API
|
||||
# define ROCPROFILER_REGISTER_INTERNAL_API
|
||||
#endif
|
||||
Reference in New Issue
Block a user