2
0

SWDEV-386102 - Handle code object v5

Change-Id: I47b840f484d90ca7815fb9c8af959ceaac62cf70
Este cometimento está contido em:
Anusha GodavarthySurya
2023-03-03 09:31:29 +00:00
cometido por Anusha Godavarthy Surya
ascendente 8028d327e9
cometimento 9b84e05427
3 ficheiros modificados com 31 adições e 26 eliminações
+16 -15
Ver ficheiro
@@ -256,8 +256,7 @@ static bool getProcName(uint32_t EFlags, std::string& proc_name, bool& xnackSupp
return true;
}
static bool getTripleTargetIDFromCodeObject(const void* code_object, std::string& target_id,
unsigned& co_version) {
static bool getTripleTargetIDFromCodeObject(const void* code_object, std::string& target_id) {
if (!code_object) return false;
const Elf64_Ehdr* ehdr = reinterpret_cast<const Elf64_Ehdr*>(code_object);
if (ehdr->e_machine != EM_AMDGPU) return false;
@@ -271,12 +270,12 @@ static bool getTripleTargetIDFromCodeObject(const void* code_object, std::string
switch (ehdr->e_ident[EI_ABIVERSION]) {
case ELFABIVERSION_AMDGPU_HSA_V2: {
co_version = 2;
LogPrintfInfo("[Code Object V2, target id:%s]", target_id.c_str());
return false;
}
case ELFABIVERSION_AMDGPU_HSA_V3: {
co_version = 3;
LogPrintfInfo("[Code Object V3, target id:%s]", target_id.c_str());
if (isSramEccSupported) {
if (ehdr->e_flags & EF_AMDGPU_FEATURE_SRAMECC_V3)
target_id += ":sramecc+";
@@ -292,8 +291,13 @@ static bool getTripleTargetIDFromCodeObject(const void* code_object, std::string
break;
}
case ELFABIVERSION_AMDGPU_HSA_V4: {
co_version = 4;
case ELFABIVERSION_AMDGPU_HSA_V4:
case ELFABIVERSION_AMDGPU_HSA_V5: {
if (ehdr->e_ident[EI_ABIVERSION] & ELFABIVERSION_AMDGPU_HSA_V4) {
LogPrintfInfo("[Code Object V4, target id:%s]", target_id.c_str());
} else {
LogPrintfInfo("[Code Object V5, target id:%s]", target_id.c_str());
}
unsigned co_sram_value = (ehdr->e_flags) & EF_AMDGPU_FEATURE_SRAMECC_V4;
if (co_sram_value == EF_AMDGPU_FEATURE_SRAMECC_OFF_V4)
target_id += ":sramecc-";
@@ -361,18 +365,17 @@ static bool getTargetIDValue(std::string& input, std::string& processor, char& s
}
static bool getTripleTargetID(std::string bundled_co_entry_id, const void* code_object,
std::string& co_triple_target_id, unsigned& co_version) {
std::string& co_triple_target_id) {
std::string offload_kind = trimName(bundled_co_entry_id, '-');
if (offload_kind != OFFLOAD_KIND_HIPV4 && offload_kind != OFFLOAD_KIND_HIP &&
offload_kind != OFFLOAD_KIND_HCC)
return false;
if (offload_kind != OFFLOAD_KIND_HIPV4)
return getTripleTargetIDFromCodeObject(code_object, co_triple_target_id, co_version);
return getTripleTargetIDFromCodeObject(code_object, co_triple_target_id);
// For code object V4 onwards the bundled code object entry ID correctly
// specifies the target tripple.
co_version = 4;
// specifies the target triple.
co_triple_target_id = bundled_co_entry_id.substr(1);
return true;
}
@@ -485,9 +488,8 @@ hipError_t CodeObject::extractCodeObjectFromFatBinary(
if (num_code_objs == 0) break;
std::string bundleEntryId{desc->bundleEntryId, desc->bundleEntryIdSize};
unsigned co_version = 0;
std::string co_triple_target_id;
if (!getTripleTargetID(bundleEntryId, image, co_triple_target_id, co_version)) continue;
if (!getTripleTargetID(bundleEntryId, image, co_triple_target_id)) continue;
for (size_t dev = 0; dev < agent_triple_target_ids.size(); ++dev) {
if (code_objs[dev].first) continue;
@@ -518,12 +520,11 @@ hipError_t CodeObject::extractCodeObjectFromFatBinary(
const void* image =
reinterpret_cast<const void*>(reinterpret_cast<uintptr_t>(obheader) + desc->offset);
unsigned co_version = 0;
std::string co_triple_target_id;
bool valid_co = getTripleTargetID(bundleEntryId, image, co_triple_target_id, co_version);
bool valid_co = getTripleTargetID(bundleEntryId, image, co_triple_target_id);
if (valid_co) {
LogPrintfError(" %s - [code object v%u is %s]", bundleEntryId.c_str(), co_version,
LogPrintfError(" %s - [code object targetID is %s]", bundleEntryId.c_str(),
co_triple_target_id.c_str());
} else {
LogPrintfError(" %s - [Unsupported]", bundleEntryId.c_str());