Use global timestamps for TimestampPacket profiling calculations

Change-Id: I53ffe566b78c1b86cf430c23e0c0bb9000532b0c
Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
Bartosz Dunajski
2020-07-31 10:34:29 +02:00
committed by sys_ocldev
parent b6e98c4eb4
commit 8b267fd949
2 changed files with 21 additions and 39 deletions

View File

@@ -253,7 +253,6 @@ bool Event::calcProfilingData() {
if (!dataCalculated && !profilingCpuPath) {
if (timestampPacketContainer && timestampPacketContainer->peekNodes().size() > 0) {
const auto timestamps = timestampPacketContainer->peekNodes();
auto isMultiOsContextCapable = this->getCommandQueue()->getGpgpuCommandStreamReceiver().isMultiOsContextCapable();
if (DebugManager.flags.PrintTimestampPacketContents.get()) {
for (auto i = 0u; i < timestamps.size(); i++) {
@@ -268,8 +267,7 @@ bool Event::calcProfilingData() {
}
}
if (isMultiOsContextCapable) {
auto globalStartTS = timestamps[0]->tagForCpuAccess->packets[0].globalStart;
uint64_t globalStartTS = timestamps[0]->tagForCpuAccess->packets[0].globalStart;
uint64_t globalEndTS = timestamps[0]->tagForCpuAccess->packets[0].globalEnd;
for (const auto &timestamp : timestamps) {
@@ -284,25 +282,7 @@ bool Event::calcProfilingData() {
}
}
calculateProfilingDataInternal(globalStartTS, globalEndTS, &globalEndTS, globalStartTS);
} else {
auto contextStartTS = timestamps[0]->tagForCpuAccess->packets[0].contextStart;
uint64_t contextEndTS = timestamps[0]->tagForCpuAccess->packets[0].contextEnd;
auto globalStartTS = timestamps[0]->tagForCpuAccess->packets[0].globalStart;
for (const auto &timestamp : timestamps) {
const auto &packet = timestamp->tagForCpuAccess->packets[0];
if (contextStartTS > packet.contextStart) {
contextStartTS = packet.contextStart;
}
if (contextEndTS < packet.contextEnd) {
contextEndTS = packet.contextEnd;
}
if (globalStartTS > packet.globalStart) {
globalStartTS = packet.globalStart;
}
}
calculateProfilingDataInternal(contextStartTS, contextEndTS, &contextEndTS, globalStartTS);
}
} else if (timeStampNode) {
calculateProfilingDataInternal(
timeStampNode->tagForCpuAccess->ContextStartTS,

View File

@@ -1033,7 +1033,7 @@ struct ProfilingTimestampPacketsTest : public ::testing::Test {
ev->timestampPacketContainer = std::make_unique<MockTimestampContainer>();
}
void addTimestampNode(int contextStart, int contextEnd, int globalStart) {
void addTimestampNode(int contextStart, int contextEnd, int globalStart, int globalEnd) {
auto node = new MockTagNode<TimestampPacketStorage>();
auto timestampPacketStorage = new TimestampPacketStorage();
node->tagForCpuAccess = timestampPacketStorage;
@@ -1041,6 +1041,7 @@ struct ProfilingTimestampPacketsTest : public ::testing::Test {
timestampPacketStorage->packets[0].contextStart = contextStart;
timestampPacketStorage->packets[0].contextEnd = contextEnd;
timestampPacketStorage->packets[0].globalStart = globalStart;
timestampPacketStorage->packets[0].globalEnd = globalEnd;
ev->timestampPacketContainer->add(node);
}
@@ -1082,20 +1083,21 @@ struct ProfilingTimestampPacketsTest : public ::testing::Test {
};
TEST_F(ProfilingTimestampPacketsTest, givenTimestampsPacketContainerWithOneElementAndTimestampNodeWhenCalculatingProfilingThenTimesAreTakenFromPacket) {
addTimestampNode(10, 11, 12);
addTimestampNode(10, 11, 12, 13);
HwTimeStamps hwTimestamps;
hwTimestamps.ContextStartTS = 100;
hwTimestamps.ContextEndTS = 110;
hwTimestamps.GlobalStartTS = 120;
MockTagNode<HwTimeStamps> hwTimestampsNode;
hwTimestampsNode.tagForCpuAccess = &hwTimestamps;
ev->timeStampNode = &hwTimestampsNode;
ev->calcProfilingData();
EXPECT_EQ(10u, ev->getStartTimeStamp());
EXPECT_EQ(11u, ev->getEndTimeStamp());
EXPECT_EQ(12u, ev->getStartTimeStamp());
EXPECT_EQ(13u, ev->getEndTimeStamp());
EXPECT_EQ(12u, ev->getGlobalStartTimestamp());
ev->timeStampNode = nullptr;
@@ -1153,14 +1155,14 @@ TEST_F(ProfilingTimestampPacketsTest, givenPrintTimestampPacketContentsSetWhenCa
}
TEST_F(ProfilingTimestampPacketsTest, givenTimestampsPacketContainerWithThreeElementsWhenCalculatingProfilingThenTimesAreTakenFromProperPacket) {
addTimestampNode(10, 11, 12);
addTimestampNode(1, 21, 22);
addTimestampNode(5, 31, 2);
addTimestampNode(10, 11, 12, 13);
addTimestampNode(1, 21, 22, 13);
addTimestampNode(5, 31, 2, 13);
ev->calcProfilingData();
EXPECT_EQ(1u, ev->getStartTimeStamp());
EXPECT_EQ(31u, ev->getEndTimeStamp());
EXPECT_EQ(2u, ev->getStartTimeStamp());
EXPECT_EQ(13u, ev->getEndTimeStamp());
EXPECT_EQ(2u, ev->getGlobalStartTimestamp());
}