Skip to content

Commit

Permalink
Fix completion check for TimestampPacketStorage
Browse files Browse the repository at this point in the history
Change-Id: If15d2bbc49a1dc2dfb29e3b6cdc3ad1523997cd5
Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
  • Loading branch information
BartoszDunajski authored and Compute-Runtime-Automation committed Nov 29, 2019
1 parent 8784491 commit b1fbced
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion runtime/helpers/timestamp_packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct TimestampPacketStorage {

bool isCompleted() const {
for (uint32_t i = 0; i < packetsUsed; i++) {
if ((packets[0].contextEnd & 1) || (packets[0].globalEnd & 1)) {
if ((packets[i].contextEnd & 1) || (packets[i].globalEnd & 1)) {
return false;
}
}
Expand Down
19 changes: 19 additions & 0 deletions unit_tests/helpers/timestamp_packet_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,25 @@ TEST_F(TimestampPacketSimpleTests, whenIsCompletedIsCalledThenItReturnsProperTim
EXPECT_TRUE(timestampPacketStorage.isCompleted());
}

TEST_F(TimestampPacketSimpleTests, givenMultiplePacketsInUseWhenCompletionIsCheckedTheVerifyAllUsedNodes) {
TimestampPacketStorage timestampPacketStorage;
auto &packets = timestampPacketStorage.packets;

timestampPacketStorage.packetsUsed = TimestampPacketSizeControl::preferredPacketCount - 1;

for (uint32_t i = 0; i < timestampPacketStorage.packetsUsed - 1; i++) {
packets[i].contextEnd = 0;
packets[i].globalEnd = 0;
EXPECT_FALSE(timestampPacketStorage.isCompleted());
}

packets[timestampPacketStorage.packetsUsed - 1].contextEnd = 0;
EXPECT_FALSE(timestampPacketStorage.isCompleted());

packets[timestampPacketStorage.packetsUsed - 1].globalEnd = 0;
EXPECT_TRUE(timestampPacketStorage.isCompleted());
}

TEST_F(TimestampPacketSimpleTests, givenImplicitDependencyWhenEndTagIsWrittenThenCantBeReleased) {
TimestampPacketStorage timestampPacketStorage;

Expand Down

0 comments on commit b1fbced

Please sign in to comment.