mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 09:14:47 +08:00
feature: Add CPU side USM allocation to trim candidate list on page fault
Enable eviction of CPU side USM allocation for UMD migrations on Windows. Reverts incorrect auto-revert commit 218de586a4f28b1de3e983b9006e7a99d3a4d10e. Related-To: NEO-8015 Signed-off-by: Milczarek, Slawomir <slawomir.milczarek@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
6656e23b86
commit
027c51d396
@@ -113,6 +113,7 @@ void PageFaultManager::transferAndUnprotectMemory(PageFaultManager *pageFaultHan
|
||||
pageFaultHandler->migrateStorageToCpuDomain(allocPtr, pageFaultData);
|
||||
pageFaultHandler->allowCPUMemoryAccess(allocPtr, pageFaultData.size);
|
||||
pageFaultHandler->setCpuAllocEvictable(true, allocPtr, pageFaultData.unifiedMemoryManager);
|
||||
pageFaultHandler->allowCPUMemoryEviction(allocPtr, pageFaultData);
|
||||
}
|
||||
|
||||
void PageFaultManager::unprotectAndTransferMemory(PageFaultManager *pageFaultHandler, void *allocPtr, PageFaultData &pageFaultData) {
|
||||
|
||||
@@ -15,9 +15,11 @@
|
||||
|
||||
namespace NEO {
|
||||
struct MemoryProperties;
|
||||
class CommandStreamReceiver;
|
||||
class GraphicsAllocation;
|
||||
class Device;
|
||||
class SVMAllocsManager;
|
||||
class OSInterface;
|
||||
|
||||
class PageFaultManager : public NonCopyableOrMovableClass {
|
||||
public:
|
||||
@@ -53,11 +55,13 @@ class PageFaultManager : public NonCopyableOrMovableClass {
|
||||
|
||||
protected:
|
||||
virtual void evictMemoryAfterImplCopy(GraphicsAllocation *allocation, Device *device) = 0;
|
||||
virtual void allowCPUMemoryEvictionImpl(void *ptr, CommandStreamReceiver &csr, OSInterface *osInterface) = 0;
|
||||
|
||||
MOCKABLE_VIRTUAL bool verifyPageFault(void *ptr);
|
||||
MOCKABLE_VIRTUAL void transferToGpu(void *ptr, void *cmdQ);
|
||||
MOCKABLE_VIRTUAL void setAubWritable(bool writable, void *ptr, SVMAllocsManager *unifiedMemoryManager);
|
||||
MOCKABLE_VIRTUAL void setCpuAllocEvictable(bool evictable, void *ptr, SVMAllocsManager *unifiedMemoryManager);
|
||||
MOCKABLE_VIRTUAL void allowCPUMemoryEviction(void *ptr, PageFaultData &pageFaultData);
|
||||
|
||||
static void transferAndUnprotectMemory(PageFaultManager *pageFaultHandler, void *alloc, PageFaultData &pageFaultData);
|
||||
static void unprotectAndTransferMemory(PageFaultManager *pageFaultHandler, void *alloc, PageFaultData &pageFaultData);
|
||||
|
||||
@@ -84,6 +84,8 @@ void PageFaultManagerLinux::evictMemoryAfterImplCopy(GraphicsAllocation *allocat
|
||||
if (evictMemoryAfterCopy) {
|
||||
device->getRootDeviceEnvironment().memoryOperationsInterface->evict(device, *allocation);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void PageFaultManagerLinux::allowCPUMemoryEvictionImpl(void *ptr, CommandStreamReceiver &csr, OSInterface *osInterface) {}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -25,6 +25,7 @@ class PageFaultManagerLinux : public PageFaultManager {
|
||||
void protectCPUMemoryAccess(void *ptr, size_t size) override;
|
||||
|
||||
void evictMemoryAfterImplCopy(GraphicsAllocation *allocation, Device *device) override;
|
||||
void allowCPUMemoryEvictionImpl(void *ptr, CommandStreamReceiver &csr, OSInterface *osInterface) override;
|
||||
|
||||
void callPreviousHandler(int signal, siginfo_t *info, void *context);
|
||||
bool previousHandlerRestored = false;
|
||||
|
||||
@@ -7,7 +7,12 @@
|
||||
|
||||
#include "shared/source/page_fault_manager/windows/cpu_page_fault_manager_windows.h"
|
||||
|
||||
#include "shared/source/command_stream/command_stream_receiver.h"
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/source/helpers/debug_helpers.h"
|
||||
#include "shared/source/memory_manager/unified_memory_manager.h"
|
||||
#include "shared/source/os_interface/os_interface.h"
|
||||
#include "shared/source/os_interface/windows/os_context_win.h"
|
||||
|
||||
namespace NEO {
|
||||
std::unique_ptr<PageFaultManager> PageFaultManager::create() {
|
||||
@@ -56,4 +61,16 @@ void PageFaultManagerWindows::protectCPUMemoryAccess(void *ptr, size_t size) {
|
||||
|
||||
void PageFaultManagerWindows::evictMemoryAfterImplCopy(GraphicsAllocation *allocation, Device *device) {}
|
||||
|
||||
void PageFaultManagerWindows::allowCPUMemoryEvictionImpl(void *ptr, CommandStreamReceiver &csr, OSInterface *osInterface) {
|
||||
NEO::SvmAllocationData *allocData = memoryData[ptr].unifiedMemoryManager->getSVMAlloc(ptr);
|
||||
UNRECOVERABLE_IF(allocData == nullptr);
|
||||
|
||||
if (osInterface) {
|
||||
auto &residencyController = static_cast<OsContextWin *>(&csr.getOsContext())->getResidencyController();
|
||||
|
||||
auto lock = residencyController.acquireLock();
|
||||
residencyController.addToTrimCandidateList(allocData->cpuAllocation);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -26,6 +26,7 @@ class PageFaultManagerWindows : public PageFaultManager {
|
||||
void protectCPUMemoryAccess(void *ptr, size_t size) override;
|
||||
|
||||
void evictMemoryAfterImplCopy(GraphicsAllocation *allocation, Device *device) override;
|
||||
void allowCPUMemoryEvictionImpl(void *ptr, CommandStreamReceiver &csr, OSInterface *osInterface) override;
|
||||
|
||||
static std::function<LONG(struct _EXCEPTION_POINTERS *exceptionInfo)> pageFaultHandler;
|
||||
PVOID previousHandler;
|
||||
|
||||
Reference in New Issue
Block a user