From 4f8410dbdb87648212ec04ac69a01d430d403525 Mon Sep 17 00:00:00 2001
From: foreman
Date: Wed, 30 Sep 2015 00:26:52 -0400
Subject: [PATCH] P4 to Git Change 1195643 by lnguyen@P4_LN on 2015/09/29
16:07:33
SWDEV-5 - Updated power strip table.
Affected files ...
... //depot/stg/opencl/drivers/opencl/tools/teamcity/server/scripts/teamcity.xml#49 edit
---
.../lib/backends/common/v0_8/if_acl.cpp | 29 ++++---------------
rocclr/compiler/lib/utils/options.cpp | 4 +--
rocclr/runtime/device/gpu/gpuprogram.cpp | 22 ++------------
rocclr/runtime/platform/program.cpp | 26 ++++++++---------
rocclr/runtime/platform/program.hpp | 2 +-
5 files changed, 22 insertions(+), 61 deletions(-)
diff --git a/rocclr/compiler/lib/backends/common/v0_8/if_acl.cpp b/rocclr/compiler/lib/backends/common/v0_8/if_acl.cpp
index 95139446ef..ed37aaef32 100644
--- a/rocclr/compiler/lib/backends/common/v0_8/if_acl.cpp
+++ b/rocclr/compiler/lib/backends/common/v0_8/if_acl.cpp
@@ -391,20 +391,14 @@ SPIRVToModule(
acl_error *error)
{
auto compiler = reinterpret_cast(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(cl, "SPIR-V not supported on legacy compiler lib");
+ appendLogToCL(compiler->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);
- /// 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(bin->options);
+ auto opt = compiler->Options();
if (opt->isDumpFlagSet(amd::option::DUMP_SPIRV)) {
std::ofstream ofs(opt->getDumpFileName(".spv"), std::ios::binary);
ofs << spvImg;
@@ -432,20 +426,14 @@ SPIRVToModule(
}
if (!errMsg.empty()) {
- appendLogToCL(cl, errMsg);
+ appendLogToCL(compiler->CL(), errMsg);
}
if (!success || llMod == nullptr) {
if (error != nullptr) (*error) = ACL_SPIRV_LOAD_FAIL;
return nullptr;
}
- llvm::SmallVector array;
- llvm::raw_svector_ostream outstream(array);
- llvm::WriteBitcodeToFile(reinterpret_cast(llMod), outstream);
- outstream.flush();
- auto errCode = cl->clAPI.insSec(cl, bin, &array[0], array.size(), aclLLVMIR);
- if (error != nullptr) (*error) = errCode;
-
+ if (error != nullptr) (*error) = ACL_SUCCESS;
return reinterpret_cast(llMod);
#endif // LEGACY_COMPLIB
}
@@ -1635,14 +1623,7 @@ 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) {
- if (to != ACL_TYPE_LLVMIR_BINARY)
- cl->feAPI.toModule = &SPIRVToModule;
- else {
- cl->feAPI.toISA = NULL;
- cl->feAPI.toIR = &SPIRVToModule;
- start = 0;
- stop = 1;
- }
+ cl->feAPI.toModule = &SPIRVToModule;
} else if (from == ACL_TYPE_RSLLVMIR_BINARY) {
cl->feAPI.toModule = &RSLLVMIRToModule;
} else {
diff --git a/rocclr/compiler/lib/utils/options.cpp b/rocclr/compiler/lib/utils/options.cpp
index 131cc56eda..f23ca1be32 100644
--- a/rocclr/compiler/lib/utils/options.cpp
+++ b/rocclr/compiler/lib/utils/options.cpp
@@ -1255,7 +1255,6 @@ Options::Options() :
oVariables(NULL),
clcOptions(),
llvmOptions(),
- kernelArgAlign(0),
basename_max(0),
OptionsLog(),
flagsSize (((OID_LAST + 31)/32) * 32),
@@ -1265,8 +1264,7 @@ Options::Options() :
dumpFileRoot(),
currKernelName(NULL),
encryptCode(0),
- MemoryHandles(),
- libraryType_(amd::LibraryUndefined)
+ MemoryHandles()
{
oVariables = new OptionVariables();
::memset(flags, 0, sizeof(flags));
diff --git a/rocclr/runtime/device/gpu/gpuprogram.cpp b/rocclr/runtime/device/gpu/gpuprogram.cpp
index 014de53f12..bff20bf113 100644
--- a/rocclr/runtime/device/gpu/gpuprogram.cpp
+++ b/rocclr/runtime/device/gpu/gpuprogram.cpp
@@ -1801,27 +1801,9 @@ HSAILProgram::linkImpl(
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 : \
+ 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_);
diff --git a/rocclr/runtime/platform/program.cpp b/rocclr/runtime/platform/program.cpp
index cf23e45f19..c579b7f6a1 100644
--- a/rocclr/runtime/platform/program.cpp
+++ b/rocclr/runtime/platform/program.cpp
@@ -43,8 +43,7 @@ Program::findSymbol(const char* kernelName) const
}
cl_int
-Program::addDeviceProgram(Device& device, const void* image, size_t length,
- bool hsail)
+Program::addDeviceProgram(Device& device, const void* image, size_t length, int oclVer)
{
if (image != NULL &&
!aclValidateBinaryImage(image, length,
@@ -64,7 +63,8 @@ Program::addDeviceProgram(Device& device, const void* image, size_t length,
return CL_SUCCESS;
}
- device::Program* program = rootDev.createProgram(hsail || isIL_);
+ bool hsail = (oclVer >= 200) || isIL_;
+ device::Program* program = rootDev.createProgram(hsail);
if (program == NULL) {
return CL_OUT_OF_HOST_MEMORY;
}
@@ -201,16 +201,15 @@ Program::compile(
device::Program* devProgram = getDeviceProgram(**it);
if (devProgram == NULL) {
const binary_t& bin = binary(**it);
- retval = addDeviceProgram(**it, bin.first, bin.second,
- GetOclCVersion(parsedOptions.oVariables->CLStd) >= 200);
+ const int oclVer = GetOclCVersion(parsedOptions.oVariables->CLStd);
+ retval = addDeviceProgram(**it, bin.first, bin.second, oclVer);
if (retval != CL_SUCCESS) {
return retval;
}
devProgram = getDeviceProgram(**it);
}
- if (devProgram->type() == device::Program::TYPE_INTERMEDIATE ||
- isIL_) {
+ if (devProgram->type() == device::Program::TYPE_INTERMEDIATE) {
continue;
}
// We only build a Device-Program once
@@ -301,10 +300,9 @@ Program::link(
// find the corresponding device program in each input program
std::vector inputDevPrograms(numInputs);
bool found = false;
- bool hsail = GetOclCVersion(parsedOptions.oVariables->CLStd) >= 200;
+ int maxOclVer = GetOclCVersion(parsedOptions.oVariables->CLStd);
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()) {
@@ -317,8 +315,10 @@ Program::link(
if (pos != std::string::npos) {
std::string clStd =
inputDevPrograms[i]->compileOptions().substr((pos+8), 5);
- hsail = hsail || GetOclCVersion(clStd.c_str()) >= 200;
+ int oclVer = GetOclCVersion(clStd.c_str());
+ maxOclVer = (maxOclVer > oclVer) ? maxOclVer : oclVer;
}
+
}
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, hsail);
+ retval = addDeviceProgram(**it, bin.first, bin.second, maxOclVer);
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,
- GetOclCVersion(parsedOptions.oVariables->CLStd) >= 200);
+ retval = addDeviceProgram(**it, bin.first, bin.second, oclVer);
if (retval != CL_SUCCESS) {
return retval;
}
diff --git a/rocclr/runtime/platform/program.hpp b/rocclr/runtime/platform/program.hpp
index e1fccc5054..16a070f4b5 100644
--- a/rocclr/runtime/platform/program.hpp
+++ b/rocclr/runtime/platform/program.hpp
@@ -139,7 +139,7 @@ public:
//! Add a binary image to this program.
cl_int addDeviceProgram(Device&, const void* image = NULL,
- size_t len = 0, bool hsail = false);
+ size_t len = 0, int oclVer = 120);
//! Find the section for the given device. Return NULL if not found.
device::Program* getDeviceProgram(const Device& device) const;