P4 to Git Change 1358063 by wchau@wchau_OCL_boltzmann on 2017/01/03 16:44:42

SWDEV-102698 - [OCL-LC-ROCm] Add code caching support to OpenCL program manager

Affected files ...

... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/build/Makefile.api#146 edit
... //depot/stg/opencl/drivers/opencl/compiler/tools/Makefile#20 edit
... //depot/stg/opencl/drivers/opencl/runtime/build/Makefile.runtime#65 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/device.cpp#205 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#280 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/build/Makefile.oclrocm#10 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/roccompiler.cpp#25 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.cpp#30 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.hpp#10 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.cpp#49 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.hpp#17 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocsettings.cpp#10 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocsettings.hpp#4 edit
... //depot/stg/opencl/drivers/opencl/runtime/utils/flags.hpp#261 edit
This commit is contained in:
foreman
2017-01-03 16:56:06 -05:00
vanhempi b48cac624d
commit b9916d35f4
9 muutettua tiedostoa jossa 336 lisäystä ja 26 poistoa
@@ -195,19 +195,20 @@ HSAILProgram::compileImpl_LC(
return false;
}
driverOptions.append(" -include-pch " + pch->Name());
driverOptions.append(" -Xclang -fno-validate-pch");
// save the options for caching before including the temporary header file for amdgcn
std::string cacheOpts = driverOptions + std::to_string(clcStd);
driverOptions.append(" -include-pch " + pch->Name());
// Tokenize the options string into a vector of strings
std::istringstream istrstr(driverOptions);
std::istream_iterator<std::string> sit(istrstr), end;
std::vector<std::string> params(sit, end);
// Compile source to IR
bool ret = C->CompileToLLVMBitcode(inputs, output, params);
buildLog_ += C->Output();
if (!ret) {
buildLog_ += "Error: Failed to compile opencl source (from CL to LLVM IR).\n";
if (!dev().cacheCompilation()->compileToLLVMBitcode(C.get(), inputs, output, params, cacheOpts)) {
buildLog_ += dev().cacheCompilation()->buildLog();
return false;
}
@@ -296,7 +296,7 @@ bool NullDevice::init() {
bool isOnline = false;
//Check if the particular device is online
for (unsigned int i=0; i< devices.size(); i++) {
if (static_cast<NullDevice*>(devices[i])->deviceInfo_.hsaDeviceId_ ==
if (static_cast<NullDevice*>(devices[i])->deviceInfo_.hsaDeviceId_ ==
DeviceInfo[id].hsaDeviceId_){
isOnline = true;
}
@@ -588,6 +588,29 @@ Device::mapHSADeviceToOpenCLDevice(hsa_agent_t dev)
}
}
#if defined(WITH_LIGHTNING_COMPILER)
// create compilation object with cache support
int gfxipMajor = deviceInfo_.gfxipVersion_ / 100;
int gfxipMinor = deviceInfo_.gfxipVersion_ / 10 % 10;
int gfxipStepping = deviceInfo_.gfxipVersion_ % 10;
// Use compute capability as target (AMD:AMDGPU:major:minor:stepping)
// with dash as delimiter to be compatible with Windows directory name
std::ostringstream cacheTarget;
cacheTarget << "AMD-AMDGPU-" << gfxipMajor << "-" << gfxipMinor << "-" << gfxipStepping;
amd::CacheCompilation* compObj = new amd::CacheCompilation(cacheTarget.str(),
"_rocm",
hsaSettings->enableCodeCache_,
hsaSettings->resetCodeCache_);
if (!compObj) {
LogError("Unable to create cache compilation object!");
return false;
}
cacheCompilation_.reset(compObj);
#endif
return true;
}
@@ -1076,7 +1099,7 @@ Device::bindExternalDevice(
#else
if((flags&amd::Context::GLDeviceKhr)==0)
return false;
MesaInterop::MESA_INTEROP_KIND kind=MesaInterop::MESA_INTEROP_NONE;
MesaInterop::DisplayHandle display;
MesaInterop::ContextHandle context;
@@ -80,6 +80,8 @@ public:
Compiler* compiler() const { return compilerHandle_; }
const Settings &settings() const { return reinterpret_cast<Settings &>(*settings_); }
//! Construct an HSAIL program object from the ELF assuming it is valid
virtual device::Program *createProgram(amd::option::Options* options = NULL);
const AMDDeviceInfo& deviceInfo() const {
@@ -193,6 +195,10 @@ public:
return false;
}
#if defined(WITH_LIGHTNING_COMPILER)
amd::CacheCompilation* cacheCompilation() const { return cacheCompilation_.get(); }
#endif
protected:
//! Initialize compiler instance and handle
static bool initCompiler(bool isOffline);
@@ -202,6 +208,10 @@ protected:
static Compiler* compilerHandle_;
//! Device Id for an HsaDevice
AMDDeviceInfo deviceInfo_;
#if defined(WITH_LIGHTNING_COMPILER)
//! Compilation with cache support
std::unique_ptr<amd::CacheCompilation> cacheCompilation_;
#endif
private:
static const bool offlineDevice_;
};
@@ -329,8 +339,6 @@ public:
virtual void svmFree(void* ptr) const;
const Settings &settings() const { return reinterpret_cast<Settings &>(*settings_); }
//! Returns transfer engine object
const device::BlitManager& xferMgr() const { return xferQueue()->blitMgr(); }
@@ -531,10 +531,8 @@ HSAILProgram::linkImpl_LC(
}
std::vector<std::string> linkOptions;
bool ret = C->LinkLLVMBitcode(inputs, output, linkOptions);
buildLog_ += C->Output();
if (!ret) {
buildLog_ += "Error: Linking bitcode failed: linking source & IR libraries.\n";
if (!dev().cacheCompilation()->linkLLVMBitcode(C.get(), inputs, output, linkOptions, "")) {
buildLog_ += dev().cacheCompilation()->buildLog();
return false;
}
@@ -770,10 +768,8 @@ HSAILProgram::linkImpl_LC(amd::option::Options *options)
return false;
}
bool ret = C->LinkLLVMBitcode(inputs, linked_bc, linkOptions);
buildLog_ += C->Output();
if (!ret) {
buildLog_ += "Error: Linking bitcode failed: linking source & IR libraries.\n";
if (!dev().cacheCompilation()->linkLLVMBitcode(C.get(), inputs, linked_bc, linkOptions, "")) {
buildLog_ += dev().cacheCompilation()->buildLog();
return false;
}
@@ -812,10 +808,9 @@ HSAILProgram::linkImpl_LC(amd::option::Options *options)
std::istream_iterator<std::string> sit(strstr), end;
std::vector<std::string> params(sit, end);
ret = C->CompileAndLinkExecutable(inputs, out_exec, params);
buildLog_ += C->Output();
if (!ret) {
buildLog_ += "Error: Creating the executable failed: Compiling LLVM IRs to exe.\n";
if (!dev().cacheCompilation()->compileAndLinkExecutable(C.get(), inputs, out_exec, params,
codegenOptions)) {
buildLog_ += dev().cacheCompilation()->buildLog();
return false;
}
@@ -54,6 +54,14 @@ Settings::Settings()
partialDispatch_ = (partialDispatch) ? false : true;
commandQueues_ = 100; //!< Field value set to maximum number
//!< concurrent Virtual GPUs for ROCm backend
// Determine if user is requesting code caching for
// compiling and linking when using Lightening Compiler
enableCodeCache_ = OCL_CODE_CACHE_ENABLE;
// Determine if user is requesting reset the code cache
// storage (note that code cache must be enable)
resetCodeCache_ = OCL_CODE_CACHE_RESET;
}
bool
@@ -26,7 +26,9 @@ public:
uint enableImageHandle_: 1; //!< Use HSAIL image/sampler pointer
uint enableNCMode_: 1; //!< Enable Non Coherent mode for system memory
uint enablePartialDispatch_: 1; //!< Enable support for Partial Dispatch
uint reserved_: 26;
uint enableCodeCache_: 1; //!< Enable support for compiler code cache
uint resetCodeCache_: 1; //!< Reset the compiler code cache storage
uint reserved_: 24;
};
uint value_;
};