2022-08-03 00:08:54 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2022 Intel Corporation
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "shared/source/memory_manager/prefetch_manager.h"
|
|
|
|
|
|
|
|
#include "shared/source/device/device.h"
|
|
|
|
#include "shared/source/memory_manager/unified_memory_manager.h"
|
|
|
|
|
|
|
|
namespace NEO {
|
|
|
|
|
|
|
|
std::unique_ptr<PrefetchManager> PrefetchManager::create() {
|
|
|
|
return std::make_unique<PrefetchManager>();
|
|
|
|
}
|
|
|
|
|
2022-11-22 20:33:16 +08:00
|
|
|
void PrefetchManager::insertAllocation(PrefetchContext &context, SvmAllocationData &svmData) {
|
|
|
|
std::unique_lock<SpinLock> lock{context.lock};
|
2022-08-03 00:08:54 +08:00
|
|
|
if (svmData.memoryType == InternalMemoryType::SHARED_UNIFIED_MEMORY) {
|
2022-11-22 20:33:16 +08:00
|
|
|
context.allocations.push_back(svmData);
|
2022-08-03 00:08:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-22 20:33:16 +08:00
|
|
|
void PrefetchManager::migrateAllocationsToGpu(PrefetchContext &context, SVMAllocsManager &unifiedMemoryManager, Device &device) {
|
|
|
|
std::unique_lock<SpinLock> lock{context.lock};
|
|
|
|
for (auto allocData : context.allocations) {
|
2022-08-03 00:08:54 +08:00
|
|
|
unifiedMemoryManager.prefetchMemory(device, allocData);
|
|
|
|
}
|
2022-11-22 20:33:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void PrefetchManager::removeAllocations(PrefetchContext &context) {
|
|
|
|
std::unique_lock<SpinLock> lock{context.lock};
|
|
|
|
context.allocations.clear();
|
2022-08-03 00:08:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace NEO
|