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

Function PopulateCodeObjectMap

hipamd/src/hip_fatbin.cpp:389–438  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

387}
388
389static bool PopulateCodeObjectMap(
390 const void* image, const std::set<std::string>& unique_isa_names,
391 std::map<std::string, std::pair<const void*, size_t>>& code_obj_map) {
392 bool passed = false;
393 do {
394 comgr_helper::ComgrDataUniqueHandle data_object;
395 if (auto comgr_status = data_object.Create(AMD_COMGR_DATA_KIND_FATBIN);
396 comgr_status != AMD_COMGR_STATUS_SUCCESS) {
397 LogPrintfError("Creating data object failed with status %d ", comgr_status);
398 break;
399 }
400
401 // There is no way to find size of offload bundle, so we pass 4096 here.
402 if (auto comgr_status =
403 amd::Comgr::set_data(data_object.get(), 4096, reinterpret_cast<const char*>(image));
404 comgr_status != AMD_COMGR_STATUS_SUCCESS) {
405 LogPrintfError("Setting data from file slice failed with status %d ", comgr_status);
406 break;
407 }
408
409 // Create a query list using COMGR info for unique ISAs.
410 std::vector<amd_comgr_code_object_info_t> query_list_array;
411 query_list_array.reserve(unique_isa_names.size());
412 for (const auto& isa_name : unique_isa_names) {
413 auto& item = query_list_array.emplace_back();
414 item.isa = isa_name.c_str();
415 item.size = 0;
416 item.offset = 0;
417 }
418
419 // Look up the code object info passing the query list.
420 if (auto comgr_status = amd::Comgr::lookup_code_object(
421 data_object.get(), query_list_array.data(), unique_isa_names.size());
422 comgr_status != AMD_COMGR_STATUS_SUCCESS) {
423 LogPrintfError("Setting data from file slice failed with status %d ", comgr_status);
424 break;
425 }
426
427 for (const auto& item : query_list_array) {
428 if (item.size > 0) {
429 // Map the offset pointer and size from the image
430 auto loc = reinterpret_cast<const char*>(image) + item.offset;
431 code_obj_map[item.isa] = std::make_pair(loc, item.size);
432 }
433 }
434
435 passed = true;
436 } while (0);
437 return passed;
438}
439
440hipError_t FatBinaryInfo::ExtractFatBinaryUsingCOMGR(const std::vector<hip::Device*>& devices) {
441 if (fname_.empty() && image_ == nullptr) {

Callers 1

Calls 5

reserveMethod · 0.80
CreateMethod · 0.45
getMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected