Skip to content

Commit e2c9a25

Browse files
Add concept of chunks into timestamp packets.
Change-Id: Ic9a978224862e237a7268525f05b059756da06e7
1 parent 7488d79 commit e2c9a25

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

runtime/helpers/timestamp_packet.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,17 @@ class MemoryManager;
2222
template <typename TagType>
2323
struct TagNode;
2424

25+
namespace TimestampPacketSizeControl {
26+
constexpr uint32_t preferedChunkCount = 16u;
27+
}
28+
2529
#pragma pack(1)
2630
class TimestampPacket {
2731
public:
32+
TimestampPacket() {
33+
initialize();
34+
}
35+
2836
enum class DataIndex : uint32_t {
2937
ContextStart = 0,
3038
GlobalStart,
@@ -50,20 +58,22 @@ class TimestampPacket {
5058
}
5159

5260
void initialize() {
53-
data = {{1, 1, 1, 1}};
61+
for (auto index = 0u; index < data.size(); index++) {
62+
data[index] = 1;
63+
}
5464
implicitDependenciesCount.store(0);
5565
}
5666

5767
void incImplicitDependenciesCount() { implicitDependenciesCount++; }
5868
uint64_t pickImplicitDependenciesCountWriteAddress() const { return reinterpret_cast<uint64_t>(&implicitDependenciesCount); }
5969

6070
protected:
61-
std::array<uint32_t, static_cast<uint32_t>(DataIndex::Max)> data = {{1, 1, 1, 1}};
62-
std::atomic<uint32_t> implicitDependenciesCount{0};
71+
std::array<uint32_t, static_cast<uint32_t>(DataIndex::Max) * TimestampPacketSizeControl::preferedChunkCount> data;
72+
std::atomic<uint32_t> implicitDependenciesCount;
6373
};
6474
#pragma pack()
6575

66-
static_assert(((static_cast<uint32_t>(TimestampPacket::DataIndex::Max) + 1) * sizeof(uint32_t)) == sizeof(TimestampPacket),
76+
static_assert(((static_cast<uint32_t>(TimestampPacket::DataIndex::Max) * TimestampPacketSizeControl::preferedChunkCount + 1) * sizeof(uint32_t)) == sizeof(TimestampPacket),
6777
"This structure is consumed by GPU and has to follow specific restrictions for padding and size");
6878

6979
struct TimestampPacketHelper {

unit_tests/helpers/timestamp_packet_tests.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,10 @@ TEST_F(TimestampPacketSimpleTests, whenNewTagIsTakenThenReinitialize) {
163163
MockTagAllocator<MockTimestampPacket> allocator(&memoryManager, 1);
164164

165165
auto firstNode = allocator.getTag();
166-
firstNode->tag->data = {{5, 6, 7, 8}};
166+
for (uint32_t i = 0; i < static_cast<uint32_t>(TimestampPacket::DataIndex::Max) * TimestampPacketSizeControl::preferedChunkCount; i++) {
167+
firstNode->tag->data[i] = i;
168+
}
169+
167170
auto dependenciesCount = reinterpret_cast<std::atomic<uint32_t> *>(reinterpret_cast<void *>(firstNode->tag->pickImplicitDependenciesCountWriteAddress()));
168171

169172
setTagToReadyState(firstNode->tag);
@@ -174,19 +177,21 @@ TEST_F(TimestampPacketSimpleTests, whenNewTagIsTakenThenReinitialize) {
174177
EXPECT_EQ(secondNode, firstNode);
175178

176179
EXPECT_EQ(0u, dependenciesCount->load());
177-
for (uint32_t i = 0; i < static_cast<uint32_t>(TimestampPacket::DataIndex::Max); i++) {
180+
for (uint32_t i = 0; i < static_cast<uint32_t>(TimestampPacket::DataIndex::Max) * TimestampPacketSizeControl::preferedChunkCount; i++) {
178181
EXPECT_EQ(1u, secondNode->tag->data[i]);
179182
}
180183
}
181184

182185
TEST_F(TimestampPacketSimpleTests, whenObjectIsCreatedThenInitializeAllStamps) {
183186
MockTimestampPacket timestampPacket;
184-
auto maxElements = static_cast<uint32_t>(TimestampPacket::DataIndex::Max);
185-
EXPECT_EQ(4u, maxElements);
187+
auto entityElements = static_cast<uint32_t>(TimestampPacket::DataIndex::Max);
188+
auto allElements = entityElements * TimestampPacketSizeControl::preferedChunkCount;
189+
EXPECT_EQ(4u, entityElements);
190+
EXPECT_EQ(64u, allElements);
186191

187-
EXPECT_EQ(maxElements, timestampPacket.data.size());
192+
EXPECT_EQ(allElements, timestampPacket.data.size());
188193

189-
for (uint32_t i = 0; i < maxElements; i++) {
194+
for (uint32_t i = 0; i < allElements; i++) {
190195
EXPECT_EQ(1u, timestampPacket.data[i]);
191196
}
192197
}

0 commit comments

Comments
 (0)