diff --git a/runtime/helpers/timestamp_packet.h b/runtime/helpers/timestamp_packet.h index 4eb373c05b..241c1dae21 100644 --- a/runtime/helpers/timestamp_packet.h +++ b/runtime/helpers/timestamp_packet.h @@ -22,9 +22,17 @@ class MemoryManager; template struct TagNode; +namespace TimestampPacketSizeControl { +constexpr uint32_t preferedChunkCount = 16u; +} + #pragma pack(1) class TimestampPacket { public: + TimestampPacket() { + initialize(); + } + enum class DataIndex : uint32_t { ContextStart = 0, GlobalStart, @@ -50,7 +58,9 @@ class TimestampPacket { } void initialize() { - data = {{1, 1, 1, 1}}; + for (auto index = 0u; index < data.size(); index++) { + data[index] = 1; + } implicitDependenciesCount.store(0); } @@ -58,12 +68,12 @@ class TimestampPacket { uint64_t pickImplicitDependenciesCountWriteAddress() const { return reinterpret_cast(&implicitDependenciesCount); } protected: - std::array(DataIndex::Max)> data = {{1, 1, 1, 1}}; - std::atomic implicitDependenciesCount{0}; + std::array(DataIndex::Max) * TimestampPacketSizeControl::preferedChunkCount> data; + std::atomic implicitDependenciesCount; }; #pragma pack() -static_assert(((static_cast(TimestampPacket::DataIndex::Max) + 1) * sizeof(uint32_t)) == sizeof(TimestampPacket), +static_assert(((static_cast(TimestampPacket::DataIndex::Max) * TimestampPacketSizeControl::preferedChunkCount + 1) * sizeof(uint32_t)) == sizeof(TimestampPacket), "This structure is consumed by GPU and has to follow specific restrictions for padding and size"); struct TimestampPacketHelper { diff --git a/unit_tests/helpers/timestamp_packet_tests.cpp b/unit_tests/helpers/timestamp_packet_tests.cpp index a013517e47..3488b5d92d 100644 --- a/unit_tests/helpers/timestamp_packet_tests.cpp +++ b/unit_tests/helpers/timestamp_packet_tests.cpp @@ -163,7 +163,10 @@ TEST_F(TimestampPacketSimpleTests, whenNewTagIsTakenThenReinitialize) { MockTagAllocator allocator(&memoryManager, 1); auto firstNode = allocator.getTag(); - firstNode->tag->data = {{5, 6, 7, 8}}; + for (uint32_t i = 0; i < static_cast(TimestampPacket::DataIndex::Max) * TimestampPacketSizeControl::preferedChunkCount; i++) { + firstNode->tag->data[i] = i; + } + auto dependenciesCount = reinterpret_cast *>(reinterpret_cast(firstNode->tag->pickImplicitDependenciesCountWriteAddress())); setTagToReadyState(firstNode->tag); @@ -174,19 +177,21 @@ TEST_F(TimestampPacketSimpleTests, whenNewTagIsTakenThenReinitialize) { EXPECT_EQ(secondNode, firstNode); EXPECT_EQ(0u, dependenciesCount->load()); - for (uint32_t i = 0; i < static_cast(TimestampPacket::DataIndex::Max); i++) { + for (uint32_t i = 0; i < static_cast(TimestampPacket::DataIndex::Max) * TimestampPacketSizeControl::preferedChunkCount; i++) { EXPECT_EQ(1u, secondNode->tag->data[i]); } } TEST_F(TimestampPacketSimpleTests, whenObjectIsCreatedThenInitializeAllStamps) { MockTimestampPacket timestampPacket; - auto maxElements = static_cast(TimestampPacket::DataIndex::Max); - EXPECT_EQ(4u, maxElements); + auto entityElements = static_cast(TimestampPacket::DataIndex::Max); + auto allElements = entityElements * TimestampPacketSizeControl::preferedChunkCount; + EXPECT_EQ(4u, entityElements); + EXPECT_EQ(64u, allElements); - EXPECT_EQ(maxElements, timestampPacket.data.size()); + EXPECT_EQ(allElements, timestampPacket.data.size()); - for (uint32_t i = 0; i < maxElements; i++) { + for (uint32_t i = 0; i < allElements; i++) { EXPECT_EQ(1u, timestampPacket.data[i]); } }