P4 to Git Change 1611613 by gandryey@gera-w8 on 2018/09/27 12:54:08
SWDEV-79445 - OCL generic changes and code clean-up Program compilation clean-up. Step#5: - Move the first linkImpl() method to the abstraciton layer. Utilize the new method in GPU/PAL/ROCr backends Affected files ... ... //depot/stg/opencl/drivers/opencl/runtime/device/devprogram.cpp#7 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/devprogram.hpp#5 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuprogram.cpp#244 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuprogram.hpp#77 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palprogram.cpp#78 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palprogram.hpp#34 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.cpp#90 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.hpp#39 edit
Этот коммит содержится в:
@@ -1610,94 +1610,6 @@ bool HSAILProgram::finiBuild(bool isBuildGood) {
|
||||
return device::Program::finiBuild(isBuildGood);
|
||||
}
|
||||
|
||||
bool HSAILProgram::linkImpl(const std::vector<device::Program*>& inputPrograms,
|
||||
amd::option::Options* options, bool createLibrary) {
|
||||
auto it = inputPrograms.cbegin();
|
||||
const auto itEnd = inputPrograms.cend();
|
||||
acl_error errorCode;
|
||||
|
||||
// For each program we need to extract the LLVMIR and create
|
||||
// aclBinary for each
|
||||
std::vector<aclBinary*> binaries_to_link;
|
||||
|
||||
for (size_t i = 0; it != itEnd; ++it, ++i) {
|
||||
HSAILProgram* program = (HSAILProgram*)*it;
|
||||
// Check if the program was created with clCreateProgramWIthBinary
|
||||
binary_t binary = program->binary();
|
||||
if ((binary.first != NULL) && (binary.second > 0)) {
|
||||
// Binary already exists -- we can also check if there is no
|
||||
// opencl source code
|
||||
// Need to check if LLVMIR exists in the binary
|
||||
// If LLVMIR does not exist then is it valid
|
||||
// We need to pull out all the compiled kernels
|
||||
// We cannot do this at present because we need at least
|
||||
// Hsail text to pull the kernels oout
|
||||
void* mem = const_cast<void*>(binary.first);
|
||||
binaryElf_ = aclReadFromMem(mem, binary.second, &errorCode);
|
||||
if (errorCode != ACL_SUCCESS) {
|
||||
LogWarning("Error while linking : Could not read from raw binary");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// At this stage each HSAILProgram contains a valid binary_elf
|
||||
// Check if LLVMIR is in the binary
|
||||
// @TODO - Memory leak , cannot free this buffer
|
||||
// need to fix this.. File EPR on compiler library
|
||||
size_t llvmirSize = 0;
|
||||
const void* llvmirText =
|
||||
aclExtractSection(dev().hsaCompiler(), binaryElf_, &llvmirSize, aclLLVMIR, &errorCode);
|
||||
if (errorCode != ACL_SUCCESS) {
|
||||
bool spirv = false;
|
||||
size_t boolSize = sizeof(bool);
|
||||
errorCode =
|
||||
aclQueryInfo(dev().hsaCompiler(), binaryElf_, RT_CONTAINS_SPIRV, NULL, &spirv, &boolSize);
|
||||
if (errorCode != ACL_SUCCESS) {
|
||||
spirv = false;
|
||||
}
|
||||
if (spirv) {
|
||||
errorCode = aclCompile(dev().hsaCompiler(), binaryElf_, options->origOptionStr.c_str(),
|
||||
ACL_TYPE_SPIRV_BINARY, ACL_TYPE_LLVMIR_BINARY, NULL);
|
||||
buildLog_ += aclGetCompilerLog(dev().hsaCompiler());
|
||||
if (errorCode != ACL_SUCCESS) {
|
||||
buildLog_ += "Error while linking: Could not load SPIR-V";
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
buildLog_ +=
|
||||
"Error while linking : \
|
||||
Invalid binary (Missing LLVMIR section)";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Create a new aclBinary for each LLVMIR and save it in a list
|
||||
aclBIFVersion ver = aclBinaryVersion(binaryElf_);
|
||||
aclBinary* bin = aclCreateFromBinary(binaryElf_, ver);
|
||||
binaries_to_link.push_back(bin);
|
||||
}
|
||||
|
||||
errorCode = aclLink(dev().hsaCompiler(), binaries_to_link[0], binaries_to_link.size() - 1,
|
||||
binaries_to_link.size() > 1 ? &binaries_to_link[1] : NULL,
|
||||
ACL_TYPE_LLVMIR_BINARY, "-create-library", NULL);
|
||||
if (errorCode != ACL_SUCCESS) {
|
||||
buildLog_ += aclGetCompilerLog(dev().hsaCompiler());
|
||||
buildLog_ += "Error while linking : aclLink failed";
|
||||
return false;
|
||||
}
|
||||
// Store the newly linked aclBinary for this program.
|
||||
binaryElf_ = binaries_to_link[0];
|
||||
// Free all the other aclBinaries
|
||||
for (size_t i = 1; i < binaries_to_link.size(); i++) {
|
||||
aclBinaryFini(binaries_to_link[i]);
|
||||
}
|
||||
if (createLibrary) {
|
||||
saveBinaryAndSetType(TYPE_LIBRARY);
|
||||
buildLog_ += aclGetCompilerLog(dev().hsaCompiler());
|
||||
return true;
|
||||
}
|
||||
// Now call linkImpl with the new options
|
||||
return linkImpl(options);
|
||||
}
|
||||
|
||||
inline static std::vector<std::string> splitSpaceSeparatedString(char* str) {
|
||||
std::string s(str);
|
||||
std::stringstream ss(s);
|
||||
|
||||
Ссылка в новой задаче
Block a user