Skip to content

Commit 1d42fe1

Browse files
Add allocation types for MCS, preemption and shared context image
Related-To: NEO-2733 Change-Id: I3e3e4ea6d4fe084c8c32c0e24c537c9131ce1e60 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
1 parent c5274c5 commit 1d42fe1

File tree

10 files changed

+46
-12
lines changed

10 files changed

+46
-12
lines changed

runtime/device/device.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,7 @@ bool Device::createDeviceImpl(const HardwareInfo *pHwInfo) {
142142
executionEnvironment->memoryManager->setForce32BitAllocations(getDeviceInfo().force32BitAddressess);
143143

144144
if (preemptionMode == PreemptionMode::MidThread || isSourceLevelDebuggerActive()) {
145-
AllocationProperties properties(true, pHwInfo->capabilityTable.requiredPreemptionSurfaceSize, GraphicsAllocation::AllocationType::UNDECIDED);
146-
properties.flags.uncacheable = getWaTable()->waCSRUncachable;
147-
properties.alignment = 256 * MemoryConstants::kiloByte;
148-
preemptionAllocation = executionEnvironment->memoryManager->allocateGraphicsMemoryWithProperties(properties);
145+
preemptionAllocation = executionEnvironment->memoryManager->allocateGraphicsMemoryWithProperties(getAllocationPropertiesForPreemption());
149146
if (!preemptionAllocation) {
150147
return false;
151148
}
@@ -162,6 +159,12 @@ bool Device::createDeviceImpl(const HardwareInfo *pHwInfo) {
162159
return true;
163160
}
164161

162+
AllocationProperties Device::getAllocationPropertiesForPreemption() const {
163+
AllocationProperties properties{true, getHardwareInfo().capabilityTable.requiredPreemptionSurfaceSize, GraphicsAllocation::AllocationType::PREEMPTION};
164+
properties.flags.uncacheable = getWaTable()->waCSRUncachable;
165+
properties.alignment = 256 * MemoryConstants::kiloByte;
166+
return properties;
167+
}
165168
bool Device::createEngines(const HardwareInfo *pHwInfo) {
166169
auto defaultEngineType = getChosenEngineType(*pHwInfo);
167170
auto &gpgpuEngines = HwHelper::get(pHwInfo->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances();

runtime/device/device.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ class Device : public BaseObject<_cl_device_id> {
139139
MOCKABLE_VIRTUAL void initializeCaps();
140140
void setupFp64Flags();
141141
void appendOSExtensions(std::string &deviceExtensions);
142+
AllocationProperties getAllocationPropertiesForPreemption() const;
142143

143144
unsigned int enabledClVersion = 0u;
144145

runtime/mem_obj/image.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ Image *Image::create(Context *context,
237237
}
238238
} else {
239239
gmm = new Gmm(imgInfo);
240-
memory = memoryManager->allocateGraphicsMemoryWithProperties({false, imgInfo.size, GraphicsAllocation::AllocationType::UNDECIDED}, hostPtr);
240+
memory = memoryManager->allocateGraphicsMemoryWithProperties({false, imgInfo.size, GraphicsAllocation::AllocationType::SHARED_CONTEXT_IMAGE}, hostPtr);
241241
memory->setDefaultGmm(gmm);
242242
zeroCopy = true;
243243
}

runtime/memory_manager/graphics_allocation.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,16 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
5656
INTERNAL_HOST_MEMORY,
5757
KERNEL_ISA,
5858
LINEAR_STREAM,
59+
MCS,
5960
PIPE,
61+
PREEMPTION,
6062
PRINTF_SURFACE,
6163
PRIVATE_SURFACE,
6264
PROFILING_TAG_BUFFER,
6365
SCRATCH_SURFACE,
64-
SHARED_IMAGE,
6566
SHARED_BUFFER,
67+
SHARED_CONTEXT_IMAGE,
68+
SHARED_IMAGE,
6669
SHARED_RESOURCE_COPY,
6770
SURFACE_STATE_HEAP,
6871
SVM_CPU,

runtime/memory_manager/memory_manager.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,12 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo
274274
case GraphicsAllocation::AllocationType::EXTERNAL_HOST_PTR:
275275
case GraphicsAllocation::AllocationType::FILL_PATTERN:
276276
case GraphicsAllocation::AllocationType::GLOBAL_SURFACE:
277+
case GraphicsAllocation::AllocationType::MCS:
277278
case GraphicsAllocation::AllocationType::PIPE:
279+
case GraphicsAllocation::AllocationType::PREEMPTION:
278280
case GraphicsAllocation::AllocationType::PRINTF_SURFACE:
279281
case GraphicsAllocation::AllocationType::PROFILING_TAG_BUFFER:
282+
case GraphicsAllocation::AllocationType::SHARED_CONTEXT_IMAGE:
280283
case GraphicsAllocation::AllocationType::SVM_CPU:
281284
case GraphicsAllocation::AllocationType::SVM_ZERO_COPY:
282285
case GraphicsAllocation::AllocationType::TAG_BUFFER:

runtime/os_interface/debug_settings_manager.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,12 @@ const char *DebugSettingsManager<DebugLevel>::getAllocationTypeString(GraphicsAl
339339
return "KERNEL_ISA";
340340
case GraphicsAllocation::AllocationType::LINEAR_STREAM:
341341
return "LINEAR_STREAM";
342+
case GraphicsAllocation::AllocationType::MCS:
343+
return "MCS";
342344
case GraphicsAllocation::AllocationType::PIPE:
343345
return "PIPE";
346+
case GraphicsAllocation::AllocationType::PREEMPTION:
347+
return "PREEMPTION";
344348
case GraphicsAllocation::AllocationType::PRINTF_SURFACE:
345349
return "PRINTF_SURFACE";
346350
case GraphicsAllocation::AllocationType::PRIVATE_SURFACE:
@@ -351,6 +355,8 @@ const char *DebugSettingsManager<DebugLevel>::getAllocationTypeString(GraphicsAl
351355
return "SCRATCH_SURFACE";
352356
case GraphicsAllocation::AllocationType::SHARED_BUFFER:
353357
return "SHARED_BUFFER";
358+
case GraphicsAllocation::AllocationType::SHARED_CONTEXT_IMAGE:
359+
return "SHARED_CONTEXT_IMAGE";
354360
case GraphicsAllocation::AllocationType::SHARED_IMAGE:
355361
return "SHARED_IMAGE";
356362
case GraphicsAllocation::AllocationType::SHARED_RESOURCE_COPY:

runtime/sharings/gl/gl_texture.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Image *GlTexture::createSharedGlTexture(Context *context, cl_mem_flags flags, cl
4545

4646
errorCode.set(CL_SUCCESS);
4747

48-
AllocationProperties allocProperties(nullptr, false, GraphicsAllocation::AllocationType::SHARED_IMAGE);
48+
AllocationProperties allocProperties(false, 0u, GraphicsAllocation::AllocationType::SHARED_IMAGE);
4949
auto alloc = memoryManager->createGraphicsAllocationFromSharedHandle(texInfo.globalShareHandle, allocProperties, false);
5050

5151
if (alloc == nullptr) {
@@ -114,7 +114,7 @@ Image *GlTexture::createSharedGlTexture(Context *context, cl_mem_flags flags, cl
114114

115115
GraphicsAllocation *mcsAlloc = nullptr;
116116
if (texInfo.globalShareHandleMCS) {
117-
AllocationProperties allocProperties(0, GraphicsAllocation::AllocationType::UNDECIDED);
117+
AllocationProperties allocProperties(0, GraphicsAllocation::AllocationType::MCS);
118118
mcsAlloc = memoryManager->createGraphicsAllocationFromSharedHandle(texInfo.globalShareHandleMCS, allocProperties, false);
119119
if (texInfo.pGmmResInfoMCS) {
120120
DEBUG_BREAK_IF(mcsAlloc->getDefaultGmm() != nullptr);

unit_tests/memory_manager/memory_manager_allocate_in_preferred_pool_tests.inl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,24 @@ TEST(MemoryManagerTest, givenTagBufferTypeWhenGetAllocationDataIsCalledThenSyste
368368
EXPECT_TRUE(allocData.flags.useSystemMemory);
369369
}
370370

371+
TEST(MemoryManagerTest, givenPreemptionTypeWhenGetAllocationDataIsCalledThenSystemMemoryIsRequested) {
372+
AllocationData allocData;
373+
MockMemoryManager::getAllocationData(allocData, {1, GraphicsAllocation::AllocationType::PREEMPTION}, {}, nullptr);
374+
EXPECT_TRUE(allocData.flags.useSystemMemory);
375+
}
376+
377+
TEST(MemoryManagerTest, givenSharedContextImageTypeWhenGetAllocationDataIsCalledThenSystemMemoryIsRequested) {
378+
AllocationData allocData;
379+
MockMemoryManager::getAllocationData(allocData, {1, GraphicsAllocation::AllocationType::SHARED_CONTEXT_IMAGE}, {}, nullptr);
380+
EXPECT_TRUE(allocData.flags.useSystemMemory);
381+
}
382+
383+
TEST(MemoryManagerTest, givenMCSTypeWhenGetAllocationDataIsCalledThenSystemMemoryIsRequested) {
384+
AllocationData allocData;
385+
MockMemoryManager::getAllocationData(allocData, {1, GraphicsAllocation::AllocationType::MCS}, {}, nullptr);
386+
EXPECT_TRUE(allocData.flags.useSystemMemory);
387+
}
388+
371389
TEST(MemoryManagerTest, givenDeviceQueueBufferTypeWhenGetAllocationDataIsCalledThenSystemMemoryIsRequested) {
372390
AllocationData allocData;
373391
MockMemoryManager::getAllocationData(allocData, {1, GraphicsAllocation::AllocationType::DEVICE_QUEUE_BUFFER}, {}, nullptr);

unit_tests/mocks/mock_device.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,7 @@ class MockDevice : public Device {
102102
void allocatePreemptionAllocationIfNotPresent() {
103103
if (this->preemptionAllocation == nullptr) {
104104
if (preemptionMode == PreemptionMode::MidThread || isSourceLevelDebuggerActive()) {
105-
MockAllocationProperties allocationProperties(hwInfo.capabilityTable.requiredPreemptionSurfaceSize);
106-
allocationProperties.flags.uncacheable = getWaTable()->waCSRUncachable;
107-
allocationProperties.alignment = 256 * MemoryConstants::kiloByte;
108-
this->preemptionAllocation = executionEnvironment->memoryManager->allocateGraphicsMemoryWithProperties(allocationProperties);
105+
this->preemptionAllocation = executionEnvironment->memoryManager->allocateGraphicsMemoryWithProperties(getAllocationPropertiesForPreemption());
109106
this->engines[defaultEngineIndex].commandStreamReceiver->setPreemptionCsrAllocation(preemptionAllocation);
110107
}
111108
}

unit_tests/os_interface/debug_settings_manager_tests.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,12 +908,15 @@ AllocationTypeTestCase allocationTypeValues[] = {
908908
{GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY, "INTERNAL_HOST_MEMORY"},
909909
{GraphicsAllocation::AllocationType::KERNEL_ISA, "KERNEL_ISA"},
910910
{GraphicsAllocation::AllocationType::LINEAR_STREAM, "LINEAR_STREAM"},
911+
{GraphicsAllocation::AllocationType::MCS, "MCS"},
911912
{GraphicsAllocation::AllocationType::PIPE, "PIPE"},
913+
{GraphicsAllocation::AllocationType::PREEMPTION, "PREEMPTION"},
912914
{GraphicsAllocation::AllocationType::PRINTF_SURFACE, "PRINTF_SURFACE"},
913915
{GraphicsAllocation::AllocationType::PRIVATE_SURFACE, "PRIVATE_SURFACE"},
914916
{GraphicsAllocation::AllocationType::PROFILING_TAG_BUFFER, "PROFILING_TAG_BUFFER"},
915917
{GraphicsAllocation::AllocationType::SCRATCH_SURFACE, "SCRATCH_SURFACE"},
916918
{GraphicsAllocation::AllocationType::SHARED_BUFFER, "SHARED_BUFFER"},
919+
{GraphicsAllocation::AllocationType::SHARED_CONTEXT_IMAGE, "SHARED_CONTEXT_IMAGE"},
917920
{GraphicsAllocation::AllocationType::SHARED_IMAGE, "SHARED_IMAGE"},
918921
{GraphicsAllocation::AllocationType::SHARED_RESOURCE_COPY, "SHARED_RESOURCE_COPY"},
919922
{GraphicsAllocation::AllocationType::SURFACE_STATE_HEAP, "SURFACE_STATE_HEAP"},

0 commit comments

Comments
 (0)