MCPcopy Create free account
hub / github.com/ROCm/clr / UnbundleUsingComgr

Function UnbundleUsingComgr

hipamd/src/hip_comgr_helper.cpp:467–525  ·  view source on GitHub ↗

Unbundle Bitcode using COMGR action Supports only 1 Bundle Entry ID for now

Source from the content-addressed store, hash-verified

465// Unbundle Bitcode using COMGR action
466// Supports only 1 Bundle Entry ID for now
467bool UnbundleUsingComgr(std::vector<char>& source, const std::string& isa,
468 std::vector<std::string>& linkOptions, std::string& buildLog,
469 std::vector<char>& unbundled_bitcode, const char* bundleEntryIDs[],
470 size_t bundleEntryIDsCount) {
471 amd_comgr_data_set_t linkinput;
472 if (amd::Comgr::create_data_set(&linkinput) != AMD_COMGR_STATUS_SUCCESS) {
473 return false;
474 }
475 std::string name = "UnbundleCode.bc";
476 if (!helpers::addCodeObjData(linkinput, source, name, AMD_COMGR_DATA_KIND_BC_BUNDLE)) {
477 return false;
478 }
479
480 amd_comgr_action_info_t action;
481 if (!createAction(action, linkOptions, isa, AMD_COMGR_LANGUAGE_NONE)) {
482 return false;
483 }
484
485 if (bundleEntryIDsCount > 1) {
486 LogError("Error in hip Linker : bundleEntryID count > 1");
487 return false;
488 }
489
490 if (amd::Comgr::action_info_set_bundle_entry_ids(action, bundleEntryIDs, bundleEntryIDsCount) !=
491 AMD_COMGR_STATUS_SUCCESS) {
492 amd::Comgr::destroy_action_info(action);
493 return false;
494 }
495
496 amd_comgr_data_set_t output;
497 if (amd::Comgr::create_data_set(&output) != AMD_COMGR_STATUS_SUCCESS) {
498 amd::Comgr::destroy_action_info(action);
499 return false;
500 }
501
502 if (auto res = amd::Comgr::do_action(AMD_COMGR_ACTION_UNBUNDLE, action, linkinput, output);
503 res != AMD_COMGR_STATUS_SUCCESS) {
504 amd::Comgr::destroy_action_info(action);
505 amd::Comgr::destroy_data_set(output);
506 return false;
507 }
508
509 if (!extractBuildLog(output, buildLog)) {
510 amd::Comgr::destroy_action_info(action);
511 amd::Comgr::destroy_data_set(output);
512 return false;
513 }
514
515 if (!extractByteCodeBinary(output, AMD_COMGR_DATA_KIND_BC, unbundled_bitcode)) {
516 amd::Comgr::destroy_action_info(action);
517 amd::Comgr::destroy_data_set(output);
518 return false;
519 }
520
521 amd::Comgr::destroy_action_info(action);
522 amd::Comgr::destroy_data_set(output);
523 amd::Comgr::destroy_data_set(linkinput);
524 return true;

Callers 1

AddLinkerDataImplMethod · 0.85

Calls 4

addCodeObjDataFunction · 0.85
createActionFunction · 0.85
extractBuildLogFunction · 0.85
extractByteCodeBinaryFunction · 0.85

Tested by

no test coverage detected