13 #ifndef HTGS_ANYITASK_HPP 14 #define HTGS_ANYITASK_HPP 28 #include <htgs/utils/ProfileUtils.hpp> 32 #include <htgs/core/graph/profile/ProfileData.hpp> 33 #include <htgs/core/graph/profile/CustomProfile.hpp> 128 virtual std::string
getName() = 0;
192 virtual bool canTerminate(std::shared_ptr<AnyConnector> inputConnector) = 0;
204 std::shared_ptr<htgs::AnyConnector> input,
205 std::shared_ptr<htgs::AnyConnector> output) {
206 std::ostringstream oss;
210 if (input !=
nullptr) {
211 oss << input->getDotId() <<
" -> " << dotId <<
";" << std::endl;
212 oss << input->genDot(flags);
215 if (output !=
nullptr) {
216 oss << dotId <<
" -> " << output->getDotId() <<
";" << std::endl;
217 oss << output->genDot(flags);
221 oss <<
genDot(flags, dotId);
227 virtual std::string getConsumerDotIds() {
231 virtual std::string getProducerDotIds() {
236 virtual std::string genDotProducerEdgeToTask(std::map<std::shared_ptr<AnyConnector>,
AnyITask *> &inputConnectorDotMap,
int dotFlags) = 0;
238 virtual std::string genDotConsumerEdgeFromConnector(std::shared_ptr<AnyConnector> connector,
int flags) = 0;
239 virtual std::string genDotProducerEdgeFromConnector(std::shared_ptr<AnyConnector> connector,
int flags) = 0;
256 virtual std::string
genDot(
int flags, std::string dotId) {
257 return dotId +
";\n";
460 std::string
genDot(
int flags, std::shared_ptr<AnyConnector> input, std::shared_ptr<AnyConnector> output) {
461 std::string dotId = this->
getDotId();
462 std::ostringstream oss;
463 oss <<
genDot(flags, dotId, input, output);
468 oss << kv.second->getDotId() <<
" -> " << dotId <<
"[label=\"get\", color=sienna];" << std::endl;
485 std::cout <<
"Mem getter: " << kv.first <<
" profile; ";
487 kv.second->profileConsume(this->
numThreads,
false);
498 std::ostringstream id;
500 std::string idStr =
id.str();
550 std::shared_ptr<AnyConnector> releaseMemoryConnector,
MMType type) {
552 std::cerr <<
"ERROR: " << this->
getName() <<
" already has a memory edge named " << name << std::endl;
577 void sendWSProfileUpdate(StatusCode code)
579 if (this->
getName() ==
"WebSocketProfiler")
581 std::shared_ptr<ProfileData> updateStatus(
new ChangeStatusProfile(
this, code));
582 std::shared_ptr<DataPacket> dataPacket(
new DataPacket(this->
getName(), this->
getAddress(),
"WebSocketProfiler",
"0", updateStatus));
583 this->taskGraphCommunicator->produceDataPacket(dataPacket);
589 void setMemoryEdges(std::shared_ptr<ConnectorMap> memGetter) { this->
memoryEdges = memGetter; }
607 std::shared_ptr<ConnectorMap>
609 std::shared_ptr<ConnectorMap>
620 #endif //HTGS_ANYITASK_HPP Implements the parent class for a Task to remove the template arguments and the TaskManagerThread to ...
virtual std::string debugDotNode()
Provides debug output for a node in the dot graph.
Definition: AnyITask.hpp:282
const std::shared_ptr< ConnectorMap > & getReleaseMemoryEdges() const
Gets the memory edges for releasing memory for the memory manager, used to shutdown the memory manage...
Definition: AnyITask.hpp:523
virtual std::string getName()=0
Virtual function to get the name of an ITask.
virtual void printProfile()=0
Prints the profile data to std::out.
virtual void debug()
Virtual function that is called to debug the ITask.
Definition: AnyITask.hpp:276
Implements the parent ITask, which removes the template arguments of an ITask.
Definition: AnyITask.hpp:48
std::string getNameWithPipelineId()
Gets the name of the ITask with it's pipeline ID.
Definition: AnyITask.hpp:509
std::string getDotId()
Gets the id used for dot nodes.
Definition: AnyITask.hpp:497
virtual std::string profileStr()
Virtual function that is called after executionTask is called.
Definition: AnyITask.hpp:301
bool hasMemoryEdge(std::string name)
Checks whether this ITask contains a memory edge for a specified name.
Definition: AnyITask.hpp:535
MMType
The memory manager types.
Definition: MMType.hpp:38
virtual std::string inTypeName()=0
Gets the demangled input type name of the connector.
size_t getNumThreads() const
Gets the number of threads associated with this ITask.
Definition: AnyITask.hpp:412
Provides the Connector class for managing input/output of AbsData between Tasks.
void profileITask()
Provides profile output for the ITask,.
Definition: AnyITask.hpp:482
bool startTask
Whether the ITask will be a start task used when creating a TaskManager.
Definition: AnyITask.hpp:601
void incMemoryWaitTime(unsigned long long int val)
Increments memory wait time.
Definition: AnyITask.hpp:574
unsigned long long int memoryWaitTime
The amount of time this task waited for memory.
Definition: AnyITask.hpp:615
virtual void profile()
Virtual function that is called to provide profile output for the ITask.
Definition: AnyITask.hpp:290
virtual std::string genDot(int flags, std::string dotId)
Virtual function that adds additional dot attributes to this node.
Definition: AnyITask.hpp:256
void initialize(size_t pipelineId, size_t numPipeline)
Virtual function that is called when an ITask is being initialized by it's owner thread.
Definition: AnyITask.hpp:346
size_t getNumPipelines() const
Sets the task graph communicator.
Definition: AnyITask.hpp:404
size_t getPipelineId()
Gets the pipeline ID.
Definition: AnyITask.hpp:367
AnyITask(size_t numThreads, bool isStartTask, bool poll, size_t microTimeoutTime)
Constructs an ITask with a specified number of threads as well as additional scheduling options...
Definition: AnyITask.hpp:94
unsigned long long int getMemoryWaitTime() const
Gets the amount of time the task was waiting for memory.
Definition: AnyITask.hpp:566
virtual AnyITask * copyITask(bool deep)=0
Copies the ITask including its list of memGetters and memReleasers.
size_t numThreads
The number of threads to be used with this ITask (forms a thread pool) used when creating a TaskManag...
Definition: AnyITask.hpp:600
virtual std::string genDot(int flags, std::string dotId, std::shared_ptr< htgs::AnyConnector > input, std::shared_ptr< htgs::AnyConnector > output)
Virtual function that generates the input/output and per-task dot notation.
Definition: AnyITask.hpp:202
virtual void initialize()=0
Virtual function that is called when an ITask is being initialized by it's owner thread.
virtual std::string getDotShape()=0
Gets the shape for graphviz dot.
void attachMemoryEdge(std::string name, std::shared_ptr< AnyConnector > getMemoryConnector, std::shared_ptr< AnyConnector > releaseMemoryConnector, MMType type)
Attaches a memory edge to this ITask to get memory.
Definition: AnyITask.hpp:549
size_t numPipelines
The number of pipelines that exist for this task.
Definition: AnyITask.hpp:605
virtual void shutdown()=0
Virtual function that is called when an ITask is being shutdown by it's owner thread.
AnyITask()
Creates an ITask with number of threads equal to 1.
Definition: AnyITask.hpp:54
#define DOTGEN_FLAG_HIDE_MEM_EDGES
Hides memory edges during dot generation.
Definition: TaskGraphDotGenFlags.hpp:20
virtual std::string genCustomDot(ProfileUtils *profileUtils, int colorFlag)
Virtual function to generate customized dot file.
Definition: AnyITask.hpp:270
void setNumPipelines(size_t numPipelines)
Sets the number of pipelines that this ITask belongs too.
Definition: AnyITask.hpp:378
Defines the Memory Manager types MMType.
Holds parent class for Connector, removes template type of Connector.
#define HTGS_DEBUG(msg)
Prints a debug message to std::cerr with standard level If DEBUG_FLAG is not defined, this equates to a no op Each message includes the file and line number for where the debug is called.
Definition: debug_message.hpp:65
virtual std::string outTypeName()=0
Gets the demangled output type name of the connector.
bool isStartTask() const
Gets whether this ITask is a starting task.
Definition: AnyITask.hpp:422
size_t getMicroTimeoutTime() const
Gets the timeout time for polling.
Definition: AnyITask.hpp:440
Defines common types used throughout the HTGS API and some of which that are used by users of HTGS su...
virtual ~AnyITask()
Destructor.
Definition: AnyITask.hpp:116
const std::shared_ptr< ConnectorMap > & getMemoryEdges() const
Gets the memory edges for the task.
Definition: AnyITask.hpp:515
virtual std::string getDotLabelName()=0
Virtual function to get the label name used for dot graph viz.
bool poll
Whether the ITask should poll for data used when creating a TaskManager.
Definition: AnyITask.hpp:602
size_t microTimeoutTime
The timeout time for polling in microseconds used when creating a TaskManager.
Definition: AnyITask.hpp:603
Implements a data packet that is transmitted to the TaskGraphCommunicator.
std::pair< std::string, std::shared_ptr< AnyConnector > > ConnectorPair
A pair used for the ConnectorMap.
Definition: Types.hpp:48
virtual std::string getAddress()=0
Gets the address from the owner task, which is the address of the task graph.
void copyMemoryEdges(AnyITask *iTaskCopy)
Copies the memory edges from this AnyITask to another AnyITask.
Definition: AnyITask.hpp:448
std::unordered_map< std::string, std::shared_ptr< AnyConnector > > ConnectorMap
A mapping between the name of a task and its connector.
Definition: Types.hpp:42
std::shared_ptr< ConnectorMap > memoryEdges
A mapping from memory edge name to memory manager connector for getting memory.
Definition: AnyITask.hpp:608
virtual void executeTaskFinal()=0
Virtual function that is called just before the task has shutdown.
std::string genDot(int flags, std::shared_ptr< AnyConnector > input, std::shared_ptr< AnyConnector > output)
Creates a dot notation representation for this task.
Definition: AnyITask.hpp:460
AnyITask(size_t numThreads)
Constructs an ITask with a specified number of threads.
Definition: AnyITask.hpp:72
virtual std::string getDotCustomProfile()=0
Virtual function that can be used to add custom output for dot visualizations.
bool isPoll() const
Gets whether this ITask is polling for data or not.
Definition: AnyITask.hpp:432
void setPipelineId(size_t pipelineId)
Sets the pipeline Id for this ITask.
Definition: AnyITask.hpp:359
virtual bool canTerminate(std::shared_ptr< AnyConnector > inputConnector)=0
Virtual function that is called when an ITask is checking if it can be terminated.
Implements MemoryData used by a MemoryManager, which can be shared among multiple ITask...
size_t pipelineId
The execution pipeline id for the ITask.
Definition: AnyITask.hpp:604
virtual std::string getDotFillColor()=0
Gets the color for filling the shape for graphviz dot.
virtual AnyITask * copy()=0
Pure virtual function to copy an ITask.
std::shared_ptr< ConnectorMap > releaseMemoryEdges
A mapping from the memory edge name to the memory manager's input connector to shutdown the memory ma...
Definition: AnyITask.hpp:610
Definition: ProfileUtils.hpp:13
Definition: Bookkeeper.hpp:23
virtual std::string getDotShapeColor()=0
Gets the color of the shape for graphviz dot.
Defines DOTGEN flags used for dot file generation.
Provides functionality for debug messaging.
#define DOTGEN_FLAG_SHOW_CONNECTOR_VERBOSE
Shows verbose information within each connector in the graph.
Definition: TaskGraphDotGenFlags.hpp:92