Skip to content

Commit d5c9816

Browse files
Remove store allocation methods from memory manager
Move setGPUAddress method to WddmAllocation Change-Id: I91d877c3791e9eff69276e4258e3ce9c3111ca45 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
1 parent f992cff commit d5c9816

31 files changed

+319
-324
lines changed

runtime/command_queue/command_queue.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include "runtime/mem_obj/buffer.h"
2727
#include "runtime/mem_obj/image.h"
2828
#include "runtime/helpers/surface_formats.h"
29-
#include "runtime/memory_manager/memory_manager.h"
29+
#include "runtime/memory_manager/internal_allocation_storage.h"
3030
#include "runtime/helpers/string.h"
3131
#include "CL/cl_ext.h"
3232
#include "runtime/utilities/api_intercept.h"
@@ -91,11 +91,10 @@ CommandQueue::~CommandQueue() {
9191
}
9292

9393
if (device) {
94-
auto memoryManager = device->getMemoryManager();
95-
DEBUG_BREAK_IF(nullptr == memoryManager);
94+
auto storageForAllocation = device->getCommandStreamReceiver().getInternalAllocationStorage();
9695

9796
if (commandStream && commandStream->getGraphicsAllocation()) {
98-
memoryManager->storeAllocation(std::unique_ptr<GraphicsAllocation>(commandStream->getGraphicsAllocation()), REUSABLE_ALLOCATION);
97+
storageForAllocation->storeAllocation(std::unique_ptr<GraphicsAllocation>(commandStream->getGraphicsAllocation()), REUSABLE_ALLOCATION);
9998
commandStream->replaceGraphicsAllocation(nullptr);
10099
}
101100
delete commandStream;
@@ -198,6 +197,7 @@ uint32_t CommandQueue::getTaskLevelFromWaitList(uint32_t taskLevel,
198197
LinearStream &CommandQueue::getCS(size_t minRequiredSize) {
199198
DEBUG_BREAK_IF(nullptr == device);
200199
auto &commandStreamReceiver = device->getCommandStreamReceiver();
200+
auto storageForAllocation = commandStreamReceiver.getInternalAllocationStorage();
201201
auto memoryManager = commandStreamReceiver.getMemoryManager();
202202
DEBUG_BREAK_IF(nullptr == memoryManager);
203203

@@ -226,7 +226,7 @@ LinearStream &CommandQueue::getCS(size_t minRequiredSize) {
226226
auto oldAllocation = commandStream->getGraphicsAllocation();
227227

228228
if (oldAllocation) {
229-
memoryManager->storeAllocation(std::unique_ptr<GraphicsAllocation>(oldAllocation), REUSABLE_ALLOCATION);
229+
storageForAllocation->storeAllocation(std::unique_ptr<GraphicsAllocation>(oldAllocation), REUSABLE_ALLOCATION);
230230
}
231231
commandStream->replaceBuffer(allocation->getUnderlyingBuffer(), minRequiredSize - CSRequirements::minCommandQueueCommandStreamSize);
232232
commandStream->replaceGraphicsAllocation(allocation);

runtime/command_queue/enqueue_common.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "runtime/helpers/task_information.h"
2424
#include "runtime/mem_obj/buffer.h"
2525
#include "runtime/mem_obj/image.h"
26+
#include "runtime/memory_manager/internal_allocation_storage.h"
2627
#include "runtime/memory_manager/memory_manager.h"
2728
#include "runtime/memory_manager/surface.h"
2829
#include "runtime/program/printf_handler.h"
@@ -740,7 +741,8 @@ bool CommandQueueHw<GfxFamily>::createAllocationForHostSurface(HostPtrSurface &s
740741
}
741742
allocation->taskCount = Event::eventNotReady;
742743
surface.setAllocation(allocation);
743-
memoryManager->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation), TEMPORARY_ALLOCATION);
744+
auto storageForAllocation = device->getCommandStreamReceiver().getInternalAllocationStorage();
745+
storageForAllocation->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation), TEMPORARY_ALLOCATION);
744746
return true;
745747
}
746748

runtime/command_queue/enqueue_fill_buffer.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "runtime/helpers/kernel_commands.h"
1313
#include "runtime/mem_obj/buffer.h"
1414
#include "runtime/memory_manager/surface.h"
15+
#include "runtime/memory_manager/internal_allocation_storage.h"
1516
#include "runtime/memory_manager/memory_manager.h"
1617
#include "runtime/built_ins/built_ins.h"
1718
#include <new>
@@ -72,7 +73,8 @@ cl_int CommandQueueHw<GfxFamily>::enqueueFillBuffer(
7273
eventWaitList,
7374
event);
7475

75-
memoryManager->storeAllocation(std::unique_ptr<GraphicsAllocation>(patternAllocation), TEMPORARY_ALLOCATION, taskCount);
76+
auto storageForAllocation = device->getCommandStreamReceiver().getInternalAllocationStorage();
77+
storageForAllocation->storeAllocationWithTaskCount(std::unique_ptr<GraphicsAllocation>(patternAllocation), TEMPORARY_ALLOCATION, taskCount);
7678

7779
return CL_SUCCESS;
7880
}

runtime/command_queue/enqueue_svm.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,8 @@ cl_int CommandQueueHw<GfxFamily>::enqueueSVMMemFill(void *svmPtr,
271271
eventWaitList,
272272
event);
273273

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

276277
return CL_SUCCESS;
277278
}

runtime/command_queue/hardware_interface.inl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void HardwareInterface<GfxFamily>::dispatchWalker(
6767

6868
using UniqueIH = std::unique_ptr<IndirectHeap>;
6969
*blockedCommandsData = new KernelOperation(std::unique_ptr<LinearStream>(commandStream), UniqueIH(dsh), UniqueIH(ioh),
70-
UniqueIH(ssh), *commandQueue.getDevice().getMemoryManager());
70+
UniqueIH(ssh), *commandQueue.getDevice().getCommandStreamReceiver().getInternalAllocationStorage());
7171
if (parentKernel) {
7272
(*blockedCommandsData)->doNotFreeISH = true;
7373
}

runtime/command_stream/command_stream_receiver.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ CommandStreamReceiver::~CommandStreamReceiver() {
4343
if (indirectHeap[i] != nullptr) {
4444
auto allocation = indirectHeap[i]->getGraphicsAllocation();
4545
if (allocation != nullptr) {
46-
getMemoryManager()->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation), REUSABLE_ALLOCATION);
46+
internalAllocationStorage->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation), REUSABLE_ALLOCATION);
4747
}
4848
delete indirectHeap[i];
4949
}
@@ -143,7 +143,7 @@ LinearStream &CommandStreamReceiver::getCS(size_t minRequiredSize) {
143143

144144
//pass current allocation to reusable list
145145
if (commandStream.getCpuBase()) {
146-
getMemoryManager()->storeAllocation(std::unique_ptr<GraphicsAllocation>(commandStream.getGraphicsAllocation()), REUSABLE_ALLOCATION);
146+
internalAllocationStorage->storeAllocation(std::unique_ptr<GraphicsAllocation>(commandStream.getGraphicsAllocation()), REUSABLE_ALLOCATION);
147147
}
148148

149149
commandStream.replaceBuffer(allocation->getUnderlyingBuffer(), minRequiredSize - sizeForSubmission);
@@ -259,7 +259,7 @@ IndirectHeap &CommandStreamReceiver::getIndirectHeap(IndirectHeap::Type heapType
259259
heapMemory = heap->getGraphicsAllocation();
260260

261261
if (heap && heap->getAvailableSpace() < minRequiredSize && heapMemory) {
262-
getMemoryManager()->storeAllocation(std::unique_ptr<GraphicsAllocation>(heapMemory), REUSABLE_ALLOCATION);
262+
internalAllocationStorage->storeAllocation(std::unique_ptr<GraphicsAllocation>(heapMemory), REUSABLE_ALLOCATION);
263263
heapMemory = nullptr;
264264
}
265265

@@ -322,7 +322,7 @@ void CommandStreamReceiver::releaseIndirectHeap(IndirectHeap::Type heapType) {
322322
if (heap) {
323323
auto heapMemory = heap->getGraphicsAllocation();
324324
if (heapMemory != nullptr)
325-
getMemoryManager()->storeAllocation(std::unique_ptr<GraphicsAllocation>(heapMemory), REUSABLE_ALLOCATION);
325+
internalAllocationStorage->storeAllocation(std::unique_ptr<GraphicsAllocation>(heapMemory), REUSABLE_ALLOCATION);
326326
heap->replaceBuffer(nullptr, 0);
327327
heap->replaceGraphicsAllocation(nullptr);
328328
}

runtime/command_stream/command_stream_receiver_hw.inl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "runtime/helpers/state_base_address.h"
1919
#include "runtime/helpers/options.h"
2020
#include "runtime/indirect_heap/indirect_heap.h"
21+
#include "runtime/memory_manager/internal_allocation_storage.h"
2122
#include "runtime/memory_manager/memory_manager.h"
2223
#include "runtime/os_interface/debug_settings_manager.h"
2324
#include "runtime/command_stream/preemption.h"
@@ -247,7 +248,7 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
247248
if (requiredScratchSize && (!scratchAllocation || scratchAllocation->getUnderlyingBufferSize() < requiredScratchSizeInBytes)) {
248249
if (scratchAllocation) {
249250
scratchAllocation->taskCount = this->taskCount;
250-
getMemoryManager()->storeAllocation(std::unique_ptr<GraphicsAllocation>(scratchAllocation), TEMPORARY_ALLOCATION);
251+
internalAllocationStorage->storeAllocation(std::unique_ptr<GraphicsAllocation>(scratchAllocation), TEMPORARY_ALLOCATION);
251252
}
252253
createScratchSpaceAllocation(requiredScratchSizeInBytes);
253254
overrideMediaVFEStateDirty(true);

runtime/command_stream/experimental_command_buffer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "runtime/command_stream/command_stream_receiver.h"
99
#include "runtime/command_stream/experimental_command_buffer.h"
1010
#include "runtime/command_stream/linear_stream.h"
11+
#include "runtime/memory_manager/internal_allocation_storage.h"
1112
#include "runtime/memory_manager/memory_constants.h"
1213
#include "runtime/memory_manager/memory_manager.h"
1314
#include <cstring>
@@ -66,7 +67,7 @@ void ExperimentalCommandBuffer::getCS(size_t minRequiredSize) {
6667
// Deallocate the old block, if not null
6768
auto oldAllocation = currentStream->getGraphicsAllocation();
6869
if (oldAllocation) {
69-
memoryManager->storeAllocation(std::unique_ptr<GraphicsAllocation>(oldAllocation), REUSABLE_ALLOCATION);
70+
commandStreamReceiver->getInternalAllocationStorage()->storeAllocation(std::unique_ptr<GraphicsAllocation>(oldAllocation), REUSABLE_ALLOCATION);
7071
}
7172
currentStream->replaceBuffer(allocation->getUnderlyingBuffer(), minRequiredSize - CSRequirements::minCommandQueueCommandStreamSize);
7273
currentStream->replaceGraphicsAllocation(allocation);

runtime/helpers/task_information.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@
1717
#include "runtime/helpers/string.h"
1818
#include "runtime/helpers/task_information.h"
1919
#include "runtime/mem_obj/mem_obj.h"
20-
#include "runtime/memory_manager/memory_manager.h"
20+
#include "runtime/memory_manager/internal_allocation_storage.h"
2121
#include "runtime/memory_manager/surface.h"
2222

2323
namespace OCLRT {
2424
KernelOperation::~KernelOperation() {
25-
memoryManager.storeAllocation(std::unique_ptr<GraphicsAllocation>(dsh->getGraphicsAllocation()), REUSABLE_ALLOCATION);
25+
storageForAllocations.storeAllocation(std::unique_ptr<GraphicsAllocation>(dsh->getGraphicsAllocation()), REUSABLE_ALLOCATION);
2626
if (ioh.get() == dsh.get()) {
2727
ioh.release();
2828
}
2929
if (ioh) {
30-
memoryManager.storeAllocation(std::unique_ptr<GraphicsAllocation>(ioh->getGraphicsAllocation()), REUSABLE_ALLOCATION);
30+
storageForAllocations.storeAllocation(std::unique_ptr<GraphicsAllocation>(ioh->getGraphicsAllocation()), REUSABLE_ALLOCATION);
3131
}
32-
memoryManager.storeAllocation(std::unique_ptr<GraphicsAllocation>(ssh->getGraphicsAllocation()), REUSABLE_ALLOCATION);
32+
storageForAllocations.storeAllocation(std::unique_ptr<GraphicsAllocation>(ssh->getGraphicsAllocation()), REUSABLE_ALLOCATION);
3333
alignedFree(commandStream->getCpuBase());
3434
}
3535

runtime/helpers/task_information.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
namespace OCLRT {
2020
class CommandQueue;
2121
class CommandStreamReceiver;
22+
class InternalAllocationStorage;
2223
class Kernel;
2324
class MemObj;
2425
class Surface;
2526
class PrintfHandler;
2627
struct HwTimeStamps;
27-
class MemoryManager;
2828
class TimestampPacketContainer;
2929

3030
enum MapOperationType {
@@ -65,10 +65,10 @@ class CommandMapUnmap : public Command {
6565

6666
struct KernelOperation {
6767
KernelOperation(std::unique_ptr<LinearStream> commandStream, std::unique_ptr<IndirectHeap> dsh, std::unique_ptr<IndirectHeap> ioh, std::unique_ptr<IndirectHeap> ssh,
68-
MemoryManager &memoryManager)
68+
InternalAllocationStorage &storageForAllocations)
6969
: commandStream(std::move(commandStream)), dsh(std::move(dsh)),
7070
ioh(std::move(ioh)), ssh(std::move(ssh)),
71-
surfaceStateHeapSizeEM(0), doNotFreeISH(false), memoryManager(memoryManager) {
71+
surfaceStateHeapSizeEM(0), doNotFreeISH(false), storageForAllocations(storageForAllocations) {
7272
}
7373

7474
~KernelOperation();
@@ -80,7 +80,7 @@ struct KernelOperation {
8080

8181
size_t surfaceStateHeapSizeEM;
8282
bool doNotFreeISH;
83-
MemoryManager &memoryManager;
83+
InternalAllocationStorage &storageForAllocations;
8484
};
8585

8686
class CommandComputeKernel : public Command {

0 commit comments

Comments
 (0)