HTGS  v2.0
The Hybrid Task Graph Scheduler
RuleEdge.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 
14 #ifndef HTGS_RULEEDGE_HPP
15 #define HTGS_RULEEDGE_HPP
16 
18 #include <htgs/api/ITask.hpp>
20 #include <htgs/api/Bookkeeper.hpp>
21 
22 namespace htgs {
23 
43 template<class T, class U, class W>
44 class RuleEdge : public EdgeDescriptor {
45  public:
46 
54  bookkeeper(bookkeeper), rule(rule), consumer(consumer) {}
55 
56  ~RuleEdge() override {}
57 
58  void applyEdge(AnyTaskGraphConf *graph) override {
59  graph->getTaskManager(bookkeeper);
60  TaskManager<U, W> *consumerTaskManager = graph->getTaskManager(consumer);
61 
62  auto connector = consumerTaskManager->getInputConnector();
63 #ifdef WS_PROFILE
64  bool newConnector = false;
65 #endif
66  if (connector == nullptr) {
67 #ifdef WS_PROFILE
68  newConnector = true;
69 #endif
70  connector = std::shared_ptr<Connector<U>>(new Connector<U>());
71  }
72 
73  RuleManager<T, U> *ruleManager = new RuleManager<T, U>(rule); // TODO: Delete or Add #ifdef , graph->getTaskGraphCommunicator());
74  ruleManager->setOutputConnector(connector);
75 
76  connector->incrementInputTaskCount();
77 
78  consumerTaskManager->setInputConnector(connector);
79  bookkeeper->addRuleManager(ruleManager);
80 
81 #ifdef WS_PROFILE
82  // Add nodes
83  std::shared_ptr<ProfileData> producerData(new CreateNodeProfile(bookkeeper, graph, "Bookkeeper"));
84  std::shared_ptr<ProfileData> consumerData(new CreateNodeProfile(consumer, graph, consumer->getName()));
85  std::shared_ptr<ProfileData> connectorData(new CreateConnectorProfile(connector.get(), graph, connector->getProducerCount(), ""));
86 
87  graph->sendProfileData(producerData);
88  graph->sendProfileData(consumerData);
89  graph->sendProfileData(connectorData);
90 
91  std::shared_ptr<ProfileData> producerConnectorData(new CreateEdgeProfile(bookkeeper, connector.get(), rule->getName(), ruleManager));
92  graph->sendProfileData(producerConnectorData);
93 
94  if (newConnector) {
95  std::shared_ptr<ProfileData> connectorConsumerData(new CreateEdgeProfile(connector.get(), consumer, "", nullptr));
96  graph->sendProfileData(connectorConsumerData);
97  }
98 
99 
100 
101 #endif
102 
103  }
104 
106  return new RuleEdge<T, U, W>((Bookkeeper<T> *) graph->getCopy(bookkeeper), rule, graph->getCopy(consumer));
107  }
108 
109  private:
111  std::shared_ptr<IRule<T, U>> rule;
113 };
114 }
115 #endif //HTGS_RULEEDGE_HPP
std::shared_ptr< AnyConnector > getInputConnector() override
Gets the input Connector.
Definition: TaskManager.hpp:119
ITask< U, W > * consumer
the consumer task
Definition: RuleEdge.hpp:112
ITask< T, U > * getCopy(ITask< T, U > *orig)
Gets the copy for an ITask based on some original ITask reference.
Definition: AnyTaskGraphConf.hpp:327
RuleEdge(Bookkeeper< T > *bookkeeper, std::shared_ptr< IRule< T, U >> rule, ITask< U, W > *consumer)
Creates a rule edge.
Definition: RuleEdge.hpp:53
std::shared_ptr< IRule< T, U > > rule
the rule
Definition: RuleEdge.hpp:111
Implements the rule edge that is added to the graph.
Definition: RuleEdge.hpp:44
Bookkeeper< T > * bookkeeper
The bookkeeper task.
Definition: RuleEdge.hpp:110
Manages the input/output of IData between Tasks.
Definition: Connector.hpp:62
Provides an interface to send data along RuleManager edges for processing state and dependencies...
Definition: ExecutionPipeline.hpp:34
Implements the Bookkeeper class.
TaskManager< T, U > * getTaskManager(ITask< T, U > *task)
Gets the task manager that is responsible for a particular ITask.
Definition: AnyTaskGraphConf.hpp:362
void setOutputConnector(std::shared_ptr< AnyConnector > connector) override
Sets the output connector that the RuleManager is attached to.
Definition: RuleManager.hpp:157
Implements the base class used by the TaskGraphConf, which removes the template arguments and impleme...
void applyEdge(AnyTaskGraphConf *graph) override
Applies an edge to a task graph.
Definition: RuleEdge.hpp:58
Connects a Bookkeeper to another ITask using one or more IRule(s).
Definition: RuleManager.hpp:57
EdgeDescriptor * copy(AnyTaskGraphConf *graph) override
Creates a copy of the edge descriptor to be added to other graphs, such as those within execution pip...
Definition: RuleEdge.hpp:105
Implements the base class for the TaskGraphConf class, removing the template arguments and providing ...
Definition: AnyTaskGraphConf.hpp:66
void setInputConnector(std::shared_ptr< AnyConnector > connector) override
Sets the input BaseConnector.
Definition: TaskManager.hpp:318
The edge descriptor is an interface used to describe how an edge is applied and copied to a task grap...
Definition: EdgeDescriptor.hpp:39
Implements the edge descriptor interface to build edges for a task graph.
An interface to process input data and forward results within a TaskGraph.
Definition: Bookkeeper.hpp:23
virtual std::string getName() override
Virtual function to get the name of an ITask.
Definition: ITask.hpp:236
Special task used to manage rules.
Definition: Bookkeeper.hpp:60