P4 to Git Change 1196211 by nhaustov@nhaustov_hsa on 2015/10/01 08:27:23

SWDEV-76911 - Bug 11070: ViennaCL fails in amd::hsa::loader::Executable::Destroy

	Destructors of global variables run in undefined order, so loader cannot
	be global. Encapsulate loader functionality in Loader class and link its lifecycle
	to Runtime.
	In HSA Runtime, create Loader as part of Runtime singleton.
	In ORCA Runtime, create Loader as part of HSAILProgram class.

	Testing: smoke, pre-checkin

Affected files ...

... //depot/stg/opencl/drivers/opencl/compiler/sc/HSAIL/ext/amdhsacod/amdhsacod.cpp#10 integrate
... //depot/stg/opencl/drivers/opencl/compiler/sc/HSAIL/ext/loader/executable.cpp#12 integrate
... //depot/stg/opencl/drivers/opencl/compiler/sc/HSAIL/ext/loader/executable.hpp#8 integrate
... //depot/stg/opencl/drivers/opencl/compiler/sc/HSAIL/include/amd_hsa_loader.hpp#5 integrate
... //depot/stg/opencl/drivers/opencl/compiler/tools/aoc2/aoc2.cpp#78 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuprogram.cpp#210 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuprogram.hpp#61 edit
This commit is contained in:
foreman
2015-10-01 08:37:19 -04:00
parent 90efd5a216
commit f670ae2f8d
2 changed files with 8 additions and 2 deletions
+6 -2
View File
@@ -18,6 +18,7 @@
#include "utils/options.hpp"
#include "hsa.h"
#include "hsa_ext_image.h"
#include "amd_hsa_loader.hpp"
namespace gpu {
@@ -1670,6 +1671,7 @@ HSAILProgram::HSAILProgram(Device& device)
binOpts_.bitness = ELFDATA2LSB;
binOpts_.alloc = &::malloc;
binOpts_.dealloc = &::free;
loader_ = amd::hsa::loader::Loader::Create(&loaderContext_);
}
HSAILProgram::HSAILProgram(NullDevice& device)
@@ -1689,6 +1691,7 @@ HSAILProgram::HSAILProgram(NullDevice& device)
binOpts_.bitness = ELFDATA2LSB;
binOpts_.alloc = &::malloc;
binOpts_.dealloc = &::free;
loader_ = amd::hsa::loader::Loader::Create(&loaderContext_);
}
HSAILProgram::~HSAILProgram()
@@ -1710,9 +1713,10 @@ HSAILProgram::~HSAILProgram()
}
releaseClBinary();
if (executable_ != NULL) {
Executable::Destroy(executable_);
loader_->DestroyExecutable(executable_);
}
delete kernels_;
amd::hsa::loader::Loader::Destroy(loader_);
}
bool
@@ -2132,7 +2136,7 @@ HSAILProgram::linkImpl(amd::option::Options* options)
hsa_agent_t agent;
agent.handle = 1;
if (!isNull() && hsaLoad) {
executable_ = Executable::Create(HSA_PROFILE_BASE, &loaderContext_, NULL);
executable_ = loader_->CreateExecutable(HSA_PROFILE_BASE, NULL);
if (executable_ == NULL) {
buildLog_ += "Error: Executable for AMD HSA Code Object isn't created.\n";
return false;