forked from GPUOpen-Tools/radeon_compute_profiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CLMemSummarizer.h
84 lines (70 loc) · 3.15 KB
/
CLMemSummarizer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//==============================================================================
// Copyright (c) 2015 Advanced Micro Devices, Inc. All rights reserved.
/// \author AMD Developer Tools Team
/// \file
/// \brief This file provides the CL Memory Summarizer
//==============================================================================
#ifndef _CL_MEM_SUMMARIZER_H_
#define _CL_MEM_SUMMARIZER_H_
#include <set>
#include "../CLTraceAgent/CLAPIInfo.h"
#include "../Common/IParserListener.h"
#include "../Common/OSUtils.h"
//------------------------------------------------------------------------------------
/// Mem Duration compare
//------------------------------------------------------------------------------------
struct CLMemDurationCmp
{
bool operator()(const CLMemAPIInfo* left, const CLMemAPIInfo* right)
{
ULONGLONG ullDurationLeft = left->m_ullComplete - left->m_ullRunning;
ULONGLONG ullDurationRight = right->m_ullComplete - right->m_ullRunning;
return ullDurationLeft < ullDurationRight;
}
};
//------------------------------------------------------------------------------------
/// Memory operation summarizer
//------------------------------------------------------------------------------------
class CLMemSummarizer
: public IParserListener<CLAPIInfo>
{
public:
/// Constructor
CLMemSummarizer(void);
/// Destructor
~CLMemSummarizer(void);
/// Listener function
/// \param pAPIInfo API Info object
/// \param[out] stopParsing flag indicating if parsing should stop after this item
void OnParse(CLAPIInfo* pAPIInfo, bool& stopParsing);
/// Generate Top X data transfer HTML table from statistic data and write to std::ostream
/// \param sout output stream
/// \param useTopX flag indicating if the table should include all data transfers (false) or just the top X (true)
void GenerateTopXHTMLTable(std::ostream& sout, bool useTopX);
/// Generate HTML table from statistic data and write to std::ostream
/// \param sout output stream
void GenerateDataTransferSummaryHTMLTable(std::ostream& sout);
/// Generate simple HTML page with list of data transfers
/// \param szFileName file name
/// \return true if the page was generated, false otherwise
bool GenerateDataTransferHTMLPage(const char* szFileName);
/// Generate simple HTML page with Top X data transfers
/// \param szFileName file name
/// \param useTopX flag indicating if the table should include all data transfers (false) or just the top X (true)
/// \return true if the page was generated, false otherwise
bool GenerateTopXDataTransferHTMLPage(const char* szFileName, bool useTopX);
/// Debug
void Debug();
protected:
std::multiset<CLMemAPIInfo*, CLMemDurationCmp> m_memAPISet; /// memory api map, sorted by duration
unsigned int m_uiTopX; ///< Number of top items to list
private:
/// Copy constructor
/// \param obj object
CLMemSummarizer(const CLMemSummarizer& obj);
/// Assignment operator
/// \param obj object
/// \return ref to itself
const CLMemSummarizer& operator = (const CLMemSummarizer& obj);
};
#endif //_CL_MEM_SUMMARIZER_H_