| 1 | //===- InstrProfilingPlatformROCmHSADefs.h - mirrored HSA decls ----------===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // Minimal HSA type/enum/function-pointer declarations used by the Linux-only |
| 10 | // supplemental HSA drain (InstrProfilingPlatformROCmHSA.cpp). compiler-rt |
| 11 | // cannot depend on the ROCm headers at build time, and the runtime dlopens |
| 12 | // libhsa-runtime64.so rather than linking it, so the handful of declarations |
| 13 | // the drain needs are mirrored here under a prof_hsa_* prefix. |
| 14 | // |
| 15 | // Values mirror hsa/hsa.h and hsa/hsa_ven_amd_loader.h. These are part of HSA's |
| 16 | // stable, versioned C ABI (libhsa-runtime64.so.1), so they do not shift. |
| 17 | // |
| 18 | //===----------------------------------------------------------------------===// |
| 19 | |
| 20 | #ifndef PROFILE_INSTRPROFILINGPLATFORMROCMHSADEFS_H |
| 21 | #define PROFILE_INSTRPROFILINGPLATFORMROCMHSADEFS_H |
| 22 | |
| 23 | #include <stddef.h> |
| 24 | #include <stdint.h> |
| 25 | |
| 26 | typedef uint32_t prof_hsa_status_t; |
| 27 | #define PROF_HSA_STATUS_SUCCESS ((prof_hsa_status_t)0x0) |
| 28 | #define PROF_HSA_STATUS_INFO_BREAK ((prof_hsa_status_t)0x1) |
| 29 | |
| 30 | typedef struct { |
| 31 | uint64_t handle; |
| 32 | } prof_hsa_agent_t; |
| 33 | typedef struct { |
| 34 | uint64_t handle; |
| 35 | } prof_hsa_executable_t; |
| 36 | typedef struct { |
| 37 | uint64_t handle; |
| 38 | } prof_hsa_executable_symbol_t; |
| 39 | |
| 40 | typedef uint32_t prof_hsa_agent_info_t; |
| 41 | #define PROF_HSA_AGENT_INFO_NAME ((prof_hsa_agent_info_t)0) |
| 42 | #define PROF_HSA_AGENT_INFO_DEVICE ((prof_hsa_agent_info_t)17) |
| 43 | |
| 44 | typedef uint32_t prof_hsa_device_type_t; |
| 45 | #define PROF_HSA_DEVICE_TYPE_GPU ((prof_hsa_device_type_t)1) |
| 46 | |
| 47 | typedef uint32_t prof_hsa_symbol_kind_t; |
| 48 | #define PROF_HSA_SYMBOL_KIND_VARIABLE ((prof_hsa_symbol_kind_t)0) |
| 49 | |
| 50 | typedef uint32_t prof_hsa_executable_symbol_info_t; |
| 51 | #define PROF_HSA_EXECUTABLE_SYMBOL_INFO_TYPE \ |
| 52 | ((prof_hsa_executable_symbol_info_t)0) |
| 53 | #define PROF_HSA_EXECUTABLE_SYMBOL_INFO_NAME_LENGTH \ |
| 54 | ((prof_hsa_executable_symbol_info_t)1) |
| 55 | #define PROF_HSA_EXECUTABLE_SYMBOL_INFO_NAME \ |
| 56 | ((prof_hsa_executable_symbol_info_t)2) |
| 57 | #define PROF_HSA_EXECUTABLE_SYMBOL_INFO_VARIABLE_ADDRESS \ |
| 58 | ((prof_hsa_executable_symbol_info_t)21) |
| 59 | |
| 60 | #define PROF_HSA_EXTENSION_AMD_LOADER ((uint16_t)0x201) |
| 61 | |
| 62 | typedef uint32_t prof_hsa_loader_storage_type_t; |
| 63 | |
| 64 | typedef struct { |
| 65 | prof_hsa_agent_t agent; |
| 66 | prof_hsa_executable_t executable; |
| 67 | prof_hsa_loader_storage_type_t code_object_storage_type; |
| 68 | const void *code_object_storage_base; |
| 69 | size_t code_object_storage_size; |
| 70 | size_t code_object_storage_offset; |
| 71 | const void *segment_base; |
| 72 | size_t segment_size; |
| 73 | } prof_hsa_loader_segment_descriptor_t; |
| 74 | |
| 75 | typedef prof_hsa_status_t (*hsa_init_ty)(void); |
| 76 | typedef prof_hsa_status_t (*hsa_iterate_agents_ty)( |
| 77 | prof_hsa_status_t (*)(prof_hsa_agent_t, void *), void *); |
| 78 | typedef prof_hsa_status_t (*hsa_agent_get_info_ty)(prof_hsa_agent_t, |
| 79 | prof_hsa_agent_info_t, |
| 80 | void *); |
| 81 | typedef prof_hsa_status_t (*hsa_executable_iterate_agent_symbols_ty)( |
| 82 | prof_hsa_executable_t, prof_hsa_agent_t, |
| 83 | prof_hsa_status_t (*)(prof_hsa_executable_t, prof_hsa_agent_t, |
| 84 | prof_hsa_executable_symbol_t, void *), |
| 85 | void *); |
| 86 | typedef prof_hsa_status_t (*hsa_executable_symbol_get_info_ty)( |
| 87 | prof_hsa_executable_symbol_t, prof_hsa_executable_symbol_info_t, void *); |
| 88 | typedef prof_hsa_status_t (*hsa_system_get_major_extension_table_ty)(uint16_t, |
| 89 | uint16_t, |
| 90 | size_t, |
| 91 | void *); |
| 92 | typedef prof_hsa_status_t (*hsa_loader_query_segment_descriptors_ty)( |
| 93 | prof_hsa_loader_segment_descriptor_t *, size_t *); |
| 94 | |
| 95 | /* First two members of hsa_ven_amd_loader_1_00_pfn_t; query_host_address only |
| 96 | * pads the offset to query_segment_descriptors. */ |
| 97 | typedef struct { |
| 98 | void *query_host_address; |
| 99 | hsa_loader_query_segment_descriptors_ty query_segment_descriptors; |
| 100 | } prof_hsa_loader_pfn_t; |
| 101 | |
| 102 | #endif // PROFILE_INSTRPROFILINGPLATFORMROCMHSADEFS_H |
| 103 | |