Add executable symbol info for the wavefront size

The wavefront size is currently only exposed as an agent level
attribute. This is not correctyl, because while the agent has a default
wave front size that is usually correct, it can easily be overridden via
options like -mwavefrontsize64 on various ISAs. The wavefrontsize
attribute is actually more of a calling convention that is consistent
within a callgraph. Because the root of each call graph is a kernel in
this architecture, we need to be able to query this on a per-kernel
basis. This information is already avialable in the kernel descriptor
packet, but it wasn't exported.

This patch adds HSA_CODE_SYMBOL_INFO_KERNEL_WAVEFRONT_SIZE as a new
option to query on the executable symbol.

Change-Id: I744815c89cc9d4c82f25479bdd48ae1f32e859ff
This commit is contained in:
Joseph Huber
2024-02-09 15:47:05 +00:00
zatwierdzone przez David Yat Sin
rodzic e911335cee
commit 9e26cbac14
3 zmienionych plików z 18 dodań i 2 usunięć
+6 -1
Wyświetl plik
@@ -5656,7 +5656,12 @@ typedef enum {
* undefined if the symbol is not an indirect function. The type of this
* attribute is uint32_t.
*/
HSA_CODE_SYMBOL_INFO_INDIRECT_FUNCTION_CALL_CONVENTION = 16
HSA_CODE_SYMBOL_INFO_INDIRECT_FUNCTION_CALL_CONVENTION = 16,
/**
* Wavefront size used by the kernel. The value of this attribute is either
* 32 or 64. The type of this attribute is uint32_t.
*/
HSA_CODE_SYMBOL_INFO_KERNEL_WAVEFRONT_SIZE = 19
} hsa_code_symbol_info_t;
/**
@@ -522,6 +522,10 @@ bool KernelSymbol::GetInfo(hsa_symbol_info32_t symbol_info, void *value) {
*((bool*)value) = is_dynamic_callstack;
break;
}
case HSA_CODE_SYMBOL_INFO_KERNEL_WAVEFRONT_SIZE: {
*((uint32_t*)value) = wavefront_size;
break;
}
case HSA_EXT_EXECUTABLE_SYMBOL_INFO_KERNEL_OBJECT_SIZE: {
*((uint32_t*)value) = size;
break;
@@ -1434,6 +1438,7 @@ hsa_status_t ExecutableImpl::LoadDefinitionSymbol(hsa_agent_t agent,
uint32_t group_segment_size = kd.group_segment_fixed_size;
uint32_t private_segment_size = kd.private_segment_fixed_size;
bool is_dynamic_callstack = AMDHSA_BITS_GET(kd.kernel_code_properties, rocr::llvm::amdhsa::KERNEL_CODE_PROPERTY_USES_DYNAMIC_STACK);
bool uses_wave32 = AMDHSA_BITS_GET( kd.kernel_code_properties, rocr::llvm::amdhsa::KERNEL_CODE_PROPERTY_ENABLE_WAVEFRONT_SIZE32);
uint64_t size = sym->Size();
@@ -1449,6 +1454,7 @@ hsa_status_t ExecutableImpl::LoadDefinitionSymbol(hsa_agent_t agent,
is_dynamic_callstack,
size,
64,
uses_wave32 ? 32 : 64,
address);
symbol = kernel_symbol;
} else if (sym->IsVariableSymbol()) {
@@ -1478,6 +1484,7 @@ hsa_status_t ExecutableImpl::LoadDefinitionSymbol(hsa_agent_t agent,
uint32_t(akc.workitem_private_segment_byte_size);
bool is_dynamic_callstack =
AMD_HSA_BITS_GET(akc.kernel_code_properties, AMD_KERNEL_CODE_PROPERTIES_IS_DYNAMIC_CALLSTACK) ? true : false;
bool uses_wave32 = akc.wavefront_size == AMD_POWERTWO_32;
uint64_t size = sym->Size();
@@ -1498,6 +1505,7 @@ hsa_status_t ExecutableImpl::LoadDefinitionSymbol(hsa_agent_t agent,
is_dynamic_callstack,
size,
256,
uses_wave32 ? 32 : 64,
address);
kernel_symbol->debug_info.elf_raw = code->ElfData();
kernel_symbol->debug_info.elf_size = code->ElfSize();
@@ -144,6 +144,7 @@ public:
const bool &_is_dynamic_callstack,
const uint32_t &_size,
const uint32_t &_alignment,
const uint32_t &_wavefront_size,
const uint64_t &_address = 0)
: SymbolImpl(_is_loaded,
HSA_SYMBOL_KIND_KERNEL,
@@ -159,7 +160,8 @@ public:
, private_segment_size(_private_segment_size)
, is_dynamic_callstack(_is_dynamic_callstack)
, size(_size)
, alignment(_alignment) {}
, alignment(_alignment)
, wavefront_size(_wavefront_size) {}
~KernelSymbol() {}
@@ -173,6 +175,7 @@ public:
bool is_dynamic_callstack;
uint32_t size;
uint32_t alignment;
uint32_t wavefront_size;
amd_runtime_loader_debug_info_t debug_info;
private: