SWDEV-459610 - Skip destruction for the child process

Fork() duplicates all system memory resources, but runtime can't duplicate
GPU resources. Thus, avoid tearDown() calls for the child process(s).

Change-Id: Id6b12bacd5112b9ad3747c218e09cba98ea1b42c
This commit is contained in:
German Andryeyev
2024-06-05 16:02:04 -04:00
committed by Maneesh Gupta
vanhempi 3a5cbb91b9
commit ae2992ea43
2 muutettua tiedostoa jossa 10 lisäystä ja 4 poistoa
+5 -1
Näytä tiedosto
@@ -47,6 +47,7 @@ namespace amd {
volatile bool Runtime::initialized_ = false;
bool Runtime::LibraryDetached = false;
volatile int Runtime::pid_ = 0;
bool Runtime::init() {
if (initialized_) {
@@ -80,6 +81,7 @@ bool Runtime::init() {
}
initialized_ = true;
pid_ = amd::Os::getProcessId();
ClTrace(LOG_DEBUG, LOG_INIT);
return true;
}
@@ -104,7 +106,9 @@ std::vector<ReferenceCountedObject*> RuntimeTearDown::external_;
RuntimeTearDown::~RuntimeTearDown() {
#ifndef _WIN32
if (amd::IS_HIP) {
// Only perform destruction if process matches the initialization,
// to avoid a call with the child process after fork()
if (amd::IS_HIP && amd::Os::getProcessId() == Runtime::pid()) {
for (auto it: external_) {
it->release();
}