mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 18:06:32 +08:00
Change MemoryPool to enum class
Use enum class for MemoryPool in GraphicsAllocation This change will ensure that GA is constructed in the proper way - Rename namespace for isSystemMemoryPool method - Add method getMemoryPoolString for logging actual pool which is in used - Remove wrong pattern in GraphicsAllocation constructor Related-To: NEO-6523 Signed-off-by: Krzysztof Gibala <krzysztof.gibala@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
e082b80e0a
commit
dc1fe7d59a
@@ -306,7 +306,7 @@ Buffer *Buffer::create(Context *context,
|
||||
}
|
||||
}
|
||||
|
||||
if (allocationInfo[rootDeviceIndex].allocateMemory && allocationInfo[rootDeviceIndex].memory && MemoryPool::isSystemMemoryPool(allocationInfo[rootDeviceIndex].memory->getMemoryPool())) {
|
||||
if (allocationInfo[rootDeviceIndex].allocateMemory && allocationInfo[rootDeviceIndex].memory && MemoryPoolHelper::isSystemMemoryPool(allocationInfo[rootDeviceIndex].memory->getMemoryPool())) {
|
||||
memoryManager->addAllocationToHostPtrManager(allocationInfo[rootDeviceIndex].memory);
|
||||
}
|
||||
|
||||
@@ -330,7 +330,7 @@ Buffer *Buffer::create(Context *context,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!MemoryPool::isSystemMemoryPool(allocationInfo[rootDeviceIndex].memory->getMemoryPool())) {
|
||||
if (!MemoryPoolHelper::isSystemMemoryPool(allocationInfo[rootDeviceIndex].memory->getMemoryPool())) {
|
||||
allocationInfo[rootDeviceIndex].zeroCopyAllowed = false;
|
||||
if (hostPtr) {
|
||||
if (!allocationInfo[rootDeviceIndex].isHostPtrSVM) {
|
||||
@@ -376,7 +376,7 @@ Buffer *Buffer::create(Context *context,
|
||||
DBG_LOG(LogMemoryObject, __FUNCTION__, "Created Buffer: Handle: ", pBuffer, ", hostPtr: ", hostPtr, ", size: ", size,
|
||||
", memoryStorage: ", allocationInfo[rootDeviceIndex].memory->getUnderlyingBuffer(),
|
||||
", GPU address: ", allocationInfo[rootDeviceIndex].memory->getGpuAddress(),
|
||||
", memoryPool: ", allocationInfo[rootDeviceIndex].memory->getMemoryPool());
|
||||
", memoryPool: ", getMemoryPoolString(allocationInfo[rootDeviceIndex].memory));
|
||||
|
||||
for (auto &rootDeviceIndex : context->getRootDeviceIndices()) {
|
||||
if (memoryProperties.flags.useHostPtr) {
|
||||
@@ -399,7 +399,7 @@ Buffer *Buffer::create(Context *context,
|
||||
pBuffer->setHostPtrMinSize(size);
|
||||
|
||||
if (allocationInfo[rootDeviceIndex].copyMemoryFromHostPtr && !copyExecuted) {
|
||||
auto isLocalMemory = !MemoryPool::isSystemMemoryPool(allocationInfo[rootDeviceIndex].memory->getMemoryPool());
|
||||
auto isLocalMemory = !MemoryPoolHelper::isSystemMemoryPool(allocationInfo[rootDeviceIndex].memory->getMemoryPool());
|
||||
bool gpuCopyRequired = (allocationInfo[rootDeviceIndex].memory->isCompressionEnabled()) || isLocalMemory;
|
||||
|
||||
if (gpuCopyRequired) {
|
||||
@@ -652,7 +652,7 @@ bool Buffer::isReadWriteOnCpuAllowed(const Device &device) {
|
||||
|
||||
bool Buffer::isReadWriteOnCpuPreferred(void *ptr, size_t size, const Device &device) {
|
||||
auto graphicsAllocation = multiGraphicsAllocation.getGraphicsAllocation(device.getRootDeviceIndex());
|
||||
if (MemoryPool::isSystemMemoryPool(graphicsAllocation->getMemoryPool())) {
|
||||
if (MemoryPoolHelper::isSystemMemoryPool(graphicsAllocation->getMemoryPool())) {
|
||||
//if buffer is not zero copy and pointer is aligned it will be more beneficial to do the transfer on GPU
|
||||
if (!isMemObjZeroCopy() && (reinterpret_cast<uintptr_t>(ptr) & (MemoryConstants::cacheLineSize - 1)) == 0) {
|
||||
return false;
|
||||
|
||||
@@ -334,7 +334,7 @@ Image *Image::create(Context *context,
|
||||
allocProperties.flags.preferCompressed = preferCompression;
|
||||
allocationInfo[rootDeviceIndex].memory = memoryManager->allocateGraphicsMemoryWithProperties(allocProperties);
|
||||
|
||||
if (allocationInfo[rootDeviceIndex].memory && MemoryPool::isSystemMemoryPool(allocationInfo[rootDeviceIndex].memory->getMemoryPool())) {
|
||||
if (allocationInfo[rootDeviceIndex].memory && MemoryPoolHelper::isSystemMemoryPool(allocationInfo[rootDeviceIndex].memory->getMemoryPool())) {
|
||||
allocationInfo[rootDeviceIndex].zeroCopyAllowed = true;
|
||||
}
|
||||
}
|
||||
@@ -431,7 +431,7 @@ Image *Image::create(Context *context,
|
||||
}
|
||||
|
||||
bool isCpuTransferPreferrred = imgInfo.linearStorage &&
|
||||
(MemoryPool::isSystemMemoryPool(allocationInfo[rootDeviceIndex].memory->getMemoryPool()) ||
|
||||
(MemoryPoolHelper::isSystemMemoryPool(allocationInfo[rootDeviceIndex].memory->getMemoryPool()) ||
|
||||
defaultHwHelper.isCpuImageTransferPreferred(hwInfo));
|
||||
if (!isCpuTransferPreferrred) {
|
||||
auto cmdQ = context->getSpecialQueue(rootDeviceIndex);
|
||||
@@ -445,7 +445,7 @@ Image *Image::create(Context *context,
|
||||
}
|
||||
} else {
|
||||
void *pDestinationAddress = allocationInfo[rootDeviceIndex].memory->getUnderlyingBuffer();
|
||||
auto isNotInSystemMemory = !MemoryPool::isSystemMemoryPool(allocationInfo[rootDeviceIndex].memory->getMemoryPool());
|
||||
auto isNotInSystemMemory = !MemoryPoolHelper::isSystemMemoryPool(allocationInfo[rootDeviceIndex].memory->getMemoryPool());
|
||||
if (isNotInSystemMemory) {
|
||||
pDestinationAddress = context->getMemoryManager()->lockResource(allocationInfo[rootDeviceIndex].memory);
|
||||
}
|
||||
|
||||
@@ -415,7 +415,7 @@ bool MemObj::isTiledAllocation() const {
|
||||
bool MemObj::mappingOnCpuAllowed() const {
|
||||
auto graphicsAllocation = multiGraphicsAllocation.getDefaultGraphicsAllocation();
|
||||
return !isTiledAllocation() && !peekSharingHandler() && !isMipMapped(this) && !DebugManager.flags.DisableZeroCopyForBuffers.get() &&
|
||||
!graphicsAllocation->isCompressionEnabled() && MemoryPool::isSystemMemoryPool(graphicsAllocation->getMemoryPool());
|
||||
!graphicsAllocation->isCompressionEnabled() && MemoryPoolHelper::isSystemMemoryPool(graphicsAllocation->getMemoryPool());
|
||||
}
|
||||
|
||||
void MemObj::storeProperties(const cl_mem_properties *properties) {
|
||||
|
||||
Reference in New Issue
Block a user