diff --git a/projects/rocprofiler-sdk/samples/api_buffered_tracing/main.cpp b/projects/rocprofiler-sdk/samples/api_buffered_tracing/main.cpp index 7cec6e9ab7..93b0631730 100644 --- a/projects/rocprofiler-sdk/samples/api_buffered_tracing/main.cpp +++ b/projects/rocprofiler-sdk/samples/api_buffered_tracing/main.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #define HIP_API_CALL(CALL) \ { \ diff --git a/projects/rocprofiler-sdk/samples/api_callback_tracing/main.cpp b/projects/rocprofiler-sdk/samples/api_callback_tracing/main.cpp index 59678c3f93..e49255a59e 100644 --- a/projects/rocprofiler-sdk/samples/api_callback_tracing/main.cpp +++ b/projects/rocprofiler-sdk/samples/api_callback_tracing/main.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #define HIP_API_CALL(CALL) \ { \ diff --git a/projects/rocprofiler-sdk/samples/code_object_isa_decode/main.cpp b/projects/rocprofiler-sdk/samples/code_object_isa_decode/main.cpp index 31ab9e9d38..3349cb17ee 100644 --- a/projects/rocprofiler-sdk/samples/code_object_isa_decode/main.cpp +++ b/projects/rocprofiler-sdk/samples/code_object_isa_decode/main.cpp @@ -22,13 +22,16 @@ #include "hip/hip_runtime.h" +#include #include #include #include #include +#include #include #include #include +#include #include "transpose_kernels.hpp" #define PRINT_ALIGN 36 diff --git a/projects/rocprofiler-sdk/samples/code_object_tracing/main.cpp b/projects/rocprofiler-sdk/samples/code_object_tracing/main.cpp index 9a9c3179cd..3a47d4cb85 100644 --- a/projects/rocprofiler-sdk/samples/code_object_tracing/main.cpp +++ b/projects/rocprofiler-sdk/samples/code_object_tracing/main.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #define HIP_API_CALL(CALL) \ { \ diff --git a/projects/rocprofiler-sdk/samples/counter_collection/device_counting_async_client.cpp b/projects/rocprofiler-sdk/samples/counter_collection/device_counting_async_client.cpp index 0712e43155..0c7bdf3f17 100644 --- a/projects/rocprofiler-sdk/samples/counter_collection/device_counting_async_client.cpp +++ b/projects/rocprofiler-sdk/samples/counter_collection/device_counting_async_client.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include diff --git a/projects/rocprofiler-sdk/samples/counter_collection/device_counting_sync_client.cpp b/projects/rocprofiler-sdk/samples/counter_collection/device_counting_sync_client.cpp index d31cb7247c..1a9ecfdaf6 100644 --- a/projects/rocprofiler-sdk/samples/counter_collection/device_counting_sync_client.cpp +++ b/projects/rocprofiler-sdk/samples/counter_collection/device_counting_sync_client.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include diff --git a/projects/rocprofiler-sdk/samples/counter_collection/print_functional_counters_client.cpp b/projects/rocprofiler-sdk/samples/counter_collection/print_functional_counters_client.cpp index 6a23895ada..82a3dbfb3d 100644 --- a/projects/rocprofiler-sdk/samples/counter_collection/print_functional_counters_client.cpp +++ b/projects/rocprofiler-sdk/samples/counter_collection/print_functional_counters_client.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include diff --git a/projects/rocprofiler-sdk/samples/external_correlation_id_request/main.cpp b/projects/rocprofiler-sdk/samples/external_correlation_id_request/main.cpp index 3ddb39973e..5064335768 100644 --- a/projects/rocprofiler-sdk/samples/external_correlation_id_request/main.cpp +++ b/projects/rocprofiler-sdk/samples/external_correlation_id_request/main.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #define HIP_API_CALL(CALL) \ { \ diff --git a/projects/rocprofiler-sdk/samples/intercept_table/main.cpp b/projects/rocprofiler-sdk/samples/intercept_table/main.cpp index c8a82a82af..3378bbb359 100644 --- a/projects/rocprofiler-sdk/samples/intercept_table/main.cpp +++ b/projects/rocprofiler-sdk/samples/intercept_table/main.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #define HIP_API_CALL(CALL) \ { \ diff --git a/projects/rocprofiler-sdk/samples/pc_sampling/main.cpp b/projects/rocprofiler-sdk/samples/pc_sampling/main.cpp index 3ddb39973e..5064335768 100644 --- a/projects/rocprofiler-sdk/samples/pc_sampling/main.cpp +++ b/projects/rocprofiler-sdk/samples/pc_sampling/main.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #define HIP_API_CALL(CALL) \ { \ diff --git a/projects/rocprofiler-sdk/samples/pc_sampling/pcs.hpp b/projects/rocprofiler-sdk/samples/pc_sampling/pcs.hpp index 1aca31da76..df62a1582c 100644 --- a/projects/rocprofiler-sdk/samples/pc_sampling/pcs.hpp +++ b/projects/rocprofiler-sdk/samples/pc_sampling/pcs.hpp @@ -25,6 +25,7 @@ #include #include +#include #include namespace client diff --git a/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/defines.h b/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/defines.h index 0501742537..cda6d6a88f 100644 --- a/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/defines.h +++ b/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/defines.h @@ -80,6 +80,23 @@ * @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) @@ -219,3 +236,9 @@ #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) diff --git a/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/hip/api_args.h b/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/hip/api_args.h index 9cb90ff048..2c40358308 100644 --- a/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/hip/api_args.h +++ b/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/hip/api_args.h @@ -261,8 +261,17 @@ typedef union rocprofiler_hip_api_args_t } hipCtxEnablePeerAccess; struct { + // In HIP v7.0, apiVersion was changed from int* to unsigned int* to match CUDA signature. + // If rocprofiler-sdk is compiled with HIP >= 7.0 and HIP is < 7.0 at runtime, there is + // expectation that this will NOT cause issues: apiVersion should never be negative and + // should never be >= INT_MAX hipCtx_t ctx; - int* apiVersion; +#if ROCPROFILER_SDK_COMPUTE_VERSION(HIP_VERSION_MAJOR, HIP_VERSION_MINOR, 0) >= \ + ROCPROFILER_SDK_COMPUTE_VERSION(7, 0, 0) + unsigned int* apiVersion; +#else + int* apiVersion; // HIP version < 7.0 +#endif } hipCtxGetApiVersion; struct { @@ -1787,13 +1796,13 @@ typedef union rocprofiler_hip_api_args_t struct { hipDeviceptr_t dst; - void* src; + const void* src; size_t sizeBytes; } hipMemcpyHtoD; struct { hipDeviceptr_t dst; - void* src; + const void* src; size_t sizeBytes; hipStream_t stream; } hipMemcpyHtoDAsync; diff --git a/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/version.h.in b/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/version.h.in index aa09d574b4..a5c001cc9d 100644 --- a/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/version.h.in +++ b/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/version.h.in @@ -22,74 +22,172 @@ #pragma once +#include + /** * @def ROCPROFILER_IS_ROCPROFILER_SDK - * @brief Preprocessor define indicating the rocprofiler header is a rocprofiler-sdk project + * @brief Preprocessor define indicating the header is from rocprofiler-sdk project (i.e. not + * rocprofiler v1 or v2). * @addtogroup VERSIONING_GROUP * - * @def ROCPROFILER_VERSION_MAJOR + * @def ROCPROFILER_SDK_VERSION_MAJOR * @brief The major version of the interface as a macro so it can be used * by the preprocessor. * @addtogroup VERSIONING_GROUP * - * @def ROCPROFILER_VERSION_MINOR + * @def ROCPROFILER_SDK_VERSION_MINOR * @brief The minor version of the interface as a macro so it can be used * by the preprocessor. * @addtogroup VERSIONING_GROUP * - * @def ROCPROFILER_VERSION_PATCH + * @def ROCPROFILER_SDK_VERSION_PATCH * @brief The patch version of the interface as a macro so it can be used * by the preprocessor. * @addtogroup VERSIONING_GROUP * - * @def ROCPROFILER_VERSION + * @def ROCPROFILER_SDK_VERSION * @brief Numerically increasing version number encoding major, minor, and patch via computing `((10000 * ) + (100 * ) + )`. * @addtogroup VERSIONING_GROUP * - * @def ROCPROFILER_SOVERSION + * @def ROCPROFILER_SDK_SOVERSION * @brief Shared object versioning value whose value is at least `(10000 * )`. * @addtogroup VERSIONING_GROUP * - * @def ROCPROFILER_VERSION_STRING + * @def ROCPROFILER_SDK_VERSION_STRING * @brief Version string in form: `..`. * @addtogroup VERSIONING_GROUP * - * @def ROCPROFILER_GIT_DESCRIBE - * @brief String encoding of `git describe --tags` when rocprofiler was built. + * @def ROCPROFILER_SDK_GIT_DESCRIBE + * @brief String encoding of `git describe --tags` when rocprofiler-sdk was built. * @addtogroup VERSIONING_GROUP * - * @def ROCPROFILER_GIT_REVISION - * @brief String encoding of `git rev-parse HEAD` when rocprofiler was built. + * @def ROCPROFILER_SDK_GIT_REVISION + * @brief String encoding of `git rev-parse HEAD` when rocprofiler-sdk was built. * @addtogroup VERSIONING_GROUP * - * @def ROCPROFILER_LIBRARY_ARCH - * @brief Architecture triplet of rocprofiler build. + * @def ROCPROFILER_SDK_LIBRARY_ARCH + * @brief Architecture triplet of rocprofiler-sdk build. * @addtogroup VERSIONING_GROUP * - * @def ROCPROFILER_SYSTEM_NAME - * @brief Target operating system for rocprofiler build, e.g. Linux. + * @def ROCPROFILER_SDK_SYSTEM_NAME + * @brief Target operating system for rocprofiler-sdk build, e.g. Linux. * @addtogroup VERSIONING_GROUP * - * @def ROCPROFILER_SYSTEM_PROCESSOR - * @brief Target architecture for rocprofiler build. + * @def ROCPROFILER_SDK_SYSTEM_PROCESSOR + * @brief Target architecture for rocprofiler-sdk build. * @addtogroup VERSIONING_GROUP * - * @def ROCPROFILER_SYSTEM_VERSION + * @def ROCPROFILER_SDK_SYSTEM_VERSION * @brief Version of the operating system which built rocprofiler * @addtogroup VERSIONING_GROUP * - * @def ROCPROFILER_COMPILER_ID + * @def ROCPROFILER_SDK_COMPILER_ID * @brief C++ compiler identifier which built rocprofiler, e.g., GNU * @addtogroup VERSIONING_GROUP * - * @def ROCPROFILER_COMPILER_VERSION + * @def ROCPROFILER_SDK_COMPILER_VERSION * @brief C++ compiler version which built rocprofiler * @addtogroup VERSIONING_GROUP + * + * @def ROCPROFILER_VERSION_MAJOR + * @brief The major version of the interface as a macro so it can be used + * by the preprocessor. Deprecated in favor of `ROCPROFILER_SDK_` variant. + * @addtogroup VERSIONING_GROUP + * + * @def ROCPROFILER_VERSION_MINOR + * @brief The minor version of the interface as a macro so it can be used + * by the preprocessor. Deprecated in favor of `ROCPROFILER_SDK_` variant. + * @addtogroup VERSIONING_GROUP + * + * @def ROCPROFILER_VERSION_PATCH + * @brief The patch version of the interface as a macro so it can be used + * by the preprocessor. Deprecated in favor of `ROCPROFILER_SDK_` variant. + * @addtogroup VERSIONING_GROUP + * + * @def ROCPROFILER_VERSION + * @brief Numerically increasing version number encoding major, minor, and patch via + * computing `((10000 * ) + (100 * ) + )`. Deprecated in favor + * of `ROCPROFILER_SDK_` variant. + * @addtogroup VERSIONING_GROUP + * + * @def ROCPROFILER_SOVERSION + * @brief Shared object versioning value whose value is at least `(10000 * )`. + * Deprecated in favor of `ROCPROFILER_SDK_` variant. + * @addtogroup VERSIONING_GROUP + * + * @def ROCPROFILER_VERSION_STRING + * @brief Version string in form: `..`. Deprecated in favor of + * `ROCPROFILER_SDK_` variant. + * @addtogroup VERSIONING_GROUP + * + * @def ROCPROFILER_GIT_DESCRIBE + * @brief String encoding of `git describe --tags` when rocprofiler-sdk was built. Deprecated in + * favor of `ROCPROFILER_SDK_` variant. + * @addtogroup VERSIONING_GROUP + * + * @def ROCPROFILER_GIT_REVISION + * @brief String encoding of `git rev-parse HEAD` when rocprofiler-sdk was built. Deprecated in + * favor of `ROCPROFILER_SDK_` variant. + * @addtogroup VERSIONING_GROUP + * + * @def ROCPROFILER_LIBRARY_ARCH + * @brief Architecture triplet of rocprofiler-sdk build. Deprecated in favor of `ROCPROFILER_SDK_` + * variant. + * @addtogroup VERSIONING_GROUP + * + * @def ROCPROFILER_SYSTEM_NAME + * @brief Target operating system for rocprofiler-sdk build, e.g. Linux. Deprecated in favor of + * `ROCPROFILER_SDK_` variant. + * @addtogroup VERSIONING_GROUP + * + * @def ROCPROFILER_SYSTEM_PROCESSOR + * @brief Target architecture for rocprofiler-sdk build. Deprecated in favor of `ROCPROFILER_SDK_` + * variant. + * @addtogroup VERSIONING_GROUP + * + * @def ROCPROFILER_SYSTEM_VERSION + * @brief Version of the operating system which built rocprofiler. Deprecated in favor of + * `ROCPROFILER_SDK_` variant. + * @addtogroup VERSIONING_GROUP + * + * @def ROCPROFILER_COMPILER_ID + * @brief C++ compiler identifier which built rocprofiler, e.g., GNU. Deprecated in favor of + * `ROCPROFILER_SDK_` variant. + * @addtogroup VERSIONING_GROUP + * + * @def ROCPROFILER_COMPILER_VERSION + * @brief C++ compiler version which built rocprofiler-sdk. Deprecated in favor of + * `ROCPROFILER_SDK_` variant. + * @addtogroup VERSIONING_GROUP */ #define ROCPROFILER_IS_ROCPROFILER_SDK 1 +// clang-format off +#define ROCPROFILER_SDK_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ +#define ROCPROFILER_SDK_VERSION_MINOR @PROJECT_VERSION_MINOR@ +#define ROCPROFILER_SDK_VERSION_PATCH @PROJECT_VERSION_PATCH@ +#define ROCPROFILER_SDK_SOVERSION @PROJECT_VERSION_MAJOR@ +#define ROCPROFILER_SDK_VERSION_STRING "@FULL_VERSION_STRING@" +#define ROCPROFILER_SDK_GIT_DESCRIBE "@ROCPROFILER_SDK_GIT_DESCRIBE@" +#define ROCPROFILER_SDK_GIT_REVISION "@ROCPROFILER_SDK_GIT_REVISION@" + +// system info during compilation +#define ROCPROFILER_SDK_LIBRARY_ARCH "@CMAKE_LIBRARY_ARCHITECTURE@" +#define ROCPROFILER_SDK_SYSTEM_NAME "@CMAKE_SYSTEM_NAME@" +#define ROCPROFILER_SDK_SYSTEM_PROCESSOR "@CMAKE_SYSTEM_PROCESSOR@" +#define ROCPROFILER_SDK_SYSTEM_VERSION "@CMAKE_SYSTEM_VERSION@" + +// compiler information +#define ROCPROFILER_SDK_COMPILER_ID "@CMAKE_CXX_COMPILER_ID@" +#define ROCPROFILER_SDK_COMPILER_VERSION "@CMAKE_CXX_COMPILER_VERSION@" +// clang-format on + +#define ROCPROFILER_SDK_VERSION \ + ROCPROFILER_SDK_COMPUTE_VERSION( \ + ROCPROFILER_VERSION_MAJOR, ROCPROFILER_VERSION_MINOR, ROCPROFILER_VERSION_PATCH) + // clang-format off #define ROCPROFILER_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ #define ROCPROFILER_VERSION_MINOR @PROJECT_VERSION_MINOR@ @@ -111,5 +209,5 @@ // clang-format on #define ROCPROFILER_VERSION \ - ((10000 * ROCPROFILER_VERSION_MAJOR) + (100 * ROCPROFILER_VERSION_MINOR) + \ - ROCPROFILER_VERSION_PATCH) + ROCPROFILER_SDK_COMPUTE_VERSION( \ + ROCPROFILER_VERSION_MAJOR, ROCPROFILER_VERSION_MINOR, ROCPROFILER_VERSION_PATCH) diff --git a/projects/rocprofiler-sdk/source/lib/common/defines.hpp b/projects/rocprofiler-sdk/source/lib/common/defines.hpp index c0fc154d8d..0f35b70234 100644 --- a/projects/rocprofiler-sdk/source/lib/common/defines.hpp +++ b/projects/rocprofiler-sdk/source/lib/common/defines.hpp @@ -65,7 +65,8 @@ # endif #endif -#define ROCPROFILER_COMPUTE_VERSION(MAJOR, MINOR, PATCH) ((10000 * MAJOR) + (100 * MINOR) + (PATCH)) +#define ROCPROFILER_COMPUTE_VERSION(MAJOR, MINOR, PATCH) \ + ROCPROFILER_SDK_COMPUTE_VERSION(MAJOR, MINOR, PATCH) // Below are used in HSA, HIP, and Marker API tracing #define IMPL_DETAIL_EXPAND(X) X diff --git a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/hsa/aql_packet.hpp b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/hsa/aql_packet.hpp index e6cd8974a8..733dcfae67 100644 --- a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/hsa/aql_packet.hpp +++ b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/hsa/aql_packet.hpp @@ -43,7 +43,7 @@ namespace hsa #define HSA_AMD_INTERFACE_VERSION \ ROCPROFILER_COMPUTE_VERSION(HSA_AMD_INTERFACE_VERSION_MAJOR, HSA_AMD_INTERFACE_VERSION_MINOR, 0) -#if HSA_AMD_INTERFACE_VERSION >= 10700 +#if HSA_AMD_INTERFACE_VERSION >= ROCPROFILER_COMPUTE_VERSION(1, 7, 0) constexpr auto hsa_amd_memory_pool_executable_flag = HSA_AMD_MEMORY_POOL_EXECUTABLE_FLAG; #else constexpr auto hsa_amd_memory_pool_executable_flag = (1 << 2); diff --git a/projects/rocprofiler-sdk/tests/thread-trace/main.cpp b/projects/rocprofiler-sdk/tests/thread-trace/main.cpp index e85b752e0b..88584d2f4b 100644 --- a/projects/rocprofiler-sdk/tests/thread-trace/main.cpp +++ b/projects/rocprofiler-sdk/tests/thread-trace/main.cpp @@ -25,6 +25,7 @@ # undef NDEBUG #endif +#include #include #include #include