diff --git a/runtime/command_queue/command_queue.cpp b/runtime/command_queue/command_queue.cpp index 9c861a49de..71f9b1d9ab 100644 --- a/runtime/command_queue/command_queue.cpp +++ b/runtime/command_queue/command_queue.cpp @@ -214,7 +214,7 @@ LinearStream &CommandQueue::getCS(size_t minRequiredSize) { auto requiredSize = minRequiredSize + CSRequirements::csOverfetchSize; - GraphicsAllocation *allocation = memoryManager->obtainReusableAllocation(requiredSize, false).release(); + GraphicsAllocation *allocation = storageForAllocation->obtainReusableAllocation(requiredSize, false).release(); if (!allocation) { allocation = memoryManager->allocateGraphicsMemory(requiredSize); diff --git a/runtime/command_queue/enqueue_svm.h b/runtime/command_queue/enqueue_svm.h index 378acdf680..1135c9a050 100644 --- a/runtime/command_queue/enqueue_svm.h +++ b/runtime/command_queue/enqueue_svm.h @@ -223,7 +223,8 @@ cl_int CommandQueueHw::enqueueSVMMemFill(void *svmPtr, DEBUG_BREAK_IF(nullptr == memoryManager); auto commandStreamReceieverOwnership = device->getCommandStreamReceiver().obtainUniqueOwnership(); - auto patternAllocation = memoryManager->obtainReusableAllocation(patternSize, false).release(); + auto storageWithAllocations = device->getCommandStreamReceiver().getInternalAllocationStorage(); + auto patternAllocation = storageWithAllocations->obtainReusableAllocation(patternSize, false).release(); commandStreamReceieverOwnership.unlock(); if (!patternAllocation) { @@ -271,8 +272,7 @@ cl_int CommandQueueHw::enqueueSVMMemFill(void *svmPtr, eventWaitList, event); - auto storageForAllocation = device->getCommandStreamReceiver().getInternalAllocationStorage(); - storageForAllocation->storeAllocationWithTaskCount(std::unique_ptr(patternAllocation), REUSABLE_ALLOCATION, taskCount); + storageWithAllocations->storeAllocationWithTaskCount(std::unique_ptr(patternAllocation), REUSABLE_ALLOCATION, taskCount); return CL_SUCCESS; } diff --git a/runtime/command_stream/command_stream_receiver.cpp b/runtime/command_stream/command_stream_receiver.cpp index 7a6329cde0..ac5f857b86 100644 --- a/runtime/command_stream/command_stream_receiver.cpp +++ b/runtime/command_stream/command_stream_receiver.cpp @@ -134,7 +134,7 @@ LinearStream &CommandStreamReceiver::getCS(size_t minRequiredSize) { auto requiredSize = minRequiredSize + CSRequirements::csOverfetchSize; - auto allocation = getMemoryManager()->obtainReusableAllocation(requiredSize, false).release(); + auto allocation = internalAllocationStorage->obtainReusableAllocation(requiredSize, false).release(); if (!allocation) { allocation = getMemoryManager()->allocateGraphicsMemory(requiredSize); } @@ -287,7 +287,7 @@ void CommandStreamReceiver::allocateHeapMemory(IndirectHeap::Type heapType, finalHeapSize = alignUp(std::max(finalHeapSize, minRequiredSize), MemoryConstants::pageSize); - auto heapMemory = getMemoryManager()->obtainReusableAllocation(finalHeapSize, requireInternalHeap).release(); + auto heapMemory = internalAllocationStorage->obtainReusableAllocation(finalHeapSize, requireInternalHeap).release(); if (!heapMemory) { if (requireInternalHeap) { diff --git a/runtime/command_stream/experimental_command_buffer.cpp b/runtime/command_stream/experimental_command_buffer.cpp index e347a833e0..296a120db5 100644 --- a/runtime/command_stream/experimental_command_buffer.cpp +++ b/runtime/command_stream/experimental_command_buffer.cpp @@ -58,8 +58,8 @@ void ExperimentalCommandBuffer::getCS(size_t minRequiredSize) { minRequiredSize = alignUp(minRequiredSize, MemoryConstants::pageSize); auto requiredSize = minRequiredSize + CSRequirements::csOverfetchSize; - - GraphicsAllocation *allocation = memoryManager->obtainReusableAllocation(requiredSize, false).release(); + auto storageWithAllocations = commandStreamReceiver->getInternalAllocationStorage(); + GraphicsAllocation *allocation = storageWithAllocations->obtainReusableAllocation(requiredSize, false).release(); if (!allocation) { allocation = memoryManager->allocateGraphicsMemory(requiredSize); } @@ -67,7 +67,7 @@ void ExperimentalCommandBuffer::getCS(size_t minRequiredSize) { // Deallocate the old block, if not null auto oldAllocation = currentStream->getGraphicsAllocation(); if (oldAllocation) { - commandStreamReceiver->getInternalAllocationStorage()->storeAllocation(std::unique_ptr(oldAllocation), REUSABLE_ALLOCATION); + storageWithAllocations->storeAllocation(std::unique_ptr(oldAllocation), REUSABLE_ALLOCATION); } currentStream->replaceBuffer(allocation->getUnderlyingBuffer(), minRequiredSize - CSRequirements::minCommandQueueCommandStreamSize); currentStream->replaceGraphicsAllocation(allocation); diff --git a/runtime/memory_manager/memory_manager.cpp b/runtime/memory_manager/memory_manager.cpp index 2e8f5d7a20..692a87f5e0 100644 --- a/runtime/memory_manager/memory_manager.cpp +++ b/runtime/memory_manager/memory_manager.cpp @@ -148,10 +148,6 @@ void MemoryManager::freeSystemMemory(void *ptr) { ::alignedFree(ptr); } -std::unique_ptr MemoryManager::obtainReusableAllocation(size_t requiredSize, bool internalAllocation) { - return getCommandStreamReceiver(0)->getInternalAllocationStorage()->obtainReusableAllocation(requiredSize, internalAllocation); -} - void MemoryManager::setForce32BitAllocations(bool newValue) { if (newValue && !this->allocator32Bit) { this->allocator32Bit.reset(new Allocator32bit); diff --git a/runtime/memory_manager/memory_manager.h b/runtime/memory_manager/memory_manager.h index 10f57b3c58..171c052807 100644 --- a/runtime/memory_manager/memory_manager.h +++ b/runtime/memory_manager/memory_manager.h @@ -208,8 +208,6 @@ class MemoryManager { TagAllocator *getEventPerfCountAllocator(); TagAllocator *getTimestampPacketAllocator(); - MOCKABLE_VIRTUAL std::unique_ptr obtainReusableAllocation(size_t requiredSize, bool isInternalAllocationRequired); - virtual GraphicsAllocation *createGraphicsAllocation(OsHandleStorage &handleStorage, size_t hostPtrSize, const void *hostPtr) = 0; bool peek64kbPagesEnabled() const { return enable64kbpages; } diff --git a/unit_tests/command_stream/command_stream_receiver_flush_task_tests.cpp b/unit_tests/command_stream/command_stream_receiver_flush_task_tests.cpp index 75f56f6b61..c6d5db1478 100644 --- a/unit_tests/command_stream/command_stream_receiver_flush_task_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_flush_task_tests.cpp @@ -1663,7 +1663,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, InForced32BitAllocationsModeDoNotS auto newScratchAllocation = commandStreamReceiver->getScratchAllocation(); EXPECT_NE(scratchAllocation, newScratchAllocation); // Allocation changed - std::unique_ptr allocationReusable = pDevice->getMemoryManager()->obtainReusableAllocation(4096, false); + std::unique_ptr allocationReusable = commandStreamReceiver->getInternalAllocationStorage()->obtainReusableAllocation(4096, false); if (allocationReusable.get() != nullptr) { if (is64bit) {