GEGELATI

Loading...
Searching...
No Matches
executionStats.h
1
36#ifndef EXECUTION_STATS_H
37#define EXECUTION_STATS_H
38
39#include <map>
40
41#include "tpg/instrumented/tpgExecutionEngineInstrumented.h"
42#include "tpg/tpgGraph.h"
43
44 namespace TPG {
45
57 struct TraceStats
58 {
60 const std::vector<const TPG::TPGVertex*> trace;
61
63 const uint64_t nbEvaluatedTeams;
65 const uint64_t nbEvaluatedPrograms;
67 const uint64_t nbExecutedLines;
70 const std::map<uint64_t, uint64_t> nbExecutionPerInstruction;
71 };
72
110 class ExecutionStats
111 {
112
113 private:
114 /* Average results */
115
117 double avgEvaluatedTeams = 0.0;
118
120 double avgEvaluatedPrograms = 0.0;
121
123 double avgExecutedLines = 0.0;
124
130 std::map<size_t, double> avgNbExecutionPerInstruction;
131
132 /* Analyzed Traces */
133
135 std::vector<TraceStats> inferenceTracesStats;
136
137 /* Distributions */
138
145 std::map<size_t, size_t> distribEvaluatedTeams;
146
154 std::map<size_t, size_t> distribEvaluatedPrograms;
155
162 std::map<size_t, size_t> distribExecutedLines;
163
171 std::map<size_t, std::map<size_t, size_t>>
172 distribNbExecutionPerInstruction;
173
181 std::map<const TPG::TPGVertex*, size_t> distribUsedVertices;
182
184 const TPGGraph* lastAnalyzedGraph = nullptr;
185
186 protected:
195 static void analyzeProgram(
196 std::map<uint64_t, uint64_t>& instructionCounts,
197 const Program::Program& program);
198
199 public:
201 ExecutionStats() = default;
202
204 virtual ~ExecutionStats() = default;
205
216 void analyzeInstrumentedGraph(const TPGGraph* graph);
217
231 void analyzeInferenceTrace(const std::vector<const TPGVertex*>& trace);
232
244 void analyzeExecution(const TPG::TPGExecutionEngineInstrumented& tee,
245 const TPGGraph* graph);
246
248 double getAvgEvaluatedTeams() const;
249
251 double getAvgEvaluatedPrograms() const;
252
254 double getAvgExecutedLines() const;
255
258 const std::map<size_t, double>& getAvgNbExecutionPerInstruction() const;
259
261 const std::vector<TraceStats>& getInferenceTracesStats() const;
262
264 const std::map<size_t, size_t>& getDistribEvaluatedTeams() const;
265
267 const std::map<size_t, size_t>& getDistribEvaluatedPrograms() const;
268
270 const std::map<size_t, size_t>& getDistribExecutedLines() const;
271
273 const std::map<size_t, std::map<size_t, size_t>>&
274 getDistribNbExecutionPerInstruction() const;
275
277 const std::map<const TPG::TPGVertex*, size_t>& getDistribUsedVertices()
278 const;
279
281 void clearInferenceTracesStats();
282
365 void writeStatsToJson(const char* filePath,
366 bool noIndent = false) const;
367 };
368
369} // namespace TPG
370
371#endif // EXECUTION_STATS_H
Program::Program
The Program class contains a list of program lines that can be executed within a well defined Environ...
Definition program.h:57
TPG::ExecutionStats
Utility class for extracting execution statistics from a TPGExecutionEngineInstrumented and an instru...
Definition executionStats.h:111
TPG::ExecutionStats::getInferenceTracesStats
const std::vector< TraceStats > & getInferenceTracesStats() const
Get stored trace statistics.
Definition executionStats.cpp:200
TPG::ExecutionStats::writeStatsToJson
void writeStatsToJson(const char *filePath, bool noIndent=false) const
Export the execution statistics of the last analyzeExecution() call to a file using Json format.
Definition executionStats.cpp:242
TPG::ExecutionStats::getDistribNbExecutionPerInstruction
const std::map< size_t, std::map< size_t, size_t > > & getDistribNbExecutionPerInstruction() const
Get distributions of the number of executions for each instruction.
Definition executionStats.cpp:221
TPG::ExecutionStats::~ExecutionStats
virtual ~ExecutionStats()=default
Default destructor.
TPG::ExecutionStats::getAvgExecutedLines
double getAvgExecutedLines() const
Get the average number of executed lines per inference.
Definition executionStats.cpp:189
TPG::ExecutionStats::getDistribExecutedLines
const std::map< size_t, size_t > & getDistribExecutedLines() const
Get the distribution of the number of executed lines.
Definition executionStats.cpp:215
TPG::ExecutionStats::getAvgNbExecutionPerInstruction
const std::map< size_t, double > & getAvgNbExecutionPerInstruction() const
Definition executionStats.cpp:194
TPG::ExecutionStats::analyzeProgram
static void analyzeProgram(std::map< uint64_t, uint64_t > &instructionCounts, const Program::Program &program)
Analyze a program to get how many times each instruction is used.
Definition executionStats.cpp:50
TPG::ExecutionStats::getAvgEvaluatedTeams
double getAvgEvaluatedTeams() const
Get the average number of evaluated teams per inference.
Definition executionStats.cpp:181
TPG::ExecutionStats::ExecutionStats
ExecutionStats()=default
Default constructor.
TPG::ExecutionStats::analyzeExecution
void analyzeExecution(const TPG::TPGExecutionEngineInstrumented &tee, const TPGGraph *graph)
Analyze the execution statistics of multiple inferences done with a TPGExecutionEngineInstrumented.
Definition executionStats.cpp:169
TPG::ExecutionStats::getDistribEvaluatedPrograms
const std::map< size_t, size_t > & getDistribEvaluatedPrograms() const
Get the distribution of the number of evaluated programs.
Definition executionStats.cpp:211
TPG::ExecutionStats::getDistribUsedVertices
const std::map< const TPG::TPGVertex *, size_t > & getDistribUsedVertices() const
Get the distribution if the number of visit for each vertex.
Definition executionStats.cpp:226
TPG::ExecutionStats::analyzeInferenceTrace
void analyzeInferenceTrace(const std::vector< const TPGVertex * > &trace)
Analyze the execution statistics of one inference trace.
Definition executionStats.cpp:126
TPG::ExecutionStats::analyzeInstrumentedGraph
void analyzeInstrumentedGraph(const TPGGraph *graph)
Analyze the average statistics of an instrumented TPGGraph execution.
Definition executionStats.cpp:60
TPG::ExecutionStats::getDistribEvaluatedTeams
const std::map< size_t, size_t > & getDistribEvaluatedTeams() const
Get the distribution of the number of evaluated teams.
Definition executionStats.cpp:205
TPG::ExecutionStats::clearInferenceTracesStats
void clearInferenceTracesStats()
Clear stored trace statistics and distributions.
Definition executionStats.cpp:231
TPG::ExecutionStats::getAvgEvaluatedPrograms
double getAvgEvaluatedPrograms() const
Get the average number of programs evaluated per inference.
Definition executionStats.cpp:185
TPG::TPGExecutionEngineInstrumented
Definition tpgExecutionEngineInstrumented.h:55
TPG::TPGGraph
Class for storing a Tangled-Program-Graph.
Definition tpgGraph.h:58
TPG
Definition executionStats.h:44
TPG::TraceStats
Store execution statistics of one inference trace.
Definition executionStats.h:58
TPG::TraceStats::nbEvaluatedTeams
const uint64_t nbEvaluatedTeams
Number of team evaluated.
Definition executionStats.h:63
TPG::TraceStats::nbExecutedLines
const uint64_t nbExecutedLines
Number of program lines executed.
Definition executionStats.h:67
TPG::TraceStats::nbExecutionPerInstruction
const std::map< uint64_t, uint64_t > nbExecutionPerInstruction
Definition executionStats.h:70
TPG::TraceStats::nbEvaluatedPrograms
const uint64_t nbEvaluatedPrograms
Number of programs evaluated.
Definition executionStats.h:65
TPG::TraceStats::trace
const std::vector< const TPG::TPGVertex * > trace
The inference trace.
Definition executionStats.h:60