forked from intel/pti-gpu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgpu_inst_count.hpp
More file actions
156 lines (132 loc) · 5 KB
/
gpu_inst_count.hpp
File metadata and controls
156 lines (132 loc) · 5 KB
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
//==============================================================
// Copyright (C) Intel Corporation
//
// SPDX-License-Identifier: MIT
// =============================================================
#ifndef PLGG_GPU_INST_COUNT_H
#define PLGG_GPU_INST_COUNT_H
/// Uncomment PLGG_GTPIN_API_VERSION definition if tool requeres GTPin SDK with
/// specific API version. GTPin SDK version constant (GTPIN_API_VERSION) is used
/// during tool registration in case of undefined PLGG_GTPIN_API_VERSION
// #define PLGG_GTPIN_API_VERSION 1007
#include "prof_lib_gpu_gtpin.hpp"
/**
* @file Header file for GTPin-based tool draft
*/
namespace gtpin {
namespace gtpin_prof {
/**
* RESULTS classes
* Extend tool-specific delivered classes with fields specific for the profiler.
* This classes will be passed to writer
*/
struct GpuInstCountResultData : public ResultData {
public:
using ResultData::ResultData;
virtual ~GpuInstCountResultData() = default;
size_t count = 0; //!< number of executions of BBL
size_t instructionOffset = 0; //!< offset of first instruction of BBL
};
struct GpuInstCountInvocationData : public InvocationData {
public:
using InvocationData::InvocationData;
virtual ~GpuInstCountInvocationData() = default;
};
struct GpuInstCountKernelData : public KernelData {
public:
using KernelData::KernelData;
virtual ~GpuInstCountKernelData() = default;
};
struct GpuInstCountProfilerData : public ProfilerData {
public:
GpuInstCountProfilerData() { toolName = "gpu_inst_count"; }
virtual ~GpuInstCountProfilerData() = default;
};
/**
* Delivered class of GTPin buffer record class. This delivered class is a
* undividable unit in GTPin profile buffer, it is used in instrumentation and
* stores data per instrumentation point. This class defines the data layout in
* instrumentation buffer.
*/
struct GpuInstCountRecord : public GTPinProfileRecord {
uint64_t count;
};
/**
* GpuInstCountKernel
* Delivered class of GTPinProfileKernel base class that implements
* tool-specific virtual functions
*/
class GpuInstCountKernel : public GTPinProfileKernel {
using GTPinProfileKernel::GTPinProfileKernel;
public:
/**
* Called during kernel build. The function should set up number of records,
* and collect requered information about points of interests, that will be
* used on instrumentation stage
*/
PROF_STATUS AnalyzeKernel(IGtKernelInstrument& instrumentor) final;
/**
* Called during kernel build. The function should instrument each point of
* interest with tool-specific instrumentation
*/
PROF_STATUS Instrument(IGtKernelInstrument& instrumentor) final;
/**
* Called before kernel run. Initializes resulting data, set ups vector sizes,
* sets base values of variables
*/
PROF_STATUS InitResultData(std::shared_ptr<InvocationData> invocationData,
IGtKernelDispatch& dispatcher,
const GTPinKernelExecDesriptor& execDescr,
const std::shared_ptr<IToolFactory> factory) final;
/**
* Called after kernel complete during reading of the GTPin profiling buffer.
* Function should accumulate date from record into profiling results data
*/
PROF_STATUS Accumulate(std::shared_ptr<ResultData> profilingResult,
GTPinProfileRecord* record) final;
/**
* Called after all data from the buffer was read. Does post processing,
* normalization. Optional function.
*/
PROF_STATUS PostProcData(std::shared_ptr<InvocationData> invocationData) final;
private:
std::map<InstructionOffset, const IGtIns&> bblData;
};
/**
* GTPin tool registerable class
* Determ tool-specific GTPin knobs into SetGtpinKnobs function
*/
class GpuInstCount : public GTPinTool {
using GTPinTool::GTPinTool;
public:
std::vector<const char*> SetGtpinKnobs() const final;
const char* Name() const final { return "gpu_inst_count"; }
};
/**
* GpuInstCountFactory determines tool-specific objects
*/
class GpuInstCountFactory : public IToolFactory {
public:
std::shared_ptr<GTPinProfileKernel> MakeKernel(IGtKernelInstrument& instrumentor,
std::shared_ptr<KernelData> kernelData) final;
GTPinProfileRecord* MakeRecord() final;
std::shared_ptr<ProfilerData> MakeProfilerData() final;
std::shared_ptr<KernelData> MakeKernelData(IGtKernelInstrument& instrumentor) final;
std::shared_ptr<InvocationData> MakeInvocationData(
const GTPinKernelExecDesriptor& execDescr) final;
std::shared_ptr<ResultData> MakeResultData() final;
};
/**
* Profiller class implementation
*/
class GpuInstCountProfiler : public GTPinProfilerBase {
public:
GpuInstCountProfiler(
const std::shared_ptr<GTPinDataWriterBase> writer = std::make_shared<DefaultGTPinWriter>(),
const std::shared_ptr<GTPinFilterBase> filter = std::make_shared<DefaultGTPinFilter>()) {
tool = std::make_shared<GpuInstCount>(std::make_shared<GpuInstCountFactory>(), writer, filter);
}
};
} // namespace gtpin_prof
}
#endif // PLGG_GPU_INST_COUNT_H