mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-20 13:11:34 +08:00
Fallback to cpu copy when filling work partition allocation
move some command stream receiver tests to shared Related-To: NEO-6325 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
3a2b018eb6
commit
93e3d948f5
@ -1111,8 +1111,17 @@ bool DrmMemoryManager::copyMemoryToAllocation(GraphicsAllocation *graphicsAlloca
|
||||
if (graphicsAllocation->getUnderlyingBuffer() || !isLocalMemorySupported(graphicsAllocation->getRootDeviceIndex())) {
|
||||
return MemoryManager::copyMemoryToAllocation(graphicsAllocation, destinationOffset, memoryToCopy, sizeToCopy);
|
||||
}
|
||||
return copyMemoryToAllocationBanks(graphicsAllocation, destinationOffset, memoryToCopy, sizeToCopy, graphicsAllocation->storageInfo.memoryBanks);
|
||||
}
|
||||
bool DrmMemoryManager::copyMemoryToAllocationBanks(GraphicsAllocation *graphicsAllocation, size_t destinationOffset, const void *memoryToCopy, size_t sizeToCopy, DeviceBitfield dstMemoryBanks) {
|
||||
if (MemoryPool::isSystemMemoryPool(graphicsAllocation->getMemoryPool())) {
|
||||
return false;
|
||||
}
|
||||
auto drmAllocation = static_cast<DrmAllocation *>(graphicsAllocation);
|
||||
for (auto handleId = 0u; handleId < graphicsAllocation->storageInfo.getNumBanks(); handleId++) {
|
||||
for (auto handleId = 0u; handleId < graphicsAllocation->storageInfo.getTotalBanksCnt(); handleId++) {
|
||||
if (!dstMemoryBanks.test(handleId)) {
|
||||
continue;
|
||||
}
|
||||
auto ptr = lockResourceInLocalMemoryImpl(drmAllocation->getBOs()[handleId]);
|
||||
if (!ptr) {
|
||||
return false;
|
||||
|
@ -57,6 +57,7 @@ class DrmMemoryManager : public MemoryManager {
|
||||
|
||||
DrmGemCloseWorker *peekGemCloseWorker() const { return this->gemCloseWorker.get(); }
|
||||
bool copyMemoryToAllocation(GraphicsAllocation *graphicsAllocation, size_t destinationOffset, const void *memoryToCopy, size_t sizeToCopy) override;
|
||||
bool copyMemoryToAllocationBanks(GraphicsAllocation *graphicsAllocation, size_t destinationOffset, const void *memoryToCopy, size_t sizeToCopy, DeviceBitfield dstMemoryBanks) override;
|
||||
|
||||
MOCKABLE_VIRTUAL int obtainFdFromHandle(int boHandle, uint32_t rootDeviceindex);
|
||||
AddressRange reserveGpuAddress(size_t size, uint32_t rootDeviceIndex) override;
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "shared/source/helpers/heap_assigner.h"
|
||||
#include "shared/source/helpers/hw_helper.h"
|
||||
#include "shared/source/helpers/ptr_math.h"
|
||||
#include "shared/source/helpers/string.h"
|
||||
#include "shared/source/helpers/surface_format_info.h"
|
||||
#include "shared/source/memory_manager/deferrable_deletion.h"
|
||||
#include "shared/source/memory_manager/deferred_deleter.h"
|
||||
@ -857,4 +858,30 @@ bool WddmMemoryManager::isCpuCopyRequired(const void *ptr) {
|
||||
return inputPointerReadDelta > slownessFactor * fastestLocalRead;
|
||||
}
|
||||
|
||||
bool WddmMemoryManager::copyMemoryToAllocation(GraphicsAllocation *graphicsAllocation, size_t destinationOffset, const void *memoryToCopy, size_t sizeToCopy) {
|
||||
if (graphicsAllocation->getUnderlyingBuffer()) {
|
||||
return MemoryManager::copyMemoryToAllocation(graphicsAllocation, destinationOffset, memoryToCopy, sizeToCopy);
|
||||
}
|
||||
return copyMemoryToAllocationBanks(graphicsAllocation, destinationOffset, memoryToCopy, sizeToCopy, graphicsAllocation->storageInfo.memoryBanks);
|
||||
}
|
||||
|
||||
bool WddmMemoryManager::copyMemoryToAllocationBanks(GraphicsAllocation *graphicsAllocation, size_t destinationOffset, const void *memoryToCopy, size_t sizeToCopy, DeviceBitfield dstMemoryBanks) {
|
||||
if (MemoryPool::isSystemMemoryPool(graphicsAllocation->getMemoryPool())) {
|
||||
return false;
|
||||
}
|
||||
auto wddmAllocation = static_cast<WddmAllocation *>(graphicsAllocation);
|
||||
for (auto handleId = 0u; handleId < graphicsAllocation->storageInfo.getTotalBanksCnt(); handleId++) {
|
||||
if (!dstMemoryBanks.test(handleId)) {
|
||||
continue;
|
||||
}
|
||||
auto ptr = getWddm(graphicsAllocation->getRootDeviceIndex()).lockResource(wddmAllocation->getHandles()[handleId], wddmAllocation->needsMakeResidentBeforeLock, wddmAllocation->getAlignedSize());
|
||||
if (!ptr) {
|
||||
return false;
|
||||
}
|
||||
memcpy_s(ptrOffset(ptr, destinationOffset), graphicsAllocation->getUnderlyingBufferSize() - destinationOffset, memoryToCopy, sizeToCopy);
|
||||
getWddm(graphicsAllocation->getRootDeviceIndex()).unlockResource(wddmAllocation->getHandles()[handleId]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
@ -65,6 +65,7 @@ class WddmMemoryManager : public MemoryManager {
|
||||
AlignedMallocRestrictions *getAlignedMallocRestrictions() override;
|
||||
|
||||
bool copyMemoryToAllocation(GraphicsAllocation *graphicsAllocation, size_t destinationOffset, const void *memoryToCopy, size_t sizeToCopy) override;
|
||||
bool copyMemoryToAllocationBanks(GraphicsAllocation *graphicsAllocation, size_t destinationOffset, const void *memoryToCopy, size_t sizeToCopy, DeviceBitfield dstMemoryBanks) override;
|
||||
void *reserveCpuAddressRange(size_t size, uint32_t rootDeviceIndex) override;
|
||||
void releaseReservedCpuAddressRange(void *reserved, size_t size, uint32_t rootDeviceIndex) override;
|
||||
bool isCpuCopyRequired(const void *ptr) override;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2020 Intel Corporation
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@ -13,9 +13,6 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryInDevicePool(const
|
||||
status = AllocationStatus::RetryInNonDevicePool;
|
||||
return nullptr;
|
||||
}
|
||||
bool WddmMemoryManager::copyMemoryToAllocation(GraphicsAllocation *graphicsAllocation, size_t destinationOffset, const void *memoryToCopy, size_t sizeToCopy) {
|
||||
return MemoryManager::copyMemoryToAllocation(graphicsAllocation, destinationOffset, memoryToCopy, sizeToCopy);
|
||||
}
|
||||
bool WddmMemoryManager::mapGpuVirtualAddress(WddmAllocation *allocation, const void *requiredPtr) {
|
||||
if (allocation->getNumGmms() > 1) {
|
||||
return mapMultiHandleAllocationWithRetry(allocation, requiredPtr);
|
||||
|
Reference in New Issue
Block a user