Skip to content

Commit 8ec072d

Browse files
Simplify Memory Manager API [3/4]
- remove method allocateGraphicsMemory(size_t size) - pass allocation type in allocation properties - set allocation type in allocateGraphicsMemoryInPreferredPool Change-Id: Ia9296d0ab2f711b7d78aff615cb56b3a246b60ec Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
1 parent 686785c commit 8ec072d

File tree

64 files changed

+371
-339
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+371
-339
lines changed

runtime/command_queue/command_queue.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ LinearStream &CommandQueue::getCS(size_t minRequiredSize) {
212212
GraphicsAllocation *allocation = storageForAllocation->obtainReusableAllocation(requiredSize, false).release();
213213

214214
if (!allocation) {
215-
allocation = memoryManager->allocateGraphicsMemory(requiredSize);
215+
allocation = memoryManager->allocateGraphicsMemoryWithProperties({requiredSize, GraphicsAllocation::AllocationType::LINEAR_STREAM});
216216
}
217217

218218
allocation->setAllocationType(GraphicsAllocation::AllocationType::LINEAR_STREAM);

runtime/command_queue/enqueue_fill_buffer.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueFillBuffer(
3232
auto memoryManager = getDevice().getMemoryManager();
3333
DEBUG_BREAK_IF(nullptr == memoryManager);
3434

35-
auto patternAllocation = memoryManager->allocateGraphicsMemory(alignUp(patternSize, MemoryConstants::cacheLineSize));
36-
patternAllocation->setAllocationType(GraphicsAllocation::AllocationType::FILL_PATTERN);
35+
auto patternAllocation = memoryManager->allocateGraphicsMemoryWithProperties({alignUp(patternSize, MemoryConstants::cacheLineSize), GraphicsAllocation::AllocationType::FILL_PATTERN});
3736

3837
if (patternSize == 1) {
3938
int patternInt = (uint32_t)((*(uint8_t *)pattern << 24) | (*(uint8_t *)pattern << 16) | (*(uint8_t *)pattern << 8) | *(uint8_t *)pattern);

runtime/command_queue/enqueue_svm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueSVMMemFill(void *svmPtr,
228228
commandStreamReceieverOwnership.unlock();
229229

230230
if (!patternAllocation) {
231-
patternAllocation = memoryManager->allocateGraphicsMemory(patternSize);
231+
patternAllocation = memoryManager->allocateGraphicsMemoryWithProperties({patternSize, GraphicsAllocation::AllocationType::FILL_PATTERN});
232232
}
233233

234234
patternAllocation->setAllocationType(GraphicsAllocation::AllocationType::FILL_PATTERN);

runtime/command_stream/command_stream_receiver.cpp

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

136136
auto allocation = internalAllocationStorage->obtainReusableAllocation(requiredSize, false).release();
137137
if (!allocation) {
138-
allocation = getMemoryManager()->allocateGraphicsMemory(requiredSize);
138+
allocation = getMemoryManager()->allocateGraphicsMemoryWithProperties({requiredSize, GraphicsAllocation::AllocationType::LINEAR_STREAM});
139139
}
140140

141141
allocation->setAllocationType(GraphicsAllocation::AllocationType::LINEAR_STREAM);
@@ -243,7 +243,7 @@ void CommandStreamReceiver::activateAubSubCapture(const MultiDispatchInfo &dispa
243243

244244
GraphicsAllocation *CommandStreamReceiver::allocateDebugSurface(size_t size) {
245245
UNRECOVERABLE_IF(debugSurface != nullptr);
246-
debugSurface = getMemoryManager()->allocateGraphicsMemory(size);
246+
debugSurface = getMemoryManager()->allocateGraphicsMemoryWithProperties({size, GraphicsAllocation::AllocationType::UNDECIDED});
247247
return debugSurface;
248248
}
249249

@@ -291,7 +291,7 @@ void CommandStreamReceiver::allocateHeapMemory(IndirectHeap::Type heapType,
291291
if (requireInternalHeap) {
292292
heapMemory = getMemoryManager()->allocate32BitGraphicsMemory(finalHeapSize, nullptr, AllocationOrigin::INTERNAL_ALLOCATION);
293293
} else {
294-
heapMemory = getMemoryManager()->allocateGraphicsMemory(finalHeapSize);
294+
heapMemory = getMemoryManager()->allocateGraphicsMemoryWithProperties({finalHeapSize, GraphicsAllocation::AllocationType::LINEAR_STREAM});
295295
}
296296
} else {
297297
finalHeapSize = std::max(heapMemory->getUnderlyingBufferSize(), finalHeapSize);
@@ -332,7 +332,7 @@ void CommandStreamReceiver::setExperimentalCmdBuffer(std::unique_ptr<Experimenta
332332
}
333333

334334
bool CommandStreamReceiver::initializeTagAllocation() {
335-
auto tagAllocation = getMemoryManager()->allocateGraphicsMemory(sizeof(uint32_t));
335+
auto tagAllocation = getMemoryManager()->allocateGraphicsMemoryWithProperties({MemoryConstants::pageSize, GraphicsAllocation::AllocationType::UNDECIDED});
336336
if (!tagAllocation) {
337337
return false;
338338
}
@@ -355,7 +355,7 @@ bool CommandStreamReceiver::createAllocationForHostSurface(HostPtrSurface &surfa
355355
allocation = memoryManager->allocateGraphicsMemoryForHostPtr(surface.getSurfaceSize(), surface.getMemoryPointer(), device.isFullRangeSvm(), requiresL3Flush);
356356
if (allocation == nullptr && surface.peekIsPtrCopyAllowed()) {
357357
// Try with no host pointer allocation and copy
358-
AllocationProperties properties(true, surface.getSurfaceSize());
358+
AllocationProperties properties(true, surface.getSurfaceSize(), GraphicsAllocation::AllocationType::UNDECIDED);
359359
properties.alignment = MemoryConstants::pageSize;
360360
allocation = memoryManager->allocateGraphicsMemoryWithProperties(properties);
361361

runtime/command_stream/experimental_command_buffer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ ExperimentalCommandBuffer::ExperimentalCommandBuffer(CommandStreamReceiver *csr,
2222
experimentalAllocationOffset(0),
2323
defaultPrint(true),
2424
timerResolution(profilingTimerResolution) {
25-
timestamps = csr->getMemoryManager()->allocateGraphicsMemory(MemoryConstants::pageSize);
25+
timestamps = csr->getMemoryManager()->allocateGraphicsMemoryWithProperties({MemoryConstants::pageSize, GraphicsAllocation::AllocationType::UNDECIDED});
2626
memset(timestamps->getUnderlyingBuffer(), 0, timestamps->getUnderlyingBufferSize());
27-
experimentalAllocation = csr->getMemoryManager()->allocateGraphicsMemory(MemoryConstants::pageSize);
27+
experimentalAllocation = csr->getMemoryManager()->allocateGraphicsMemoryWithProperties({MemoryConstants::pageSize, GraphicsAllocation::AllocationType::UNDECIDED});
2828
memset(experimentalAllocation->getUnderlyingBuffer(), 0, experimentalAllocation->getUnderlyingBufferSize());
2929
}
3030

@@ -61,7 +61,7 @@ void ExperimentalCommandBuffer::getCS(size_t minRequiredSize) {
6161
auto storageWithAllocations = commandStreamReceiver->getInternalAllocationStorage();
6262
GraphicsAllocation *allocation = storageWithAllocations->obtainReusableAllocation(requiredSize, false).release();
6363
if (!allocation) {
64-
allocation = memoryManager->allocateGraphicsMemory(requiredSize);
64+
allocation = memoryManager->allocateGraphicsMemoryWithProperties({requiredSize, GraphicsAllocation::AllocationType::LINEAR_STREAM});
6565
}
6666
allocation->setAllocationType(GraphicsAllocation::AllocationType::LINEAR_STREAM);
6767
// Deallocate the old block, if not null

runtime/command_stream/scratch_space_controller_base.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void ScratchSpaceControllerBase::setRequiredScratchSpace(void *sshBaseAddress,
4242
}
4343

4444
void ScratchSpaceControllerBase::createScratchSpaceAllocation() {
45-
scratchAllocation = getMemoryManager()->allocateGraphicsMemoryInPreferredPool(AllocationProperties(true, scratchSizeBytes), 0, nullptr, GraphicsAllocation::AllocationType::SCRATCH_SURFACE);
45+
scratchAllocation = getMemoryManager()->allocateGraphicsMemoryWithProperties({scratchSizeBytes, GraphicsAllocation::AllocationType::SCRATCH_SURFACE});
4646
UNRECOVERABLE_IF(scratchAllocation == nullptr);
4747
}
4848

runtime/device/device.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ bool Device::createDeviceImpl(const HardwareInfo *pHwInfo, Device &outDevice) {
143143
outDevice.executionEnvironment->memoryManager->setForce32BitAllocations(outDevice.getDeviceInfo().force32BitAddressess);
144144

145145
if (outDevice.preemptionMode == PreemptionMode::MidThread || outDevice.isSourceLevelDebuggerActive()) {
146-
AllocationProperties properties(true, pHwInfo->capabilityTable.requiredPreemptionSurfaceSize);
146+
AllocationProperties properties(true, pHwInfo->capabilityTable.requiredPreemptionSurfaceSize, GraphicsAllocation::AllocationType::UNDECIDED);
147147
properties.flags.uncacheable = outDevice.getWaTable()->waCSRUncachable;
148148
properties.alignment = 256 * MemoryConstants::kiloByte;
149149
outDevice.preemptionAllocation = outDevice.executionEnvironment->memoryManager->allocateGraphicsMemoryWithProperties(properties);

runtime/device_queue/device_queue.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,32 +98,32 @@ void DeviceQueue::allocateResources() {
9898
auto &caps = device->getDeviceInfo();
9999

100100
uint32_t alignedQueueSize = alignUp(queueSize, MemoryConstants::pageSize);
101-
queueBuffer = device->getMemoryManager()->allocateGraphicsMemory(alignedQueueSize);
101+
queueBuffer = device->getMemoryManager()->allocateGraphicsMemoryWithProperties({alignedQueueSize, GraphicsAllocation::AllocationType::UNDECIDED});
102102

103103
auto eventPoolBufferSize = static_cast<size_t>(caps.maxOnDeviceEvents) * sizeof(IGIL_DeviceEvent) + sizeof(IGIL_EventPool);
104104
eventPoolBufferSize = alignUp(eventPoolBufferSize, MemoryConstants::pageSize);
105-
eventPoolBuffer = device->getMemoryManager()->allocateGraphicsMemory(eventPoolBufferSize);
105+
eventPoolBuffer = device->getMemoryManager()->allocateGraphicsMemoryWithProperties({eventPoolBufferSize, GraphicsAllocation::AllocationType::UNDECIDED});
106106

107107
auto maxEnqueue = static_cast<size_t>(alignedQueueSize) / sizeof(IGIL_CommandHeader);
108108
auto expectedStackSize = maxEnqueue * sizeof(uint32_t) * 3; // 3 full loads of commands
109109
expectedStackSize = alignUp(expectedStackSize, MemoryConstants::pageSize);
110-
stackBuffer = device->getMemoryManager()->allocateGraphicsMemory(expectedStackSize);
110+
stackBuffer = device->getMemoryManager()->allocateGraphicsMemoryWithProperties({expectedStackSize, GraphicsAllocation::AllocationType::UNDECIDED});
111111
memset(stackBuffer->getUnderlyingBuffer(), 0, stackBuffer->getUnderlyingBufferSize());
112112

113113
auto queueStorageSize = alignedQueueSize * 2; // place for 2 full loads of queue_t
114114
queueStorageSize = alignUp(queueStorageSize, MemoryConstants::pageSize);
115-
queueStorageBuffer = device->getMemoryManager()->allocateGraphicsMemory(queueStorageSize);
115+
queueStorageBuffer = device->getMemoryManager()->allocateGraphicsMemoryWithProperties({queueStorageSize, GraphicsAllocation::AllocationType::UNDECIDED});
116116
memset(queueStorageBuffer->getUnderlyingBuffer(), 0, queueStorageBuffer->getUnderlyingBufferSize());
117117

118118
auto &hwHelper = HwHelper::get(device->getHardwareInfo().pPlatform->eRenderCoreFamily);
119119
const size_t IDTSize = numberOfIDTables * interfaceDescriptorEntries * hwHelper.getInterfaceDescriptorDataSize();
120120

121121
// Additional padding of PAGE_SIZE for PageFaults just after DSH to satisfy hw requirements
122-
auto dshSize = (PARALLEL_SCHEDULER_HW_GROUPS + 2) * MAX_DSH_SIZE_PER_ENQUEUE * 8 + IDTSize + colorCalcStateSize + 4096;
122+
auto dshSize = (PARALLEL_SCHEDULER_HW_GROUPS + 2) * MAX_DSH_SIZE_PER_ENQUEUE * 8 + IDTSize + colorCalcStateSize + MemoryConstants::pageSize;
123123
dshSize = alignUp(dshSize, MemoryConstants::pageSize);
124-
dshBuffer = device->getMemoryManager()->allocateGraphicsMemory(dshSize);
124+
dshBuffer = device->getMemoryManager()->allocateGraphicsMemoryWithProperties({dshSize, GraphicsAllocation::AllocationType::UNDECIDED});
125125

126-
debugQueue = device->getMemoryManager()->allocateGraphicsMemory(4096);
126+
debugQueue = device->getMemoryManager()->allocateGraphicsMemoryWithProperties({MemoryConstants::pageSize, GraphicsAllocation::AllocationType::UNDECIDED});
127127
debugData = (DebugDataBuffer *)debugQueue->getUnderlyingBuffer();
128128
memset(debugQueue->getUnderlyingBuffer(), 0, debugQueue->getUnderlyingBufferSize());
129129
}

runtime/device_queue/device_queue_hw.inl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void DeviceQueueHw<GfxFamily>::allocateSlbBuffer() {
2525
slbSize += (4 * MemoryConstants::pageSize); // +4 pages spec restriction
2626
slbSize = alignUp(slbSize, MemoryConstants::pageSize);
2727

28-
slbBuffer = device->getMemoryManager()->allocateGraphicsMemory(slbSize);
28+
slbBuffer = device->getMemoryManager()->allocateGraphicsMemoryWithProperties({slbSize, GraphicsAllocation::AllocationType::UNDECIDED});
2929
}
3030

3131
template <typename GfxFamily>

runtime/helpers/flat_batch_buffer_helper_hw.inl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ GraphicsAllocation *FlatBatchBufferHelperHw<GfxFamily>::flattenBatchBuffer(Batch
3131
batchBuffer.chainedBatchBuffer->setAubWritable(false);
3232
auto sizeMainBatchBuffer = batchBuffer.chainedBatchBufferStartOffset - batchBuffer.startOffset;
3333
auto alignedMainBatchBufferSize = alignUp(sizeMainBatchBuffer + indirectPatchCommandsSize + batchBuffer.chainedBatchBuffer->getUnderlyingBufferSize(), MemoryConstants::pageSize);
34-
AllocationProperties flatBatchBufferProperties(true, alignedMainBatchBufferSize);
34+
AllocationProperties flatBatchBufferProperties(alignedMainBatchBufferSize, GraphicsAllocation::AllocationType::UNDECIDED);
3535
flatBatchBufferProperties.alignment = MemoryConstants::pageSize;
3636
flatBatchBuffer =
3737
getMemoryManager()->allocateGraphicsMemoryWithProperties(flatBatchBufferProperties);
@@ -109,7 +109,7 @@ GraphicsAllocation *FlatBatchBufferHelperHw<GfxFamily>::flattenBatchBuffer(Batch
109109

110110
flatBatchBufferSize = alignUp(flatBatchBufferSize, MemoryConstants::pageSize);
111111
flatBatchBufferSize += CSRequirements::csOverfetchSize;
112-
AllocationProperties flatBatchBufferProperties(true, static_cast<size_t>(flatBatchBufferSize));
112+
AllocationProperties flatBatchBufferProperties(static_cast<size_t>(flatBatchBufferSize), GraphicsAllocation::AllocationType::UNDECIDED);
113113
flatBatchBufferProperties.alignment = MemoryConstants::pageSize;
114114
flatBatchBuffer = getMemoryManager()->allocateGraphicsMemoryWithProperties(flatBatchBufferProperties);
115115
UNRECOVERABLE_IF(flatBatchBuffer == nullptr);

0 commit comments

Comments
 (0)