P4 to Git Change 1483021 by lmoriche@lmoriche_opencl_dev2 on 2017/11/15 21:49:30

SWDEV-118564 - [OCL-LC-ROCm] Disable HSAILProgram and HSAILKernel if the compiler library is not available.

Affected files ...

... //depot/stg/opencl/drivers/opencl/opencldefs#222 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/device.cpp#214 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/roccompiler.cpp#39 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.cpp#76 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rockernel.cpp#31 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rockernel.hpp#18 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.cpp#76 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.hpp#31 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/program.cpp#89 edit
This commit is contained in:
foreman
2017-11-15 21:58:49 -05:00
rodzic 88783fe59b
commit 5ec0d059a3
8 zmienionych plików z 40 dodań i 2 usunięć
@@ -46,6 +46,7 @@ static void logFunction(const char* msg, size_t size) {
static int programsCount = 0;
#if defined(WITH_COMPILER_LIB)
bool HSAILProgram::compileImpl(const std::string& sourceCode,
const std::vector<const std::string*>& headers,
const char** headerIncludeNames, amd::option::Options* options) {
@@ -160,6 +161,7 @@ bool HSAILProgram::compileImpl(const std::string& sourceCode,
saveBinaryAndSetType(TYPE_COMPILED);
return true;
}
#endif // defined(WITH_COMPILER_LIB)
#if defined(WITH_LIGHTNING_COMPILER)
bool LightningProgram::compileImpl(const std::string& sourceCode,
@@ -190,6 +190,7 @@ Device::~Device() {
}
}
bool NullDevice::initCompiler(bool isOffline) {
#if defined(WITH_COMPILER_LIB)
// Initialize the compiler handle if has already not been initialized
// This is destroyed in Device::teardown
acl_error error;
@@ -207,10 +208,12 @@ bool NullDevice::initCompiler(bool isOffline) {
#endif // !defined(WITH_LIGHTNING_COMPILER)
}
}
#endif // defined(WITH_COMPILER_LIB)
return true;
}
bool NullDevice::destroyCompiler() {
#if defined(WITH_COMPILER_LIB)
if (compilerHandle_ != nullptr) {
acl_error error = aclCompilerFini(compilerHandle_);
if (error != ACL_SUCCESS) {
@@ -218,6 +221,7 @@ bool NullDevice::destroyCompiler() {
return false;
}
}
#endif // defined(WITH_COMPILER_LIB)
return true;
}
@@ -665,7 +669,11 @@ bool Device::create() {
}
device::Program* NullDevice::createProgram(amd::option::Options* options) {
#if defined(WITH_COMPILER_LIB)
return new roc::HSAILProgram(*this);
#else // !defined(WITH_COMPILER_LIB)
return NULL;
#endif // !defined(WITH_COMPILER_LIB)
}
device::Program* Device::createProgram(amd::option::Options* options) {
@@ -674,7 +682,9 @@ device::Program* Device::createProgram(amd::option::Options* options) {
return new roc::LightningProgram(*this);
}
#endif // defined(WITH_LIGHTNING_COMPILER)
#if defined(WITH_COMPILER_LIB)
return new roc::HSAILProgram(*this);
#endif // defined(WITH_COMPILER_LIB)
}
hsa_status_t Device::iterateGpuMemoryPoolCallback(hsa_amd_memory_pool_t pool, void* data) {
@@ -498,6 +498,7 @@ static inline cl_kernel_arg_type_qualifier GetOclTypeQual(const aclArgData* argI
return rv;
}
#if defined(WITH_COMPILER_LIB)
void HSAILKernel::initArguments(const aclArgData* aclArg) {
device::Kernel::parameters_t params;
@@ -560,6 +561,7 @@ void HSAILKernel::initArguments(const aclArgData* aclArg) {
}
createSignature(params);
}
#endif // defined(WITH_COMPILER_LIB)
#if defined(WITH_LIGHTNING_COMPILER)
void LightningKernel::initArguments(const KernelMD& kernelMD) {
@@ -726,6 +728,7 @@ bool LightningKernel::init() {
}
#endif // defined(WITH_LIGHTNING_COMPILER)
#if defined(WITH_COMPILER_LIB)
bool HSAILKernel::init() {
acl_error errorCode;
// compile kernel down to ISA
@@ -830,6 +833,7 @@ bool HSAILKernel::init() {
}
return true;
}
#endif // defined(WITH_COMPILER_LIB)
#if defined(WITH_LIGHTNING_COMPILER)
void LightningKernel::initPrintf(const std::vector<std::string>& printfInfoStrings) {
@@ -923,6 +927,7 @@ void LightningKernel::initPrintf(const std::vector<std::string>& printfInfoStrin
}
#endif // defined(WITH_LIGHTNING_COMPILER)
#if defined(WITH_COMPILER_LIB)
void HSAILKernel::initPrintf(const aclPrintfFmt* aclPrintf) {
PrintfInfo info;
uint index = 0;
@@ -986,7 +991,7 @@ void HSAILKernel::initPrintf(const aclPrintfFmt* aclPrintf) {
info.arguments_.clear();
}
}
#endif // defined(WITH_COMPILER_LIB)
Kernel::~Kernel() {
while (!hsailArgList_.empty()) {
@@ -148,6 +148,7 @@ class Kernel : public device::Kernel {
std::vector<PrintfInfo> printf_;
};
#if defined(WITH_COMPILER_LIB)
class HSAILKernel : public roc::Kernel {
public:
HSAILKernel(std::string name, Program* prog, const uint64_t& kernelCodeHandle,
@@ -169,6 +170,7 @@ class HSAILKernel : public roc::Kernel {
//! Initializes HSAIL Printf metadata and info
void initPrintf(const aclPrintfFmt* aclPrintf);
};
#endif // defined(WITH_COMPILER_LIB)
#if defined(WITH_LIGHTNING_COMPILER)
class LightningKernel : public roc::Kernel {
+10 -1
Wyświetl plik
@@ -190,6 +190,7 @@ aclType Program::getNextCompilationStageFromBinary(amd::option::Options* options
binary_t binary = this->binary();
// If the binary already exists
if ((binary.first != nullptr) && (binary.second > 0)) {
#if defined(WITH_COMPILER_LIB)
if (aclValidateBinaryImage(binary.first, binary.second, BINARY_TYPE_ELF)) {
acl_error errorCode;
binaryElf_ = aclReadFromMem(binary.first, binary.second, &errorCode);
@@ -198,6 +199,7 @@ aclType Program::getNextCompilationStageFromBinary(amd::option::Options* options
return continueCompileFrom;
}
}
#endif // defined(WITH_COMPILER_LIB)
// save the current options
std::string sCurCompileOptions = compileOptions_;
@@ -227,6 +229,7 @@ aclType Program::getNextCompilationStageFromBinary(amd::option::Options* options
if (compileOptions_.empty()) break;
std::string sBinOptions;
#if defined(WITH_COMPILER_LIB)
if (binaryElf_ != nullptr) {
const oclBIFSymbolStruct* symbol = findBIF30SymStruct(symOpenclCompilerOptions);
assert(symbol && "symbol not found");
@@ -242,7 +245,9 @@ aclType Program::getNextCompilationStageFromBinary(amd::option::Options* options
break;
}
sBinOptions = std::string((char*)opts, symSize);
} else {
} else
#endif // defined(WITH_COMPILER_LIB)
{
sBinOptions = sCurOptions;
}
@@ -282,6 +287,7 @@ aclType Program::getNextCompilationStageFromBinary(amd::option::Options* options
return continueCompileFrom;
}
#if defined(WITH_COMPILER_LIB)
std::string HSAILProgram::codegenOptions(amd::option::Options* options) {
std::string optionsStr;
@@ -294,6 +300,7 @@ std::string HSAILProgram::codegenOptions(amd::option::Options* options) {
return optionsStr;
}
#endif // defined(WITH_COMPILER_LIB)
std::string Program::preprocessorOptions(amd::option::Options* options) {
std::string optionsStr;
@@ -368,6 +375,7 @@ std::string Program::preprocessorOptions(amd::option::Options* options) {
return optionsStr;
}
#if defined(WITH_COMPILER_LIB)
HSAILProgram::HSAILProgram(roc::NullDevice& device) : roc::Program(device) {
}
@@ -816,6 +824,7 @@ bool HSAILProgram::linkImpl(amd::option::Options* options) {
buildLog_ += aclGetCompilerLog(device().compiler());
return true;
}
#endif // defined(WITH_COMPILER_LIB)
#if defined(WITH_LIGHTNING_COMPILER)
LightningProgram::LightningProgram(roc::NullDevice& device) : roc::Program(device) {
@@ -122,6 +122,7 @@ protected:
hsa_code_object_reader_t hsaCodeObjectReader_; //!< Handle to HSA code reader
};
#if defined(WITH_COMPILER_LIB)
class HSAILProgram : public roc::Program {
public:
HSAILProgram(roc::NullDevice& device);
@@ -149,6 +150,7 @@ private:
bool saveBinaryAndSetType(type_t type);
};
#endif // defined(WITH_COMPILER_LIB)
#if defined(WITH_LIGHTNING_COMPILER)
class LightningProgram : public roc::Program {