P4 to Git Change 1195721 by yaxunl@yaxunl_stg_win50 on 2015/09/29 20:02:58

SWDEV-77154 - SPIR-V: runtime change for separate compile/link of SPIR-V module.

Affected files ...

... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_program.cpp#38 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuprogram.cpp#209 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/program.cpp#71 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/program.hpp#34 edit
This commit is contained in:
foreman
2015-09-30 00:42:49 -04:00
والد 4f8410dbdb
کامیت 2994854677
3فایلهای تغییر یافته به همراه34 افزوده شده و 16 حذف شده
@@ -1801,9 +1801,27 @@ HSAILProgram::linkImpl(
const void *llvmirText = aclExtractSection(dev().hsaCompiler(),
binaryElf_, &llvmirSize, aclLLVMIR, &errorCode);
if (errorCode != ACL_SUCCESS) {
buildLog_ +="Error while linking : \
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;
return false;
}
}
// Create a new aclBinary for each LLVMIR and save it in a list
aclBIFVersion ver = aclBinaryVersion(binaryElf_);
@@ -43,7 +43,8 @@ Program::findSymbol(const char* kernelName) const
}
cl_int
Program::addDeviceProgram(Device& device, const void* image, size_t length, int oclVer)
Program::addDeviceProgram(Device& device, const void* image, size_t length,
bool hsail)
{
if (image != NULL &&
!aclValidateBinaryImage(image, length,
@@ -63,8 +64,7 @@ Program::addDeviceProgram(Device& device, const void* image, size_t length, int
return CL_SUCCESS;
}
bool hsail = (oclVer >= 200) || isIL_;
device::Program* program = rootDev.createProgram(hsail);
device::Program* program = rootDev.createProgram(hsail || isIL_);
if (program == NULL) {
return CL_OUT_OF_HOST_MEMORY;
}
@@ -201,15 +201,16 @@ Program::compile(
device::Program* devProgram = getDeviceProgram(**it);
if (devProgram == NULL) {
const binary_t& bin = binary(**it);
const int oclVer = GetOclCVersion(parsedOptions.oVariables->CLStd);
retval = addDeviceProgram(**it, bin.first, bin.second, oclVer);
retval = addDeviceProgram(**it, bin.first, bin.second,
GetOclCVersion(parsedOptions.oVariables->CLStd) >= 200);
if (retval != CL_SUCCESS) {
return retval;
}
devProgram = getDeviceProgram(**it);
}
if (devProgram->type() == device::Program::TYPE_INTERMEDIATE) {
if (devProgram->type() == device::Program::TYPE_INTERMEDIATE ||
isIL_) {
continue;
}
// We only build a Device-Program once
@@ -300,9 +301,10 @@ Program::link(
// find the corresponding device program in each input program
std::vector<device::Program*> inputDevPrograms(numInputs);
bool found = false;
int maxOclVer = GetOclCVersion(parsedOptions.oVariables->CLStd);
bool hsail = GetOclCVersion(parsedOptions.oVariables->CLStd) >= 200;
for (size_t i = 0; i < numInputs; ++i) {
Program& inputProgram = *inputPrograms[i];
hsail = hsail || inputProgram.isIL_;
deviceprograms_t inputDevProgs = inputProgram.devicePrograms();
deviceprograms_t::const_iterator findIt = inputDevProgs.find(*it);
if (findIt == inputDevProgs.end()) {
@@ -315,10 +317,8 @@ Program::link(
if (pos != std::string::npos) {
std::string clStd =
inputDevPrograms[i]->compileOptions().substr((pos+8), 5);
int oclVer = GetOclCVersion(clStd.c_str());
maxOclVer = (maxOclVer > oclVer) ? maxOclVer : oclVer;
hsail = hsail || GetOclCVersion(clStd.c_str()) >= 200;
}
}
if (inputDevPrograms.size() == 0) {
continue;
@@ -330,7 +330,7 @@ Program::link(
device::Program* devProgram = getDeviceProgram(**it);
if (devProgram == NULL) {
const binary_t& bin = binary(**it);
retval = addDeviceProgram(**it, bin.first, bin.second, maxOclVer);
retval = addDeviceProgram(**it, bin.first, bin.second, hsail);
if (retval != CL_SUCCESS) {
return retval;
}
@@ -455,12 +455,12 @@ Program::build(
device::Program* devProgram = getDeviceProgram(**it);
if (devProgram == NULL) {
const binary_t& bin = binary(**it);
const int oclVer = GetOclCVersion(parsedOptions.oVariables->CLStd);
if (sourceCode_.empty() && (bin.first == NULL)) {
retval = false;
continue;
}
retval = addDeviceProgram(**it, bin.first, bin.second, oclVer);
retval = addDeviceProgram(**it, bin.first, bin.second,
GetOclCVersion(parsedOptions.oVariables->CLStd) >= 200);
if (retval != CL_SUCCESS) {
return retval;
}
@@ -139,7 +139,7 @@ public:
//! Add a binary image to this program.
cl_int addDeviceProgram(Device&, const void* image = NULL,
size_t len = 0, int oclVer = 120);
size_t len = 0, bool hsail = false);
//! Find the section for the given device. Return NULL if not found.
device::Program* getDeviceProgram(const Device& device) const;