SWDEV-277566 - Separate code object loading from building

Change-Id: I87b8178f55e8ef23762dfe11fab71665ba680f00
This commit is contained in:
Jason Tang
2021-03-26 15:29:05 -04:00
committato da Jason Tang
parent 509f528980
commit 211ba25b4e
13 ha cambiato i file con 283 aggiunte e 168 eliminazioni
+26 -17
Vedi File
@@ -219,7 +219,7 @@ bool HSAILProgram::saveBinaryAndSetType(type_t type) {
return true;
}
bool HSAILProgram::setKernels(amd::option::Options* options, void* binary, size_t binSize,
bool HSAILProgram::setKernels(void* binary, size_t binSize,
amd::Os::FileDesc fdesc, size_t foffset, std::string uri) {
return true;
}
@@ -263,7 +263,28 @@ bool LightningProgram::saveBinaryAndSetType(type_t type, void* rawBinary, size_t
return true;
}
bool LightningProgram::setKernels(amd::option::Options* options, void* binary, size_t binSize,
bool LightningProgram::createKernels(void* binary, size_t binSize, bool useUniformWorkGroupSize,
bool internalKernel) {
// Find the size of global variables from the binary
if (!FindGlobalVarSize(binary, binSize)) {
buildLog_ += "Error: Cannot Find Global Var Sizes\n";
return false;
}
for (const auto &kernelMeta : kernelMetadataMap_) {
const std::string kernelName = kernelMeta.first;
Kernel* aKernel = new roc::LightningKernel(kernelName, this);
if (!aKernel->init()) {
return false;
}
aKernel->setUniformWorkGroupSize(useUniformWorkGroupSize);
aKernel->setInternalKernelFlag(internalKernel);
kernels()[kernelName] = aKernel;
}
return true;
}
bool LightningProgram::setKernels(void* binary, size_t binSize,
amd::Os::FileDesc fdesc, size_t foffset, std::string uri) {
#if defined(USE_COMGR_LIBRARY)
// Stop compilation if it is an offline device - HSA runtime does not
@@ -272,13 +293,6 @@ bool LightningProgram::setKernels(amd::option::Options* options, void* binary, s
return true;
}
// Find the size of global variables from the binary
if (!FindGlobalVarSize(binary, binSize)) {
buildLog_ += "Error: Cannot Global Var Sizes ";
buildLog_ += "\n";
return false;
}
hsa_agent_t agent = rocDevice().getBackendDevice();
hsa_status_t status;
@@ -320,16 +334,11 @@ bool LightningProgram::setKernels(amd::option::Options* options, void* binary, s
return false;
}
for (const auto &kernelMeta : kernelMetadataMap_) {
const std::string kernelName = kernelMeta.first;
Kernel* aKernel = new roc::LightningKernel(kernelName, this);
if (!aKernel->init()) {
for (auto& kit : kernels()) {
LightningKernel* kernel = static_cast<LightningKernel*>(kit.second);
if (!kernel->postLoad()) {
return false;
}
aKernel->setUniformWorkGroupSize(options->oVariables->UniformWorkGroupSize);
aKernel->setInternalKernelFlag(compileOptions_.find("-cl-internal-kernel") !=
std::string::npos);
kernels()[kernelName] = aKernel;
}
#endif // defined(USE_COMGR_LIBRARY)
return true;