fix: earlier stopping of usm reuse cleaner thread

Usm cleaner needs to stop before usm reuse cleanup.

Related-To: HSD-18043613805

Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
This commit is contained in:
Dominik Dabek
2025-10-14 15:40:26 +00:00
committed by Compute-Runtime-Automation
parent f827cda964
commit f126203df3
4 changed files with 17 additions and 6 deletions

View File

@@ -49,9 +49,6 @@ ExecutionEnvironment::~ExecutionEnvironment() {
if (directSubmissionController) {
directSubmissionController->stopThread();
}
if (unifiedMemoryReuseCleaner) {
unifiedMemoryReuseCleaner->stopThread();
}
if (memoryManager) {
memoryManager->commonCleanup();
for (const auto &rootDeviceEnvironment : this->rootDeviceEnvironments) {
@@ -177,6 +174,9 @@ void ExecutionEnvironment::prepareRootDeviceEnvironments(uint32_t numRootDevices
}
void ExecutionEnvironment::prepareForCleanup() const {
if (unifiedMemoryReuseCleaner) {
unifiedMemoryReuseCleaner->stopThread();
}
for (auto &rootDeviceEnvironment : rootDeviceEnvironments) {
if (rootDeviceEnvironment) {
rootDeviceEnvironment->prepareForCleanup();

View File

@@ -27,7 +27,7 @@ class UnifiedMemoryReuseCleaner : NEO::NonCopyableAndNonMovableClass {
virtual ~UnifiedMemoryReuseCleaner();
MOCKABLE_VIRTUAL void startThread();
void stopThread();
MOCKABLE_VIRTUAL void stopThread();
static bool isSupported();

View File

@@ -22,15 +22,22 @@ struct MockUnifiedMemoryReuseCleaner : public UnifiedMemoryReuseCleaner {
UnifiedMemoryReuseCleaner::trimOldInCaches();
}
}
bool trimOldInCachesCalled = false;
bool callBaseTrimOldInCaches = true;
void startThread() override {
startThreadCalled = true;
if (callBaseStartThread) {
UnifiedMemoryReuseCleaner::startThread();
}
};
bool trimOldInCachesCalled = false;
bool startThreadCalled = false;
bool callBaseStartThread = false;
bool callBaseTrimOldInCaches = true;
void stopThread() override {
stopThreadCalled = true;
UnifiedMemoryReuseCleaner::stopThread();
};
bool stopThreadCalled = false;
};
} // namespace NEO

View File

@@ -314,6 +314,10 @@ TEST(SvmAllocationCacheSimpleTest, givenReuseCleanerWhenInsertingAllocationIntoC
EXPECT_TRUE(allocationCache.insert(1u, ptr, &svmAllocData, false));
EXPECT_TRUE(reuseCleaner->startThreadCalled);
EXPECT_FALSE(reuseCleaner->stopThreadCalled);
memoryManager.executionEnvironment.prepareForCleanup();
EXPECT_TRUE(reuseCleaner->stopThreadCalled);
allocationCache.allocations.clear();
svmAllocsManager.internalAllocationsMap.clear();
}