From e1734526fc9e74455597e9046543c7a6eadb984a Mon Sep 17 00:00:00 2001 From: Tony Date: Sat, 21 Nov 2020 01:01:09 +0000 Subject: [PATCH] Update code object V3 kernarg queries Code object V2 had the ability to support the following queries: - HSA_CODE_SYMBOL_INFO_KERNEL_KERNARG_SEGMENT_SIZE - HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_KERNARG_SEGMENT_SIZE - HSA_CODE_SYMBOL_INFO_KERNEL_KERNARG_SEGMENT_ALIGNMENT - HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_KERNARG_SEGMENT_ALIGNMENT However code object V3 onwards cannot support these as the kernel descriptor changed. These queries need to be deprecated. Until then return more reasonable values: - For kernarg alignment return 16 which is the minimum alignment required by the HSA standard. - For kernarg size return the field from the kernel descriptor which is a hint. If it is 0 then the compiler is not specifying the kernarg size, or the kernel has no kernarg. Change-Id: I19ce6cd0f3658a2bf62277492f39100ea5ab4256 [ROCm/ROCR-Runtime commit: ef755e4c827665f6d7711a3ef222f8c8c3a44538] --- .../runtime/hsa-runtime/loader/AMDHSAKernelDescriptor.h | 8 ++++++-- .../runtime/hsa-runtime/loader/executable.cpp | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/projects/rocr-runtime/runtime/hsa-runtime/loader/AMDHSAKernelDescriptor.h b/projects/rocr-runtime/runtime/hsa-runtime/loader/AMDHSAKernelDescriptor.h index 4f64d2482c..b1fe4d4298 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/loader/AMDHSAKernelDescriptor.h +++ b/projects/rocr-runtime/runtime/hsa-runtime/loader/AMDHSAKernelDescriptor.h @@ -167,7 +167,8 @@ enum : int32_t { struct kernel_descriptor_t { uint32_t group_segment_fixed_size; uint32_t private_segment_fixed_size; - uint8_t reserved0[8]; + uint32_t kernarg_size; + uint8_t reserved0[4]; int64_t kernel_code_entry_byte_offset; uint8_t reserved1[24]; uint32_t compute_pgm_rsrc1; @@ -185,8 +186,11 @@ static_assert( static_assert( offsetof(kernel_descriptor_t, private_segment_fixed_size) == 4, "invalid offset for private_segment_fixed_size"); +static_assert( + offsetof(kernel_descriptor_t, kernarg_size) == 8, + "invalid offset for kernarg_size"); static_assert( - offsetof(kernel_descriptor_t, reserved0) == 8, + offsetof(kernel_descriptor_t, reserved0) == 12, "invalid offset for reserved0"); static_assert( offsetof(kernel_descriptor_t, kernel_code_entry_byte_offset) == 16, diff --git a/projects/rocr-runtime/runtime/hsa-runtime/loader/executable.cpp b/projects/rocr-runtime/runtime/hsa-runtime/loader/executable.cpp index 0d982e7a5a..d53a098505 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/loader/executable.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/loader/executable.cpp @@ -1422,8 +1422,8 @@ hsa_status_t ExecutableImpl::LoadDefinitionSymbol(hsa_agent_t agent, llvm::amdhsa::kernel_descriptor_t kd; sym->GetSection()->getData(sym->SectionOffset(), &kd, sizeof(kd)); - uint32_t kernarg_segment_size = 0; // FIXME. - uint32_t kernarg_segment_alignment = 0; // FIXME. + uint32_t kernarg_segment_size = kd.kernarg_size; // FIXME: If 0 then the compiler is not specifying the size. + uint32_t kernarg_segment_alignment = 16; // FIXME: Use the minumum HSA required alignment. uint32_t group_segment_size = kd.group_segment_fixed_size; uint32_t private_segment_size = kd.private_segment_fixed_size; bool is_dynamic_callstack = false;