diff --git a/runtime/command_stream/command_stream_receiver.cpp b/runtime/command_stream/command_stream_receiver.cpp index c9dde19917..b5de3616b5 100644 --- a/runtime/command_stream/command_stream_receiver.cpp +++ b/runtime/command_stream/command_stream_receiver.cpp @@ -416,21 +416,28 @@ bool CommandStreamReceiver::createAllocationForHostSurface(HostPtrSurface &surfa TagAllocator *CommandStreamReceiver::getEventTsAllocator() { if (profilingTimeStampAllocator.get() == nullptr) { - profilingTimeStampAllocator = std::make_unique>(rootDeviceIndex, getMemoryManager(), getPreferredTagPoolSize(), MemoryConstants::cacheLineSize); + profilingTimeStampAllocator = std::make_unique>( + rootDeviceIndex, getMemoryManager(), getPreferredTagPoolSize(), MemoryConstants::cacheLineSize, sizeof(HwTimeStamps), false); } return profilingTimeStampAllocator.get(); } TagAllocator *CommandStreamReceiver::getEventPerfCountAllocator(const uint32_t tagSize) { if (perfCounterAllocator.get() == nullptr) { - perfCounterAllocator = std::make_unique>(rootDeviceIndex, getMemoryManager(), getPreferredTagPoolSize(), MemoryConstants::cacheLineSize, tagSize); + perfCounterAllocator = std::make_unique>( + rootDeviceIndex, getMemoryManager(), getPreferredTagPoolSize(), MemoryConstants::cacheLineSize, tagSize, false); } return perfCounterAllocator.get(); } TagAllocator *CommandStreamReceiver::getTimestampPacketAllocator() { if (timestampPacketAllocator.get() == nullptr) { - timestampPacketAllocator = std::make_unique>(rootDeviceIndex, getMemoryManager(), getPreferredTagPoolSize(), MemoryConstants::cacheLineSize); + // dont release nodes in aub/tbx mode, to avoid removing semaphores optimization or reusing returned tags + bool doNotReleaseNodes = (getType() > CommandStreamReceiverType::CSR_HW); + + timestampPacketAllocator = std::make_unique>( + rootDeviceIndex, getMemoryManager(), getPreferredTagPoolSize(), MemoryConstants::cacheLineSize, + sizeof(TimestampPacketStorage), doNotReleaseNodes); } return timestampPacketAllocator.get(); } diff --git a/runtime/command_stream/command_stream_receiver_with_aub_dump.h b/runtime/command_stream/command_stream_receiver_with_aub_dump.h index 62ff71033e..df22fd0052 100644 --- a/runtime/command_stream/command_stream_receiver_with_aub_dump.h +++ b/runtime/command_stream/command_stream_receiver_with_aub_dump.h @@ -29,6 +29,13 @@ class CommandStreamReceiverWithAUBDump : public BaseCSR { AubSubCaptureStatus checkAndActivateAubSubCapture(const MultiDispatchInfo &dispatchInfo) override; void setupContext(OsContext &osContext) override; + CommandStreamReceiverType getType() override { + if (BaseCSR::getType() == CommandStreamReceiverType::CSR_TBX) { + return CommandStreamReceiverType::CSR_TBX_WITH_AUB; + } + return CommandStreamReceiverType::CSR_HW_WITH_AUB; + } + std::unique_ptr aubCSR; }; diff --git a/runtime/event/hw_timestamps.h b/runtime/event/hw_timestamps.h index 76afb3ed8e..65e317bd33 100644 --- a/runtime/event/hw_timestamps.h +++ b/runtime/event/hw_timestamps.h @@ -21,7 +21,7 @@ struct HwTimeStamps { GlobalCompleteTS = 0; ContextCompleteTS = 0; } - bool canBeReleased() const { return true; } + bool isCompleted() const { return true; } static GraphicsAllocation::AllocationType getAllocationType() { return GraphicsAllocation::AllocationType::PROFILING_TAG_BUFFER; } diff --git a/runtime/event/perf_counter.h b/runtime/event/perf_counter.h index 0d437bead5..c0d6922eea 100644 --- a/runtime/event/perf_counter.h +++ b/runtime/event/perf_counter.h @@ -20,7 +20,7 @@ struct HwPerfCounter { static GraphicsAllocation::AllocationType getAllocationType() { return GraphicsAllocation::AllocationType::PROFILING_TAG_BUFFER; } - bool canBeReleased() const { return true; } + bool isCompleted() const { return true; } // Gpu report size is not known during compile time. // Such information will be provided by metrics library dll. diff --git a/runtime/helpers/timestamp_packet.cpp b/runtime/helpers/timestamp_packet.cpp index 12a4b8b71c..414e446db4 100644 --- a/runtime/helpers/timestamp_packet.cpp +++ b/runtime/helpers/timestamp_packet.cpp @@ -33,7 +33,7 @@ void TimestampPacketContainer::resolveDependencies(bool clearAllDependencies) { std::vector pendingNodes; for (auto node : timestampPacketNodes) { - if (node->tagForCpuAccess->canBeReleased() || clearAllDependencies) { + if (node->canBeReleased() || clearAllDependencies) { node->returnTag(); } else { pendingNodes.push_back(node); diff --git a/runtime/helpers/timestamp_packet.h b/runtime/helpers/timestamp_packet.h index 8eb5272c82..8bb064d83b 100644 --- a/runtime/helpers/timestamp_packet.h +++ b/runtime/helpers/timestamp_packet.h @@ -42,17 +42,13 @@ struct TimestampPacketStorage { return GraphicsAllocation::AllocationType::TIMESTAMP_PACKET_TAG_BUFFER; } - bool canBeReleased() const { - return isCompleted() && implicitDependenciesCount.load() == 0; - } - bool isCompleted() const { for (uint32_t i = 0; i < packetsUsed; i++) { if ((packets[i].contextEnd & 1) || (packets[i].globalEnd & 1)) { return false; } } - return true; + return implicitDependenciesCount.load() == 0; } void initialize() { diff --git a/runtime/utilities/tag_allocator.h b/runtime/utilities/tag_allocator.h index 1f04dc9605..2e3f461278 100644 --- a/runtime/utilities/tag_allocator.h +++ b/runtime/utilities/tag_allocator.h @@ -36,11 +36,20 @@ struct TagNode : public IDNode> { allocator->returnTag(this); } + bool canBeReleased() const { + return !doNotReleaseNodes && tagForCpuAccess->isCompleted(); + } + + void setDoNotReleaseNodes(bool doNotRelease) { + doNotReleaseNodes = doNotRelease; + } + protected: TagAllocator *allocator = nullptr; GraphicsAllocation *gfxAllocation = nullptr; uint64_t gpuAddress = 0; std::atomic refCount{0}; + bool doNotReleaseNodes = false; template friend class TagAllocator; @@ -52,10 +61,11 @@ class TagAllocator { using NodeType = TagNode; TagAllocator(uint32_t rootDeviceIndex, MemoryManager *memMngr, size_t tagCount, - size_t tagAlignment, size_t tagSize = sizeof(TagType)) : rootDeviceIndex(rootDeviceIndex), - memoryManager(memMngr), - tagCount(tagCount), - tagAlignment(tagAlignment) { + size_t tagAlignment, size_t tagSize, bool doNotReleaseNodes) : rootDeviceIndex(rootDeviceIndex), + memoryManager(memMngr), + tagCount(tagCount), + tagAlignment(tagAlignment), + doNotReleaseNodes(doNotReleaseNodes) { this->tagSize = alignUp(tagSize, tagAlignment); populateFreeTags(); @@ -95,7 +105,7 @@ class TagAllocator { MOCKABLE_VIRTUAL void returnTag(NodeType *node) { if (node->refCount.fetch_sub(1) == 1) { - if (node->tagForCpuAccess->canBeReleased()) { + if (node->canBeReleased()) { returnTagToFreePool(node); } else { returnTagToDeferredPool(node); @@ -115,6 +125,7 @@ class TagAllocator { size_t tagCount; size_t tagAlignment; size_t tagSize; + bool doNotReleaseNodes = false; std::mutex allocatorMutex; @@ -150,6 +161,7 @@ class TagAllocator { nodesMemory[i].gfxAllocation = graphicsAllocation; nodesMemory[i].tagForCpuAccess = reinterpret_cast(Start); nodesMemory[i].gpuAddress = gpuBaseAddress + (i * tagSize); + nodesMemory[i].setDoNotReleaseNodes(doNotReleaseNodes); freeTags.pushTailOne(nodesMemory[i]); Start += tagSize; } @@ -165,7 +177,7 @@ class TagAllocator { while (currentNode != nullptr) { auto nextNode = currentNode->next; - if (currentNode->tagForCpuAccess->canBeReleased()) { + if (currentNode->canBeReleased()) { pendingFreeTags.pushFrontOne(*currentNode); } else { pendingDeferredTags.pushFrontOne(*currentNode); diff --git a/unit_tests/command_queue/dispatch_walker_tests.cpp b/unit_tests/command_queue/dispatch_walker_tests.cpp index b900607092..c1314372d7 100644 --- a/unit_tests/command_queue/dispatch_walker_tests.cpp +++ b/unit_tests/command_queue/dispatch_walker_tests.cpp @@ -1367,7 +1367,8 @@ HWTEST_P(ProfilingCommandsTest, givenKernelWhenProfilingCommandStartIsTakenThenT bool checkForStart = GetParam(); auto &cmdStream = pCmdQ->getCS(0); - TagAllocator timeStampAllocator(pDevice->getRootDeviceIndex(), this->pDevice->getMemoryManager(), 10, MemoryConstants::cacheLineSize); + TagAllocator timeStampAllocator(pDevice->getRootDeviceIndex(), this->pDevice->getMemoryManager(), 10, + MemoryConstants::cacheLineSize, sizeof(HwTimeStamps), false); auto hwTimeStamp1 = timeStampAllocator.getTag(); ASSERT_NE(nullptr, hwTimeStamp1); diff --git a/unit_tests/command_stream/command_stream_receiver_with_aub_dump_tests.cpp b/unit_tests/command_stream/command_stream_receiver_with_aub_dump_tests.cpp index 4f309baf9b..6949475212 100644 --- a/unit_tests/command_stream/command_stream_receiver_with_aub_dump_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_with_aub_dump_tests.cpp @@ -7,14 +7,17 @@ #include "core/command_stream/preemption.h" #include "core/helpers/hw_helper.h" +#include "runtime/command_stream/aub_command_stream_receiver_hw.h" #include "runtime/command_stream/command_stream_receiver_with_aub_dump.h" #include "runtime/command_stream/command_stream_receiver_with_aub_dump.inl" #include "runtime/command_stream/tbx_command_stream_receiver_hw.h" #include "runtime/execution_environment/execution_environment.h" #include "runtime/helpers/dispatch_info.h" #include "runtime/helpers/flush_stamp.h" +#include "runtime/helpers/timestamp_packet.h" #include "runtime/os_interface/os_context.h" #include "runtime/platform/platform.h" +#include "runtime/utilities/tag_allocator.h" #include "test.h" #include "unit_tests/fixtures/mock_aub_center_fixture.h" #include "unit_tests/libult/ult_command_stream_receiver.h" @@ -127,6 +130,7 @@ struct CommandStreamReceiverWithAubDumpTest : public ::testing::TestWithParam *csrWithAubDump; MemoryManager *memoryManager; @@ -159,6 +163,7 @@ HWTEST_F(CommandStreamReceiverWithAubDumpSimpleTest, givenAubManagerAvailableWhe CommandStreamReceiverWithAUBDump> csrWithAubDump("aubfile", *executionEnvironment, 0); ASSERT_EQ(nullptr, csrWithAubDump.aubCSR); + EXPECT_EQ(CommandStreamReceiverType::CSR_TBX_WITH_AUB, csrWithAubDump.getType()); } HWTEST_F(CommandStreamReceiverWithAubDumpSimpleTest, givenAubManagerAvailableWhenHwCsrWithAubDumpIsCreatedThenAubCsrIsCreated) { @@ -173,6 +178,46 @@ HWTEST_F(CommandStreamReceiverWithAubDumpSimpleTest, givenAubManagerAvailableWhe CommandStreamReceiverWithAUBDump> csrWithAubDump("aubfile", *executionEnvironment, 0); ASSERT_NE(nullptr, csrWithAubDump.aubCSR); + EXPECT_EQ(CommandStreamReceiverType::CSR_HW_WITH_AUB, csrWithAubDump.getType()); +} + +struct CommandStreamReceiverTagTests : public ::testing::Test { + template + bool isTimestampPacketNodeReleasable(Args &&... args) { + CsrT csr(std::forward(args)...); + auto allocator = csr.getTimestampPacketAllocator(); + auto tag = allocator->getTag(); + memset(tag->tagForCpuAccess->packets, 0, sizeof(TimestampPacketStorage::Packet) * TimestampPacketSizeControl::preferredPacketCount); + EXPECT_TRUE(tag->tagForCpuAccess->isCompleted()); + + bool canBeReleased = tag->canBeReleased(); + allocator->returnTag(tag); + + return canBeReleased; + }; + + void SetUp() { + MockAubManager *mockManager = new MockAubManager(); + MockAubCenter *mockAubCenter = new MockAubCenter(*platformDevices, false, fileName, CommandStreamReceiverType::CSR_HW_WITH_AUB); + mockAubCenter->aubManager = std::unique_ptr(mockManager); + + executionEnvironment = platformImpl->peekExecutionEnvironment(); + executionEnvironment->initializeMemoryManager(); + executionEnvironment->rootDeviceEnvironments[0]->aubCenter = std::unique_ptr(mockAubCenter); + } + + const std::string fileName = "file_name.aub"; + ExecutionEnvironment *executionEnvironment = nullptr; +}; + +HWTEST_F(CommandStreamReceiverTagTests, givenCsrTypeWhenCreatingTimestampPacketAllocatorThenSetDefaultCompletionCheckType) { + using AubWithHw = CommandStreamReceiverWithAUBDump>; + using AubWithTbx = CommandStreamReceiverWithAUBDump>; + + EXPECT_TRUE(isTimestampPacketNodeReleasable>(*executionEnvironment, 0)); + EXPECT_FALSE(isTimestampPacketNodeReleasable>(fileName, false, *executionEnvironment, 0)); + EXPECT_FALSE(isTimestampPacketNodeReleasable(fileName, *executionEnvironment, 0)); + EXPECT_FALSE(isTimestampPacketNodeReleasable(fileName, *executionEnvironment, 0)); } using SimulatedCsrTest = ::testing::Test; diff --git a/unit_tests/event/event_tests.cpp b/unit_tests/event/event_tests.cpp index 53e3571eed..d3c0d87ecb 100644 --- a/unit_tests/event/event_tests.cpp +++ b/unit_tests/event/event_tests.cpp @@ -1118,7 +1118,7 @@ TEST_F(EventTest, getHwTimeStampsReturnsValidPointer) { ASSERT_EQ(0ULL, timeStamps->GlobalCompleteTS); ASSERT_EQ(0ULL, timeStamps->ContextCompleteTS); - EXPECT_TRUE(timeStamps->canBeReleased()); + EXPECT_TRUE(timeStamps->isCompleted()); HwTimeStamps *timeStamps2 = event->getHwTimeStampNode()->tagForCpuAccess; ASSERT_EQ(timeStamps, timeStamps2); diff --git a/unit_tests/helpers/timestamp_packet_tests.cpp b/unit_tests/helpers/timestamp_packet_tests.cpp index 38b0e6bc4b..7d6f832cb2 100644 --- a/unit_tests/helpers/timestamp_packet_tests.cpp +++ b/unit_tests/helpers/timestamp_packet_tests.cpp @@ -147,25 +147,25 @@ HWTEST_F(TimestampPacketTests, givenTagNodeWithPacketsUsed2WhenSemaphoreAndAtomi verifyMiAtomic(genCmdCast(*it++), &mockNode); } -TEST_F(TimestampPacketSimpleTests, whenEndTagIsNotOneThenCanBeReleased) { +TEST_F(TimestampPacketSimpleTests, whenEndTagIsNotOneThenMarkAsCompleted) { TimestampPacketStorage timestampPacketStorage; auto &packet = timestampPacketStorage.packets[0]; packet.contextEnd = 1; packet.globalEnd = 1; - EXPECT_FALSE(timestampPacketStorage.canBeReleased()); + EXPECT_FALSE(timestampPacketStorage.isCompleted()); packet.contextEnd = 1; packet.globalEnd = 0; - EXPECT_FALSE(timestampPacketStorage.canBeReleased()); + EXPECT_FALSE(timestampPacketStorage.isCompleted()); packet.contextEnd = 0; packet.globalEnd = 1; - EXPECT_FALSE(timestampPacketStorage.canBeReleased()); + EXPECT_FALSE(timestampPacketStorage.isCompleted()); packet.contextEnd = 0; packet.globalEnd = 0; - EXPECT_TRUE(timestampPacketStorage.canBeReleased()); + EXPECT_TRUE(timestampPacketStorage.isCompleted()); } TEST_F(TimestampPacketSimpleTests, givenTimestampPacketContainerWhenMovedTheMoveAllNodes) { @@ -239,9 +239,9 @@ TEST_F(TimestampPacketSimpleTests, givenImplicitDependencyWhenEndTagIsWrittenThe timestampPacketStorage.packets[0].contextEnd = 0; timestampPacketStorage.packets[0].globalEnd = 0; timestampPacketStorage.implicitDependenciesCount.store(1); - EXPECT_FALSE(timestampPacketStorage.canBeReleased()); + EXPECT_FALSE(timestampPacketStorage.isCompleted()); timestampPacketStorage.implicitDependenciesCount.store(0); - EXPECT_TRUE(timestampPacketStorage.canBeReleased()); + EXPECT_TRUE(timestampPacketStorage.isCompleted()); } TEST_F(TimestampPacketSimpleTests, whenNewTagIsTakenThenReinitialize) { @@ -1319,7 +1319,8 @@ HWTEST_F(TimestampPacketTests, givenAlreadyAssignedNodeWhenEnqueueingWithOmitTim } HWTEST_F(TimestampPacketTests, givenEventsWaitlistFromDifferentDevicesWhenEnqueueingThenMakeAllTimestampsResident) { - TagAllocator tagAllocator(device->getRootDeviceIndex(), executionEnvironment->memoryManager.get(), 1, 1); + TagAllocator tagAllocator(device->getRootDeviceIndex(), executionEnvironment->memoryManager.get(), 1, 1, + sizeof(TimestampPacketStorage), false); auto device2 = std::unique_ptr(Device::create(executionEnvironment, 1u)); auto &ultCsr = device->getUltCommandStreamReceiver(); @@ -1354,7 +1355,8 @@ HWTEST_F(TimestampPacketTests, givenEventsWaitlistFromDifferentDevicesWhenEnqueu } HWTEST_F(TimestampPacketTests, givenEventsWaitlistFromDifferentCSRsWhenEnqueueingThenMakeAllTimestampsResident) { - TagAllocator tagAllocator(device->getRootDeviceIndex(), executionEnvironment->memoryManager.get(), 1, 1); + TagAllocator tagAllocator(device->getRootDeviceIndex(), executionEnvironment->memoryManager.get(), 1, 1, + sizeof(TimestampPacketStorage), false); auto &ultCsr = device->getUltCommandStreamReceiver(); ultCsr.timestampPacketWriteEnabled = true; diff --git a/unit_tests/mem_obj/buffer_tests.cpp b/unit_tests/mem_obj/buffer_tests.cpp index 38ffb4f57a..382dfd7ba2 100644 --- a/unit_tests/mem_obj/buffer_tests.cpp +++ b/unit_tests/mem_obj/buffer_tests.cpp @@ -1193,7 +1193,9 @@ HWTEST_TEMPLATED_F(BcsBufferTests, givenInputAndOutputTimestampPacketWhenBlitCal auto &cmdQueueCsr = static_cast &>(cmdQ->getGpgpuCommandStreamReceiver()); auto memoryManager = cmdQueueCsr.getMemoryManager(); cmdQueueCsr.timestampPacketAllocator = std::make_unique>(device->getRootDeviceIndex(), memoryManager, 1, - MemoryConstants::cacheLineSize); + MemoryConstants::cacheLineSize, + sizeof(TimestampPacketStorage), + false); auto buffer = clUniquePtr(Buffer::create(bcsMockContext.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal)); buffer->forceDisallowCPUCopy = true; diff --git a/unit_tests/mocks/mock_timestamp_container.h b/unit_tests/mocks/mock_timestamp_container.h index 7f2bd111a9..f920936bd3 100644 --- a/unit_tests/mocks/mock_timestamp_container.h +++ b/unit_tests/mocks/mock_timestamp_container.h @@ -18,7 +18,8 @@ class MockTagAllocator : public TagAllocator { using BaseClass::usedTags; using NodeType = typename BaseClass::NodeType; - MockTagAllocator(uint32_t rootDeviceIndex, MemoryManager *memoryManager, size_t tagCount = 10) : BaseClass(rootDeviceIndex, memoryManager, tagCount, 10) {} + MockTagAllocator(uint32_t rootDeviceIndex, MemoryManager *memoryManager, size_t tagCount = 10) + : BaseClass(rootDeviceIndex, memoryManager, tagCount, MemoryConstants::cacheLineSize, sizeof(TagType), false) {} void returnTag(NodeType *node) override { releaseReferenceNodes.push_back(node); @@ -48,4 +49,4 @@ class MockTimestampPacketContainer : public TimestampPacketContainer { return timestampPacketNodes.at(position); } }; -} // namespace NEO \ No newline at end of file +} // namespace NEO diff --git a/unit_tests/os_interface/performance_counters_tests.cpp b/unit_tests/os_interface/performance_counters_tests.cpp index b45e440009..d05ef8d70a 100644 --- a/unit_tests/os_interface/performance_counters_tests.cpp +++ b/unit_tests/os_interface/performance_counters_tests.cpp @@ -492,7 +492,7 @@ TEST_F(PerformanceCountersMetricsLibraryTest, getHwPerfCounterReturnsValidPointe ASSERT_NE(nullptr, perfCounter); ASSERT_EQ(0ULL, perfCounter->report[0]); - EXPECT_TRUE(perfCounter->canBeReleased()); + EXPECT_TRUE(perfCounter->isCompleted()); HwPerfCounter *perfCounter2 = event->getHwPerfCounterNode()->tagForCpuAccess; ASSERT_EQ(perfCounter, perfCounter2); diff --git a/unit_tests/profiling/profiling_tests.cpp b/unit_tests/profiling/profiling_tests.cpp index 24fc7eed5d..f5fad4a74f 100644 --- a/unit_tests/profiling/profiling_tests.cpp +++ b/unit_tests/profiling/profiling_tests.cpp @@ -834,7 +834,8 @@ struct FixedGpuAddressTagAllocator : TagAllocator { }; FixedGpuAddressTagAllocator(CommandStreamReceiver &csr, uint64_t gpuAddress) - : TagAllocator(0, csr.getMemoryManager(), csr.getPreferredTagPoolSize(), MemoryConstants::cacheLineSize) { + : TagAllocator(0, csr.getMemoryManager(), csr.getPreferredTagPoolSize(), MemoryConstants::cacheLineSize, + sizeof(TagType), false) { auto tag = reinterpret_cast(this->freeTags.peekHead()); tag->setGpuAddress(gpuAddress); } diff --git a/unit_tests/utilities/tag_allocator_tests.cpp b/unit_tests/utilities/tag_allocator_tests.cpp index 570e61ba1d..fae5ed64fe 100644 --- a/unit_tests/utilities/tag_allocator_tests.cpp +++ b/unit_tests/utilities/tag_allocator_tests.cpp @@ -27,7 +27,7 @@ struct TimeStamps { static GraphicsAllocation::AllocationType getAllocationType() { return GraphicsAllocation::AllocationType::PROFILING_TAG_BUFFER; } - bool canBeReleased() const { return release; } + bool isCompleted() const { return release; } bool release; uint64_t start; uint64_t end; @@ -40,12 +40,18 @@ class MockTagAllocator : public TagAllocator { public: using BaseClass::deferredTags; + using BaseClass::doNotReleaseNodes; using BaseClass::freeTags; using BaseClass::populateFreeTags; using BaseClass::releaseDeferredTags; using BaseClass::usedTags; - MockTagAllocator(MemoryManager *memMngr, size_t tagCount, size_t tagAlignment) : BaseClass(0, memMngr, tagCount, tagAlignment) { + MockTagAllocator(MemoryManager *memMngr, size_t tagCount, size_t tagAlignment, bool disableCompletionCheck) + : BaseClass(0, memMngr, tagCount, tagAlignment, sizeof(TagType), disableCompletionCheck) { + } + + MockTagAllocator(MemoryManager *memMngr, size_t tagCount, size_t tagAlignment) + : MockTagAllocator(memMngr, tagCount, tagAlignment, false) { } GraphicsAllocation *getGraphicsAllocation(size_t id = 0) { @@ -315,6 +321,37 @@ TEST_F(TagAllocatorTest, givenNotReadyTagWhenReturnedThenMoveToDeferredList) { EXPECT_TRUE(tagAllocator.freeTags.peekIsEmpty()); } +TEST_F(TagAllocatorTest, givenTagNodeWhenCompletionCheckIsDisabledThenStatusIsMarkedAsNotReady) { + MockTagAllocator tagAllocator(memoryManager, 1, 1); + EXPECT_FALSE(tagAllocator.doNotReleaseNodes); + auto node = tagAllocator.getTag(); + + EXPECT_TRUE(node->canBeReleased()); + + node->setDoNotReleaseNodes(true); + EXPECT_FALSE(node->canBeReleased()); + + tagAllocator.returnTag(node); + EXPECT_FALSE(tagAllocator.deferredTags.peekIsEmpty()); + EXPECT_TRUE(tagAllocator.freeTags.peekIsEmpty()); +} + +TEST_F(TagAllocatorTest, givenTagAllocatorWhenDisabledCompletionCheckThenNodeInheritsItsState) { + MockTagAllocator tagAllocator(memoryManager, 1, 1, true); + EXPECT_TRUE(tagAllocator.doNotReleaseNodes); + + auto node = tagAllocator.getTag(); + + EXPECT_FALSE(node->canBeReleased()); + + node->setDoNotReleaseNodes(false); + EXPECT_TRUE(node->canBeReleased()); + + tagAllocator.returnTag(node); + EXPECT_TRUE(tagAllocator.deferredTags.peekIsEmpty()); + EXPECT_FALSE(tagAllocator.freeTags.peekIsEmpty()); +} + TEST_F(TagAllocatorTest, givenReadyTagWhenReturnedThenMoveToFreeList) { MockTagAllocator tagAllocator(memoryManager, 1, 1); auto node = tagAllocator.getTag(); @@ -365,9 +402,9 @@ TEST_F(TagAllocatorTest, givenTagsOnDeferredListWhenReleasingItThenMoveReadyTags } TEST_F(TagAllocatorTest, givenTagAllocatorWhenGraphicsAllocationIsCreatedThenSetValidllocationType) { - TagAllocator timestampPacketAllocator(0, memoryManager, 1, 1); - TagAllocator hwTimeStampsAllocator(0, memoryManager, 1, 1); - TagAllocator hwPerfCounterAllocator(0, memoryManager, 1, 1); + TagAllocator timestampPacketAllocator(0, memoryManager, 1, 1, sizeof(TimestampPacketStorage), false); + TagAllocator hwTimeStampsAllocator(0, memoryManager, 1, 1, sizeof(HwTimeStamps), false); + TagAllocator hwPerfCounterAllocator(0, memoryManager, 1, 1, sizeof(HwPerfCounter), false); auto timestampPacketTag = timestampPacketAllocator.getTag(); auto hwTimeStampsTag = hwTimeStampsAllocator.getTag();