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

Method createKernelMetadataMap

rocclr/device/devprogram.cpp:1773–1949  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1771}
1772
1773bool Program::createKernelMetadataMap(void* binary, size_t binSize) {
1774 ComgrBinaryData binaryData;
1775 if (!binaryData.create(AMD_COMGR_DATA_KIND_EXECUTABLE, binary, binSize)) {
1776 buildLog_ += "Error: COMGR failed to create code object data object.\n";
1777 return false;
1778 }
1779
1780 amd_comgr_status_t status;
1781 if (device().isOnline()) {
1782 size_t requiredSize = 0;
1783 status = amd::Comgr::get_data_isa_name(binaryData.data(), &requiredSize, nullptr);
1784 if (status != AMD_COMGR_STATUS_SUCCESS) {
1785 buildLog_ += "Error: COMGR failed to get code object ISA name.\n";
1786 return false;
1787 }
1788
1789 std::vector<char> binaryIsaName(requiredSize);
1790 status = amd::Comgr::get_data_isa_name(binaryData.data(), &requiredSize, binaryIsaName.data());
1791 if ((status != AMD_COMGR_STATUS_SUCCESS) || (requiredSize != binaryIsaName.size())) {
1792 buildLog_ += "Error: COMGR failed to get code object ISA name.\n";
1793 return false;
1794 }
1795
1796 const amd::Isa* binaryIsa = amd::Isa::findIsa(binaryIsaName.data());
1797 if (!binaryIsa) {
1798 buildLog_ +=
1799 "Error: Could not find the program ISA " + std::string(binaryIsaName.data()) + "\n";
1800 return false;
1801 }
1802
1803 if (!amd::Isa::isCompatible(*binaryIsa, device().isa())) {
1804 buildLog_ += "Error: The program ISA " + std::string(binaryIsaName.data());
1805 buildLog_ += " is not compatible with the device ISA " + device().isa().isaName() + "\n";
1806 return false;
1807 }
1808 }
1809
1810 status = amd::Comgr::get_data_metadata(binaryData.data(), &metadata_);
1811 if (status != AMD_COMGR_STATUS_SUCCESS) {
1812 buildLog_ += "Error: COMGR failed to get the metadata.\n";
1813 return false;
1814 }
1815
1816 amd_comgr_metadata_node_t kernelsMD;
1817 bool hasKernelMD = false;
1818 size_t size = 0;
1819
1820 status = amd::Comgr::metadata_lookup(metadata_, "Kernels", &kernelsMD);
1821 if (status == AMD_COMGR_STATUS_SUCCESS) {
1822 ClPrint(amd::LOG_DETAIL_DEBUG, amd::LOG_CODE, "Using Code Object V2.");
1823 hasKernelMD = true;
1824 codeObjectVer_ = 2;
1825 } else {
1826 amd_comgr_metadata_node_t versionMD, versionNode;
1827 char major_version, minor_version;
1828
1829 status = amd::Comgr::metadata_lookup(metadata_, "amdhsa.version", &versionMD);
1830

Callers

nothing calls this directly

Calls 9

findIsaFunction · 0.85
getMetaBufFunction · 0.85
isOnlineMethod · 0.80
isaNameMethod · 0.80
stringFunction · 0.50
createMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected