Files
compute-runtime/shared/source/page_fault_manager/cpu_page_fault_manager.h
Jaime Arteaga d46bb59508 Migrate shared-allocations made resident with makeMemoryResident
Shared-allocations are currently migrated to GPU by the page-fault
manager when calling executeCommandLists. Allocations to migrate are
taken from the lists container. However, if a shared-allocation
has been made resident with zeContextMakeMemoryResident(), it is not
added to the list container, and hence it is not migrated to device.

So, add a container of resident allocations to the driver and migrate
them along with the other allocations.

Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
2020-12-11 03:27:42 +01:00

62 lines
1.7 KiB
C++

/*
* Copyright (C) 2019-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/helpers/non_copyable_or_moveable.h"
#include "shared/source/utilities/spinlock.h"
#include "memory_properties_flags.h"
#include <memory>
#include <unordered_map>
namespace NEO {
class GraphicsAllocation;
class Device;
class SVMAllocsManager;
class PageFaultManager : public NonCopyableOrMovableClass {
public:
static std::unique_ptr<PageFaultManager> create();
virtual ~PageFaultManager() = default;
MOCKABLE_VIRTUAL void moveAllocationToGpuDomain(void *ptr);
void moveAllocationsWithinUMAllocsManagerToGpuDomain(SVMAllocsManager *unifiedMemoryManager);
void insertAllocation(void *ptr, size_t size, SVMAllocsManager *unifiedMemoryManager, void *cmdQ, const MemoryProperties &memoryProperties);
void removeAllocation(void *ptr);
enum class AllocationDomain {
None,
Cpu,
Gpu,
};
protected:
struct PageFaultData {
size_t size;
SVMAllocsManager *unifiedMemoryManager;
void *cmdQ;
AllocationDomain domain;
};
virtual void allowCPUMemoryAccess(void *ptr, size_t size) = 0;
virtual void protectCPUMemoryAccess(void *ptr, size_t size) = 0;
virtual void evictMemoryAfterImplCopy(GraphicsAllocation *allocation, Device *device) = 0;
MOCKABLE_VIRTUAL bool verifyPageFault(void *ptr);
MOCKABLE_VIRTUAL void transferToCpu(void *ptr, size_t size, void *cmdQ);
MOCKABLE_VIRTUAL void transferToGpu(void *ptr, void *cmdQ);
MOCKABLE_VIRTUAL void setAubWritable(bool writable, void *ptr, SVMAllocsManager *unifiedMemoryManager);
std::unordered_map<void *, PageFaultData> memoryData;
SpinLock mtx;
};
} // namespace NEO