17 #ifndef HTGS_TASKGRAPHPROFILER_HPP 18 #define HTGS_TASKGRAPHPROFILER_HPP 24 #include <htgs/utils/ProfileUtils.hpp> 28 class TaskManagerProfile;
63 taskManagerProfiles =
nullptr;
67 profileUtils =
nullptr;
85 std::cout << t.first->getName() <<
" addr: " << t.first->getAddress() <<
" id: " << t.first->getThreadId()
86 <<
" Profile: " << *t.second << std::endl;
103 std::string ret =
"";
110 bool useColorMap =
false;
111 std::unordered_map<std::string, std::string> *colorMap =
nullptr;
112 if (colorFlag != 0) {
119 auto tProfile = t.second;
121 auto tFun = tMan->getTaskFunction();
123 std::string dotId = tMan->getTaskFunction()->getDotId();
125 if (curDotGraph.find(dotId +
";") != std::string::npos) {
127 std::string aliveLabel =
129 std::string inOutLabel =
131 + tFun->outTypeName()) :
"");
132 std::string threadLabel =
134 ret += dotId +
"[label=\"" + tFun->getDotLabelName();
135 ret += threadLabel + inOutLabel +
"\\n";
136 ret += tProfile->genDot(
flags);
137 ret += (tFun->debugDotNode() !=
"" ? (
"\\n" + tFun->debugDotNode() +
"\\n") :
"");
139 ret += (tFun->getDotCustomProfile() !=
"" ? (
"\\n" + tFun->getDotCustomProfile() +
"\\n") :
"");
140 ret +=
"\",shape=" + tFun->getDotShape();
141 ret +=
",style=filled";
142 ret +=
",fillcolor=" + tFun->getDotFillColor();
143 ret +=(useColorMap ?
",penwidth=5,color=\"" + colorMap->at(dotId) +
"\"" :
", color=" + tFun->getDotShapeColor());
144 ret +=
",width=.2,height=.2];\n";
185 std::map<AnyTaskManager *, TaskManagerProfile *> finalProfiles;
190 std::multimap<std::string, std::pair<AnyTaskManager *, TaskManagerProfile *>> averageMap;
192 std::set<std::string> keys;
198 (tMan->getInputConnector() !=
nullptr ? tMan->getInputConnector()->getDotId() :
"")
199 + (tMan->getOutputConnector() !=
nullptr ? tMan->getOutputConnector()->getDotId() :
"")
200 + tMan->getAddress() + tMan->getName();
203 averageMap.insert(std::pair<std::string, std::pair<AnyTaskManager *, TaskManagerProfile *>>(key, t));
207 for (
auto key : keys) {
208 auto valRange = averageMap.equal_range(key);
214 for (
auto i = valRange.first; i != valRange.second; ++i) {
215 auto profilePair = (*i).second;
218 finalProfile->
sum(profilePair.second);
220 delete profilePair.second;
221 profilePair.second =
nullptr;
223 if (profilePair.first->getThreadId() == 0) {
224 mainManager = profilePair.first;
230 if (finalProfile !=
nullptr && mainManager !=
nullptr) {
232 finalProfiles.insert(std::pair<AnyTaskManager *, TaskManagerProfile *>(mainManager, finalProfile));
234 std::cout <<
"Something screwy happened . . ." << std::endl;
238 taskManagerProfiles->clear();
240 for (
auto t : finalProfiles) {
241 taskManagerProfiles->insert(t);
254 std::unordered_map<std::string, std::string> *
genColorMap(
int colorFlag) {
255 std::unordered_map<std::string, std::string> *colorMap =
new std::unordered_map<std::string, std::string>();
258 std::deque<double> vals;
260 double val = v.second->getValue(colorFlag);
279 for (
auto v : *taskManagerProfiles) {
280 if (v.second->getValue(colorFlag) == 0.0) {
281 colorMap->insert(std::pair<std::string, std::string>(v.first->getTaskFunction()->getDotId(),
"black"));
285 double tManTime = v.second->getValue(colorFlag);
289 colorMap->insert(std::pair<std::string, std::string>(v.first->getTaskFunction()->getDotId(), color));
305 double taskGraphComputeTime;
309 #endif //HTGS_TASKGRAPHPROFILER_HPP ProfileUtils * getProfileUtils()
Gets the profile utility class to obtain color codes based on the total execution time...
Definition: TaskGraphProfiler.hpp:164
std::map< AnyTaskManager *, TaskManagerProfile * > * taskManagerProfiles
The profile data for all task managers.
Definition: TaskGraphProfiler.hpp:298
void sum(TaskManagerProfile *other)
Computes the sum for the compute time and wait time between this profile and some other profile...
Definition: TaskManagerProfile.hpp:142
unsigned long long int getGraphComputeTime() const
Gets the total time the graph was computing.
Definition: AnyTaskGraphConf.hpp:536
std::string genDotProfile(std::string curDotGraph, int colorFlag)
Generates the dot profile for the graph.
Definition: TaskGraphProfiler.hpp:102
#define DOTGEN_COLOR_COMP_TIME
Creates color map using compute time.
Definition: TaskGraphDotGenFlags.hpp:56
int flags
The DOTGEN bit flags.
Definition: TaskGraphProfiler.hpp:299
void gatherProfilingData(std::map< AnyTaskManager *, TaskManagerProfile *> *taskManagerProfiles)
Gathers profiling data for this task graph's task managers, which is added into the task manager prof...
Definition: AnyTaskGraphConf.hpp:189
#define DOTGEN_FLAG_SHOW_TASK_LIVING_STATUS
Shows the number of threads that are alive running the task.
Definition: TaskGraphDotGenFlags.hpp:98
Holds the TGTask class implementation.
void setMaxQueueSize(size_t maxQueueSize)
Sets the max queue size for the profile.
Definition: TaskManagerProfile.hpp:152
void buildProfile(AnyTaskGraphConf *graphConf)
Builds a profile for the graph, (called after execution is done)
Definition: TaskGraphProfiler.hpp:75
std::map< AnyTaskManager *, TaskManagerProfile * > * getTaskManagerProfiles()
Gets the task manager profiles for all tasks in all graphs and sub-graphs.
Definition: TaskGraphProfiler.hpp:173
double maxTime
The maximum time from all task managers.
Definition: TaskGraphProfiler.hpp:304
std::unordered_map< std::string, std::string > * genColorMap(int colorFlag)
Generates the color map.
Definition: TaskGraphProfiler.hpp:254
double totalTime
Total execution time for all task managers.
Definition: TaskGraphProfiler.hpp:303
Implements a task manager profile that holds profiling data for a task manager.
Definition: TaskManagerProfile.hpp:27
void printProfiles()
Prints the profile data to console.
Definition: TaskGraphProfiler.hpp:83
Implements the base class used by the TaskGraphConf, which removes the template arguments and impleme...
void computeAverages()
Computes the averages for all profile data.
Definition: TaskGraphProfiler.hpp:184
The parent class for a Task that removes the template arguments.
Definition: AnyTaskManager.hpp:45
#define DOTGEN_FLAG_SHOW_IN_OUT_TYPES
Shows input and output types for all tasks.
Definition: TaskGraphDotGenFlags.hpp:32
Implements the base class for the TaskGraphConf class, removing the template arguments and providing ...
Definition: AnyTaskGraphConf.hpp:66
Implements the TaskManagerProfile class that is used to gather profile data for a task manager...
std::string getColorForTime(double time)
Gets the color for a given time relative to the entire graph's execution time.
Definition: ProfileUtils.hpp:23
TaskGraphProfiler(int flags)
Constructs the task graph profiler.
Definition: TaskGraphProfiler.hpp:49
~TaskGraphProfiler()
Destructor.
Definition: TaskGraphProfiler.hpp:56
void average(int count)
Computes the average compute and wait time for the profile.
Definition: TaskManagerProfile.hpp:158
#define DOTGEN_FLAG_SHOW_ALL_THREADING
Shows all threading fully expanded during dot generation.
Definition: TaskGraphDotGenFlags.hpp:26
The task graph profiler that gathers profile data and communicates via graphviz.
Definition: TaskGraphProfiler.hpp:42
Definition: ProfileUtils.hpp:13
Definition: Bookkeeper.hpp:23
ExecutionPipeline encapsulates a task graph and duplicates it, such that each duplicate task graph ex...