2
0

P4 to Git Change 1195730 by smekhano@stas-rampitec-hsa on 2015/09/29 20:53:01

SWDEV-77584 - HSA HLC: fixed reflection metadata generation on HSAIL OCL 1.2 path
	We are producing 6 extra arguments, but metadata was produced only for 3.
	Removed KE_OCL12_NUM_ARGS define to avoid confusion.

	Testing: smoke, precheckin
	Reviewed by Yaxun Liu

Affected files ...

... //depot/stg/opencl/drivers/opencl/compiler/llvm/include/llvm/AMDOpenCLKernenv.h#4 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Transforms/Scalar/AMDInsertOpenCLKernenv.cpp#10 edit
Este cometimento está contido em:
foreman
2015-09-30 00:10:02 -04:00
ascendente 1eab831776
cometimento fa3fd90fb0
5 ficheiros modificados com 61 adições e 22 eliminações
+24 -5
Ver ficheiro
@@ -391,14 +391,20 @@ SPIRVToModule(
acl_error *error)
{
auto compiler = reinterpret_cast<amdcl::LLVMCompilerStage*>(ald);
auto cl = compiler->CL();
auto bin = compiler->Elf();
#ifdef LEGACY_COMPLIB
llvm::report_fatal_error("SPIR-V not supported on legacy compiler lib");
appendLogToCL(compiler->CL(), "SPIR-V not supported on legacy compiler lib");
appendLogToCL(cl, "SPIR-V not supported on legacy compiler lib");
if (error != nullptr) (*error) = ACL_SPIRV_LOAD_FAIL;
return nullptr;
#else
std::string spvImg(image, length);
auto opt = compiler->Options();
/// ToDo: When there are multiple binaries, compiler->Options()
/// cannot carry options specified by environment variables to here
/// but bin->options can. This seems to be related to how runtime
/// sets up aclCompiler options and BIF options.
auto opt = reinterpret_cast<amd::option::Options*>(bin->options);
if (opt->isDumpFlagSet(amd::option::DUMP_SPIRV)) {
std::ofstream ofs(opt->getDumpFileName(".spv"), std::ios::binary);
ofs << spvImg;
@@ -426,14 +432,20 @@ SPIRVToModule(
}
if (!errMsg.empty()) {
appendLogToCL(compiler->CL(), errMsg);
appendLogToCL(cl, errMsg);
}
if (!success || llMod == nullptr) {
if (error != nullptr) (*error) = ACL_SPIRV_LOAD_FAIL;
return nullptr;
}
if (error != nullptr) (*error) = ACL_SUCCESS;
llvm::SmallVector<char, 4096> array;
llvm::raw_svector_ostream outstream(array);
llvm::WriteBitcodeToFile(reinterpret_cast<llvm::Module*>(llMod), outstream);
outstream.flush();
auto errCode = cl->clAPI.insSec(cl, bin, &array[0], array.size(), aclLLVMIR);
if (error != nullptr) (*error) = errCode;
return reinterpret_cast<aclModule*>(llMod);
#endif // LEGACY_COMPLIB
}
@@ -1623,7 +1635,14 @@ if_aclCompile(aclCompiler *cl,
CONDITIONAL_CMP_ASSIGN(cl->feAPI.fini, &AMDILFini, &OCLFini);
CONDITIONAL_CMP_ASSIGN(cl->feAPI.fini, &HSAILFEFini, &OCLFini);
if (from == ACL_TYPE_SPIRV_BINARY) {
cl->feAPI.toModule = &SPIRVToModule;
if (to != ACL_TYPE_LLVMIR_BINARY)
cl->feAPI.toModule = &SPIRVToModule;
else {
cl->feAPI.toISA = NULL;
cl->feAPI.toIR = &SPIRVToModule;
start = 0;
stop = 1;
}
} else if (from == ACL_TYPE_RSLLVMIR_BINARY) {
cl->feAPI.toModule = &RSLLVMIRToModule;
} else {
+3 -1
Ver ficheiro
@@ -1255,6 +1255,7 @@ Options::Options() :
oVariables(NULL),
clcOptions(),
llvmOptions(),
kernelArgAlign(0),
basename_max(0),
OptionsLog(),
flagsSize (((OID_LAST + 31)/32) * 32),
@@ -1264,7 +1265,8 @@ Options::Options() :
dumpFileRoot(),
currKernelName(NULL),
encryptCode(0),
MemoryHandles()
MemoryHandles(),
libraryType_(amd::LibraryUndefined)
{
oVariables = new OptionVariables();
::memset(flags, 0, sizeof(flags));
+20 -2
Ver ficheiro
@@ -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_);
+13 -13
Ver ficheiro
@@ -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;
}
+1 -1
Ver ficheiro
@@ -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;