forked from GPUOpen-Tools/gpu_performance_api
-
Notifications
You must be signed in to change notification settings - Fork 1
/
GPASoftwareCounters.h
113 lines (98 loc) · 4.04 KB
/
GPASoftwareCounters.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//==============================================================================
// Copyright (c) 2016-2017 Advanced Micro Devices, Inc. All rights reserved.
/// \author AMD Developer Tools Team
/// \file
/// \brief Maintains a set of software counters
//==============================================================================
#ifndef _GPA_SOFTWARE_COUNTERS_H_
#define _GPA_SOFTWARE_COUNTERS_H_
#include "GPAInternalCounter.h"
#include "Logging.h"
#include "GPASwCounterManager.h"
#include <sstream>
/// Struct to describe a software counter
struct GPA_SoftwareCounterDescExt
{
gpa_uint32 m_groupIndex; ///< index of group containing this counter
gpa_uint32 m_groupIdDriver; ///< group ID according to the driver
gpa_uint32 m_counterIdDriver; ///< counter ID according to the driver
GPA_SoftwareCounterDesc* m_pSoftwareCounter; ///< the internal counter
};
/// Maintains a set of software counters
class GPA_SoftwareCounters
{
public:
/// Initializes an instance of the GPA_SoftwareCounters class.
GPA_SoftwareCounters()
{
Clear();
}
/// Destructor
virtual ~GPA_SoftwareCounters()
{
}
/// Clears all counter data
void Clear()
{
m_counters.clear();
m_ppCounterGroupArray = nullptr;
m_pGroups = nullptr;
m_groupCount = 0;
m_countersGenerated = false;
}
/// Obtains the number of software counters
/// \return the number of software counters
gpa_uint32 GetNumCounters() const
{
return static_cast<gpa_uint32>(m_counters.size());
}
/// Gets the name of the specified counter
/// \param index the index of the counter whose name is needed
/// \return the name of the specified counter
const char* GetCounterName(gpa_uint32 index) const
{
return m_counters[index].m_pSoftwareCounter->m_name;
}
/// Gets the group name of the specified counter
/// \param index the index of the counter whose group is needed
/// \return the group name of the specified counter
const char* GetCounterGroup(gpa_uint32 index) const
{
return m_counters[index].m_pSoftwareCounter->m_group;
}
/// Gets the description of the specified counter
/// \param index the index of the counter whose description is needed
/// \return the description of the specified counter
const char* GetCounterDescription(gpa_uint32 index) const
{
return m_counters[index].m_pSoftwareCounter->m_description;
}
/// Gets a counter's UUID
/// \param index the index of the requested counter
/// \return the counter's UUID
GPA_UUID GetCounterUuid(gpa_uint32 index) const
{
return ::GetCounterUuid(GetCounterName(index), GetCounterDescription(index));
}
/// Gets a counter's supported sample type
/// \param index the index of the requested counter
/// \return the counter's supported sample type
GPA_Counter_Sample_Type GetCounterSampleType(gpa_uint32 index) const
{
UNREFERENCED_PARAMETER(index);
return GPA_COUNTER_SAMPLE_TYPE_DISCRETE; // all software counters are discrete counters
}
/// Gets the type of the specified counter
/// \param index the index of the counter whose type is needed
/// \return the type of the specified counter
GPA_Data_Type GetCounterType(gpa_uint32 index) const
{
return m_counters[index].m_pSoftwareCounter->m_type;
}
GPA_SoftwareCounterDesc** m_ppCounterGroupArray; ///< List of counter groups as defined by the list of counters in each group.
GPA_CounterGroupDesc* m_pGroups; ///< List of internal counter groups
bool m_countersGenerated; ///< Indicates that the counters have been generated
std::vector<GPA_SoftwareCounterDescExt> m_counters; ///< The list of software counters
unsigned int m_groupCount; ///< The number of internal counter groups
};
#endif //_GPA_SOFTWARE_COUNTERS_H_