feature: Implement appendMemoryPrefetch for Shared System USM allocations

Related-To: NEO-12989

Signed-off-by: John Falkowski <john.falkowski@intel.com>
This commit is contained in:
John Falkowski
2025-03-12 22:47:22 +00:00
committed by Compute-Runtime-Automation
parent cb68ada102
commit 4d281cf51d
29 changed files with 579 additions and 141 deletions

View File

@@ -16,20 +16,22 @@ std::unique_ptr<PrefetchManager> PrefetchManager::create() {
return std::make_unique<PrefetchManager>();
}
void PrefetchManager::insertAllocation(PrefetchContext &context, const void *usmPtr, SvmAllocationData &allocData) {
void PrefetchManager::insertAllocation(PrefetchContext &context, SVMAllocsManager &unifiedMemoryManager, Device &device, const void *usmPtr, const size_t size) {
std::unique_lock<SpinLock> lock{context.lock};
if (allocData.memoryType == InternalMemoryType::sharedUnifiedMemory) {
context.allocations.push_back(usmPtr);
auto allocData = unifiedMemoryManager.getSVMAlloc(usmPtr);
if (!allocData) {
if (device.areSharedSystemAllocationsAllowed()) {
context.allocations.push_back({usmPtr, size});
}
} else if (allocData->memoryType == InternalMemoryType::sharedUnifiedMemory) {
context.allocations.push_back({usmPtr, size});
}
}
void PrefetchManager::migrateAllocationsToGpu(PrefetchContext &context, SVMAllocsManager &unifiedMemoryManager, Device &device, CommandStreamReceiver &csr) {
std::unique_lock<SpinLock> lock{context.lock};
for (auto &ptr : context.allocations) {
auto allocData = unifiedMemoryManager.getSVMAlloc(ptr);
if (allocData) {
unifiedMemoryManager.prefetchMemory(device, csr, *allocData);
}
for (auto &allocation : context.allocations) {
unifiedMemoryManager.prefetchMemory(device, csr, allocation.ptr, allocation.size);
}
}