From 3e4be8d78edabf1fd75a1bc3b27a280b21214d1f Mon Sep 17 00:00:00 2001 From: Zbigniew Zdanowicz Date: Tue, 23 Feb 2021 12:09:34 +0000 Subject: [PATCH] Add new allocation type Related-To: NEO-5244 Signed-off-by: Zbigniew Zdanowicz --- level_zero/core/source/cmdlist/cmdlist_hw.inl | 6 ++++-- level_zero/core/source/event/event.cpp | 4 ++-- .../sources/cmdlist/test_cmdlist_1.cpp | 16 ++++++++++++---- .../test/unit_tests/sources/event/test_event.cpp | 2 +- .../source/memory_manager/graphics_allocation.h | 1 + shared/source/memory_manager/memory_manager.cpp | 2 ++ 6 files changed, 22 insertions(+), 9 deletions(-) diff --git a/level_zero/core/source/cmdlist/cmdlist_hw.inl b/level_zero/core/source/cmdlist/cmdlist_hw.inl index 385996363a..52f158dd9f 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw.inl @@ -1659,13 +1659,15 @@ ze_result_t CommandListCoreFamily::appendQueryKernelTimestamps( } size_t alignedSize = alignUp(sizeof(EventData) * numEvents, MemoryConstants::pageSize64k); - NEO::GraphicsAllocation::AllocationType allocationType = NEO::GraphicsAllocation::AllocationType::BUFFER; + NEO::GraphicsAllocation::AllocationType allocationType = NEO::GraphicsAllocation::AllocationType::GPU_TIMESTAMP_TAG_BUFFER; + auto devices = device->getNEODevice()->getDeviceBitfield(); NEO::AllocationProperties allocationProperties{device->getRootDeviceIndex(), true, alignedSize, allocationType, + devices.count() > 1, false, - device->getNEODevice()->getDeviceBitfield()}; + devices}; NEO::GraphicsAllocation *timestampsGPUAddress = device->getDriverHandle()->getMemoryManager()->allocateGraphicsMemoryWithProperties(allocationProperties); diff --git a/level_zero/core/source/event/event.cpp b/level_zero/core/source/event/event.cpp index b36fc556c5..406f04a79e 100644 --- a/level_zero/core/source/event/event.cpp +++ b/level_zero/core/source/event/event.cpp @@ -90,7 +90,7 @@ ze_result_t EventPoolImp::initialize(DriverHandle *driver, uint32_t numDevices, auto deviceBitfield = devices[0]->getNEODevice()->getDeviceBitfield(); auto allocationType = isEventPoolUsedForTimestamp ? NEO::GraphicsAllocation::AllocationType::TIMESTAMP_PACKET_TAG_BUFFER : NEO::GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY; if (this->allocOnDevice) { - allocationType = NEO::GraphicsAllocation::AllocationType::BUFFER; + allocationType = NEO::GraphicsAllocation::AllocationType::GPU_TIMESTAMP_TAG_BUFFER; } NEO::AllocationProperties eventPoolAllocationProperties{rootDeviceIndex, @@ -98,7 +98,7 @@ ze_result_t EventPoolImp::initialize(DriverHandle *driver, uint32_t numDevices, alignUp(numEvents * eventSize, MemoryConstants::pageSize64k), allocationType, deviceBitfield.count() > 1, - deviceBitfield.count() > 1, + false, deviceBitfield}; eventPoolAllocationProperties.alignment = MemoryConstants::cacheLineSize; diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_1.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_1.cpp index fa8904dc8c..c9f56183a0 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_1.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_1.cpp @@ -624,14 +624,22 @@ HWTEST2_F(AppendQueryKernelTimestamps, givenCommandListWhenAppendQueryKernelTime EXPECT_EQ(ZE_RESULT_SUCCESS, result); bool containsDstPtr = false; - - for (auto &a : commandList.cmdListHelper.residencyContainer) { - if (a != nullptr && a->getGpuAddress() == reinterpret_cast(alloc)) { - containsDstPtr = true; + bool gpuTimeStampAlloc = false; + for (auto &residentGfxAlloc : commandList.cmdListHelper.residencyContainer) { + if (residentGfxAlloc != nullptr) { + if (residentGfxAlloc->getGpuAddress() == + reinterpret_cast(alloc)) { + containsDstPtr = true; + } + if (residentGfxAlloc->getAllocationType() == + NEO::GraphicsAllocation::AllocationType::GPU_TIMESTAMP_TAG_BUFFER) { + gpuTimeStampAlloc = true; + } } } EXPECT_TRUE(containsDstPtr); + EXPECT_TRUE(gpuTimeStampAlloc); EXPECT_EQ(testDevice->getBuiltinFunctionsLib()->getFunction(Builtin::QueryKernelTimestamps)->getIsaAllocation()->getGpuAddress(), commandList.cmdListHelper.isaAllocation->getGpuAddress()); EXPECT_EQ(2u, commandList.cmdListHelper.groupSize[0]); diff --git a/level_zero/core/test/unit_tests/sources/event/test_event.cpp b/level_zero/core/test/unit_tests/sources/event/test_event.cpp index e67b4d0b9f..511c764f70 100644 --- a/level_zero/core/test/unit_tests/sources/event/test_event.cpp +++ b/level_zero/core/test/unit_tests/sources/event/test_event.cpp @@ -154,7 +154,7 @@ TEST_F(EventPoolCreate, whenHostVisibleFlagNotSetThenEventAllocationIsOnDevice) ASSERT_NE(nullptr, eventPool); - EXPECT_EQ(NEO::GraphicsAllocation::AllocationType::BUFFER, eventPool->getAllocation().getAllocationType()); + EXPECT_EQ(NEO::GraphicsAllocation::AllocationType::GPU_TIMESTAMP_TAG_BUFFER, eventPool->getAllocation().getAllocationType()); eventPool->destroy(); } diff --git a/shared/source/memory_manager/graphics_allocation.h b/shared/source/memory_manager/graphics_allocation.h index 8f551b4005..bee665a6f3 100644 --- a/shared/source/memory_manager/graphics_allocation.h +++ b/shared/source/memory_manager/graphics_allocation.h @@ -98,6 +98,7 @@ class GraphicsAllocation : public IDNode { DEBUG_MODULE_AREA, UNIFIED_SHARED_MEMORY, WORK_PARTITION_SURFACE, + GPU_TIMESTAMP_TAG_BUFFER }; ~GraphicsAllocation() override; diff --git a/shared/source/memory_manager/memory_manager.cpp b/shared/source/memory_manager/memory_manager.cpp index 7425a3c8f1..828856740c 100644 --- a/shared/source/memory_manager/memory_manager.cpp +++ b/shared/source/memory_manager/memory_manager.cpp @@ -297,6 +297,7 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo switch (properties.allocationType) { case GraphicsAllocation::AllocationType::SVM_GPU: case GraphicsAllocation::AllocationType::SVM_ZERO_COPY: + case GraphicsAllocation::AllocationType::GPU_TIMESTAMP_TAG_BUFFER: allow64KbPages = true; default: break; @@ -380,6 +381,7 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo case GraphicsAllocation::AllocationType::SURFACE_STATE_HEAP: case GraphicsAllocation::AllocationType::TIMESTAMP_PACKET_TAG_BUFFER: case GraphicsAllocation::AllocationType::DEBUG_MODULE_AREA: + case GraphicsAllocation::AllocationType::GPU_TIMESTAMP_TAG_BUFFER: allocationData.flags.resource48Bit = true; break; default: