SWDEV-433371 - use comgr to unbundle code objects

1.Make runtime use comgr to unbundle code objects
2.Support compressed/uncompressed modes
3.Remove HIP_USE_RUNTIME_UNBUNDLER and
  HIPRTC_USE_RUNTIME_UNBUNDLER to simplify logics
4.Add comgr wrapper for
  amd_comgr_action_info_set_bundle_entry_ids()

Change-Id: Ic41b1ad1b64cca1e31986437983a5146d52a7329
This commit is contained in:
taosang2
2024-04-11 08:57:47 -04:00
committed by Tao Sang
parent 996c16ad0a
commit e53df57ffe
11 changed files with 474 additions and 427 deletions
+2 -22
View File
@@ -545,8 +545,7 @@ amd_comgr_data_kind_t RTCLinkProgram::GetCOMGRDataKind(hiprtcJITInputType input_
data_kind = AMD_COMGR_DATA_KIND_BC;
break;
case HIPRTC_JIT_INPUT_LLVM_BUNDLED_BITCODE:
data_kind =
HIPRTC_USE_RUNTIME_UNBUNDLER ? AMD_COMGR_DATA_KIND_BC : AMD_COMGR_DATA_KIND_BC_BUNDLE;
data_kind = AMD_COMGR_DATA_KIND_BC_BUNDLE;
break;
case HIPRTC_JIT_INPUT_LLVM_ARCHIVES_OF_BUNDLED_BITCODE:
data_kind = AMD_COMGR_DATA_KIND_AR_BUNDLE;
@@ -561,32 +560,13 @@ amd_comgr_data_kind_t RTCLinkProgram::GetCOMGRDataKind(hiprtcJITInputType input_
bool RTCLinkProgram::AddLinkerDataImpl(std::vector<char>& link_data, hiprtcJITInputType input_type,
std::string& link_file_name) {
std::vector<char> llvm_bitcode;
// If this is bundled bitcode then unbundle this.
if (HIPRTC_USE_RUNTIME_UNBUNDLER && input_type == HIPRTC_JIT_INPUT_LLVM_BUNDLED_BITCODE) {
if (!findIsa()) {
return false;
}
size_t co_offset = 0;
size_t co_size = 0;
if (!UnbundleBitCode(link_data, isa_, co_offset, co_size)) {
LogError("Error in hiprtc: unable to unbundle the llvm bitcode");
return false;
}
llvm_bitcode.assign(link_data.begin() + co_offset, link_data.begin() + co_offset + co_size);
} else {
llvm_bitcode.assign(link_data.begin(), link_data.end());
}
amd_comgr_data_kind_t data_kind;
if ((data_kind = GetCOMGRDataKind(input_type)) == AMD_COMGR_DATA_KIND_UNDEF) {
LogError("Cannot find the correct COMGR data kind");
return false;
}
if (!addCodeObjData(link_input_, llvm_bitcode, link_file_name, data_kind)) {
if (!addCodeObjData(link_input_, link_data, link_file_name, data_kind)) {
LogError("Error in hiprtc: unable to add linked code object");
return false;
}