Skip to content
This repository was archived by the owner on Apr 30, 2020. It is now read-only.

Commit 9241c19

Browse files
committed
use same timestamp calculation in timeline tooltip and summary table
1 parent bebdedc commit 9241c19

7 files changed

Lines changed: 121 additions & 112 deletions

File tree

Lines changed: 92 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,85 @@
1-
//=====================================================================
2-
// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved.
3-
//
4-
/// \author GPU Developer Tools
5-
/// \file $File: //devtools/main/CodeXL/Components/GpuProfiling/AMDTGpuProfiling/APITimelineItems.cpp $
6-
/// \version $Revision: #10 $
7-
/// \brief This file contains the base timeline item classes used for all APIs
8-
//
9-
//=====================================================================
10-
// $Id: //devtools/main/CodeXL/Components/GpuProfiling/AMDTGpuProfiling/APITimelineItems.cpp#10 $
11-
// Last checkin: $DateTime: 2016/04/18 06:02:03 $
12-
// Last edited by: $Author: salgrana $
13-
// Change list: $Change: 569613 $
14-
//=====================================================================
15-
16-
// Infra:
1+
//=====================================================================
2+
// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved.
3+
//
4+
/// \author GPU Developer Tools
5+
/// \file $File: //devtools/main/CodeXL/Components/GpuProfiling/AMDTGpuProfiling/APITimelineItems.cpp $
6+
/// \version $Revision: #10 $
7+
/// \brief This file contains the base timeline item classes used for all APIs
8+
//
9+
//=====================================================================
10+
// $Id: //devtools/main/CodeXL/Components/GpuProfiling/AMDTGpuProfiling/APITimelineItems.cpp#10 $
11+
// Last checkin: $DateTime: 2016/04/18 06:02:03 $
12+
// Last edited by: $Author: salgrana $
13+
// Change list: $Change: 569613 $
14+
//=====================================================================
15+
16+
// Infra:
1717
#include <AMDTApplicationComponents/Include/acFunctions.h>
18-
#include <AMDTApplicationComponents/Include/Timeline/acTimeline.h>
19-
20-
// Local:
21-
#include <AMDTGpuProfiling/APITimelineItems.h>
22-
#include <AMDTGpuProfiling/TraceTable.h>
23-
#include <AMDTGpuProfiling/gpStringConstants.h>
24-
25-
26-
APITimelineItem::APITimelineItem() : acAPITimelineItem(std::numeric_limits<quint64>::max(), std::numeric_limits<quint64>::min(), -1), m_pTraceTableItem(NULL)
27-
{
28-
}
29-
APITimelineItem::APITimelineItem(quint64 startTime, quint64 endTime, int apiIndex) : acAPITimelineItem(startTime, endTime, apiIndex), m_pTraceTableItem(NULL)
30-
{
31-
}
32-
33-
void APITimelineItem::tooltipItems(acTimelineItemToolTip& tooltip) const
34-
{
35-
// Add the base class tooltip items:
36-
acAPITimelineItem::tooltipItems(tooltip);
37-
38-
if (m_pTraceTableItem != NULL)
39-
{
40-
QString strDeviceTime = m_pTraceTableItem->GetColumnData(TraceTableModel::TRACE_DEVICE_TIME_COLUMN).toString();
41-
42-
if (!strDeviceTime.isEmpty())
43-
{
44-
quint64 deviceTime = (quint64)(strDeviceTime.toFloat() * 1000000);
45-
strDeviceTime = getDurationString(deviceTime);
46-
tooltip.add(tr("Device Time"), strDeviceTime);
47-
}
48-
}
49-
}
50-
51-
DispatchAPITimelineItem::DispatchAPITimelineItem(acAPITimelineItem* deviceItem, acAPITimelineItem* item) : APITimelineItem(item->startTime(), item->endTime(), item->apiIndex()), m_deviceItem(deviceItem)
52-
{
53-
m_strText = item->text();
54-
m_backgroundColor = item->backgroundColor();
55-
m_foregroundColor = item->foregroundColor();
56-
}
57-
58-
DispatchAPITimelineItem::DispatchAPITimelineItem(const QString& text) : APITimelineItem(), m_deviceItem(nullptr)
59-
{
60-
m_strText = text;
61-
}
62-
63-
HostAPITimelineItem::HostAPITimelineItem(quint64 startTime, quint64 endTime, int apiIndex) : APITimelineItem(startTime, endTime, apiIndex), m_pHostItem(NULL)
64-
{
65-
}
66-
67-
68-
PerfMarkerTimelineItem::PerfMarkerTimelineItem(quint64 startTime, quint64 endTime) : acTimelineItem(startTime, endTime), m_pTraceTableItem(NULL)
69-
{
70-
71-
}
72-
73-
74-
CommandListTimelineItem::CommandListTimelineItem(quint64 startTime, quint64 endTime, const QString& commandListPtr):
75-
acTimelineItem(startTime, endTime), m_commandListPtr(commandListPtr)
76-
{
77-
78-
}
79-
80-
void CommandListTimelineItem::tooltipItems(acTimelineItemToolTip& tooltip) const
81-
{
82-
tooltip.add(text(), m_commandListPtr);
18+
#include <AMDTApplicationComponents/Include/Timeline/acTimeline.h>
19+
20+
// Local:
21+
#include <AMDTGpuProfiling/APITimelineItems.h>
22+
#include <AMDTGpuProfiling/TraceTable.h>
23+
#include <AMDTGpuProfiling/gpStringConstants.h>
24+
25+
26+
APITimelineItem::APITimelineItem() : acAPITimelineItem(std::numeric_limits<quint64>::max(), std::numeric_limits<quint64>::min(), -1), m_pTraceTableItem(NULL)
27+
{
28+
}
29+
APITimelineItem::APITimelineItem(quint64 startTime, quint64 endTime, int apiIndex) : acAPITimelineItem(startTime, endTime, apiIndex), m_pTraceTableItem(NULL)
30+
{
31+
}
32+
33+
void APITimelineItem::tooltipItems(acTimelineItemToolTip& tooltip) const
34+
{
35+
// Add the base class tooltip items:
36+
acAPITimelineItem::tooltipItems(tooltip);
37+
38+
if (m_pTraceTableItem != NULL)
39+
{
40+
QString strDeviceTime = m_pTraceTableItem->GetColumnData(TraceTableModel::TRACE_DEVICE_TIME_COLUMN).toString();
41+
42+
if (!strDeviceTime.isEmpty())
43+
{
44+
quint64 deviceTime = (quint64)(strDeviceTime.toFloat() * 1000000);
45+
strDeviceTime = getDurationString(deviceTime);
46+
tooltip.add(tr("Device Time"), strDeviceTime);
47+
}
48+
}
49+
}
50+
51+
DispatchAPITimelineItem::DispatchAPITimelineItem(acAPITimelineItem* deviceItem, acAPITimelineItem* item) : APITimelineItem(item->startTime(), item->endTime(), item->apiIndex()), m_deviceItem(deviceItem)
52+
{
53+
m_strText = item->text();
54+
m_backgroundColor = item->backgroundColor();
55+
m_foregroundColor = item->foregroundColor();
56+
}
57+
58+
DispatchAPITimelineItem::DispatchAPITimelineItem(const QString& text) : APITimelineItem(), m_deviceItem(nullptr)
59+
{
60+
m_strText = text;
61+
}
62+
63+
HostAPITimelineItem::HostAPITimelineItem(quint64 startTime, quint64 endTime, int apiIndex) : APITimelineItem(startTime, endTime, apiIndex), m_pHostItem(NULL)
64+
{
65+
}
66+
67+
68+
PerfMarkerTimelineItem::PerfMarkerTimelineItem(quint64 startTime, quint64 endTime) : acTimelineItem(startTime, endTime), m_pTraceTableItem(NULL)
69+
{
70+
71+
}
72+
73+
74+
CommandListTimelineItem::CommandListTimelineItem(quint64 startTime, quint64 endTime, const QString& commandListPtr):
75+
acTimelineItem(startTime, endTime), m_commandListPtr(commandListPtr)
76+
{
77+
78+
}
79+
80+
void CommandListTimelineItem::tooltipItems(acTimelineItemToolTip& tooltip) const
81+
{
82+
tooltip.add(text(), m_commandListPtr);
8383

8484
quint64 timelineStartTime = 0;
8585
if (m_pParentBranch != NULL)
@@ -93,12 +93,14 @@ void CommandListTimelineItem::tooltipItems(acTimelineItemToolTip& tooltip) const
9393
}
9494

9595
// Convert the start and end times to milliseconds
96-
double fnumStart = (m_nStartTime - timelineStartTime) / 1e6;
97-
double fnumEnd = (m_nEndTime - timelineStartTime) / 1e6; // convert to milliseconds
98-
99-
quint64 duration = m_nEndTime - m_nStartTime;
100-
QString durationStr = NanosecToTimeString(duration, true, false);
101-
102-
QString tooltipLine = QString(GPU_STR_APITimeline_TimeTooltipLine).arg(fnumStart, 0, 'f', 3).arg(fnumEnd, 0, 'f', 3).arg(durationStr);
103-
tooltip.add("", tooltipLine);
104-
}
96+
double fnumStart = (m_nStartTime - timelineStartTime);
97+
double fnumEnd = (m_nEndTime - timelineStartTime);
98+
99+
quint64 duration = m_nEndTime - m_nStartTime;
100+
QString durationStr = NanosecToTimeStringFormatted(duration, true);
101+
QString fnumStartStr = NanosecToTimeStringFormatted(fnumStart, true);
102+
QString fnumEndStr = NanosecToTimeStringFormatted(fnumEnd, true);
103+
104+
QString tooltipLine = QString(GPU_STR_APITimeline_TimeTooltipLine).arg(fnumStartStr).arg(fnumEndStr).arg(durationStr);
105+
tooltip.add("", tooltipLine);
106+
}

CodeXL/Components/GpuProfiling/AMDTGpuProfiling/gpStringConstants.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@
498498
#define GPU_STR_timeline_ContextBranchNameWithParam "Queue %1 - %2 (%3)"
499499

500500
#define GPU_STR_DXAPITimeline_tooltipLine1 "Call #%1<br>%2"
501-
#define GPU_STR_APITimeline_TimeTooltipLine "Time: %3 - %4 (%5ms)"
501+
#define GPU_STR_APITimeline_TimeTooltipLine "Time: %3 - %4 (%5)"
502502

503503
// Frame info xml
504504
#define GPU_STR_frameInfoXMLLocation "Location"

CodeXL/Components/GpuProfiling/AMDTGpuProfiling/gpTraceSummaryTab.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ static const char* table_captions[] = { GPU_STR_API_Call_Summary, GPU_STR_GPU_Ca
1313
const int MAX_ITEMS_IN_TABLE = 20;
1414

1515
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
16-
gpSummaryTab::gpSummaryTab(eCallType callType)
17-
: m_callType(callType), m_pTraceView(nullptr), m_pSummaryTable(nullptr), m_pTop20Table(nullptr), m_pTop20Caption(nullptr), m_pChkboxUseScope(nullptr), m_useTimelineSelectionScope(false), m_timelineStart(0), m_timelineEnd(0), m_currentCallIndex(0)
16+
gpSummaryTab::gpSummaryTab(eCallType callType, quint64 timelineAbsoluteStart)
17+
: m_callType(callType), m_pTraceView(nullptr), m_pSummaryTable(nullptr), m_pTop20Table(nullptr), m_pTop20Caption(nullptr), m_pChkboxUseScope(nullptr), m_useTimelineSelectionScope(false), m_timelineStart(0), m_timelineEnd(0), m_currentCallIndex(0), m_timelineAbsoluteStart(timelineAbsoluteStart)
1818
{
1919
}
2020

@@ -25,11 +25,11 @@ bool gpSummaryTab::Init(gpTraceDataContainer* pDataContainer, gpTraceView* pSess
2525
m_pSessionDataContainer = pDataContainer;
2626
if (m_callType == API_CALL || m_callType == GPU_CALL)
2727
{
28-
m_pSummaryTable = new gpTraceSummaryTable(pDataContainer, pSessionView, m_callType);
28+
m_pSummaryTable = new gpTraceSummaryTable(pDataContainer, pSessionView, m_callType, m_timelineAbsoluteStart);
2929
}
3030
else
3131
{
32-
m_pSummaryTable = new gpCommandListSummaryTable(pDataContainer, pSessionView);
32+
m_pSummaryTable = new gpCommandListSummaryTable(pDataContainer, pSessionView, m_timelineAbsoluteStart);
3333
}
3434

3535
m_pTop20Table = new acListCtrl(this);

CodeXL/Components/GpuProfiling/AMDTGpuProfiling/gpTraceSummaryTab.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class gpSummaryTab : public QWidget
2727
public:
2828
/// Ctor
2929
/// \param callType the type of items displayed in this tab
30-
gpSummaryTab(eCallType callType);
30+
gpSummaryTab(eCallType callType, quint64 timelineAbsoluteStart);
3131

3232
/// Initializes the summary widget
3333
/// \param pDataContainer
@@ -122,14 +122,15 @@ class gpSummaryTab : public QWidget
122122

123123
bool m_useTimelineSelectionScope;
124124
QString m_currentCallName;
125+
quint64 m_timelineAbsoluteStart;
125126

126127
};
127128

128129
class gpTraceSummaryTab : public gpSummaryTab
129130
{
130131
Q_OBJECT
131132
public:
132-
gpTraceSummaryTab(eCallType callType) :gpSummaryTab(callType) {}
133+
gpTraceSummaryTab(eCallType callType, quint64 timelineAbsoluteStart) :gpSummaryTab(callType, timelineAbsoluteStart) {}
133134
virtual void RefreshAndMaintainSelection(bool check);
134135

135136
public slots :
@@ -149,7 +150,7 @@ class gpCommandListSummaryTab : public gpSummaryTab
149150
{
150151
Q_OBJECT
151152
public:
152-
gpCommandListSummaryTab(eCallType callType) :gpSummaryTab(callType) {}
153+
gpCommandListSummaryTab(eCallType callType, quint64 timelineAbsoluteStart) :gpSummaryTab(callType, timelineAbsoluteStart) {}
153154
virtual void RefreshAndMaintainSelection(bool check);
154155
public slots :
155156
/// Handles selection change in summary table: updates top20 table accordingly

CodeXL/Components/GpuProfiling/AMDTGpuProfiling/gpTraceSummaryTable.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ void gpSummaryTable::Refresh(bool useTimelineScope, quint64 min, quint64 max)
2525
FillTable();
2626
}
2727

28-
gpTraceSummaryTable::gpTraceSummaryTable(gpTraceDataContainer* pDataContainer, gpTraceView* pSessionView, eCallType callType)
29-
: gpSummaryTable(pDataContainer, pSessionView, callType), m_callType(callType)
28+
gpTraceSummaryTable::gpTraceSummaryTable(gpTraceDataContainer* pDataContainer, gpTraceView* pSessionView, eCallType callType, quint64 timelineAbsoluteStart)
29+
: gpSummaryTable(pDataContainer, pSessionView, callType, timelineAbsoluteStart), m_callType(callType)
3030
{
3131
m_pSessionDataContainer = pDataContainer;
3232

@@ -257,8 +257,8 @@ void gpTraceSummaryTable::OnCellEntered(int row, int column)
257257
}
258258
}
259259

260-
gpSummaryTable::gpSummaryTable(gpTraceDataContainer* pDataContainer, gpTraceView* pSessionView, eCallType callType)
261-
:acListCtrl(nullptr), m_pSessionDataContainer(pDataContainer), m_pTraceView(pSessionView), m_lastSelectedRowIndex(-1)
260+
gpSummaryTable::gpSummaryTable(gpTraceDataContainer* pDataContainer, gpTraceView* pSessionView, eCallType callType, quint64 timelineAbsoluteStart)
261+
:acListCtrl(nullptr), m_pSessionDataContainer(pDataContainer), m_pTraceView(pSessionView), m_lastSelectedRowIndex(-1), m_timelineAbsoluteStart(timelineAbsoluteStart)
262262
{
263263
GT_UNREFERENCED_PARAMETER(callType);
264264
}
@@ -582,8 +582,8 @@ void gpTraceSummaryTable::Cleanup()
582582
}
583583

584584
/////////////////////////////////////////////////////////////////////////////////
585-
gpCommandListSummaryTable::gpCommandListSummaryTable(gpTraceDataContainer* pDataContainer, gpTraceView* pSessionView)
586-
: gpSummaryTable(pDataContainer, pSessionView, (eCallType)3), m_pSessionDataContainer(pDataContainer), m_pTraceView(pSessionView), m_lastSelectedRowIndex(-1)
585+
gpCommandListSummaryTable::gpCommandListSummaryTable(gpTraceDataContainer* pDataContainer, gpTraceView* pSessionView, quint64 timelineAbsoluteStart)
586+
: gpSummaryTable(pDataContainer, pSessionView, (eCallType)3, timelineAbsoluteStart), m_pSessionDataContainer(pDataContainer), m_pTraceView(pSessionView), m_lastSelectedRowIndex(-1)
587587
{
588588
m_pSessionDataContainer = pDataContainer;
589589
bool isDx12 = (pDataContainer != nullptr && pDataContainer->SessionAPIType() == ProfileSessionDataItem::ProfileItemAPIType::DX12_API_PROFILE_ITEM);
@@ -680,6 +680,7 @@ void gpCommandListSummaryTable::InitCommandListItems()
680680
info.m_address = (*iter).m_commandListPtr;
681681
info.m_minTimeMs = (*iter).m_startTime;
682682
info.m_maxTimeMs = (*iter).m_endTime;
683+
683684
info.m_numCalls = (*iter).m_apiIndices.size();
684685
info.m_executionTimeMS = ((*iter).m_endTime - (*iter).m_startTime);
685686
info.m_typeColor = APIColorMap::Instance()->GetCommandListColor(commandListIndex);
@@ -705,6 +706,9 @@ void gpCommandListSummaryTable::InitCommandListItems()
705706
}
706707
}
707708
}
709+
// normalize to timeline start
710+
info.m_minTimeMs = (info.m_minTimeMs - m_timelineAbsoluteStart);
711+
info.m_maxTimeMs = (info.m_maxTimeMs - m_timelineAbsoluteStart);
708712

709713
commandListIndex++;
710714

CodeXL/Components/GpuProfiling/AMDTGpuProfiling/gpTraceSummaryTable.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,15 @@ class APISummaryCommandListInfo : public APISummaryInfo
109109
void TableItemsAsString(QStringList& membersStringsList)
110110
{
111111
membersStringsList << m_index;
112-
membersStringsList << QString::number(m_executionTimeMS, 'f', 6);
113-
membersStringsList << QString::number(m_minTimeMs, 'f', 6);
114-
membersStringsList << QString::number(m_maxTimeMs, 'f', 6);
112+
membersStringsList << QString::number(m_executionTimeMS, 'f', 3);
113+
membersStringsList << QString::number(m_minTimeMs, 'f', 3);
114+
membersStringsList << QString::number(m_maxTimeMs, 'f', 3);
115115
membersStringsList << QString::number(m_numCalls);
116116
membersStringsList << m_gpuQueue;
117117
membersStringsList << m_address;
118118
}
119119

120+
120121
QString m_index;
121122
QString m_address;
122123
QString m_gpuQueue;
@@ -132,7 +133,7 @@ class gpSummaryTable : public acListCtrl
132133

133134
Q_OBJECT
134135
public :
135-
gpSummaryTable(gpTraceDataContainer* pDataContainer, gpTraceView* pSessionView, eCallType callType);
136+
gpSummaryTable(gpTraceDataContainer* pDataContainer, gpTraceView* pSessionView, eCallType callType, quint64 timelineAbsoluteStart);
136137
virtual ~gpSummaryTable();
137138
// Save selection in summary table to be restored on tab switch
138139
// Restores selection
@@ -165,6 +166,7 @@ public :
165166
gpTraceView* m_pTraceView;
166167

167168
int m_lastSelectedRowIndex;
169+
quint64 m_timelineAbsoluteStart;
168170

169171
private:
170172
/// Fills table only with calls within the timeline start and end
@@ -196,7 +198,7 @@ public :
196198
COLUMN_NUM_OF_CALLS,
197199
COLUMN_COUNT
198200
};
199-
gpTraceSummaryTable(gpTraceDataContainer* pDataContainer, gpTraceView* pSessionView, eCallType callType);
201+
gpTraceSummaryTable(gpTraceDataContainer* pDataContainer, gpTraceView* pSessionView, eCallType callType, quint64 timelineAbsoluteStart);
200202

201203
/// class destructor.
202204
virtual ~gpTraceSummaryTable();
@@ -297,7 +299,7 @@ class gpCommandListSummaryTable : public gpSummaryTable
297299
COLUMN_ADDRESS,
298300
COLUMN_COUNT
299301
};
300-
gpCommandListSummaryTable(gpTraceDataContainer* pDataContainer, gpTraceView* pSessionView);
302+
gpCommandListSummaryTable(gpTraceDataContainer* pDataContainer, gpTraceView* pSessionView, quint64 timelineAbsoluteStart);
301303

302304
/// class destructor.
303305
virtual ~gpCommandListSummaryTable();

CodeXL/Components/GpuProfiling/AMDTGpuProfiling/gpTraceSummaryWidget.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ void gpTraceSummaryWidget::Init(gpTraceDataContainer* pDataContainer, gpTraceVie
4242
{
4343
if (i == eCallType::API_CALL || i == eCallType::GPU_CALL)
4444
{
45-
m_tabs[i] = new gpTraceSummaryTab((eCallType)i);
45+
m_tabs[i] = new gpTraceSummaryTab((eCallType)i, m_timelineAbsoluteStart);
4646
}
4747
else
4848
{
49-
m_tabs[i] = new gpCommandListSummaryTab((eCallType)i);
49+
m_tabs[i] = new gpCommandListSummaryTab((eCallType)i, m_timelineAbsoluteStart);
5050
}
5151

5252
bool rc = m_tabs[i]->Init(pDataContainer, pSessionView, timelineStartTime, timelineRange);

0 commit comments

Comments
 (0)