SWDEV-280473 - Remove HSAIL support from the ROCm backend
In adition to removing the HSAIL logic from the ROCm backend, guard all of the HSAIL includes in the common layer behind the WITH_COMPILER_LIB define. This is to avoid including HSAIL headers when building with no support for it. In common logic replace the use of the aclType enum with the new Program::file_type_t enum. This is essentially a local copy of the HSAIL enum to avoid including any HSAIL headers. Change-Id: Ica0651d1b29dfccc255cc584eb82a5cb35e1b520
This commit is contained in:
@@ -174,118 +174,5 @@ bool LightningKernel::init() {
|
||||
}
|
||||
#endif // defined(USE_COMGR_LIBRARY)
|
||||
|
||||
#if defined(WITH_COMPILER_LIB)
|
||||
bool HSAILKernel::init() {
|
||||
acl_error errorCode;
|
||||
// Pull out metadata from the ELF
|
||||
size_t sizeOfArgList;
|
||||
aclCompiler* compileHandle = program()->rocDevice().compiler();
|
||||
std::string openClKernelName("&__OpenCL_" + name() + "_kernel");
|
||||
errorCode = aclQueryInfo(compileHandle, program()->binaryElf(), RT_ARGUMENT_ARRAY,
|
||||
openClKernelName.c_str(), nullptr, &sizeOfArgList);
|
||||
if (errorCode != ACL_SUCCESS) {
|
||||
LogPrintfError("Query Info failed with error code: %d \n", errorCode);
|
||||
return false;
|
||||
}
|
||||
std::unique_ptr<char[]> argList(new char[sizeOfArgList]);
|
||||
errorCode = aclQueryInfo(compileHandle, program()->binaryElf(), RT_ARGUMENT_ARRAY,
|
||||
openClKernelName.c_str(), argList.get(), &sizeOfArgList);
|
||||
if (errorCode != ACL_SUCCESS) {
|
||||
LogPrintfError("Query Info failed with error code: %d \n", errorCode);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set the argList
|
||||
InitParameters((const aclArgData*)argList.get(), KernargSegmentByteSize());
|
||||
|
||||
// Set the workgroup information for the kernel
|
||||
memset(&workGroupInfo_, 0, sizeof(workGroupInfo_));
|
||||
workGroupInfo_.availableLDSSize_ = program()->rocDevice().info().localMemSizePerCU_;
|
||||
assert(workGroupInfo_.availableLDSSize_ > 0);
|
||||
workGroupInfo_.availableSGPRs_ = 104;
|
||||
workGroupInfo_.availableVGPRs_ = 256;
|
||||
size_t sizeOfWorkGroupSize;
|
||||
errorCode = aclQueryInfo(compileHandle, program()->binaryElf(), RT_WORK_GROUP_SIZE,
|
||||
openClKernelName.c_str(), nullptr, &sizeOfWorkGroupSize);
|
||||
if (errorCode != ACL_SUCCESS) {
|
||||
LogPrintfError("Query Info failed with error code: %d \n", errorCode);
|
||||
return false;
|
||||
}
|
||||
errorCode = aclQueryInfo(compileHandle, program()->binaryElf(), RT_WORK_GROUP_SIZE,
|
||||
openClKernelName.c_str(), workGroupInfo_.compileSize_,
|
||||
&sizeOfWorkGroupSize);
|
||||
if (errorCode != ACL_SUCCESS) {
|
||||
LogPrintfError("Query Info failed with error code: %d \n ", errorCode);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t wavefront_size = 0;
|
||||
hsa_status_t hsaStatus = hsa_agent_get_info(program()->rocDevice().getBackendDevice(),
|
||||
HSA_AGENT_INFO_WAVEFRONT_SIZE, &wavefront_size);
|
||||
if (HSA_STATUS_SUCCESS != hsaStatus) {
|
||||
DevLogPrintfError("Could not get Wave Info Size: %d, failed with hsa_status: %d \n",
|
||||
errorCode, hsaStatus);
|
||||
return false;
|
||||
}
|
||||
assert(wavefront_size > 0);
|
||||
|
||||
// Setting it the same as used LDS.
|
||||
workGroupInfo_.localMemSize_ = workgroupGroupSegmentByteSize_;
|
||||
workGroupInfo_.privateMemSize_ = workitemPrivateSegmentByteSize_;
|
||||
workGroupInfo_.usedLDSSize_ = workgroupGroupSegmentByteSize_;
|
||||
workGroupInfo_.preferredSizeMultiple_ = wavefront_size;
|
||||
|
||||
// Query kernel header object to initialize the number of
|
||||
// SGPR's and VGPR's used by the kernel
|
||||
const void* kernelHostPtr = nullptr;
|
||||
if (Device::loaderQueryHostAddress(reinterpret_cast<const void*>(kernelCodeHandle_),
|
||||
&kernelHostPtr) == HSA_STATUS_SUCCESS) {
|
||||
auto akc = reinterpret_cast<const amd_kernel_code_t*>(kernelHostPtr);
|
||||
workGroupInfo_.usedSGPRs_ = akc->wavefront_sgpr_count;
|
||||
workGroupInfo_.usedVGPRs_ = akc->workitem_vgpr_count;
|
||||
} else {
|
||||
workGroupInfo_.usedSGPRs_ = 0;
|
||||
workGroupInfo_.usedVGPRs_ = 0;
|
||||
}
|
||||
|
||||
workGroupInfo_.usedStackSize_ = 0;
|
||||
workGroupInfo_.wavefrontPerSIMD_ = program()->rocDevice().info().maxWorkItemSizes_[0] / wavefront_size;
|
||||
workGroupInfo_.wavefrontSize_ = wavefront_size;
|
||||
if (workGroupInfo_.compileSize_[0] != 0) {
|
||||
workGroupInfo_.size_ = workGroupInfo_.compileSize_[0] * workGroupInfo_.compileSize_[1] *
|
||||
workGroupInfo_.compileSize_[2];
|
||||
} else {
|
||||
workGroupInfo_.size_ = program()->rocDevice().info().preferredWorkGroupSize_;
|
||||
}
|
||||
|
||||
// Pull out printf metadata from the ELF
|
||||
size_t sizeOfPrintfList;
|
||||
errorCode = aclQueryInfo(compileHandle, program()->binaryElf(), RT_GPU_PRINTF_ARRAY,
|
||||
openClKernelName.c_str(), nullptr, &sizeOfPrintfList);
|
||||
if (errorCode != ACL_SUCCESS) {
|
||||
LogPrintfError("Query Info failed with error code: %d \n", errorCode);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Make sure kernel has any printf info
|
||||
if (0 != sizeOfPrintfList) {
|
||||
std::unique_ptr<char[]> aclPrintfList(new char[sizeOfPrintfList]);
|
||||
if (!aclPrintfList) {
|
||||
return false;
|
||||
}
|
||||
errorCode = aclQueryInfo(compileHandle, program()->binaryElf(),
|
||||
RT_GPU_PRINTF_ARRAY, openClKernelName.c_str(),
|
||||
aclPrintfList.get(), &sizeOfPrintfList);
|
||||
if (errorCode != ACL_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set the Printf List
|
||||
InitPrintf(reinterpret_cast<aclPrintfFmt*>(aclPrintfList.get()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif // defined(WITH_COMPILER_LIB)
|
||||
|
||||
} // namespace roc
|
||||
#endif // WITHOUT_HSA_BACKEND
|
||||
|
||||
مرجع در شماره جدید
Block a user