Skip to content

Commit baa9ce7

Browse files
Remove obtainReusableAllocation method from memory manager
Change-Id: I629044d109822f02cfddc6418f025010e62ab65b Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
1 parent d5c9816 commit baa9ce7

File tree

7 files changed

+10
-16
lines changed

7 files changed

+10
-16
lines changed

runtime/command_queue/command_queue.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ LinearStream &CommandQueue::getCS(size_t minRequiredSize) {
214214

215215
auto requiredSize = minRequiredSize + CSRequirements::csOverfetchSize;
216216

217-
GraphicsAllocation *allocation = memoryManager->obtainReusableAllocation(requiredSize, false).release();
217+
GraphicsAllocation *allocation = storageForAllocation->obtainReusableAllocation(requiredSize, false).release();
218218

219219
if (!allocation) {
220220
allocation = memoryManager->allocateGraphicsMemory(requiredSize);

runtime/command_queue/enqueue_svm.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ cl_int CommandQueueHw<GfxFamily>::enqueueSVMMemFill(void *svmPtr,
223223
DEBUG_BREAK_IF(nullptr == memoryManager);
224224

225225
auto commandStreamReceieverOwnership = device->getCommandStreamReceiver().obtainUniqueOwnership();
226-
auto patternAllocation = memoryManager->obtainReusableAllocation(patternSize, false).release();
226+
auto storageWithAllocations = device->getCommandStreamReceiver().getInternalAllocationStorage();
227+
auto patternAllocation = storageWithAllocations->obtainReusableAllocation(patternSize, false).release();
227228
commandStreamReceieverOwnership.unlock();
228229

229230
if (!patternAllocation) {
@@ -271,8 +272,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueSVMMemFill(void *svmPtr,
271272
eventWaitList,
272273
event);
273274

274-
auto storageForAllocation = device->getCommandStreamReceiver().getInternalAllocationStorage();
275-
storageForAllocation->storeAllocationWithTaskCount(std::unique_ptr<GraphicsAllocation>(patternAllocation), REUSABLE_ALLOCATION, taskCount);
275+
storageWithAllocations->storeAllocationWithTaskCount(std::unique_ptr<GraphicsAllocation>(patternAllocation), REUSABLE_ALLOCATION, taskCount);
276276

277277
return CL_SUCCESS;
278278
}

runtime/command_stream/command_stream_receiver.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ LinearStream &CommandStreamReceiver::getCS(size_t minRequiredSize) {
134134

135135
auto requiredSize = minRequiredSize + CSRequirements::csOverfetchSize;
136136

137-
auto allocation = getMemoryManager()->obtainReusableAllocation(requiredSize, false).release();
137+
auto allocation = internalAllocationStorage->obtainReusableAllocation(requiredSize, false).release();
138138
if (!allocation) {
139139
allocation = getMemoryManager()->allocateGraphicsMemory(requiredSize);
140140
}
@@ -287,7 +287,7 @@ void CommandStreamReceiver::allocateHeapMemory(IndirectHeap::Type heapType,
287287

288288
finalHeapSize = alignUp(std::max(finalHeapSize, minRequiredSize), MemoryConstants::pageSize);
289289

290-
auto heapMemory = getMemoryManager()->obtainReusableAllocation(finalHeapSize, requireInternalHeap).release();
290+
auto heapMemory = internalAllocationStorage->obtainReusableAllocation(finalHeapSize, requireInternalHeap).release();
291291

292292
if (!heapMemory) {
293293
if (requireInternalHeap) {

runtime/command_stream/experimental_command_buffer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,16 @@ void ExperimentalCommandBuffer::getCS(size_t minRequiredSize) {
5858
minRequiredSize = alignUp(minRequiredSize, MemoryConstants::pageSize);
5959

6060
auto requiredSize = minRequiredSize + CSRequirements::csOverfetchSize;
61-
62-
GraphicsAllocation *allocation = memoryManager->obtainReusableAllocation(requiredSize, false).release();
61+
auto storageWithAllocations = commandStreamReceiver->getInternalAllocationStorage();
62+
GraphicsAllocation *allocation = storageWithAllocations->obtainReusableAllocation(requiredSize, false).release();
6363
if (!allocation) {
6464
allocation = memoryManager->allocateGraphicsMemory(requiredSize);
6565
}
6666
allocation->setAllocationType(GraphicsAllocation::AllocationType::LINEAR_STREAM);
6767
// Deallocate the old block, if not null
6868
auto oldAllocation = currentStream->getGraphicsAllocation();
6969
if (oldAllocation) {
70-
commandStreamReceiver->getInternalAllocationStorage()->storeAllocation(std::unique_ptr<GraphicsAllocation>(oldAllocation), REUSABLE_ALLOCATION);
70+
storageWithAllocations->storeAllocation(std::unique_ptr<GraphicsAllocation>(oldAllocation), REUSABLE_ALLOCATION);
7171
}
7272
currentStream->replaceBuffer(allocation->getUnderlyingBuffer(), minRequiredSize - CSRequirements::minCommandQueueCommandStreamSize);
7373
currentStream->replaceGraphicsAllocation(allocation);

runtime/memory_manager/memory_manager.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,6 @@ void MemoryManager::freeSystemMemory(void *ptr) {
148148
::alignedFree(ptr);
149149
}
150150

151-
std::unique_ptr<GraphicsAllocation> MemoryManager::obtainReusableAllocation(size_t requiredSize, bool internalAllocation) {
152-
return getCommandStreamReceiver(0)->getInternalAllocationStorage()->obtainReusableAllocation(requiredSize, internalAllocation);
153-
}
154-
155151
void MemoryManager::setForce32BitAllocations(bool newValue) {
156152
if (newValue && !this->allocator32Bit) {
157153
this->allocator32Bit.reset(new Allocator32bit);

runtime/memory_manager/memory_manager.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,6 @@ class MemoryManager {
208208
TagAllocator<HwPerfCounter> *getEventPerfCountAllocator();
209209
TagAllocator<TimestampPacket> *getTimestampPacketAllocator();
210210

211-
MOCKABLE_VIRTUAL std::unique_ptr<GraphicsAllocation> obtainReusableAllocation(size_t requiredSize, bool isInternalAllocationRequired);
212-
213211
virtual GraphicsAllocation *createGraphicsAllocation(OsHandleStorage &handleStorage, size_t hostPtrSize, const void *hostPtr) = 0;
214212

215213
bool peek64kbPagesEnabled() const { return enable64kbpages; }

unit_tests/command_stream/command_stream_receiver_flush_task_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1663,7 +1663,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, InForced32BitAllocationsModeDoNotS
16631663
auto newScratchAllocation = commandStreamReceiver->getScratchAllocation();
16641664
EXPECT_NE(scratchAllocation, newScratchAllocation); // Allocation changed
16651665

1666-
std::unique_ptr<GraphicsAllocation> allocationReusable = pDevice->getMemoryManager()->obtainReusableAllocation(4096, false);
1666+
std::unique_ptr<GraphicsAllocation> allocationReusable = commandStreamReceiver->getInternalAllocationStorage()->obtainReusableAllocation(4096, false);
16671667

16681668
if (allocationReusable.get() != nullptr) {
16691669
if (is64bit) {

0 commit comments

Comments
 (0)