HTGS  v2.0
The Hybrid Task Graph Scheduler
TaskManagerProfile.hpp
Go to the documentation of this file.
1 // NIST-developed software is provided by NIST as a public service. You may use, copy and distribute copies of the software in any medium, provided that you keep intact this entire notice. You may improve, modify and create derivative works of the software or any portion of the software, and you may copy and distribute such modifications or works. Modified works should carry a notice stating that you changed the software and should note the date and nature of any such change. Please explicitly acknowledge the National Institute of Standards and Technology as the source of the software.
2 // NIST-developed software is expressly provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED, IN FACT OR ARISING BY OPERATION OF LAW, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT AND DATA ACCURACY. NIST NEITHER REPRESENTS NOR WARRANTS THAT THE OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED OR ERROR-FREE, OR THAT ANY DEFECTS WILL BE CORRECTED. NIST DOES NOT WARRANT OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF THE SOFTWARE OR THE RESULTS THEREOF, INCLUDING BUT NOT LIMITED TO THE CORRECTNESS, ACCURACY, RELIABILITY, OR USEFULNESS OF THE SOFTWARE.
3 // You are solely responsible for determining the appropriateness of using and distributing the software and you assume all risks associated with its use, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and the unavailability or interruption of operation. This software is not intended to be used in any situation where a failure could cause risk of injury or damage to property. The software developed by NIST employees is not subject to copyright protection within the United States.
4 
13 #ifndef HTGS_TASKMANAGERPROFILE_HPP
14 #define HTGS_TASKMANAGERPROFILE_HPP
15 
16 #include <cstddef>
17 #include <ostream>
19 namespace htgs {
20 
28  public:
29 
34  computeTime = 0;
35  waitTime = 0;
36  maxQueueSize = 0;
37  memoryWaitTime = 0;
38  }
39 
47  TaskManagerProfile(unsigned long long int computeTime, unsigned long long int waitTime, size_t maxQueueSize, unsigned long long int memoryWaitTime)
48  : computeTime(computeTime), waitTime(waitTime), memoryWaitTime(memoryWaitTime), maxQueueSize(maxQueueSize) {}
49 
56  std::string genDot(int flags) {
57  std::string ret = "";
58 #ifdef PROFILE
59  if ((flags & DOTGEN_FLAG_HIDE_PROFILE_COMP_TIME) == 0)
60  ret += "computeTime: " + std::to_string((double)computeTime/1000000.0) + " s\\n";
61 
62  if ((flags & DOTGEN_FLAG_HIDE_PROFILE_WAIT_TIME) == 0)
63  ret += "waitTime: " + std::to_string((double)waitTime/1000000.0) + " s\\n";
64 
65  if ((flags & DOTGEN_FLAG_HIDE_PROFILE_MAX_Q_SZ) == 0)
66  ret += "maxQueueSize: " + std::to_string(maxQueueSize) + "\\n";
67 
68  if ((flags & DOTGEN_FLAG_HIDE_MEMORY_WAIT_TIME) == 0 && memoryWaitTime > 0)
69  ret += "memoryWaitTime: " + std::to_string((double)memoryWaitTime/1000000.0) + " sec\\n";
70 #endif
71  return ret;
72  }
73 
80  friend std::ostream &operator<<(std::ostream &os, const TaskManagerProfile &profile) {
81  os << "computeTime: " << profile.computeTime << " waitTime: " << profile.waitTime << " maxQueueSize: "
82  << profile.maxQueueSize << (profile.memoryWaitTime == 0 ? "" : " memoryWaitTime: " + profile.memoryWaitTime);
83  return os;
84  }
85 
91  double getValue(int colorFlag) {
92  if (colorFlag == DOTGEN_COLOR_COMP_TIME)
93  return (double)computeTime;
94  else if (colorFlag == DOTGEN_COLOR_WAIT_TIME)
95  return (double)waitTime;
96  else if (colorFlag == DOTGEN_COLOR_MAX_Q_SZ)
97  return (double)maxQueueSize;
98  else if (colorFlag == DOTGEN_COLOR_MEMORY_WAIT_TIME)
99  return (double)memoryWaitTime;
100  else
101  return 0.0;
102 
103  }
104 
109  unsigned long long int getComputeTime() const {
110  return computeTime;
111  }
112 
117  unsigned long long int getWaitTime() const {
118  return waitTime;
119  }
120 
125  size_t getMaxQueueSize() const {
126  return maxQueueSize;
127  }
128 
133  unsigned long long int getMemoryWaitTime() const {
134  return memoryWaitTime;
135  }
136 
142  void sum(TaskManagerProfile *other) {
143  this->computeTime += other->getComputeTime();
144  this->waitTime += other->getWaitTime();
145  this->memoryWaitTime += other->getMemoryWaitTime();
146  }
147 
152  void setMaxQueueSize(size_t maxQueueSize) { this->maxQueueSize = maxQueueSize; }
153 
158  void average(int count) {
159  this->computeTime = (unsigned long long int) (this->computeTime / (double) count);
160  this->waitTime = (unsigned long long int) (this->waitTime / (double) count);
161  this->memoryWaitTime = (unsigned long long int) (this->memoryWaitTime / (double) count);
162  }
163 
164  private:
165  unsigned long long int computeTime;
166  unsigned long long int waitTime;
167  unsigned long long int memoryWaitTime;
168  size_t maxQueueSize;
169 
170 };
171 }
172 #endif //HTGS_TASKMANAGERPROFILE_HPP
#define DOTGEN_FLAG_HIDE_MEMORY_WAIT_TIME
Hides profiling data for waiting for memory.
Definition: TaskGraphDotGenFlags.hpp:74
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 waitTime
The wait time for the task manager.
Definition: TaskManagerProfile.hpp:166
unsigned long long int computeTime
The compute time for the task manager.
Definition: TaskManagerProfile.hpp:165
#define DOTGEN_COLOR_WAIT_TIME
Creates color map using wait time.
Definition: TaskGraphDotGenFlags.hpp:68
#define DOTGEN_COLOR_COMP_TIME
Creates color map using compute time.
Definition: TaskGraphDotGenFlags.hpp:56
size_t maxQueueSize
The maximum queue size for the task manager.
Definition: TaskManagerProfile.hpp:168
void setMaxQueueSize(size_t maxQueueSize)
Sets the max queue size for the profile.
Definition: TaskManagerProfile.hpp:152
size_t getMaxQueueSize() const
Gets the maximum queue size.
Definition: TaskManagerProfile.hpp:125
Implements a task manager profile that holds profiling data for a task manager.
Definition: TaskManagerProfile.hpp:27
double getValue(int colorFlag)
Gets one of the values based on the DOTGEN color flag.
Definition: TaskManagerProfile.hpp:91
unsigned long long int getWaitTime() const
Gets the wait time.
Definition: TaskManagerProfile.hpp:117
#define DOTGEN_COLOR_MEMORY_WAIT_TIME
Creates color map using memory wait time.
Definition: TaskGraphDotGenFlags.hpp:80
std::string genDot(int flags)
Generates the dot contents for the task manager profile.
Definition: TaskManagerProfile.hpp:56
unsigned long long int memoryWaitTime
The time spent waiting for memory from the memory manager.
Definition: TaskManagerProfile.hpp:167
#define DOTGEN_FLAG_HIDE_PROFILE_MAX_Q_SZ
Hides profiling data for maximum queue size.
Definition: TaskGraphDotGenFlags.hpp:44
#define DOTGEN_FLAG_HIDE_PROFILE_COMP_TIME
Hides profiling data for compute time.
Definition: TaskGraphDotGenFlags.hpp:38
#define DOTGEN_COLOR_MAX_Q_SZ
Creates color map using maximum queue size.
Definition: TaskGraphDotGenFlags.hpp:62
unsigned long long int getComputeTime() const
Gets the compute time.
Definition: TaskManagerProfile.hpp:109
void average(int count)
Computes the average compute and wait time for the profile.
Definition: TaskManagerProfile.hpp:158
unsigned long long int getMemoryWaitTime() const
Gets the memory wait time.
Definition: TaskManagerProfile.hpp:133
TaskManagerProfile()
Constructs a task manager profile with no profiling data.
Definition: TaskManagerProfile.hpp:33
Definition: Bookkeeper.hpp:23
friend std::ostream & operator<<(std::ostream &os, const TaskManagerProfile &profile)
Output stream operator to output the task manager profile to a stream.
Definition: TaskManagerProfile.hpp:80
Defines DOTGEN flags used for dot file generation.
#define DOTGEN_FLAG_HIDE_PROFILE_WAIT_TIME
Hides profiling data for wait time.
Definition: TaskGraphDotGenFlags.hpp:50
TaskManagerProfile(unsigned long long int computeTime, unsigned long long int waitTime, size_t maxQueueSize, unsigned long long int memoryWaitTime)
Constructs a task manager profile with profiling data.
Definition: TaskManagerProfile.hpp:47