From 4e46eded66360e86379686ff8fcd373a2349c01d Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Tue, 29 Aug 2023 21:51:55 +0000 Subject: [PATCH] Increment HSA API table stepping on new APIs Add compile time asserts to force incrementing API table STEP versions each time a new function is added to each table. This is required for profiler team to be able to add preprocessor macros to determine which versions contain the new APIs. Also incrementing the major versions to 2 to indicate new numbering scheme. Change-Id: I148a436a5ceab6be3906f8263b40ea9b07841577 [ROCm/ROCR-Runtime commit: 03f2f69d166533c05253847e118d6ddcf774a35f] --- .../core/runtime/hsa_api_trace.cpp | 22 +++++++++++++++++++ .../runtime/hsa-runtime/inc/hsa_api_trace.h | 10 ++++----- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa_api_trace.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa_api_trace.cpp index 2ee8ffe90d..08441e78e3 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa_api_trace.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa_api_trace.cpp @@ -75,6 +75,28 @@ HsaApiTable::HsaApiTable() { // Member fields for Finalizer and Image extensions will be // updated as part of Hsa Runtime initialization. void HsaApiTable::Init() { + // Compile time checks to make sure we increment STEPPING when new APIs are added. + // Profiler team needs STEPPING to change every time we add functions to the tables so that + // they can add preprocessor macros on the new functions + + constexpr size_t expected_core_api_table_size = 1016; + constexpr size_t expected_amd_ext_table_size = 552; + constexpr size_t expected_image_ext_table_size = 120; + constexpr size_t expected_finalizer_ext_table_size = 64; + + static_assert(sizeof(CoreApiTable) == expected_core_api_table_size, + "HSA core API table size changed, bump HSA_CORE_API_TABLE_STEP_VERSION and set " + "expected_core_api_table_size to the new size of the struct"); + static_assert(sizeof(AmdExtTable) == expected_amd_ext_table_size, + "HSA AMD ext table size changed, bump HSA_AMD_EXT_API_TABLE_STEP_VERSION, " + "HSA_AMD_INTERFACE_VERSION_MINOR and set expected_amd_ext_table_size to the new " + "size of the struct"); + static_assert(sizeof(ImageExtTable) == expected_image_ext_table_size, + "HSA image ext table size changed, bump HSA_IMAGE_API_TABLE_STEP_VERSION and set " + "expected_image_ext_table_size to the new size of the struct"); + static_assert(sizeof(FinalizerExtTable) == expected_finalizer_ext_table_size, + "HSA finalizer ext table size changed, bump HSA_FINALIZER_API_TABLE_STEP_VERSION " + "and set expected_finalizer_ext_table_size to the new size of the struct"); // Initialize Version of Api Table hsa_api.version.major_id = HSA_API_TABLE_MAJOR_VERSION; diff --git a/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_api_trace.h b/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_api_trace.h index 6efaf87726..f2b748a6e7 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_api_trace.h +++ b/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_api_trace.h @@ -59,11 +59,11 @@ #include // Major Ids of the Api tables exported by Hsa Core Runtime -#define HSA_API_TABLE_MAJOR_VERSION 0x01 -#define HSA_CORE_API_TABLE_MAJOR_VERSION 0x01 -#define HSA_AMD_EXT_API_TABLE_MAJOR_VERSION 0x01 -#define HSA_FINALIZER_API_TABLE_MAJOR_VERSION 0x01 -#define HSA_IMAGE_API_TABLE_MAJOR_VERSION 0x01 +#define HSA_API_TABLE_MAJOR_VERSION 0x02 +#define HSA_CORE_API_TABLE_MAJOR_VERSION 0x02 +#define HSA_AMD_EXT_API_TABLE_MAJOR_VERSION 0x02 +#define HSA_FINALIZER_API_TABLE_MAJOR_VERSION 0x02 +#define HSA_IMAGE_API_TABLE_MAJOR_VERSION 0x02 #define HSA_AQLPROFILE_API_TABLE_MAJOR_VERSION 0x01 // Step Ids of the Api tables exported by Hsa Core Runtime