mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-30 18:37:46 +08:00
fix: use condition variables instead of busy waits in worker threads
Resolves: NEO-16085, GSD-11678, HSD-14025819208 Signed-off-by: Igor Venevtsev <igor.venevtsev@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
a817bf0920
commit
db0b4a616c
@@ -67,7 +67,7 @@ bool SVMAllocsManager::SvmAllocationCache::insert(size_t size, void *ptr, SvmAll
|
||||
return false;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(this->mtx);
|
||||
std::unique_lock<std::mutex> lock(this->mtx);
|
||||
if (svmData->device ? svmData->device->shouldLimitAllocationsReuse() : memoryManager->shouldLimitAllocationsReuse()) {
|
||||
return false;
|
||||
}
|
||||
@@ -99,8 +99,11 @@ bool SVMAllocsManager::SvmAllocationCache::insert(size_t size, void *ptr, SvmAll
|
||||
}
|
||||
svmData->isSavedForReuse = true;
|
||||
allocations.emplace(std::lower_bound(allocations.begin(), allocations.end(), size), size, ptr, svmData, waitForCompletion);
|
||||
if (memoryManager->peekExecutionEnvironment().unifiedMemoryReuseCleaner) {
|
||||
memoryManager->peekExecutionEnvironment().unifiedMemoryReuseCleaner->startThread();
|
||||
empty = false;
|
||||
if (auto usmReuseCleaner = this->memoryManager->peekExecutionEnvironment().unifiedMemoryReuseCleaner.get()) {
|
||||
lock.unlock();
|
||||
usmReuseCleaner->startThread();
|
||||
usmReuseCleaner->notifySvmAllocationsCacheUpdate();
|
||||
}
|
||||
}
|
||||
if (enablePerformanceLogging) {
|
||||
@@ -110,6 +113,7 @@ bool SVMAllocsManager::SvmAllocationCache::insert(size_t size, void *ptr, SvmAll
|
||||
.operationType = CacheOperationType::insert,
|
||||
.isSuccess = isSuccess});
|
||||
}
|
||||
|
||||
return isSuccess;
|
||||
}
|
||||
|
||||
@@ -181,6 +185,7 @@ void *SVMAllocsManager::SvmAllocationCache::get(size_t size, const UnifiedMemory
|
||||
svmAllocsManager->reinsertToAllocsForIndirectAccess(*allocationIter->svmData);
|
||||
}
|
||||
allocations.erase(allocationIter);
|
||||
empty = allocations.empty();
|
||||
return allocationPtr;
|
||||
}
|
||||
}
|
||||
@@ -215,6 +220,7 @@ void SVMAllocsManager::SvmAllocationCache::trim() {
|
||||
svmAllocsManager->freeSVMAllocImpl(cachedAllocationInfo.allocation, FreePolicyType::none, cachedAllocationInfo.svmData);
|
||||
}
|
||||
this->allocations.clear();
|
||||
empty = true;
|
||||
}
|
||||
|
||||
void SVMAllocsManager::SvmAllocationCache::cleanup() {
|
||||
@@ -299,6 +305,7 @@ void SVMAllocsManager::SvmAllocationCache::trimOldAllocs(std::chrono::high_resol
|
||||
if (trimAll) {
|
||||
std::erase_if(allocations, SvmCacheAllocationInfo::isMarkedForDelete);
|
||||
}
|
||||
empty = allocations.empty();
|
||||
}
|
||||
|
||||
SvmAllocationData *SVMAllocsManager::MapBasedAllocationTracker::get(const void *ptr) {
|
||||
|
||||
Reference in New Issue
Block a user