SWDEV-444670 - Enable teardown class
Force implicit runtime teardown with a global destructor. Change-Id: Iabe63dedf5b94fefc98668585c45a61607120669
This commit is contained in:
@@ -1521,7 +1521,6 @@ bool SvmBuffer::Contains(uintptr_t ptr) {
|
||||
// The allocation flags are ignored for now.
|
||||
void* SvmBuffer::malloc(Context& context, cl_svm_mem_flags flags, size_t size, size_t alignment,
|
||||
const amd::Device* curDev) {
|
||||
bool atomics = (flags & CL_MEM_SVM_ATOMICS) != 0;
|
||||
void* ret = context.svmAlloc(size, alignment, flags, curDev);
|
||||
if (ret == nullptr) {
|
||||
LogError("Unable to allocate aligned memory");
|
||||
|
||||
@@ -100,11 +100,24 @@ void Runtime::tearDown() {
|
||||
initialized_ = false;
|
||||
}
|
||||
|
||||
class RuntimeTearDown : public amd::HeapObject {
|
||||
public:
|
||||
RuntimeTearDown() {}
|
||||
~RuntimeTearDown() { /*Runtime::tearDown();*/ }
|
||||
} runtime_tear_down;
|
||||
std::vector<ReferenceCountedObject*> RuntimeTearDown::external_;
|
||||
|
||||
RuntimeTearDown::~RuntimeTearDown() {
|
||||
#ifndef _WIN32
|
||||
if (amd::IS_HIP) {
|
||||
for (auto it: external_) {
|
||||
it->release();
|
||||
}
|
||||
Runtime::tearDown();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void RuntimeTearDown::RegisterObject(ReferenceCountedObject* obj) {
|
||||
external_.push_back(obj);
|
||||
}
|
||||
|
||||
class RuntimeTearDown runtime_tear_down;
|
||||
|
||||
uint ReferenceCountedObject::retain() {
|
||||
return referenceCount_.fetch_add(1, std::memory_order_relaxed) + 1;
|
||||
|
||||
@@ -91,6 +91,16 @@ public:
|
||||
|
||||
inline bool Runtime::initialized() { return initialized_; }
|
||||
|
||||
class RuntimeTearDown : public HeapObject {
|
||||
static std::vector<ReferenceCountedObject*> external_;
|
||||
|
||||
public:
|
||||
RuntimeTearDown() {}
|
||||
~RuntimeTearDown();
|
||||
|
||||
static void RegisterObject(ReferenceCountedObject* obj);
|
||||
};
|
||||
|
||||
} // namespace amd
|
||||
|
||||
#endif /*RUNTIME_HPP_*/
|
||||
|
||||
Reference in New Issue
Block a user