Skip to content

Commit 3e4be8d

Browse files
Add new allocation type
Related-To: NEO-5244 Signed-off-by: Zbigniew Zdanowicz <[email protected]>
1 parent 464e4fd commit 3e4be8d

File tree

6 files changed

+22
-9
lines changed

6 files changed

+22
-9
lines changed

level_zero/core/source/cmdlist/cmdlist_hw.inl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,13 +1659,15 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendQueryKernelTimestamps(
16591659
}
16601660

16611661
size_t alignedSize = alignUp<size_t>(sizeof(EventData) * numEvents, MemoryConstants::pageSize64k);
1662-
NEO::GraphicsAllocation::AllocationType allocationType = NEO::GraphicsAllocation::AllocationType::BUFFER;
1662+
NEO::GraphicsAllocation::AllocationType allocationType = NEO::GraphicsAllocation::AllocationType::GPU_TIMESTAMP_TAG_BUFFER;
1663+
auto devices = device->getNEODevice()->getDeviceBitfield();
16631664
NEO::AllocationProperties allocationProperties{device->getRootDeviceIndex(),
16641665
true,
16651666
alignedSize,
16661667
allocationType,
1668+
devices.count() > 1,
16671669
false,
1668-
device->getNEODevice()->getDeviceBitfield()};
1670+
devices};
16691671

16701672
NEO::GraphicsAllocation *timestampsGPUAddress = device->getDriverHandle()->getMemoryManager()->allocateGraphicsMemoryWithProperties(allocationProperties);
16711673

level_zero/core/source/event/event.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,15 @@ ze_result_t EventPoolImp::initialize(DriverHandle *driver, uint32_t numDevices,
9090
auto deviceBitfield = devices[0]->getNEODevice()->getDeviceBitfield();
9191
auto allocationType = isEventPoolUsedForTimestamp ? NEO::GraphicsAllocation::AllocationType::TIMESTAMP_PACKET_TAG_BUFFER : NEO::GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY;
9292
if (this->allocOnDevice) {
93-
allocationType = NEO::GraphicsAllocation::AllocationType::BUFFER;
93+
allocationType = NEO::GraphicsAllocation::AllocationType::GPU_TIMESTAMP_TAG_BUFFER;
9494
}
9595

9696
NEO::AllocationProperties eventPoolAllocationProperties{rootDeviceIndex,
9797
true,
9898
alignUp<size_t>(numEvents * eventSize, MemoryConstants::pageSize64k),
9999
allocationType,
100100
deviceBitfield.count() > 1,
101-
deviceBitfield.count() > 1,
101+
false,
102102
deviceBitfield};
103103
eventPoolAllocationProperties.alignment = MemoryConstants::cacheLineSize;
104104

level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_1.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -624,14 +624,22 @@ HWTEST2_F(AppendQueryKernelTimestamps, givenCommandListWhenAppendQueryKernelTime
624624
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
625625

626626
bool containsDstPtr = false;
627-
628-
for (auto &a : commandList.cmdListHelper.residencyContainer) {
629-
if (a != nullptr && a->getGpuAddress() == reinterpret_cast<uint64_t>(alloc)) {
630-
containsDstPtr = true;
627+
bool gpuTimeStampAlloc = false;
628+
for (auto &residentGfxAlloc : commandList.cmdListHelper.residencyContainer) {
629+
if (residentGfxAlloc != nullptr) {
630+
if (residentGfxAlloc->getGpuAddress() ==
631+
reinterpret_cast<uint64_t>(alloc)) {
632+
containsDstPtr = true;
633+
}
634+
if (residentGfxAlloc->getAllocationType() ==
635+
NEO::GraphicsAllocation::AllocationType::GPU_TIMESTAMP_TAG_BUFFER) {
636+
gpuTimeStampAlloc = true;
637+
}
631638
}
632639
}
633640

634641
EXPECT_TRUE(containsDstPtr);
642+
EXPECT_TRUE(gpuTimeStampAlloc);
635643

636644
EXPECT_EQ(testDevice->getBuiltinFunctionsLib()->getFunction(Builtin::QueryKernelTimestamps)->getIsaAllocation()->getGpuAddress(), commandList.cmdListHelper.isaAllocation->getGpuAddress());
637645
EXPECT_EQ(2u, commandList.cmdListHelper.groupSize[0]);

level_zero/core/test/unit_tests/sources/event/test_event.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ TEST_F(EventPoolCreate, whenHostVisibleFlagNotSetThenEventAllocationIsOnDevice)
154154

155155
ASSERT_NE(nullptr, eventPool);
156156

157-
EXPECT_EQ(NEO::GraphicsAllocation::AllocationType::BUFFER, eventPool->getAllocation().getAllocationType());
157+
EXPECT_EQ(NEO::GraphicsAllocation::AllocationType::GPU_TIMESTAMP_TAG_BUFFER, eventPool->getAllocation().getAllocationType());
158158
eventPool->destroy();
159159
}
160160

shared/source/memory_manager/graphics_allocation.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
9898
DEBUG_MODULE_AREA,
9999
UNIFIED_SHARED_MEMORY,
100100
WORK_PARTITION_SURFACE,
101+
GPU_TIMESTAMP_TAG_BUFFER
101102
};
102103

103104
~GraphicsAllocation() override;

shared/source/memory_manager/memory_manager.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo
297297
switch (properties.allocationType) {
298298
case GraphicsAllocation::AllocationType::SVM_GPU:
299299
case GraphicsAllocation::AllocationType::SVM_ZERO_COPY:
300+
case GraphicsAllocation::AllocationType::GPU_TIMESTAMP_TAG_BUFFER:
300301
allow64KbPages = true;
301302
default:
302303
break;
@@ -380,6 +381,7 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo
380381
case GraphicsAllocation::AllocationType::SURFACE_STATE_HEAP:
381382
case GraphicsAllocation::AllocationType::TIMESTAMP_PACKET_TAG_BUFFER:
382383
case GraphicsAllocation::AllocationType::DEBUG_MODULE_AREA:
384+
case GraphicsAllocation::AllocationType::GPU_TIMESTAMP_TAG_BUFFER:
383385
allocationData.flags.resource48Bit = true;
384386
break;
385387
default:

0 commit comments

Comments
 (0)