P4 to Git Change 1308882 by lmoriche@lmoriche_opencl_dev on 2016/08/30 17:43:27
SWDEV-101678 - Create a new instance of the ROCm-OpenCL-Driver for each call to compileImpl and linkImpl.
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/device.cpp#202 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/roccompiler.cpp#11 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.cpp#12 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.hpp#5 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.cpp#18 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.hpp#9 edit
[ROCm/clr commit: bac3dbc7a8]
This commit is contained in:
@@ -44,6 +44,10 @@
|
||||
#include <iostream>
|
||||
#include <istream>
|
||||
|
||||
#if defined(ATI_OS_LINUX)
|
||||
#include <dlfcn.h>
|
||||
#include <libgen.h>
|
||||
#endif // defined(ATI_OS_LINUX)
|
||||
|
||||
#endif // WITHOUT_HSA_BACKEND
|
||||
|
||||
@@ -485,7 +489,7 @@ namespace roc {
|
||||
bool createLibrary)
|
||||
{
|
||||
using namespace amd::opencl_driver;
|
||||
Compiler* C = device().compiler();
|
||||
std::auto_ptr<Compiler> C(newCompilerInstance());
|
||||
|
||||
std::vector<Data*> inputs;
|
||||
for (auto program : (const std::vector<HSAILProgram*>&)inputPrograms) {
|
||||
@@ -727,7 +731,7 @@ namespace roc {
|
||||
bool HSAILProgram::linkImpl_LC(amd::option::Options *options)
|
||||
{
|
||||
using namespace amd::opencl_driver;
|
||||
Compiler* C = device().compiler();
|
||||
std::auto_ptr<Compiler> C(newCompilerInstance());
|
||||
|
||||
// call LinkLLVMBitcode
|
||||
std::vector<Data*> inputs;
|
||||
@@ -1463,6 +1467,49 @@ namespace roc {
|
||||
}
|
||||
return hsailOptions;
|
||||
}
|
||||
|
||||
#if defined(WITH_LIGHTNING_COMPILER)
|
||||
|
||||
static std::string llvmBin_(amd::Os::getEnvironment("LLVM_BIN"));
|
||||
|
||||
#if defined(ATI_OS_LINUX)
|
||||
static pthread_once_t once = PTHREAD_ONCE_INIT;
|
||||
|
||||
static void
|
||||
checkLLVM_BIN()
|
||||
{
|
||||
if (llvmBin_.empty()) {
|
||||
Dl_info info;
|
||||
if (dladdr((const void*)&amd::Device::init, &info)) {
|
||||
llvmBin_ = dirname(strdup(info.dli_fname));
|
||||
size_t pos = llvmBin_.rfind("lib");
|
||||
if (pos != std::string::npos) {
|
||||
llvmBin_.replace(pos, 3, "bin");
|
||||
}
|
||||
}
|
||||
}
|
||||
#if defined(DEBUG)
|
||||
std::string clangExe(llvmBin_ + "/clang");
|
||||
struct stat buf;
|
||||
if (stat(clangExe.c_str(), &buf)) {
|
||||
std::string msg("Could not find the Clang binary in " + llvmBin_);
|
||||
LogWarning(msg.c_str());
|
||||
}
|
||||
#endif // defined(DEBUG)
|
||||
}
|
||||
#endif // defined(ATI_OS_LINUX)
|
||||
|
||||
std::auto_ptr<amd::opencl_driver::Compiler>
|
||||
HSAILProgram::newCompilerInstance()
|
||||
{
|
||||
#if defined(ATI_OS_LINUX)
|
||||
pthread_once(&once, checkLLVM_BIN);
|
||||
#endif // defined(ATI_OS_LINUX)
|
||||
return std::auto_ptr<amd::opencl_driver::Compiler>(
|
||||
amd::opencl_driver::CompilerFactory().CreateAMDGPUCompiler(llvmBin_));
|
||||
}
|
||||
#endif // defined(WITH_LIGHTNING_COMPILER)
|
||||
|
||||
#endif // WITHOUT_HSA_BACKEND
|
||||
} // namespace roc
|
||||
|
||||
|
||||
Reference in New Issue
Block a user