diff --git a/level_zero/core/source/device/device.cpp b/level_zero/core/source/device/device.cpp index 598d7fac55..c5e7712d4c 100644 --- a/level_zero/core/source/device/device.cpp +++ b/level_zero/core/source/device/device.cpp @@ -39,7 +39,7 @@ NEO::TagAllocatorBase *getInOrderCounterAllocator(std::unique_ptr MemoryConstants::pageSize64k); allocator = std::make_unique>(rootDeviceIndices, neoDevice.getMemoryManager(), NodeT::defaultAllocatorTagCount, - MemoryConstants::cacheLineSize, nodeSize, false, false, neoDevice.getDeviceBitfield()); + MemoryConstants::cacheLineSize, nodeSize, 0, false, false, neoDevice.getDeviceBitfield()); } } diff --git a/level_zero/core/source/gfx_core_helpers/l0_gfx_core_helper_base.inl b/level_zero/core/source/gfx_core_helpers/l0_gfx_core_helper_base.inl index 0af0380ee7..af878e64e7 100644 --- a/level_zero/core/source/gfx_core_helpers/l0_gfx_core_helper_base.inl +++ b/level_zero/core/source/gfx_core_helpers/l0_gfx_core_helper_base.inl @@ -81,7 +81,7 @@ std::unique_ptr L0GfxCoreHelperHw::getInOrderTime size_t size = sizeof(TimestampPacketsT) * packetsCountPerElement; - return std::make_unique>(rootDeviceIndices, memoryManager, initialTagCount, tagAlignment, size, false, false, deviceBitfield); + return std::make_unique>(rootDeviceIndices, memoryManager, initialTagCount, tagAlignment, size, 0, false, false, deviceBitfield); } template diff --git a/shared/source/command_stream/command_stream_receiver.cpp b/shared/source/command_stream/command_stream_receiver.cpp index 47fa5e4f51..351579c463 100644 --- a/shared/source/command_stream/command_stream_receiver.cpp +++ b/shared/source/command_stream/command_stream_receiver.cpp @@ -960,7 +960,7 @@ TagAllocatorBase *CommandStreamReceiver::getEventTsAllocator() { if (profilingTimeStampAllocator.get() == nullptr) { RootDeviceIndicesContainer rootDeviceIndices = {rootDeviceIndex}; profilingTimeStampAllocator = std::make_unique>(rootDeviceIndices, getMemoryManager(), getPreferredTagPoolSize(), MemoryConstants::cacheLineSize, - sizeof(HwTimeStamps), false, true, osContext->getDeviceBitfield()); + sizeof(HwTimeStamps), 0, false, true, osContext->getDeviceBitfield()); } return profilingTimeStampAllocator.get(); } @@ -969,7 +969,7 @@ TagAllocatorBase *CommandStreamReceiver::getEventPerfCountAllocator(const uint32 if (perfCounterAllocator.get() == nullptr) { RootDeviceIndicesContainer rootDeviceIndices = {rootDeviceIndex}; perfCounterAllocator = std::make_unique>( - rootDeviceIndices, getMemoryManager(), getPreferredTagPoolSize(), MemoryConstants::cacheLineSize, tagSize, false, true, osContext->getDeviceBitfield()); + rootDeviceIndices, getMemoryManager(), getPreferredTagPoolSize(), MemoryConstants::cacheLineSize, tagSize, 0, false, true, osContext->getDeviceBitfield()); } return perfCounterAllocator.get(); } diff --git a/shared/source/helpers/gfx_core_helper_base.inl b/shared/source/helpers/gfx_core_helper_base.inl index 38570f8524..92a99b7662 100644 --- a/shared/source/helpers/gfx_core_helper_base.inl +++ b/shared/source/helpers/gfx_core_helper_base.inl @@ -446,10 +446,12 @@ std::unique_ptr GfxCoreHelperHw::createTimestampPac if (debugManager.flags.OverrideTimestampPacketSize.get() != -1) { if (debugManager.flags.OverrideTimestampPacketSize.get() == 4) { using TimestampPackets32T = TimestampPackets; - return std::make_unique>(rootDeviceIndices, memoryManager, initialTagCount, tagAlignment, sizeof(TimestampPackets32T), doNotReleaseNodes, true, deviceBitfield); + return std::make_unique>(rootDeviceIndices, memoryManager, initialTagCount, tagAlignment, sizeof(TimestampPackets32T), NEO::TimestampPacketConstants::initValue, + doNotReleaseNodes, true, deviceBitfield); } else if (debugManager.flags.OverrideTimestampPacketSize.get() == 8) { using TimestampPackets64T = TimestampPackets; - return std::make_unique>(rootDeviceIndices, memoryManager, initialTagCount, tagAlignment, sizeof(TimestampPackets64T), doNotReleaseNodes, true, deviceBitfield); + return std::make_unique>(rootDeviceIndices, memoryManager, initialTagCount, tagAlignment, sizeof(TimestampPackets64T), NEO::TimestampPacketConstants::initValue, + doNotReleaseNodes, true, deviceBitfield); } else { UNRECOVERABLE_IF(true); } @@ -458,7 +460,8 @@ std::unique_ptr GfxCoreHelperHw::createTimestampPac using TimestampPacketType = typename GfxFamily::TimestampPacketType; using TimestampPacketsT = TimestampPackets; - return std::make_unique>(rootDeviceIndices, memoryManager, initialTagCount, tagAlignment, sizeof(TimestampPacketsT), doNotReleaseNodes, true, deviceBitfield); + return std::make_unique>(rootDeviceIndices, memoryManager, initialTagCount, tagAlignment, sizeof(TimestampPacketsT), NEO::TimestampPacketConstants::initValue, + doNotReleaseNodes, true, deviceBitfield); } template diff --git a/shared/source/helpers/in_order_cmd_helpers.h b/shared/source/helpers/in_order_cmd_helpers.h index 4e34945533..2cc9d7040d 100644 --- a/shared/source/helpers/in_order_cmd_helpers.h +++ b/shared/source/helpers/in_order_cmd_helpers.h @@ -26,6 +26,8 @@ class TagNodeBase; template class DeviceAllocNodeType { public: + using ValueT = uint64_t; + static constexpr size_t defaultAllocatorTagCount = 128; static constexpr AllocationType getAllocationType() { return deviceAlloc ? AllocationType::timestampPacketTagBuffer : NEO::AllocationType::bufferHostMemory; } @@ -34,7 +36,7 @@ class DeviceAllocNodeType { static constexpr size_t getSinglePacketSize() { return sizeof(uint64_t); } - void initialize() { data = 0; } + void initialize(uint64_t initValue) { data = initValue; } protected: uint64_t data = {}; diff --git a/shared/source/helpers/timestamp_packet.h b/shared/source/helpers/timestamp_packet.h index e0fd301ff9..5cea1e8495 100644 --- a/shared/source/helpers/timestamp_packet.h +++ b/shared/source/helpers/timestamp_packet.h @@ -29,6 +29,8 @@ class LinearStream; template class TimestampPackets : public TagTypeBase { public: + using ValueT = TSize; + static constexpr AllocationType getAllocationType() { return AllocationType::timestampPacketTagBuffer; } @@ -37,12 +39,12 @@ class TimestampPackets : public TagTypeBase { static constexpr size_t getSinglePacketSize() { return sizeof(Packet); } - void initialize() { + void initialize(TSize initValue) { for (auto &packet : packets) { - packet.contextStart = TimestampPacketConstants::initValue; - packet.globalStart = TimestampPacketConstants::initValue; - packet.contextEnd = TimestampPacketConstants::initValue; - packet.globalEnd = TimestampPacketConstants::initValue; + packet.contextStart = initValue; + packet.globalStart = initValue; + packet.contextEnd = initValue; + packet.globalEnd = initValue; } } diff --git a/shared/source/utilities/hw_timestamps.h b/shared/source/utilities/hw_timestamps.h index 3e0f2f68a9..8fe1bc6a6f 100644 --- a/shared/source/utilities/hw_timestamps.h +++ b/shared/source/utilities/hw_timestamps.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2023 Intel Corporation + * Copyright (C) 2018-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -14,13 +14,15 @@ namespace NEO { class HwTimeStamps : public TagTypeBase { public: - void initialize() { - globalStartTS = 0; - contextStartTS = 0; - globalEndTS = 0; - contextEndTS = 0; - globalCompleteTS = 0; - contextCompleteTS = 0; + using ValueT = uint64_t; + + void initialize(uint64_t initValue) { + globalStartTS = initValue; + contextStartTS = initValue; + globalEndTS = initValue; + contextEndTS = initValue; + globalCompleteTS = initValue; + contextCompleteTS = initValue; } static constexpr AllocationType getAllocationType() { diff --git a/shared/source/utilities/perf_counter.h b/shared/source/utilities/perf_counter.h index 0b6f5406d6..74b0ce4045 100644 --- a/shared/source/utilities/perf_counter.h +++ b/shared/source/utilities/perf_counter.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2023 Intel Corporation + * Copyright (C) 2018-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -14,9 +14,11 @@ namespace NEO { class HwPerfCounter : public TagTypeBase { public: - void initialize() { + using ValueT = uint8_t; + + void initialize(uint8_t initValue) { query = {}; - report[0] = 0; + report[0] = initValue; } static constexpr AllocationType getAllocationType() { diff --git a/shared/source/utilities/tag_allocator.h b/shared/source/utilities/tag_allocator.h index ab967c94bd..2ff808a7c7 100644 --- a/shared/source/utilities/tag_allocator.h +++ b/shared/source/utilities/tag_allocator.h @@ -104,10 +104,11 @@ class TagNode : public TagNodeBase, public IDNode> { "This structure is consumed by GPU and has to follow specific restrictions for padding and size"); public: + using ValueT = typename TagType::ValueT; TagType *tagForCpuAccess; void initialize() override { - tagForCpuAccess->initialize(); + tagForCpuAccess->initialize(static_cast *>(allocator)->getInitialValue()); packetsUsed = 1; setProfilingCapable(true); } @@ -177,13 +178,15 @@ template class TagAllocator : public TagAllocatorBase { public: using NodeType = TagNode; + using ValueT = typename TagType::ValueT; TagAllocator(const RootDeviceIndicesContainer &rootDeviceIndices, MemoryManager *memMngr, size_t tagCount, - size_t tagAlignment, size_t tagSize, bool doNotReleaseNodes, bool initializeTags, DeviceBitfield deviceBitfield); + size_t tagAlignment, size_t tagSize, ValueT initialValue, bool doNotReleaseNodes, bool initializeTags, DeviceBitfield deviceBitfield); TagNodeBase *getTag() override; void returnTag(TagNodeBase *node) override; + ValueT getInitialValue() const { return initialValue; } protected: TagAllocator() = delete; @@ -202,6 +205,7 @@ class TagAllocator : public TagAllocatorBase { std::vector> tagPoolMemory; + const ValueT initialValue; bool initializeTags = true; }; } // namespace NEO diff --git a/shared/source/utilities/tag_allocator.inl b/shared/source/utilities/tag_allocator.inl index aa6e56820f..723e4e722b 100644 --- a/shared/source/utilities/tag_allocator.inl +++ b/shared/source/utilities/tag_allocator.inl @@ -13,8 +13,8 @@ namespace NEO { template TagAllocator::TagAllocator(const RootDeviceIndicesContainer &rootDeviceIndices, MemoryManager *memMngr, size_t tagCount, size_t tagAlignment, - size_t tagSize, bool doNotReleaseNodes, bool initializeTags, DeviceBitfield deviceBitfield) - : TagAllocatorBase(rootDeviceIndices, memMngr, tagCount, tagAlignment, tagSize, doNotReleaseNodes, deviceBitfield), initializeTags(initializeTags) { + size_t tagSize, ValueT initialValue, bool doNotReleaseNodes, bool initializeTags, DeviceBitfield deviceBitfield) + : TagAllocatorBase(rootDeviceIndices, memMngr, tagCount, tagAlignment, tagSize, doNotReleaseNodes, deviceBitfield), initialValue(initialValue), initializeTags(initializeTags) { populateFreeTags(); } diff --git a/shared/test/common/mocks/mock_timestamp_container.h b/shared/test/common/mocks/mock_timestamp_container.h index 741cbc387b..4bb5681d35 100644 --- a/shared/test/common/mocks/mock_timestamp_container.h +++ b/shared/test/common/mocks/mock_timestamp_container.h @@ -21,7 +21,7 @@ class MockTagAllocator : public TagAllocator { MockTagAllocator(uint32_t rootDeviceIndex, MemoryManager *memoryManager, size_t tagCount, size_t tagAlignment, size_t tagSize, bool doNotReleaseNodes, DeviceBitfield deviceBitfield) - : BaseClass(RootDeviceIndicesContainer({rootDeviceIndex}), memoryManager, tagCount, tagAlignment, tagSize, doNotReleaseNodes, true, deviceBitfield) { + : BaseClass(RootDeviceIndicesContainer({rootDeviceIndex}), memoryManager, tagCount, tagAlignment, tagSize, NEO::TimestampPacketConstants::initValue, doNotReleaseNodes, true, deviceBitfield) { } MockTagAllocator(uint32_t rootDeviceIndex, MemoryManager *memoryManager, size_t tagCount = 10) @@ -29,7 +29,7 @@ class MockTagAllocator : public TagAllocator { } MockTagAllocator(const RootDeviceIndicesContainer &rootDeviceIndices, MemoryManager *memoryManager, size_t tagCount = 10) - : BaseClass(rootDeviceIndices, memoryManager, tagCount, MemoryConstants::cacheLineSize, sizeof(TagType), false, true, mockDeviceBitfield) {} + : BaseClass(rootDeviceIndices, memoryManager, tagCount, MemoryConstants::cacheLineSize, sizeof(TagType), NEO::TimestampPacketConstants::initValue, false, true, mockDeviceBitfield) {} void returnTag(TagNodeBase *node) override { releaseReferenceNodes.push_back(static_cast(node)); diff --git a/shared/test/common/mocks/mock_timestamp_packet.h b/shared/test/common/mocks/mock_timestamp_packet.h index 04016cf6b6..36c41a207b 100644 --- a/shared/test/common/mocks/mock_timestamp_packet.h +++ b/shared/test/common/mocks/mock_timestamp_packet.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2023 Intel Corporation + * Copyright (C) 2022-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -16,7 +16,7 @@ class MockTimestampPackets32 : public TimestampPackets::packets; void setTagToReadyState() { - initialize(); + initialize(0); uint32_t zeros[4] = {}; diff --git a/shared/test/unit_test/utilities/tag_allocator_tests.cpp b/shared/test/unit_test/utilities/tag_allocator_tests.cpp index d76a94cb23..5fc79bbfc6 100644 --- a/shared/test/unit_test/utilities/tag_allocator_tests.cpp +++ b/shared/test/unit_test/utilities/tag_allocator_tests.cpp @@ -36,7 +36,8 @@ struct TagAllocatorTest : public Test { }; struct TimeStamps { - void initialize() { + using ValueT = uint64_t; + void initialize(uint64_t initValue) { initializeCount++; start = 1; end = 2; @@ -94,7 +95,7 @@ class MockTagAllocator : public TagAllocator { MockTagAllocator(uint32_t rootDeviceIndex, MemoryManager *memoryManager, size_t tagCount, size_t tagAlignment, size_t tagSize, bool doNotReleaseNodes, DeviceBitfield deviceBitfield) - : BaseClass(RootDeviceIndicesContainer{rootDeviceIndex}, memoryManager, tagCount, tagAlignment, tagSize, doNotReleaseNodes, true, deviceBitfield) { + : BaseClass(RootDeviceIndicesContainer{rootDeviceIndex}, memoryManager, tagCount, tagAlignment, tagSize, 0, doNotReleaseNodes, true, deviceBitfield) { } MockTagAllocator(MemoryManager *memMngr, size_t tagCount, size_t tagAlignment, bool disableCompletionCheck, DeviceBitfield deviceBitfield) @@ -357,8 +358,8 @@ TEST_F(TagAllocatorTest, whenNewTagIsTakenThenItIsInitialized) { } TEST_F(TagAllocatorTest, givenReinitializationDisabledWhenGettingNewTagThenDontInitialize) { - MockTagAllocator tagAllocator1(RootDeviceIndicesContainer{0}, memoryManager, 1, 2, sizeof(TimeStamps), false, true, deviceBitfield); - MockTagAllocator tagAllocator2(RootDeviceIndicesContainer{0}, memoryManager, 1, 2, sizeof(TimeStamps), false, false, deviceBitfield); + MockTagAllocator tagAllocator1(RootDeviceIndicesContainer{0}, memoryManager, 1, 2, sizeof(TimeStamps), 0, false, true, deviceBitfield); + MockTagAllocator tagAllocator2(RootDeviceIndicesContainer{0}, memoryManager, 1, 2, sizeof(TimeStamps), 0, false, false, deviceBitfield); tagAllocator1.freeTags.peekHead()->tagForCpuAccess->initializeCount = 0; tagAllocator2.freeTags.peekHead()->tagForCpuAccess->initializeCount = 0; @@ -500,7 +501,7 @@ TEST_F(TagAllocatorTest, givenMultipleRootDevicesWhenPopulatingTagsThenCreateMul const RootDeviceIndicesContainer indices = {0, 2, maxRootDeviceIndex}; MockTagAllocator> timestampPacketAllocator(indices, testMemoryManager, 1, 1, - sizeof(TimestampPackets), false, + sizeof(TimestampPackets), 0, false, true, mockDeviceBitfield); EXPECT_EQ(1u, timestampPacketAllocator.getGraphicsAllocationsCount()); @@ -532,7 +533,7 @@ HWTEST_F(TagAllocatorTest, givenMultipleRootDevicesWhenCallingMakeResidentThenUs const RootDeviceIndicesContainer indicesVector = {0, 1}; MockTagAllocator> timestampPacketAllocator(indicesVector, testMemoryManager, 1, 1, sizeof(TimestampPackets), - false, true, mockDeviceBitfield); + 0, false, true, mockDeviceBitfield); EXPECT_EQ(1u, timestampPacketAllocator.getGraphicsAllocationsCount());