From 7a639f34394f3660d5ffff54d89ebb02320f8d8d Mon Sep 17 00:00:00 2001 From: "Jonathan R. Madsen" Date: Tue, 20 Aug 2024 01:08:34 -0500 Subject: [PATCH] Update HSA ABI checks for tracing (#1027) * Update HSA ABI checks for tracing * Update lib/common/abi.hpp - perform ABI versioning checks even when `ROCPROFILER_CI` is not defined (or ROCPROFILER_CI=0) * Enforce versioning size for various HSA AmdExt step versions + hsa_amd_enable_logging support * Minor HIP abi.cpp updates --- .../rocprofiler-sdk/hsa/amd_ext_api_id.h | 3 + source/include/rocprofiler-sdk/hsa/api_args.h | 7 + source/lib/common/abi.hpp | 20 +- source/lib/rocprofiler-sdk/hip/abi.cpp | 11 +- source/lib/rocprofiler-sdk/hsa/CMakeLists.txt | 2 +- source/lib/rocprofiler-sdk/hsa/abi.cpp | 318 ++++++++++++++++++ source/lib/rocprofiler-sdk/hsa/hsa.cpp | 1 - source/lib/rocprofiler-sdk/hsa/hsa.def.cpp | 8 + source/lib/rocprofiler-sdk/hsa/types.hpp | 219 ------------ 9 files changed, 363 insertions(+), 226 deletions(-) create mode 100644 source/lib/rocprofiler-sdk/hsa/abi.cpp delete mode 100644 source/lib/rocprofiler-sdk/hsa/types.hpp diff --git a/source/include/rocprofiler-sdk/hsa/amd_ext_api_id.h b/source/include/rocprofiler-sdk/hsa/amd_ext_api_id.h index 4301c2ed..9675f245 100644 --- a/source/include/rocprofiler-sdk/hsa/amd_ext_api_id.h +++ b/source/include/rocprofiler-sdk/hsa/amd_ext_api_id.h @@ -109,6 +109,9 @@ typedef enum // NOLINT(performance-enum-size) # 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 #endif ROCPROFILER_HSA_AMD_EXT_API_ID_LAST, diff --git a/source/include/rocprofiler-sdk/hsa/api_args.h b/source/include/rocprofiler-sdk/hsa/api_args.h index 158eed53..1e4a5891 100644 --- a/source/include/rocprofiler-sdk/hsa/api_args.h +++ b/source/include/rocprofiler-sdk/hsa/api_args.h @@ -1407,6 +1407,13 @@ typedef union rocprofiler_hsa_api_args_t uint64_t flags; } hsa_amd_vmem_address_reserve_align; # endif +# if HSA_AMD_EXT_API_TABLE_STEP_VERSION >= 0x04 + struct + { + uint8_t* flags; + void* file; + } hsa_amd_enable_logging; +# endif #endif } rocprofiler_hsa_api_args_t; diff --git a/source/lib/common/abi.hpp b/source/lib/common/abi.hpp index 9f9015c5..d0f11ed8 100644 --- a/source/lib/common/abi.hpp +++ b/source/lib/common/abi.hpp @@ -56,7 +56,7 @@ compute_table_offset(size_t num_funcs) // sure these versioning values are appropriately updated -- so commenting out this check, only // updating the size field in ROCP_SDK_ENFORCE_ABI_VERSIONING, etc. will result in the // rocprofiler-sdk failing to build and you will be forced to do the work anyway. -#if !defined(ROCPROFILER_UNSAFE_NO_VERSION_CHECK) && (defined(ROCPROFILER_CI) && ROCPROFILER_CI > 0) +#if !defined(ROCPROFILER_UNSAFE_NO_VERSION_CHECK) # define ROCP_SDK_ENFORCE_ABI_VERSIONING(TABLE, NUM) \ static_assert( \ sizeof(TABLE) == ::rocprofiler::common::abi::compute_table_offset(NUM), \ @@ -72,3 +72,21 @@ compute_table_offset(size_t num_funcs) # define ROCP_SDK_ENFORCE_ABI_VERSIONING(TABLE, NUM) # define ROCP_SDK_ENFORCE_ABI(TABLE, ENTRY, NUM) #endif + +// These are guarded by ROCPROFILER_CI=1 +#if !defined(ROCPROFILER_UNSAFE_NO_VERSION_CHECK) && (defined(ROCPROFILER_CI) && ROCPROFILER_CI > 0) +# define INTERNAL_CI_ROCP_SDK_ENFORCE_ABI_VERSIONING(TABLE, NUM) \ + static_assert( \ + sizeof(TABLE) == ::rocprofiler::common::abi::compute_table_offset(NUM), \ + "size of the API table struct has changed. Update the STEP_VERSION number (or " \ + "in rare cases, the MAJOR_VERSION number)"); + +# define INTERNAL_CI_ROCP_SDK_ENFORCE_ABI(TABLE, ENTRY, NUM) \ + static_assert( \ + offsetof(TABLE, ENTRY) == ::rocprofiler::common::abi::compute_table_offset(NUM), \ + "ABI break for " #TABLE "." #ENTRY \ + ". Only add new function pointers to end of struct and do not rearrange them"); +#else +# define INTERNAL_CI_ROCP_SDK_ENFORCE_ABI_VERSIONING(TABLE, NUM) +# define INTERNAL_CI_ROCP_SDK_ENFORCE_ABI(TABLE, ENTRY, NUM) +#endif diff --git a/source/lib/rocprofiler-sdk/hip/abi.cpp b/source/lib/rocprofiler-sdk/hip/abi.cpp index 038feb3f..c261b792 100644 --- a/source/lib/rocprofiler-sdk/hip/abi.cpp +++ b/source/lib/rocprofiler-sdk/hip/abi.cpp @@ -32,6 +32,8 @@ namespace hip { static_assert(HIP_COMPILER_API_TABLE_MAJOR_VERSION == 0, "Major version updated for HIP compiler dispatch table"); +static_assert(HIP_RUNTIME_API_TABLE_MAJOR_VERSION == 0, + "Major version updated for HIP runtime dispatch table"); // These ensure that function pointers are not re-ordered ROCP_SDK_ENFORCE_ABI(HipCompilerDispatchTable, __hipPopCallConfiguration_fn, 0) @@ -46,11 +48,10 @@ ROCP_SDK_ENFORCE_ABI(HipCompilerDispatchTable, __hipUnregisterFatBinary_fn, 8) #if HIP_COMPILER_API_TABLE_STEP_VERSION == 0 ROCP_SDK_ENFORCE_ABI_VERSIONING(HipCompilerDispatchTable, 9) +#else +ROCP_SDK_ENFORCE_ABI_VERSIONING(HipCompilerDispatchTable, 0) #endif -static_assert(HIP_RUNTIME_API_TABLE_MAJOR_VERSION == 0, - "Major version updated for HIP runtime dispatch table"); - // These ensure that function pointers are not re-ordered ROCP_SDK_ENFORCE_ABI(HipDispatchTable, hipApiName_fn, 0) ROCP_SDK_ENFORCE_ABI(HipDispatchTable, hipArray3DCreate_fn, 1) @@ -520,7 +521,9 @@ ROCP_SDK_ENFORCE_ABI_VERSIONING(HipDispatchTable, 444) #elif HIP_RUNTIME_API_TABLE_STEP_VERSION == 3 ROCP_SDK_ENFORCE_ABI_VERSIONING(HipDispatchTable, 445) #elif HIP_RUNTIME_API_TABLE_STEP_VERSION == 4 -ROCP_SDK_ENFORCE_ABI_VERSIONING(HipDispatchTable, 459) +INTERNAL_CI_ROCP_SDK_ENFORCE_ABI_VERSIONING(HipDispatchTable, 458) +#else +INTERNAL_CI_ROCP_SDK_ENFORCE_ABI_VERSIONING(HipDispatchTable, 0) #endif } // namespace hip } // namespace rocprofiler diff --git a/source/lib/rocprofiler-sdk/hsa/CMakeLists.txt b/source/lib/rocprofiler-sdk/hsa/CMakeLists.txt index d41c6021..fee75d6c 100644 --- a/source/lib/rocprofiler-sdk/hsa/CMakeLists.txt +++ b/source/lib/rocprofiler-sdk/hsa/CMakeLists.txt @@ -1,5 +1,6 @@ # set(ROCPROFILER_LIB_HSA_SOURCES + abi.cpp agent_cache.cpp aql_packet.cpp async_copy.cpp @@ -25,7 +26,6 @@ set(ROCPROFILER_LIB_HSA_HEADERS queue_info_session.hpp rocprofiler_packet.hpp scratch_memory.hpp - types.hpp utils.hpp) target_sources(rocprofiler-object-library PRIVATE ${ROCPROFILER_LIB_HSA_SOURCES} diff --git a/source/lib/rocprofiler-sdk/hsa/abi.cpp b/source/lib/rocprofiler-sdk/hsa/abi.cpp new file mode 100644 index 00000000..98bcbb62 --- /dev/null +++ b/source/lib/rocprofiler-sdk/hsa/abi.cpp @@ -0,0 +1,318 @@ +// MIT License +// +// Copyright (c) 2023 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. + +#include +#include + +#include "lib/common/abi.hpp" +#include "lib/common/defines.hpp" + +namespace rocprofiler +{ +namespace hsa +{ +static_assert(HSA_CORE_API_TABLE_MAJOR_VERSION == 0x02, "Major version updated"); +static_assert(HSA_AMD_EXT_API_TABLE_MAJOR_VERSION == 0x02, "Major version updated"); +static_assert(HSA_IMAGE_API_TABLE_MAJOR_VERSION == 0x02, "Major version updated"); +static_assert(HSA_FINALIZER_API_TABLE_MAJOR_VERSION == 0x02, "Major version updated"); +static_assert(HSA_TOOLS_API_TABLE_MAJOR_VERSION == 0x01, "Major version updated"); +static_assert(HSA_PC_SAMPLING_API_TABLE_MAJOR_VERSION == 0x01, "Major version updated"); + +#if HSA_CORE_API_TABLE_STEP_VERSION == 0x00 +ROCP_SDK_ENFORCE_ABI_VERSIONING(::CoreApiTable, 126) +#endif + +#if HSA_AMD_EXT_API_TABLE_STEP_VERSION == 0x00 +ROCP_SDK_ENFORCE_ABI_VERSIONING(::AmdExtTable, 68); +#elif HSA_AMD_EXT_API_TABLE_STEP_VERSION == 0x01 +ROCP_SDK_ENFORCE_ABI_VERSIONING(::AmdExtTable, 69); +#elif HSA_AMD_EXT_API_TABLE_STEP_VERSION == 0x02 +ROCP_SDK_ENFORCE_ABI_VERSIONING(::AmdExtTable, 70); +#elif HSA_AMD_EXT_API_TABLE_STEP_VERSION == 0x03 +ROCP_SDK_ENFORCE_ABI_VERSIONING(::AmdExtTable, 71); +#elif HSA_AMD_EXT_API_TABLE_STEP_VERSION == 0x04 +ROCP_SDK_ENFORCE_ABI_VERSIONING(::AmdExtTable, 72); +#else +INTERNAL_CI_ROCP_SDK_ENFORCE_ABI_VERSIONING(::AmdExtTable, 0); +#endif + +#if HSA_IMAGE_EXT_API_TABLE_STEP_VERSION == 0x00 +ROCP_SDK_ENFORCE_ABI_VERSIONING(::ImageExtTable, 14); +#endif + +#if HSA_FINALIZER_EXT_API_TABLE_STEP_VERSION == 0x00 +ROCP_SDK_ENFORCE_ABI_VERSIONING(::FinalizerExtTable, 7); +#endif + +#if HSA_TOOLS_API_TABLE_STEP_VERSION == 0x00 +ROCP_SDK_ENFORCE_ABI_VERSIONING(::ToolsApiTable, 7); +#endif + +#if HSA_PC_SAMPLING_API_TABLE_STEP_VERSION == 0x00 +ROCP_SDK_ENFORCE_ABI_VERSIONING(::PcSamplingExtTable, 8); +#endif + +// These ensure that function pointers are not re-ordered +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_init_fn, 1); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_shut_down_fn, 2); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_system_get_info_fn, 3); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_system_extension_supported_fn, 4); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_system_get_extension_table_fn, 5); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_iterate_agents_fn, 6); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_agent_get_info_fn, 7); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_queue_create_fn, 8); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_soft_queue_create_fn, 9); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_queue_destroy_fn, 10); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_queue_inactivate_fn, 11); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_queue_load_read_index_scacquire_fn, 12); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_queue_load_read_index_relaxed_fn, 13); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_queue_load_write_index_scacquire_fn, 14); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_queue_load_write_index_relaxed_fn, 15); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_queue_store_write_index_relaxed_fn, 16); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_queue_store_write_index_screlease_fn, 17); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_queue_cas_write_index_scacq_screl_fn, 18); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_queue_cas_write_index_scacquire_fn, 19); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_queue_cas_write_index_relaxed_fn, 20); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_queue_cas_write_index_screlease_fn, 21); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_queue_add_write_index_scacq_screl_fn, 22); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_queue_add_write_index_scacquire_fn, 23); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_queue_add_write_index_relaxed_fn, 24); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_queue_add_write_index_screlease_fn, 25); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_queue_store_read_index_relaxed_fn, 26); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_queue_store_read_index_screlease_fn, 27); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_agent_iterate_regions_fn, 28); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_region_get_info_fn, 29); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_agent_get_exception_policies_fn, 30); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_agent_extension_supported_fn, 31); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_memory_register_fn, 32); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_memory_deregister_fn, 33); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_memory_allocate_fn, 34); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_memory_free_fn, 35); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_memory_copy_fn, 36); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_memory_assign_agent_fn, 37); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_create_fn, 38); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_destroy_fn, 39); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_load_relaxed_fn, 40); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_load_scacquire_fn, 41); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_store_relaxed_fn, 42); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_store_screlease_fn, 43); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_wait_relaxed_fn, 44); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_wait_scacquire_fn, 45); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_and_relaxed_fn, 46); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_and_scacquire_fn, 47); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_and_screlease_fn, 48); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_and_scacq_screl_fn, 49); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_or_relaxed_fn, 50); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_or_scacquire_fn, 51); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_or_screlease_fn, 52); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_or_scacq_screl_fn, 53); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_xor_relaxed_fn, 54); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_xor_scacquire_fn, 55); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_xor_screlease_fn, 56); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_xor_scacq_screl_fn, 57); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_exchange_relaxed_fn, 58); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_exchange_scacquire_fn, 59); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_exchange_screlease_fn, 60); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_exchange_scacq_screl_fn, 61); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_add_relaxed_fn, 62); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_add_scacquire_fn, 63); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_add_screlease_fn, 64); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_add_scacq_screl_fn, 65); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_subtract_relaxed_fn, 66); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_subtract_scacquire_fn, 67); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_subtract_screlease_fn, 68); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_subtract_scacq_screl_fn, 69); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_cas_relaxed_fn, 70); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_cas_scacquire_fn, 71); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_cas_screlease_fn, 72); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_cas_scacq_screl_fn, 73); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_isa_from_name_fn, 74); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_isa_get_info_fn, 75); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_isa_compatible_fn, 76); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_code_object_serialize_fn, 77); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_code_object_deserialize_fn, 78); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_code_object_destroy_fn, 79); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_code_object_get_info_fn, 80); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_code_object_get_symbol_fn, 81); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_code_symbol_get_info_fn, 82); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_code_object_iterate_symbols_fn, 83); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_executable_create_fn, 84); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_executable_destroy_fn, 85); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_executable_load_code_object_fn, 86); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_executable_freeze_fn, 87); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_executable_get_info_fn, 88); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_executable_global_variable_define_fn, 89); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_executable_agent_global_variable_define_fn, 90); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_executable_readonly_variable_define_fn, 91); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_executable_validate_fn, 92); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_executable_get_symbol_fn, 93); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_executable_symbol_get_info_fn, 94); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_executable_iterate_symbols_fn, 95); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_status_string_fn, 96); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_extension_get_name_fn, 97); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_system_major_extension_supported_fn, 98); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_system_get_major_extension_table_fn, 99); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_agent_major_extension_supported_fn, 100); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_cache_get_info_fn, 101); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_agent_iterate_caches_fn, 102); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_silent_store_relaxed_fn, 103); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_silent_store_screlease_fn, 104); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_group_create_fn, 105); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_group_destroy_fn, 106); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_group_wait_any_scacquire_fn, 107); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_signal_group_wait_any_relaxed_fn, 108); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_agent_iterate_isas_fn, 109); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_isa_get_info_alt_fn, 110); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_isa_get_exception_policies_fn, 111); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_isa_get_round_method_fn, 112); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_wavefront_get_info_fn, 113); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_isa_iterate_wavefronts_fn, 114); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_code_object_get_symbol_from_name_fn, 115); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_code_object_reader_create_from_file_fn, 116); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_code_object_reader_create_from_memory_fn, 117); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_code_object_reader_destroy_fn, 118); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_executable_create_alt_fn, 119); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_executable_load_program_code_object_fn, 120); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_executable_load_agent_code_object_fn, 121); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_executable_validate_alt_fn, 122); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_executable_get_symbol_by_name_fn, 123); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_executable_iterate_agent_symbols_fn, 124); +ROCP_SDK_ENFORCE_ABI(::CoreApiTable, hsa_executable_iterate_program_symbols_fn, 125); + +// These ensure that function pointers are not re-ordered +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_coherency_get_type_fn, 1); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_coherency_set_type_fn, 2); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_profiling_set_profiler_enabled_fn, 3); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_profiling_async_copy_enable_fn, 4); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_profiling_get_dispatch_time_fn, 5); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_profiling_get_async_copy_time_fn, 6); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_profiling_convert_tick_to_system_domain_fn, 7); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_signal_async_handler_fn, 8); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_async_function_fn, 9); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_signal_wait_any_fn, 10); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_queue_cu_set_mask_fn, 11); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_memory_pool_get_info_fn, 12); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_agent_iterate_memory_pools_fn, 13); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_memory_pool_allocate_fn, 14); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_memory_pool_free_fn, 15); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_memory_async_copy_fn, 16); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_memory_async_copy_on_engine_fn, 17); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_memory_copy_engine_status_fn, 18); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_agent_memory_pool_get_info_fn, 19); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_agents_allow_access_fn, 20); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_memory_pool_can_migrate_fn, 21); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_memory_migrate_fn, 22); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_memory_lock_fn, 23); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_memory_unlock_fn, 24); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_memory_fill_fn, 25); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_interop_map_buffer_fn, 26); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_interop_unmap_buffer_fn, 27); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_image_create_fn, 28); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_pointer_info_fn, 29); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_pointer_info_set_userdata_fn, 30); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_ipc_memory_create_fn, 31); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_ipc_memory_attach_fn, 32); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_ipc_memory_detach_fn, 33); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_signal_create_fn, 34); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_ipc_signal_create_fn, 35); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_ipc_signal_attach_fn, 36); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_register_system_event_handler_fn, 37); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_queue_intercept_create_fn, 38); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_queue_intercept_register_fn, 39); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_queue_set_priority_fn, 40); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_memory_async_copy_rect_fn, 41); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_runtime_queue_create_register_fn, 42); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_memory_lock_to_pool_fn, 43); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_register_deallocation_callback_fn, 44); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_deregister_deallocation_callback_fn, 45); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_signal_value_pointer_fn, 46); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_svm_attributes_set_fn, 47); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_svm_attributes_get_fn, 48); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_svm_prefetch_async_fn, 49); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_spm_acquire_fn, 50); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_spm_release_fn, 51); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_spm_set_dest_buffer_fn, 52); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_queue_cu_get_mask_fn, 53); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_portable_export_dmabuf_fn, 54); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_portable_close_dmabuf_fn, 55); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_vmem_address_reserve_fn, 56); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_vmem_address_free_fn, 57); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_vmem_handle_create_fn, 58); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_vmem_handle_release_fn, 59); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_vmem_map_fn, 60); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_vmem_unmap_fn, 61); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_vmem_set_access_fn, 62); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_vmem_get_access_fn, 63); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_vmem_export_shareable_handle_fn, 64); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_vmem_import_shareable_handle_fn, 65); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_vmem_retain_alloc_handle_fn, 66); +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_vmem_get_alloc_properties_from_handle_fn, 67); +#if HSA_AMD_EXT_API_TABLE_STEP_VERSION >= 0x01 +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_agent_set_async_scratch_limit_fn, 68); +#endif +#if HSA_AMD_EXT_API_TABLE_STEP_VERSION >= 0x02 +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_queue_get_info_fn, 69); +#endif +#if HSA_AMD_EXT_API_TABLE_STEP_VERSION >= 0x03 +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_vmem_address_reserve_align_fn, 70); +#endif +#if HSA_AMD_EXT_API_TABLE_STEP_VERSION >= 0x04 +ROCP_SDK_ENFORCE_ABI(::AmdExtTable, hsa_amd_enable_logging_fn, 71); +#endif + +ROCP_SDK_ENFORCE_ABI(::ImageExtTable, hsa_ext_image_get_capability_fn, 1); +ROCP_SDK_ENFORCE_ABI(::ImageExtTable, hsa_ext_image_data_get_info_fn, 2); +ROCP_SDK_ENFORCE_ABI(::ImageExtTable, hsa_ext_image_create_fn, 3); +ROCP_SDK_ENFORCE_ABI(::ImageExtTable, hsa_ext_image_import_fn, 4); +ROCP_SDK_ENFORCE_ABI(::ImageExtTable, hsa_ext_image_export_fn, 5); +ROCP_SDK_ENFORCE_ABI(::ImageExtTable, hsa_ext_image_copy_fn, 6); +ROCP_SDK_ENFORCE_ABI(::ImageExtTable, hsa_ext_image_clear_fn, 7); +ROCP_SDK_ENFORCE_ABI(::ImageExtTable, hsa_ext_image_destroy_fn, 8); +ROCP_SDK_ENFORCE_ABI(::ImageExtTable, hsa_ext_sampler_create_fn, 9); +ROCP_SDK_ENFORCE_ABI(::ImageExtTable, hsa_ext_sampler_destroy_fn, 10); +ROCP_SDK_ENFORCE_ABI(::ImageExtTable, hsa_ext_image_get_capability_with_layout_fn, 11); +ROCP_SDK_ENFORCE_ABI(::ImageExtTable, hsa_ext_image_data_get_info_with_layout_fn, 12); +ROCP_SDK_ENFORCE_ABI(::ImageExtTable, hsa_ext_image_create_with_layout_fn, 13); + +ROCP_SDK_ENFORCE_ABI(::FinalizerExtTable, hsa_ext_program_create_fn, 1); +ROCP_SDK_ENFORCE_ABI(::FinalizerExtTable, hsa_ext_program_destroy_fn, 2); +ROCP_SDK_ENFORCE_ABI(::FinalizerExtTable, hsa_ext_program_add_module_fn, 3); +ROCP_SDK_ENFORCE_ABI(::FinalizerExtTable, hsa_ext_program_iterate_modules_fn, 4); +ROCP_SDK_ENFORCE_ABI(::FinalizerExtTable, hsa_ext_program_get_info_fn, 5); +ROCP_SDK_ENFORCE_ABI(::FinalizerExtTable, hsa_ext_program_finalize_fn, 6); + +ROCP_SDK_ENFORCE_ABI(::ToolsApiTable, hsa_amd_tool_scratch_event_alloc_start_fn, 1); +ROCP_SDK_ENFORCE_ABI(::ToolsApiTable, hsa_amd_tool_scratch_event_alloc_end_fn, 2); +ROCP_SDK_ENFORCE_ABI(::ToolsApiTable, hsa_amd_tool_scratch_event_free_start_fn, 3); +ROCP_SDK_ENFORCE_ABI(::ToolsApiTable, hsa_amd_tool_scratch_event_free_end_fn, 4); +ROCP_SDK_ENFORCE_ABI(::ToolsApiTable, hsa_amd_tool_scratch_event_async_reclaim_start_fn, 5); +ROCP_SDK_ENFORCE_ABI(::ToolsApiTable, hsa_amd_tool_scratch_event_async_reclaim_end_fn, 6); + +ROCP_SDK_ENFORCE_ABI(::PcSamplingExtTable, hsa_ven_amd_pcs_iterate_configuration_fn, 1); +ROCP_SDK_ENFORCE_ABI(::PcSamplingExtTable, hsa_ven_amd_pcs_create_fn, 2); +ROCP_SDK_ENFORCE_ABI(::PcSamplingExtTable, hsa_ven_amd_pcs_create_from_id_fn, 3); +ROCP_SDK_ENFORCE_ABI(::PcSamplingExtTable, hsa_ven_amd_pcs_destroy_fn, 4); +ROCP_SDK_ENFORCE_ABI(::PcSamplingExtTable, hsa_ven_amd_pcs_start_fn, 5); +ROCP_SDK_ENFORCE_ABI(::PcSamplingExtTable, hsa_ven_amd_pcs_stop_fn, 6); +ROCP_SDK_ENFORCE_ABI(::PcSamplingExtTable, hsa_ven_amd_pcs_flush_fn, 7); +} // namespace hsa +} // namespace rocprofiler diff --git a/source/lib/rocprofiler-sdk/hsa/hsa.cpp b/source/lib/rocprofiler-sdk/hsa/hsa.cpp index 5474e0ef..00cb3a0f 100644 --- a/source/lib/rocprofiler-sdk/hsa/hsa.cpp +++ b/source/lib/rocprofiler-sdk/hsa/hsa.cpp @@ -29,7 +29,6 @@ #include "lib/rocprofiler-sdk/hsa/details/ostream.hpp" #include "lib/rocprofiler-sdk/hsa/pc_sampling.hpp" #include "lib/rocprofiler-sdk/hsa/scratch_memory.hpp" -#include "lib/rocprofiler-sdk/hsa/types.hpp" #include "lib/rocprofiler-sdk/hsa/utils.hpp" #include "lib/rocprofiler-sdk/registration.hpp" #include "lib/rocprofiler-sdk/tracing/tracing.hpp" diff --git a/source/lib/rocprofiler-sdk/hsa/hsa.def.cpp b/source/lib/rocprofiler-sdk/hsa/hsa.def.cpp index 5e3dd6fa..0ee22b56 100644 --- a/source/lib/rocprofiler-sdk/hsa/hsa.def.cpp +++ b/source/lib/rocprofiler-sdk/hsa/hsa.def.cpp @@ -455,6 +455,14 @@ HSA_API_INFO_DEFINITION_V(ROCPROFILER_HSA_TABLE_ID_AmdExt, alignment, flags) # endif +# if HSA_AMD_EXT_API_TABLE_STEP_VERSION >= 0x04 +HSA_API_INFO_DEFINITION_V(ROCPROFILER_HSA_TABLE_ID_AmdExt, + ROCPROFILER_HSA_AMD_EXT_API_ID_hsa_amd_enable_logging, + hsa_amd_enable_logging, + hsa_amd_enable_logging_fn, + flags, + file) +# endif # endif #elif defined(ROCPROFILER_LIB_ROCPROFILER_HSA_ASYNC_COPY_CPP_IMPL) && \ diff --git a/source/lib/rocprofiler-sdk/hsa/types.hpp b/source/lib/rocprofiler-sdk/hsa/types.hpp deleted file mode 100644 index 7994393f..00000000 --- a/source/lib/rocprofiler-sdk/hsa/types.hpp +++ /dev/null @@ -1,219 +0,0 @@ -// MIT License -// -// Copyright (c) 2023 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 -#include - -#include "lib/common/defines.hpp" - -#ifndef ROCPROFILER_UNSAFE_NO_VERSION_CHECK -# if defined(ROCPROFILER_CI) && ROCPROFILER_CI > 0 -# if HSA_API_TABLE_MAJOR_VERSION <= 0x01 -namespace rocprofiler -{ -namespace hsa -{ -static_assert(HSA_CORE_API_TABLE_MAJOR_VERSION == 0x01, - "Change in the major version of HSA core API table"); -static_assert(HSA_AMD_EXT_API_TABLE_MAJOR_VERSION == 0x01, - "Change in the major version of HSA amd-extended API table"); -static_assert(HSA_FINALIZER_API_TABLE_MAJOR_VERSION == 0x01, - "Change in the major version of HSA finalizer API table"); -static_assert(HSA_IMAGE_API_TABLE_MAJOR_VERSION == 0x01, - "Change in the major version of HSA image API table"); -static_assert(HSA_TOOLS_API_TABLE_MAJOR_VERSION == 0x01, - "Change in the major version of HSA AMD tool API table"); - -static_assert(HSA_CORE_API_TABLE_STEP_VERSION == 0x00, - "Change in the step version of HSA core API table"); -static_assert(HSA_AMD_EXT_API_TABLE_STEP_VERSION == 0x00, - "Change in the step version of HSA amd-extended API table"); -static_assert(HSA_FINALIZER_API_TABLE_STEP_VERSION == 0x00, - "Change in the step version of HSA finalizer API table"); -static_assert(HSA_IMAGE_API_TABLE_STEP_VERSION == 0x00, - "Change in the step version of HSA image API table"); -static_assert(HSA_TOOLS_API_TABLE_STEP_VERSION == 0x00, - "Change in the step version of HSA AMD tool API table"); - -// this should always be updated to latest table size -template -struct table_size; - -// latest version of hsa runtime that has been updated for support by rocprofiler -// and the current version of hsa runtime during this compilation -constexpr size_t latest_version = ROCPROFILER_COMPUTE_VERSION(1, 11, 0); -constexpr size_t current_version = ROCPROFILER_HSA_RUNTIME_VERSION; - -// aliases to the template specializations providing the table size info -using current_table_size_t = table_size; -using latest_table_size_t = table_size; - -// specialization for v1.9 -template <> -struct table_size -{ - static constexpr size_t finalizer_ext = 64; - static constexpr size_t image_ext = 120; - static constexpr size_t amd_ext = 456; - static constexpr size_t core_api_ext = 1016; -}; - -// specialization for v1.10 - increased amd_ext by 10 functions -template <> -struct table_size -: table_size -{ - static constexpr size_t amd_ext = 552; -}; - -// version 1.11 is same as 1.10 -template <> -struct table_size -: table_size -{}; - -// default static asserts to check against latest version -// e.g. v1.12 might have the same table sizes as v1.11 so -// we don't want to fail to compile if nothing has changed -template -struct table_size : latest_table_size_t -{}; - -// if you hit these static asserts, that means HSA added entries to the table but did not update the -// step numbers -static_assert(sizeof(FinalizerExtTable) == current_table_size_t::finalizer_ext, - "HSA finalizer API table size changed or version not supported"); -static_assert(sizeof(ImageExtTable) == current_table_size_t::image_ext, - "HSA image-extended API table size changed or version not supported"); -static_assert(sizeof(AmdExtTable) == current_table_size_t::amd_ext, - "HSA amd-extended API table size changed or version not supported"); -static_assert(sizeof(CoreApiTable) == current_table_size_t::core_api_ext, - "HSA core API table size changed or version not supported"); -} // namespace hsa -} // namespace rocprofiler -# else -namespace rocprofiler -{ -namespace hsa -{ -static_assert(HSA_CORE_API_TABLE_MAJOR_VERSION == 0x02, - "Change in the major version of HSA core API table"); -static_assert(HSA_AMD_EXT_API_TABLE_MAJOR_VERSION == 0x02, - "Change in the major version of HSA amd-extended API table"); -static_assert(HSA_FINALIZER_API_TABLE_MAJOR_VERSION == 0x02, - "Change in the major version of HSA finalizer API table"); -static_assert(HSA_IMAGE_API_TABLE_MAJOR_VERSION == 0x02, - "Change in the major version of HSA image API table"); -static_assert(HSA_TOOLS_API_TABLE_MAJOR_VERSION == 0x01, - "Change in the major version of HSA AMD tool API table"); - -// this should always be updated to latest table size -template -struct table_size; - -// latest version of hsa runtime that has been updated for support by rocprofiler -// and the current version of hsa runtime during this compilation -constexpr size_t latest_version = ROCPROFILER_COMPUTE_VERSION(1, 14, 0); -constexpr size_t current_version = ROCPROFILER_HSA_RUNTIME_VERSION; - -// aliases to the template specializations providing the table size info -using current_table_size_t = table_size; -using latest_table_size_t = table_size; - -// specialization for v1.12 -template <> -struct table_size -{ - static constexpr size_t finalizer_ext = 64; - static constexpr size_t image_ext = 120; - static constexpr size_t core_api_ext = 1016; - - // TODO(jomadsen): come up with a better way of handling this -# if HSA_AMD_EXT_API_TABLE_STEP_VERSION == 0x00 - static constexpr size_t amd_ext = 552; -# elif HSA_AMD_EXT_API_TABLE_STEP_VERSION == 0x1 - static constexpr size_t amd_ext = 560; -# else - static constexpr size_t amd_ext = 568; -# endif -}; - -// specialization for v1.13 -template <> -struct table_size -{ - static constexpr size_t finalizer_ext = 64; - static constexpr size_t image_ext = 120; - static constexpr size_t core_api_ext = 1016; - static constexpr size_t amd_tool = 64; - - // TODO(jomadsen): come up with a better way of handling this -# if HSA_AMD_EXT_API_TABLE_STEP_VERSION == 0x00 - static constexpr size_t amd_ext = 552; -# elif HSA_AMD_EXT_API_TABLE_STEP_VERSION == 0x1 - static constexpr size_t amd_ext = 560; -# elif HSA_AMD_EXT_API_TABLE_STEP_VERSION == 0x2 - static constexpr size_t amd_ext = 568; -# elif HSA_AMD_EXT_API_TABLE_STEP_VERSION > 0x2 - static constexpr size_t amd_ext = 576; -# endif -}; - -// specialization for v1.14 -template <> -struct table_size -{ - static constexpr size_t finalizer_ext = 64; - static constexpr size_t image_ext = 120; - static constexpr size_t core_api_ext = 1016; - static constexpr size_t amd_tool = 64; -# if HSA_AMD_EXT_API_TABLE_STEP_VERSION == 0x2 - static constexpr size_t amd_ext = 568; -# elif HSA_AMD_EXT_API_TABLE_STEP_VERSION > 0x2 - static constexpr size_t amd_ext = 576; -# endif -}; - -// default static asserts to check against latest version -// e.g. v1.12 might have the same table sizes as v1.11 so -// we don't want to fail to compile if nothing has changed -template -struct table_size : latest_table_size_t -{}; - -// if you hit these static asserts, that means HSA added entries to the table but did not update the -// step numbers -static_assert(sizeof(FinalizerExtTable) == current_table_size_t::finalizer_ext, - "HSA finalizer API table size changed or version not supported"); -static_assert(sizeof(ImageExtTable) == current_table_size_t::image_ext, - "HSA image-extended API table size changed or version not supported"); -static_assert(sizeof(AmdExtTable) == current_table_size_t::amd_ext, - "HSA amd-extended API table size changed or version not supported"); -static_assert(sizeof(CoreApiTable) == current_table_size_t::core_api_ext, - "HSA core API table size changed or version not supported"); -} // namespace hsa -} // namespace rocprofiler -# endif -# endif -#endif