Skip to content

Commit aa0388e

Browse files
Add debug flag to print time stamps
Change-Id: I198dca8e1310f7663baeebb20f6ae2552e608e99 Signed-off-by: Lukasz Jobczyk <[email protected]>
1 parent aa8e9fb commit aa0388e

File tree

4 files changed

+56
-2
lines changed

4 files changed

+56
-2
lines changed

opencl/source/event/event.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,19 @@ bool Event::calcProfilingData() {
250250
const auto timestamps = timestampPacketContainer->peekNodes();
251251
auto isMultiOsContextCapable = this->getCommandQueue()->getGpgpuCommandStreamReceiver().isMultiOsContextCapable();
252252

253+
if (DebugManager.flags.PrintTimestampPacketContents.get()) {
254+
for (auto i = 0u; i < timestamps.size(); i++) {
255+
for (auto j = 0u; j < timestamps[i]->tagForCpuAccess->packetsUsed; j++) {
256+
const auto &packet = timestamps[i]->tagForCpuAccess->packets[j];
257+
std::cout << "Timestamp " << i << ", packet " << j << ": "
258+
<< "global start: " << packet.globalStart << ", "
259+
<< "global end: " << packet.globalEnd << ", "
260+
<< "context start: " << packet.contextStart << ", "
261+
<< "context end: " << packet.contextEnd << std::endl;
262+
}
263+
}
264+
}
265+
253266
if (isMultiOsContextCapable) {
254267
auto globalStartTS = timestamps[0]->tagForCpuAccess->packets[0].globalStart;
255268
uint64_t globalEndTS = timestamps[0]->tagForCpuAccess->packets[0].globalEnd;

opencl/test/unit_test/profiling/profiling_tests.cpp

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -924,14 +924,16 @@ struct ProfilingTimestampPacketsTest : public ::testing::Test {
924924
ev->timestampPacketContainer->add(node);
925925
}
926926

927-
void addTimestampNodeMultiOsContext(int globalStart[16], int globalEnd[16], uint32_t size) {
927+
void addTimestampNodeMultiOsContext(int globalStart[16], int globalEnd[16], int contextStart[16], int contextEnd[16], uint32_t size) {
928928
auto node = new MockTagNode<TimestampPacketStorage>();
929929
auto timestampPacketStorage = new TimestampPacketStorage();
930930
timestampPacketStorage->packetsUsed = size;
931931

932932
for (uint32_t i = 0u; i < timestampPacketStorage->packetsUsed; ++i) {
933933
timestampPacketStorage->packets[i].globalStart = globalStart[i];
934934
timestampPacketStorage->packets[i].globalEnd = globalEnd[i];
935+
timestampPacketStorage->packets[i].contextStart = contextStart[i];
936+
timestampPacketStorage->packets[i].contextEnd = contextEnd[i];
935937
}
936938

937939
node->tagForCpuAccess = timestampPacketStorage;
@@ -981,8 +983,10 @@ TEST_F(ProfilingTimestampPacketsTest, givenTimestampsPacketContainerWithOneEleme
981983
TEST_F(ProfilingTimestampPacketsTest, givenMultiOsContextCapableSetToTrueWhenCalcProfilingDataIsCalledThenCorrectedValuesAreReturned) {
982984
int globalStart[16] = {0};
983985
int globalEnd[16] = {0};
986+
int contextStart[16] = {0};
987+
int contextEnd[16] = {0};
984988
initTimestampNodeMultiOsContextData(globalStart, globalEnd, 16u);
985-
addTimestampNodeMultiOsContext(globalStart, globalEnd, 16u);
989+
addTimestampNodeMultiOsContext(globalStart, globalEnd, contextStart, contextEnd, 16u);
986990
auto &device = reinterpret_cast<MockDevice &>(cmdQ->getDevice());
987991
auto &csr = device.getUltCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>();
988992
csr.multiOsContextCapable = true;
@@ -992,6 +996,41 @@ TEST_F(ProfilingTimestampPacketsTest, givenMultiOsContextCapableSetToTrueWhenCal
992996
EXPECT_EQ(350u, ev->getEndTimeStamp());
993997
}
994998

999+
TEST_F(ProfilingTimestampPacketsTest, givenPrintTimestampPacketContentsSetWhenCalcProfilingDataThenTimeStampsArePrinted) {
1000+
DebugManagerStateRestore restorer;
1001+
DebugManager.flags.PrintTimestampPacketContents.set(true);
1002+
testing::internal::CaptureStdout();
1003+
1004+
auto &device = reinterpret_cast<MockDevice &>(cmdQ->getDevice());
1005+
auto &csr = device.getUltCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>();
1006+
csr.multiOsContextCapable = true;
1007+
1008+
int globalStart[16] = {0};
1009+
int globalEnd[16] = {0};
1010+
int contextStart[16] = {0};
1011+
int contextEnd[16] = {0};
1012+
for (int i = 0; i < 16; i++) {
1013+
globalStart[i] = 2 * i;
1014+
globalEnd[i] = 500 * i;
1015+
contextStart[i] = 7 * i;
1016+
contextEnd[i] = 94 * i;
1017+
}
1018+
addTimestampNodeMultiOsContext(globalStart, globalEnd, contextStart, contextEnd, 16u);
1019+
1020+
ev->calcProfilingData();
1021+
1022+
std::string output = testing::internal::GetCapturedStdout();
1023+
std::stringstream expected;
1024+
for (int i = 0; i < 16; i++) {
1025+
expected << "Timestamp 0, packet " << i << ": "
1026+
<< "global start: " << globalStart[i] << ", "
1027+
<< "global end: " << globalEnd[i] << ", "
1028+
<< "context start: " << contextStart[i] << ", "
1029+
<< "context end: " << contextEnd[i] << std::endl;
1030+
}
1031+
EXPECT_EQ(0, output.compare(expected.str().c_str()));
1032+
}
1033+
9951034
TEST_F(ProfilingTimestampPacketsTest, givenTimestampsPacketContainerWithThreeElementsWhenCalculatingProfilingThenTimesAreTakenFromProperPacket) {
9961035
addTimestampNode(10, 11, 12);
9971036
addTimestampNode(1, 21, 22);

opencl/test/unit_test/test_files/igdrcl.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ PrintLWSSizes = 0
6767
PrintDispatchParameters = 0
6868
PrintProgramBinaryProcessingTime = 0
6969
PrintRelocations = 0
70+
PrintTimestampPacketContents = 0
7071
WddmResidencyLogger = 0
7172
PrintDriverDiagnostics = -1
7273
PrintDeviceAndEngineIdOnSubmission = 0

shared/source/debug_settings/debug_variables_base.inl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ DECLARE_DEBUG_VARIABLE(bool, PrintLWSSizes, false, "prints driver choosen local
8383
DECLARE_DEBUG_VARIABLE(bool, PrintDispatchParameters, false, "prints dispatch paramters of kernels passed to clEnqueueNDRangeKernel")
8484
DECLARE_DEBUG_VARIABLE(bool, PrintProgramBinaryProcessingTime, false, "prints execution time of Program::processGenBinary() method during program building")
8585
DECLARE_DEBUG_VARIABLE(bool, PrintRelocations, false, "prints relocations debug information")
86+
DECLARE_DEBUG_VARIABLE(bool, PrintTimestampPacketContents, false, "prints all timestamps values during profiling data calculation")
8687
DECLARE_DEBUG_VARIABLE(bool, WddmResidencyLogger, false, "gather Wddm residency statistics to file")
8788
DECLARE_DEBUG_VARIABLE(int32_t, PrintDriverDiagnostics, -1, "prints driver diagnostics messages to standard output, value corresponds to hint level")
8889
DECLARE_DEBUG_VARIABLE(bool, PrintDeviceAndEngineIdOnSubmission, false, "print submissions device and engine IDs to standard output")

0 commit comments

Comments
 (0)