SWDEV-277566 - HSAIL: put back the original setKernels logic for now

In HSAIL path, kernel akc info is obtained after code object
loading, and kernel signature creation requires the akc info
when one of the kernel argument is a reference object.

Change-Id: I9cdb1dbf2c72f4620b0b6e46a88402a2473c3e97
Этот коммит содержится в:
Jason Tang
2021-05-20 10:58:07 -04:00
родитель a81756bba3
Коммит 8cac880779
3 изменённых файлов: 49 добавлений и 60 удалений
+19 -30
Просмотреть файл
@@ -85,14 +85,29 @@ bool HSAILKernel::setKernelCode(amd::hsa::loader::Symbol* sym, amd_kernel_code_t
return true;
}
bool HSAILKernel::aqlCreateHWInfo() {
HSAILKernel::HSAILKernel(std::string name, HSAILProgram* prog, bool internalKernel)
: device::Kernel(prog->device(), name, *prog),
index_(0),
code_(0),
codeSize_(0) {
flags_.hsa_ = true;
flags_.internalKernel_ = internalKernel;
}
HSAILKernel::~HSAILKernel() {}
bool HSAILKernel::postLoad() {
return true;
}
bool HSAILKernel::init() {
#if defined(WITH_COMPILER_LIB)
hsa_agent_t agent = {amd::Device::toHandle(&(device()))};
std::string openclKernelName = device::Kernel::openclMangledName(name());
amd::hsa::loader::Symbol* sym = prog().getSymbol(openclKernelName.c_str(), &agent);
std::string openClKernelName = openclMangledName(name());
amd::hsa::loader::Symbol* sym = prog().getSymbol(openClKernelName.c_str(), &agent);
if (!sym) {
LogPrintfError("Error: Getting kernel ISA code symbol %s from AMD HSA Code Object failed.\n",
openclKernelName.c_str());
openClKernelName.c_str());
return false;
}
@@ -115,34 +130,8 @@ bool HSAILKernel::aqlCreateHWInfo() {
workgroupGroupSegmentByteSize_ = workGroupInfo_.usedLDSSize_;
kernargSegmentByteSize_ = akc->kernarg_segment_byte_size;
#endif // defined(WITH_COMPILER_LIB)
return true;
}
HSAILKernel::HSAILKernel(std::string name, HSAILProgram* prog, bool internalKernel)
: device::Kernel(prog->device(), name, *prog),
index_(0),
code_(0),
codeSize_(0) {
flags_.hsa_ = true;
flags_.internalKernel_ = internalKernel;
}
HSAILKernel::~HSAILKernel() {}
bool HSAILKernel::postLoad() {
#if defined(WITH_COMPILER_LIB)
if (!aqlCreateHWInfo()) {
return false;
}
#endif // defined(WITH_COMPILER_LIB)
return true;
}
bool HSAILKernel::init() {
#if defined(WITH_COMPILER_LIB)
acl_error error = ACL_SUCCESS;
std::string openClKernelName = openclMangledName(name());
// Pull out metadata from the ELF
size_t sizeOfArgList;
-3
Просмотреть файл
@@ -123,9 +123,6 @@ class HSAILKernel : public device::Kernel {
HSAILKernel& operator=(const HSAILKernel&);
protected:
//! Creates AQL kernel HW info
bool aqlCreateHWInfo();
//! Get the kernel code and copy the code object from the program CPU segment
bool setKernelCode(amd::hsa::loader::Symbol* sym, amd_kernel_code_t* akc);
+30 -27
Просмотреть файл
@@ -246,6 +246,34 @@ inline static std::vector<std::string> splitSpaceSeparatedString(char* str) {
bool HSAILProgram::createKernels(void* binary, size_t binSize, bool useUniformWorkGroupSize,
bool internalKernel) {
#if defined(WITH_COMPILER_LIB)
// Stop compilation if it is an offline device - PAL runtime does not
// support ISA compiled offline
if (!device().isOnline()) {
return true;
}
// ACL_TYPE_CG stage is not performed for offline compilation
executable_ = loader_->CreateExecutable(HSA_PROFILE_FULL, nullptr);
if (executable_ == nullptr) {
buildLog_ += "Error: Executable for AMD HSA Code Object isn't created.\n";
return false;
}
size_t size = binSize;
hsa_code_object_t code_object;
code_object.handle = reinterpret_cast<uint64_t>(binary);
hsa_agent_t agent = {amd::Device::toHandle(&(device()))};
hsa_status_t status = executable_->LoadCodeObject(agent, code_object, nullptr);
if (status != HSA_STATUS_SUCCESS) {
buildLog_ += "Error: AMD HSA Code Object loading failed.\n";
return false;
}
status = executable_->Freeze(nullptr);
if (status != HSA_STATUS_SUCCESS) {
buildLog_ += "Error: AMD HSA Code Object freeze failed.\n";
return false;
}
size_t kernelNamesSize = 0;
acl_error errorCode = amd::Hsail::QueryInfo(palNullDevice().compiler(), binaryElf_,
RT_KERNEL_NAMES, nullptr, nullptr, &kernelNamesSize);
@@ -278,6 +306,8 @@ bool HSAILProgram::createKernels(void* binary, size_t binSize, bool useUniformWo
aKernel->setUniformWorkGroupSize(useUniformWorkGroupSize);
}
}
DestroySegmentCpuAccess();
#endif // defined(WITH_COMPILER_LIB)
return true;
}
@@ -285,35 +315,10 @@ bool HSAILProgram::createKernels(void* binary, size_t binSize, bool useUniformWo
bool HSAILProgram::setKernels(void* binary, size_t binSize,
amd::Os::FileDesc fdesc, size_t foffset, std::string uri) {
#if defined(WITH_COMPILER_LIB)
// Stop compilation if it is an offline device - PAL runtime does not
// support ISA compiled offline
if (!device().isOnline()) {
return true;
}
// ACL_TYPE_CG stage is not performed for offline compilation
executable_ = loader_->CreateExecutable(HSA_PROFILE_FULL, nullptr);
if (executable_ == nullptr) {
buildLog_ += "Error: Executable for AMD HSA Code Object isn't created.\n";
return false;
}
size_t size = binSize;
hsa_code_object_t code_object;
code_object.handle = reinterpret_cast<uint64_t>(binary);
hsa_agent_t agent = {amd::Device::toHandle(&(device()))};
hsa_status_t status = executable_->LoadCodeObject(agent, code_object, nullptr);
if (status != HSA_STATUS_SUCCESS) {
buildLog_ += "Error: AMD HSA Code Object loading failed.\n";
return false;
}
status = executable_->Freeze(nullptr);
if (status != HSA_STATUS_SUCCESS) {
buildLog_ += "Error: AMD HSA Code Object freeze failed.\n";
return false;
}
bool dynamicParallelism = false;
for (auto& kit : kernels()) {
HSAILKernel* aKernel = static_cast<HSAILKernel*>(kit.second);
@@ -332,8 +337,6 @@ bool HSAILProgram::setKernels(void* binary, size_t binSize,
if (!isNull() && dynamicParallelism && !allocKernelTable()) {
return false;
}
DestroySegmentCpuAccess();
#endif // defined(WITH_COMPILER_LIB)
return true;
}