2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2021-05-16 20:51:16 +02:00
|
|
|
* Copyright (C) 2018-2021 Intel Corporation
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
2018-09-17 14:03:37 +02:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/command_stream/preemption_mode.h"
|
|
|
|
|
#include "shared/source/helpers/aligned_memory.h"
|
|
|
|
|
#include "shared/source/helpers/bit_helpers.h"
|
|
|
|
|
#include "shared/source/helpers/common_types.h"
|
|
|
|
|
#include "shared/source/helpers/engine_control.h"
|
2020-08-27 08:55:09 +02:00
|
|
|
#include "shared/source/helpers/heap_assigner.h"
|
|
|
|
|
#include "shared/source/helpers/hw_helper.h"
|
2021-05-27 13:37:06 +00:00
|
|
|
#include "shared/source/memory_manager/alignment_selector.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/memory_manager/allocation_properties.h"
|
|
|
|
|
#include "shared/source/memory_manager/gfx_partition.h"
|
|
|
|
|
#include "shared/source/memory_manager/graphics_allocation.h"
|
|
|
|
|
#include "shared/source/memory_manager/host_ptr_defines.h"
|
|
|
|
|
#include "shared/source/memory_manager/local_memory_usage.h"
|
2021-10-06 23:22:22 +00:00
|
|
|
#include "shared/source/memory_manager/memadvise_flags.h"
|
2020-08-21 13:10:59 +02:00
|
|
|
#include "shared/source/memory_manager/multi_graphics_allocation.h"
|
2021-05-25 15:37:44 +00:00
|
|
|
#include "shared/source/os_interface/os_interface.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/page_fault_manager/cpu_page_fault_manager.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
|
2018-11-26 14:04:52 +01:00
|
|
|
#include "engine_node.h"
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2019-03-13 15:00:07 +01:00
|
|
|
#include <bitset>
|
2017-12-21 00:45:38 +01:00
|
|
|
#include <cstdint>
|
|
|
|
|
#include <mutex>
|
2018-07-22 19:27:33 +02:00
|
|
|
#include <vector>
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2017-12-21 00:45:38 +01:00
|
|
|
class DeferredDeleter;
|
2018-10-01 16:10:54 +02:00
|
|
|
class ExecutionEnvironment;
|
2018-12-20 16:58:15 +01:00
|
|
|
class Gmm;
|
2018-10-24 08:46:54 +02:00
|
|
|
class HostPtrManager;
|
2018-10-22 16:43:20 +02:00
|
|
|
class OsContext;
|
2018-12-20 16:58:15 +01:00
|
|
|
|
2018-07-05 16:31:57 +02:00
|
|
|
enum AllocationUsage {
|
2017-12-21 00:45:38 +01:00
|
|
|
TEMPORARY_ALLOCATION,
|
|
|
|
|
REUSABLE_ALLOCATION
|
|
|
|
|
};
|
|
|
|
|
|
2018-01-22 16:43:26 +01:00
|
|
|
struct AlignedMallocRestrictions {
|
|
|
|
|
uintptr_t minAddress;
|
|
|
|
|
};
|
|
|
|
|
|
2020-07-01 10:38:19 +02:00
|
|
|
struct AddressRange {
|
|
|
|
|
uint64_t address;
|
|
|
|
|
size_t size;
|
|
|
|
|
};
|
|
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
constexpr size_t paddingBufferSize = 2 * MemoryConstants::megaByte;
|
|
|
|
|
|
2020-10-09 11:52:00 +02:00
|
|
|
namespace MemoryTransferHelper {
|
|
|
|
|
bool transferMemoryToAllocation(bool useBlitter, const Device &device, GraphicsAllocation *dstAllocation, size_t dstOffset, const void *srcMemory, size_t srcSize);
|
2021-10-29 03:53:31 +02:00
|
|
|
}
|
2020-10-09 11:52:00 +02:00
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
class MemoryManager {
|
|
|
|
|
public:
|
2018-02-28 12:09:48 +01:00
|
|
|
enum AllocationStatus {
|
|
|
|
|
Success = 0,
|
|
|
|
|
Error,
|
|
|
|
|
InvalidHostPointer,
|
2018-07-18 09:48:21 +02:00
|
|
|
RetryInNonDevicePool
|
2018-02-28 12:09:48 +01:00
|
|
|
};
|
|
|
|
|
|
2019-03-15 10:22:35 +01:00
|
|
|
MemoryManager(ExecutionEnvironment &executionEnvironment);
|
2020-09-18 16:19:41 +02:00
|
|
|
bool isInitialized() const { return initialized; }
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
|
virtual ~MemoryManager();
|
2018-01-26 16:53:18 +01:00
|
|
|
MOCKABLE_VIRTUAL void *allocateSystemMemory(size_t size, size_t alignment);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2018-05-08 10:00:23 +02:00
|
|
|
virtual void addAllocationToHostPtrManager(GraphicsAllocation *memory) = 0;
|
|
|
|
|
virtual void removeAllocationFromHostPtrManager(GraphicsAllocation *memory) = 0;
|
|
|
|
|
|
2018-12-14 11:24:45 +01:00
|
|
|
MOCKABLE_VIRTUAL GraphicsAllocation *allocateGraphicsMemoryWithProperties(const AllocationProperties &properties) {
|
2019-04-04 07:49:33 +02:00
|
|
|
return allocateGraphicsMemoryInPreferredPool(properties, nullptr);
|
2018-11-30 11:01:33 +01:00
|
|
|
}
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2019-04-03 09:08:10 +02:00
|
|
|
MOCKABLE_VIRTUAL GraphicsAllocation *allocateGraphicsMemoryWithProperties(const AllocationProperties &properties, const void *ptr) {
|
2019-04-04 07:49:33 +02:00
|
|
|
return allocateGraphicsMemoryInPreferredPool(properties, ptr);
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
2020-09-30 22:21:42 -07:00
|
|
|
GraphicsAllocation *allocateInternalGraphicsMemoryWithHostCopy(uint32_t rootDeviceIndex, DeviceBitfield bitField, const void *ptr, size_t size);
|
|
|
|
|
|
2019-12-12 11:51:23 +01:00
|
|
|
MOCKABLE_VIRTUAL GraphicsAllocation *allocateGraphicsMemoryInPreferredPool(const AllocationProperties &properties, const void *hostPtr);
|
2018-07-09 14:12:32 +02:00
|
|
|
|
2020-07-31 16:52:41 +02:00
|
|
|
virtual bool verifyHandle(osHandle handle, uint32_t rootDeviceIndex, bool) { return true; }
|
2021-05-24 06:14:30 +00:00
|
|
|
virtual GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation) = 0;
|
2021-03-18 15:16:58 +00:00
|
|
|
virtual void closeSharedHandle(GraphicsAllocation *graphicsAllocation){};
|
2021-08-10 12:00:59 +00:00
|
|
|
virtual GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, GraphicsAllocation::AllocationType allocType) = 0;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2019-11-06 18:14:30 +01:00
|
|
|
virtual bool mapAuxGpuVA(GraphicsAllocation *graphicsAllocation);
|
2018-01-25 15:10:07 +01:00
|
|
|
|
2019-01-24 11:51:33 +01:00
|
|
|
void *lockResource(GraphicsAllocation *graphicsAllocation);
|
|
|
|
|
void unlockResource(GraphicsAllocation *graphicsAllocation);
|
2021-05-06 14:15:19 +00:00
|
|
|
MOCKABLE_VIRTUAL bool peek32bit() {
|
|
|
|
|
return is32bit;
|
|
|
|
|
}
|
|
|
|
|
MOCKABLE_VIRTUAL bool isLimitedGPU(uint32_t rootDeviceIndex) {
|
|
|
|
|
return peek32bit() && !peekExecutionEnvironment().rootDeviceEnvironments[rootDeviceIndex]->isFullRangeSvm();
|
|
|
|
|
}
|
|
|
|
|
MOCKABLE_VIRTUAL bool isLimitedGPUOnType(uint32_t rootDeviceIndex, GraphicsAllocation::AllocationType type) {
|
|
|
|
|
return isLimitedGPU(rootDeviceIndex) &&
|
|
|
|
|
(type != GraphicsAllocation::AllocationType::MAP_ALLOCATION) &&
|
|
|
|
|
(type != GraphicsAllocation::AllocationType::IMAGE);
|
|
|
|
|
}
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
|
void cleanGraphicsMemoryCreatedFromHostPtr(GraphicsAllocation *);
|
|
|
|
|
GraphicsAllocation *createGraphicsAllocationWithPadding(GraphicsAllocation *inputGraphicsAllocation, size_t sizeWithPadding);
|
|
|
|
|
virtual GraphicsAllocation *createPaddedAllocation(GraphicsAllocation *inputGraphicsAllocation, size_t sizeWithPadding);
|
|
|
|
|
|
2021-02-25 09:38:48 +01:00
|
|
|
MOCKABLE_VIRTUAL void *createMultiGraphicsAllocationInSystemMemoryPool(std::vector<uint32_t> &rootDeviceIndices, AllocationProperties &properties, MultiGraphicsAllocation &multiGraphicsAllocation);
|
2020-10-21 10:50:53 +02:00
|
|
|
virtual GraphicsAllocation *createGraphicsAllocationFromExistingStorage(AllocationProperties &properties, void *ptr, MultiGraphicsAllocation &multiGraphicsAllocation);
|
2020-08-21 13:10:59 +02:00
|
|
|
|
2020-01-07 07:42:40 +01:00
|
|
|
virtual AllocationStatus populateOsHandles(OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) = 0;
|
2019-11-15 09:59:48 +01:00
|
|
|
virtual void cleanOsHandles(OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) = 0;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
|
void freeSystemMemory(void *ptr);
|
|
|
|
|
|
|
|
|
|
virtual void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) = 0;
|
2019-12-12 11:51:23 +01:00
|
|
|
MOCKABLE_VIRTUAL void freeGraphicsMemory(GraphicsAllocation *gfxAllocation);
|
2019-03-04 14:50:26 +01:00
|
|
|
virtual void handleFenceCompletion(GraphicsAllocation *allocation){};
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2018-01-19 10:55:36 +01:00
|
|
|
void checkGpuUsageAndDestroyGraphicsAllocations(GraphicsAllocation *gfxAllocation);
|
|
|
|
|
|
2020-01-07 07:42:40 +01:00
|
|
|
virtual uint64_t getSystemSharedMemory(uint32_t rootDeviceIndex) = 0;
|
2020-10-30 10:27:48 +01:00
|
|
|
virtual uint64_t getLocalMemorySize(uint32_t rootDeviceIndex, uint32_t deviceBitfield) = 0;
|
2021-07-27 14:24:20 +00:00
|
|
|
virtual double getPercentOfGlobalMemoryAvailable(uint32_t rootDeviceIndex) = 0;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2019-07-04 12:40:58 +02:00
|
|
|
uint64_t getMaxApplicationAddress() { return is64bit ? MemoryConstants::max64BitAppAddress : MemoryConstants::max32BitAppAddress; };
|
2020-07-01 14:03:46 +02:00
|
|
|
MOCKABLE_VIRTUAL uint64_t getInternalHeapBaseAddress(uint32_t rootDeviceIndex, bool useLocalMemory) { return getGfxPartition(rootDeviceIndex)->getHeapBase(selectInternalHeap(useLocalMemory)); }
|
|
|
|
|
uint64_t getExternalHeapBaseAddress(uint32_t rootDeviceIndex, bool useLocalMemory) { return getGfxPartition(rootDeviceIndex)->getHeapBase(selectExternalHeap(useLocalMemory)); }
|
2019-04-16 11:47:47 +02:00
|
|
|
|
2019-10-22 10:26:23 +02:00
|
|
|
bool isLimitedRange(uint32_t rootDeviceIndex) { return getGfxPartition(rootDeviceIndex)->isLimitedRange(); }
|
2019-04-18 15:30:47 +02:00
|
|
|
|
2020-02-12 08:29:26 +01:00
|
|
|
bool peek64kbPagesEnabled(uint32_t rootDeviceIndex) const;
|
2019-02-25 14:11:34 +01:00
|
|
|
bool peekForce32BitAllocations() const { return force32bitAllocations; }
|
2019-07-04 12:40:58 +02:00
|
|
|
void setForce32BitAllocations(bool newValue) { force32bitAllocations = newValue; }
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2019-02-25 14:11:34 +01:00
|
|
|
bool peekVirtualPaddingSupport() const { return virtualPaddingAvailable; }
|
2017-12-21 00:45:38 +01:00
|
|
|
void setVirtualPaddingSupport(bool virtualPaddingSupport) { virtualPaddingAvailable = virtualPaddingSupport; }
|
|
|
|
|
|
|
|
|
|
DeferredDeleter *getDeferredDeleter() const {
|
|
|
|
|
return deferredDeleter.get();
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-04 12:17:42 +02:00
|
|
|
PageFaultManager *getPageFaultManager() const {
|
|
|
|
|
return pageFaultManager.get();
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-10 10:16:22 +02:00
|
|
|
void waitForDeletions();
|
2021-01-18 15:09:44 +00:00
|
|
|
MOCKABLE_VIRTUAL void waitForEnginesCompletion(GraphicsAllocation &graphicsAllocation);
|
2019-03-23 12:52:57 +01:00
|
|
|
void cleanTemporaryAllocationListOnAllEngines(bool waitForCompletion);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
|
bool isAsyncDeleterEnabled() const;
|
2020-02-12 08:29:26 +01:00
|
|
|
bool isLocalMemorySupported(uint32_t rootDeviceIndex) const;
|
2017-12-21 00:45:38 +01:00
|
|
|
virtual bool isMemoryBudgetExhausted() const;
|
|
|
|
|
|
2021-02-03 14:53:13 +00:00
|
|
|
virtual bool isKmdMigrationAvailable(uint32_t rootDeviceIndex) { return false; }
|
|
|
|
|
|
2018-01-22 16:43:26 +01:00
|
|
|
virtual AlignedMallocRestrictions *getAlignedMallocRestrictions() {
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MOCKABLE_VIRTUAL void *alignedMallocWrapper(size_t bytes, size_t alignment) {
|
|
|
|
|
return ::alignedMalloc(bytes, alignment);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MOCKABLE_VIRTUAL void alignedFreeWrapper(void *ptr) {
|
|
|
|
|
::alignedFree(ptr);
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 13:29:30 +01:00
|
|
|
MOCKABLE_VIRTUAL bool isHostPointerTrackingEnabled(uint32_t rootDeviceIndex);
|
2019-12-04 13:42:41 +01:00
|
|
|
|
2020-01-24 11:30:07 +01:00
|
|
|
void setForceNonSvmForExternalHostPtr(bool mode) {
|
|
|
|
|
forceNonSvmForExternalHostPtr = mode;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-02 09:13:00 +02:00
|
|
|
const ExecutionEnvironment &peekExecutionEnvironment() const { return executionEnvironment; }
|
|
|
|
|
|
2021-03-08 18:50:32 +00:00
|
|
|
OsContext *createAndRegisterOsContext(CommandStreamReceiver *commandStreamReceiver,
|
2021-08-11 17:36:00 +00:00
|
|
|
const EngineDescriptor &engineDescriptor);
|
2019-02-25 14:11:34 +01:00
|
|
|
uint32_t getRegisteredEnginesCount() const { return static_cast<uint32_t>(registeredEngines.size()); }
|
2019-02-18 13:59:16 +01:00
|
|
|
EngineControlContainer &getRegisteredEngines();
|
2019-02-26 17:52:31 +01:00
|
|
|
EngineControl *getRegisteredEngineForCsr(CommandStreamReceiver *commandStreamReceiver);
|
2019-09-02 13:23:25 +02:00
|
|
|
void unregisterEngineForCsr(CommandStreamReceiver *commandStreamReceiver);
|
2018-10-24 08:46:54 +02:00
|
|
|
HostPtrManager *getHostPtrManager() const { return hostPtrManager.get(); }
|
2021-04-20 12:24:04 +00:00
|
|
|
void setDefaultEngineIndex(uint32_t rootDeviceIndex, uint32_t engineIndex) { defaultEngineIndex[rootDeviceIndex] = engineIndex; }
|
2020-10-07 15:32:03 +02:00
|
|
|
virtual bool copyMemoryToAllocation(GraphicsAllocation *graphicsAllocation, size_t destinationOffset, const void *memoryToCopy, size_t sizeToCopy);
|
2020-10-14 09:50:07 +02:00
|
|
|
HeapIndex selectHeap(const GraphicsAllocation *allocation, bool hasPointer, bool isFullRangeSVM, bool useFrontWindow);
|
2021-05-25 15:37:44 +00:00
|
|
|
static std::unique_ptr<MemoryManager> createMemoryManager(ExecutionEnvironment &executionEnvironment, DriverModelType driverModel = DriverModelType::UNKNOWN);
|
2020-01-07 07:42:40 +01:00
|
|
|
virtual void *reserveCpuAddressRange(size_t size, uint32_t rootDeviceIndex) { return nullptr; };
|
|
|
|
|
virtual void releaseReservedCpuAddressRange(void *reserved, size_t size, uint32_t rootDeviceIndex){};
|
2019-08-27 15:26:30 +02:00
|
|
|
void *getReservedMemory(size_t size, size_t alignment);
|
2019-10-22 10:26:23 +02:00
|
|
|
GfxPartition *getGfxPartition(uint32_t rootDeviceIndex) { return gfxPartitions.at(rootDeviceIndex).get(); }
|
2020-07-07 10:50:04 +02:00
|
|
|
virtual AddressRange reserveGpuAddress(size_t size, uint32_t rootDeviceIndex) = 0;
|
|
|
|
|
virtual void freeGpuAddress(AddressRange addressRange, uint32_t rootDeviceIndex) = 0;
|
2020-07-01 14:03:46 +02:00
|
|
|
static HeapIndex selectInternalHeap(bool useLocalMemory) { return useLocalMemory ? HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY : HeapIndex::HEAP_INTERNAL; }
|
|
|
|
|
static HeapIndex selectExternalHeap(bool useLocalMemory) { return useLocalMemory ? HeapIndex::HEAP_EXTERNAL_DEVICE_MEMORY : HeapIndex::HEAP_EXTERNAL; }
|
2019-02-20 11:18:24 +01:00
|
|
|
|
2019-12-17 08:11:16 +01:00
|
|
|
static uint32_t maxOsContextCount;
|
2020-02-11 17:48:40 +01:00
|
|
|
virtual void commonCleanup(){};
|
2020-02-28 09:59:18 +01:00
|
|
|
virtual bool isCpuCopyRequired(const void *ptr) { return false; }
|
2019-12-17 08:11:16 +01:00
|
|
|
|
2020-09-10 12:36:44 +02:00
|
|
|
virtual void registerSysMemAlloc(GraphicsAllocation *allocation){};
|
|
|
|
|
virtual void registerLocalMemAlloc(GraphicsAllocation *allocation, uint32_t rootDeviceIndex){};
|
|
|
|
|
|
2021-10-11 09:27:26 +00:00
|
|
|
virtual bool setMemAdvise(GraphicsAllocation *gfxAllocation, MemAdviseFlags flags, uint32_t rootDeviceIndex) { return true; }
|
2021-10-06 23:22:22 +00:00
|
|
|
|
2021-07-22 08:43:58 +00:00
|
|
|
bool isExternalAllocation(GraphicsAllocation::AllocationType allocationType);
|
2021-07-22 06:36:45 +00:00
|
|
|
LocalMemoryUsageBankSelector *getLocalMemoryUsageBankSelector(GraphicsAllocation::AllocationType allocationType, uint32_t rootDeviceIndex);
|
|
|
|
|
|
2021-05-24 18:57:32 +00:00
|
|
|
bool isLocalMemoryUsedForIsa(uint32_t rootDeviceIndex);
|
2021-06-02 13:57:28 +00:00
|
|
|
MOCKABLE_VIRTUAL bool isNonSvmBuffer(const void *hostPtr, GraphicsAllocation::AllocationType allocationType, uint32_t rootDeviceIndex) {
|
|
|
|
|
return !force32bitAllocations && hostPtr && !isHostPointerTrackingEnabled(rootDeviceIndex) && (allocationType == GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY);
|
|
|
|
|
}
|
2021-04-29 08:58:16 +00:00
|
|
|
|
2021-10-07 07:26:03 +00:00
|
|
|
virtual void releaseDeviceSpecificMemResources(uint32_t rootDeviceIndex){};
|
|
|
|
|
virtual void createDeviceSpecificMemResources(uint32_t rootDeviceIndex){};
|
|
|
|
|
void reInitLatestContextId() {
|
|
|
|
|
latestContextId = std::numeric_limits<uint32_t>::max();
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
protected:
|
2020-05-27 17:39:43 +02:00
|
|
|
bool getAllocationData(AllocationData &allocationData, const AllocationProperties &properties, const void *hostPtr, const StorageInfo &storageInfo);
|
2020-01-15 17:02:47 +01:00
|
|
|
static void overrideAllocationData(AllocationData &allocationData, const AllocationProperties &properties);
|
2020-07-01 14:03:46 +02:00
|
|
|
|
2020-01-13 09:40:03 +01:00
|
|
|
static bool isCopyRequired(ImageInfo &imgInfo, const void *hostPtr);
|
|
|
|
|
|
2020-03-04 08:51:02 +01:00
|
|
|
bool useNonSvmHostPtrAlloc(GraphicsAllocation::AllocationType allocationType, uint32_t rootDeviceIndex);
|
2019-05-10 11:30:07 +02:00
|
|
|
StorageInfo createStorageInfoFromProperties(const AllocationProperties &properties);
|
2018-07-09 14:12:32 +02:00
|
|
|
|
2019-02-25 14:11:34 +01:00
|
|
|
virtual GraphicsAllocation *createGraphicsAllocation(OsHandleStorage &handleStorage, const AllocationData &allocationData) = 0;
|
2019-03-12 12:00:41 +01:00
|
|
|
virtual GraphicsAllocation *allocateGraphicsMemoryForNonSvmHostPtr(const AllocationData &allocationData) = 0;
|
2018-07-09 14:12:32 +02:00
|
|
|
GraphicsAllocation *allocateGraphicsMemory(const AllocationData &allocationData);
|
2018-11-30 11:01:33 +01:00
|
|
|
virtual GraphicsAllocation *allocateGraphicsMemoryWithHostPtr(const AllocationData &allocationData);
|
|
|
|
|
virtual GraphicsAllocation *allocateGraphicsMemoryWithAlignment(const AllocationData &allocationData) = 0;
|
2020-09-03 00:57:05 -07:00
|
|
|
virtual GraphicsAllocation *allocateUSMHostGraphicsMemory(const AllocationData &allocationData) = 0;
|
2019-02-28 14:12:13 +01:00
|
|
|
virtual GraphicsAllocation *allocateGraphicsMemory64kb(const AllocationData &allocationData) = 0;
|
2020-07-01 14:03:46 +02:00
|
|
|
virtual GraphicsAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData, bool useLocalMemory) = 0;
|
2019-05-25 01:55:40 +02:00
|
|
|
virtual GraphicsAllocation *allocateGraphicsMemoryInDevicePool(const AllocationData &allocationData, AllocationStatus &status) = 0;
|
2020-07-07 10:50:04 +02:00
|
|
|
virtual GraphicsAllocation *allocateGraphicsMemoryWithGpuVa(const AllocationData &allocationData) = 0;
|
2020-07-01 10:38:19 +02:00
|
|
|
|
2019-01-22 12:40:17 +01:00
|
|
|
GraphicsAllocation *allocateGraphicsMemoryForImageFromHostPtr(const AllocationData &allocationData);
|
|
|
|
|
MOCKABLE_VIRTUAL GraphicsAllocation *allocateGraphicsMemoryForImage(const AllocationData &allocationData);
|
|
|
|
|
virtual GraphicsAllocation *allocateGraphicsMemoryForImageImpl(const AllocationData &allocationData, std::unique_ptr<Gmm> gmm) = 0;
|
2021-08-11 10:36:04 +00:00
|
|
|
virtual GraphicsAllocation *allocateMemoryByKMD(const AllocationData &allocationData) = 0;
|
2019-01-24 11:51:33 +01:00
|
|
|
virtual void *lockResourceImpl(GraphicsAllocation &graphicsAllocation) = 0;
|
|
|
|
|
virtual void unlockResourceImpl(GraphicsAllocation &graphicsAllocation) = 0;
|
2019-03-11 10:19:02 +01:00
|
|
|
virtual void freeAssociatedResourceImpl(GraphicsAllocation &graphicsAllocation) { return unlockResourceImpl(graphicsAllocation); };
|
2020-10-09 10:48:37 +02:00
|
|
|
virtual void registerAllocationInOs(GraphicsAllocation *allocation) {}
|
2021-03-09 23:02:59 +00:00
|
|
|
bool isAllocationTypeToCapture(GraphicsAllocation::AllocationType type) const;
|
2021-09-21 18:17:41 +00:00
|
|
|
void zeroCpuMemoryIfRequested(const AllocationData &allocationData, void *cpuPtr, size_t size) {
|
|
|
|
|
if (allocationData.flags.zeroMemory) {
|
|
|
|
|
memset(cpuPtr, 0, size);
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-10-07 07:26:03 +00:00
|
|
|
void updateLatestContextIdForRootDevice(uint32_t rootDeviceIndex);
|
2019-01-24 11:51:33 +01:00
|
|
|
|
2020-09-18 16:19:41 +02:00
|
|
|
bool initialized = false;
|
2020-01-24 11:30:07 +01:00
|
|
|
bool forceNonSvmForExternalHostPtr = false;
|
2017-12-21 00:45:38 +01:00
|
|
|
bool force32bitAllocations = false;
|
|
|
|
|
bool virtualPaddingAvailable = false;
|
|
|
|
|
std::unique_ptr<DeferredDeleter> deferredDeleter;
|
|
|
|
|
bool asyncDeleterEnabled = false;
|
2020-02-12 08:29:26 +01:00
|
|
|
std::vector<bool> enable64kbpages;
|
|
|
|
|
std::vector<bool> localMemorySupported;
|
2021-04-20 12:24:04 +00:00
|
|
|
std::vector<uint32_t> defaultEngineIndex;
|
2019-06-06 08:45:14 +02:00
|
|
|
bool supportsMultiStorageResources = true;
|
2018-10-01 16:10:54 +02:00
|
|
|
ExecutionEnvironment &executionEnvironment;
|
2019-02-18 13:59:16 +01:00
|
|
|
EngineControlContainer registeredEngines;
|
2018-10-24 08:46:54 +02:00
|
|
|
std::unique_ptr<HostPtrManager> hostPtrManager;
|
2018-11-21 09:57:51 +01:00
|
|
|
uint32_t latestContextId = std::numeric_limits<uint32_t>::max();
|
2021-10-07 07:26:03 +00:00
|
|
|
std::map<uint32_t, uint32_t> rootDeviceIndexToContextId; // This map will contain initial value of latestContextId for each rootDeviceIndex
|
2019-01-03 14:48:24 +01:00
|
|
|
std::unique_ptr<DeferredDeleter> multiContextResourceDestructor;
|
2019-10-22 10:26:23 +02:00
|
|
|
std::vector<std::unique_ptr<GfxPartition>> gfxPartitions;
|
2021-07-22 06:36:45 +00:00
|
|
|
std::vector<std::unique_ptr<LocalMemoryUsageBankSelector>> internalLocalMemoryUsageBankSelector;
|
|
|
|
|
std::vector<std::unique_ptr<LocalMemoryUsageBankSelector>> externalLocalMemoryUsageBankSelector;
|
2019-08-27 15:26:30 +02:00
|
|
|
void *reservedMemory = nullptr;
|
2019-07-04 12:17:42 +02:00
|
|
|
std::unique_ptr<PageFaultManager> pageFaultManager;
|
2020-08-12 12:18:34 +02:00
|
|
|
OSMemory::ReservedCpuAddressRange reservedCpuAddressRange;
|
2020-08-27 08:55:09 +02:00
|
|
|
HeapAssigner heapAssigner;
|
2021-05-27 13:37:06 +00:00
|
|
|
AlignmentSelector alignmentSelector = {};
|
2021-06-21 10:45:19 +00:00
|
|
|
std::unique_ptr<std::once_flag[]> checkIsaPlacementOnceFlags;
|
|
|
|
|
std::vector<bool> isaInLocalMemory;
|
2017-12-21 00:45:38 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<DeferredDeleter> createDeferredDeleter();
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|