From a65d50b0dcb3f69a805173b59aeecb286551d3b5 Mon Sep 17 00:00:00 2001 From: Zbigniew Zdanowicz Date: Thu, 2 Mar 2023 21:59:09 +0000 Subject: [PATCH] Add timestamp buffer allocation type to aub one time writeable Related-To: NEO-7765 Signed-off-by: Zbigniew Zdanowicz --- .../test/black_box_tests/zello_sandbox.cpp | 2 ++ shared/source/aub/aub_helper.h | 3 +- .../aub_command_stream_receiver_2_tests.cpp | 30 +++++++++++++++++++ .../tbx_command_stream_tests.cpp | 28 +++++++++++++++++ 4 files changed, 62 insertions(+), 1 deletion(-) diff --git a/level_zero/core/test/black_box_tests/zello_sandbox.cpp b/level_zero/core/test/black_box_tests/zello_sandbox.cpp index 4f650e5dad..92f6118f24 100644 --- a/level_zero/core/test/black_box_tests/zello_sandbox.cpp +++ b/level_zero/core/test/black_box_tests/zello_sandbox.cpp @@ -236,6 +236,8 @@ void executeEventSyncForMultiTileAndCopy(ze_context_handle_t &context, ze_device SUCCESS_OR_TERMINATE(zeEventPoolCreate(context, &eventPoolDesc, eventPoolDevicesNum, eventPoolDevices.data(), &eventPool)); for (uint32_t i = 0; i < numEvents; i++) { eventDesc.index = i; + eventDesc.signal = ZE_EVENT_SCOPE_FLAG_HOST; + eventDesc.wait = ZE_EVENT_SCOPE_FLAG_DEVICE; SUCCESS_OR_TERMINATE(zeEventCreate(eventPool, &eventDesc, eventPtr + i)); } } diff --git a/shared/source/aub/aub_helper.h b/shared/source/aub/aub_helper.h index c4ad9cbf3a..650a776707 100644 --- a/shared/source/aub/aub_helper.h +++ b/shared/source/aub/aub_helper.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2022 Intel Corporation + * Copyright (C) 2018-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -33,6 +33,7 @@ class AubHelper : public NonCopyableOrMovableClass { case AllocationType::EXTERNAL_HOST_PTR: case AllocationType::MAP_ALLOCATION: case AllocationType::SVM_GPU: + case AllocationType::GPU_TIMESTAMP_DEVICE_BUFFER: return true; default: return false; diff --git a/shared/test/unit_test/command_stream/aub_command_stream_receiver_2_tests.cpp b/shared/test/unit_test/command_stream/aub_command_stream_receiver_2_tests.cpp index 3c1e48f063..f7e2d43615 100644 --- a/shared/test/unit_test/command_stream/aub_command_stream_receiver_2_tests.cpp +++ b/shared/test/unit_test/command_stream/aub_command_stream_receiver_2_tests.cpp @@ -1030,3 +1030,33 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWithHardwar EXPECT_TRUE(mockHardwareContext->writeMMIOCalled); } + +HWTEST_F(AubCommandStreamReceiverTests, givenTimestampBufferAllocationWhenAubWriteMemoryIsCalledForAllocationThenItIsOneTimeWriteable) { + auto aubCsr = std::make_unique>("", false, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); + aubCsr->setupContext(*pDevice->getDefaultEngine().osContext); + aubCsr->initializeEngine(); + + MemoryManager *memoryManager = aubCsr->getMemoryManager(); + ASSERT_NE(nullptr, memoryManager); + + size_t alignedSize = MemoryConstants::pageSize64k; + AllocationType allocationType = NEO::AllocationType::GPU_TIMESTAMP_DEVICE_BUFFER; + + AllocationProperties allocationProperties{pDevice->getRootDeviceIndex(), + true, + alignedSize, + allocationType, + false, + false, + pDevice->getDeviceBitfield()}; + + auto timestampAllocation = memoryManager->allocateGraphicsMemoryWithProperties(allocationProperties); + ASSERT_NE(nullptr, timestampAllocation); + + timestampAllocation->setAubWritable(true, GraphicsAllocation::defaultBank); + + EXPECT_TRUE(aubCsr->writeMemory(*timestampAllocation)); + EXPECT_FALSE(timestampAllocation->isAubWritable(GraphicsAllocation::defaultBank)); + + memoryManager->freeGraphicsMemory(timestampAllocation); +} diff --git a/shared/test/unit_test/command_stream/tbx_command_stream_tests.cpp b/shared/test/unit_test/command_stream/tbx_command_stream_tests.cpp index 51663f4dfe..d7ee3950a1 100644 --- a/shared/test/unit_test/command_stream/tbx_command_stream_tests.cpp +++ b/shared/test/unit_test/command_stream/tbx_command_stream_tests.cpp @@ -1081,3 +1081,31 @@ HWTEST_F(TbxCommandStreamTests, givenGraphicsAllocationWhenDumpAllocationIsCalle memoryManager->freeGraphicsMemory(gfxAllocation); } + +HWTEST_F(TbxCommandStreamTests, givenTimestampBufferAllocationWhenTbxWriteMemoryIsCalledForAllocationThenItIsOneTimeWriteable) { + TbxCommandStreamReceiverHw *tbxCsr = (TbxCommandStreamReceiverHw *)pCommandStreamReceiver; + tbxCsr->initializeEngine(); + MemoryManager *memoryManager = tbxCsr->getMemoryManager(); + ASSERT_NE(nullptr, memoryManager); + + size_t alignedSize = MemoryConstants::pageSize64k; + AllocationType allocationType = NEO::AllocationType::GPU_TIMESTAMP_DEVICE_BUFFER; + + AllocationProperties allocationProperties{pDevice->getRootDeviceIndex(), + true, + alignedSize, + allocationType, + false, + false, + pDevice->getDeviceBitfield()}; + + auto timestampAllocation = memoryManager->allocateGraphicsMemoryWithProperties(allocationProperties); + ASSERT_NE(nullptr, timestampAllocation); + + timestampAllocation->setTbxWritable(true, GraphicsAllocation::defaultBank); + + EXPECT_TRUE(tbxCsr->writeMemory(*timestampAllocation)); + EXPECT_FALSE(timestampAllocation->isTbxWritable(GraphicsAllocation::defaultBank)); + + memoryManager->freeGraphicsMemory(timestampAllocation); +}