mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
Extended DRM memory manager with function to copy memory to allocation
Related-To: NEO-2687 Change-Id: I2cd20c1d59dc0c28609fca7a11a5d805e2f21de4
This commit is contained in:
committed by
sys_ocldev
parent
a38e9da034
commit
6b77f94275
@@ -726,7 +726,7 @@ void Kernel::substituteKernelHeap(void *newKernelHeap, size_t newKernelHeapSize)
|
||||
auto currentAllocationSize = pKernelInfo->kernelAllocation->getUnderlyingBufferSize();
|
||||
bool status = false;
|
||||
if (currentAllocationSize >= newKernelHeapSize) {
|
||||
status = memoryManager->copyMemoryToAllocation(pKernelInfo->kernelAllocation, newKernelHeap, static_cast<uint32_t>(newKernelHeapSize));
|
||||
status = memoryManager->copyMemoryToAllocation(pKernelInfo->kernelAllocation, newKernelHeap, newKernelHeapSize);
|
||||
} else {
|
||||
memoryManager->checkGpuUsageAndDestroyGraphicsAllocations(pKernelInfo->kernelAllocation);
|
||||
pKernelInfo->kernelAllocation = nullptr;
|
||||
|
||||
@@ -425,7 +425,8 @@ HeapIndex MemoryManager::selectHeap(const GraphicsAllocation *allocation, bool h
|
||||
// Limited range allocation goes to STANDARD heap
|
||||
return HeapIndex::HEAP_STANDARD;
|
||||
}
|
||||
bool MemoryManager::copyMemoryToAllocation(GraphicsAllocation *graphicsAllocation, const void *memoryToCopy, uint32_t sizeToCopy) const {
|
||||
|
||||
bool MemoryManager::copyMemoryToAllocation(GraphicsAllocation *graphicsAllocation, const void *memoryToCopy, size_t sizeToCopy) {
|
||||
if (!graphicsAllocation->getUnderlyingBuffer()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ class MemoryManager {
|
||||
EngineControl *getRegisteredEngineForCsr(CommandStreamReceiver *commandStreamReceiver);
|
||||
HostPtrManager *getHostPtrManager() const { return hostPtrManager.get(); }
|
||||
void setDefaultEngineIndex(uint32_t index) { defaultEngineIndex = index; }
|
||||
virtual bool copyMemoryToAllocation(GraphicsAllocation *graphicsAllocation, const void *memoryToCopy, uint32_t sizeToCopy) const;
|
||||
virtual bool copyMemoryToAllocation(GraphicsAllocation *graphicsAllocation, const void *memoryToCopy, size_t sizeToCopy);
|
||||
static HeapIndex selectHeap(const GraphicsAllocation *allocation, bool hasPointer, bool isFullRangeSVM);
|
||||
static std::unique_ptr<MemoryManager> createMemoryManager(ExecutionEnvironment &executionEnvironment);
|
||||
virtual void *reserveCpuAddressRange(size_t size) = 0;
|
||||
|
||||
@@ -658,6 +658,10 @@ bool DrmMemoryManager::setDomainCpu(GraphicsAllocation &graphicsAllocation, bool
|
||||
}
|
||||
|
||||
void *DrmMemoryManager::lockResourceImpl(GraphicsAllocation &graphicsAllocation) {
|
||||
if (MemoryPool::LocalMemory == graphicsAllocation.getMemoryPool()) {
|
||||
return lockResourceInLocalMemoryImpl(graphicsAllocation);
|
||||
}
|
||||
|
||||
auto cpuPtr = graphicsAllocation.getUnderlyingBuffer();
|
||||
if (cpuPtr != nullptr) {
|
||||
auto success = setDomainCpu(graphicsAllocation, false);
|
||||
@@ -700,6 +704,7 @@ void DrmMemoryManager::unlockResourceImpl(GraphicsAllocation &graphicsAllocation
|
||||
|
||||
bo->setLockedAddress(nullptr);
|
||||
}
|
||||
|
||||
void *DrmMemoryManager::reserveCpuAddressRange(size_t size) {
|
||||
void *reservePtr = mmapFunction(nullptr, size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0);
|
||||
return reservePtr;
|
||||
|
||||
@@ -50,6 +50,7 @@ class DrmMemoryManager : public MemoryManager {
|
||||
}
|
||||
|
||||
DrmGemCloseWorker *peekGemCloseWorker() const { return this->gemCloseWorker.get(); }
|
||||
bool copyMemoryToAllocation(GraphicsAllocation *graphicsAllocation, const void *memoryToCopy, size_t sizeToCopy) override;
|
||||
void *reserveCpuAddressRange(size_t size) override;
|
||||
void releaseReservedCpuAddressRange(void *reserved, size_t size) override;
|
||||
|
||||
@@ -74,6 +75,7 @@ class DrmMemoryManager : public MemoryManager {
|
||||
GraphicsAllocation *allocateGraphicsMemoryForImageImpl(const AllocationData &allocationData, std::unique_ptr<Gmm> gmm) override;
|
||||
|
||||
void *lockResourceImpl(GraphicsAllocation &graphicsAllocation) override;
|
||||
void *lockResourceInLocalMemoryImpl(GraphicsAllocation &graphicsAllocation);
|
||||
void unlockResourceImpl(GraphicsAllocation &graphicsAllocation) override;
|
||||
DrmAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData) override;
|
||||
GraphicsAllocation *allocateGraphicsMemoryInDevicePool(const AllocationData &allocationData, AllocationStatus &status) override;
|
||||
|
||||
@@ -12,4 +12,12 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryInDevicePool(const A
|
||||
status = AllocationStatus::RetryInNonDevicePool;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void *DrmMemoryManager::lockResourceInLocalMemoryImpl(GraphicsAllocation &graphicsAllocation) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool DrmMemoryManager::copyMemoryToAllocation(GraphicsAllocation *graphicsAllocation, const void *memoryToCopy, size_t sizeToCopy) {
|
||||
return MemoryManager::copyMemoryToAllocation(graphicsAllocation, memoryToCopy, sizeToCopy);
|
||||
}
|
||||
} // namespace NEO
|
||||
|
||||
@@ -57,7 +57,7 @@ class WddmMemoryManager : public MemoryManager {
|
||||
|
||||
AlignedMallocRestrictions *getAlignedMallocRestrictions() override;
|
||||
|
||||
bool copyMemoryToAllocation(GraphicsAllocation *graphicsAllocation, const void *memoryToCopy, uint32_t sizeToCopy) const override;
|
||||
bool copyMemoryToAllocation(GraphicsAllocation *graphicsAllocation, const void *memoryToCopy, size_t sizeToCopy) override;
|
||||
void *reserveCpuAddressRange(size_t size) override;
|
||||
void releaseReservedCpuAddressRange(void *reserved, size_t size) override;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryInDevicePool(const
|
||||
status = AllocationStatus::RetryInNonDevicePool;
|
||||
return nullptr;
|
||||
}
|
||||
bool WddmMemoryManager::copyMemoryToAllocation(GraphicsAllocation *graphicsAllocation, const void *memoryToCopy, uint32_t sizeToCopy) const {
|
||||
bool WddmMemoryManager::copyMemoryToAllocation(GraphicsAllocation *graphicsAllocation, const void *memoryToCopy, size_t sizeToCopy) {
|
||||
return MemoryManager::copyMemoryToAllocation(graphicsAllocation, memoryToCopy, sizeToCopy);
|
||||
}
|
||||
bool WddmMemoryManager::mapGpuVirtualAddress(WddmAllocation *allocation, const void *requiredPtr) {
|
||||
|
||||
Reference in New Issue
Block a user