Workflow.h
1 
10 #ifndef WRENCH_WORKFLOW_H
11 #define WRENCH_WORKFLOW_H
12 
13 #include <lemon/list_graph.h>
14 #include <map>
15 #include <set>
16 
17 #include "wrench/workflow/execution_events/WorkflowExecutionEvent.h"
18 #include "WorkflowFile.h"
19 #include "WorkflowTask.h"
20 
21 class WorkflowTask;
22 
23 namespace wrench {
24 
25  class Simulation;
26 
30  class Workflow {
31 
32  public:
33  Workflow();
34 
35  WorkflowTask *addTask(std::string, double flops,
36  unsigned long min_num_cores,
37  unsigned long max_num_cores,
38  double parallel_efficiency,
39  double memory_requirement);
40 
41  void removeTask(WorkflowTask *task);
42 
43  void removeFile(WorkflowFile *file);
44 
45  WorkflowTask *getTaskByID(const std::string &id);
46 
47  WorkflowFile *addFile(std::string, double);
48 
49  WorkflowFile *getFileByID(const std::string &id);
50 
51  static double getSumFlops(std::vector<WorkflowTask *> tasks);
52 
53  void addControlDependency(WorkflowTask *src, WorkflowTask *dest, bool redundant_dependencies = false);
54 
55 // void loadFromDAX(const std::string &filename,
56 // const std::string &reference_flop_rate,
57 // bool redundant_dependencies = false);
58 //
59 // void loadFromJSON(const std::string &filename,
60 // const std::string &reference_flop_rate,
61 // bool redundant_dependencies = false);
62 //
63 // void loadFromDAXorJSON(const std::string &filename,
64 // const std::string &reference_flop_rate,
65 // bool redundant_dependencies = false);
66 
67  unsigned long getNumberOfTasks();
68 
69  unsigned long getNumLevels();
70 
71  double getCompletionDate();
72 
73  void exportToEPS(std::string);
74 
75  std::map<std::string, WorkflowFile *> getInputFiles();
76 
77  std::map<std::string, WorkflowTask *> getEntryTasks() const;
78  std::map<std::string, WorkflowTask *> getExitTasks() const;
79 
80  bool isDone();
81 
82  /***********************/
84  /***********************/
85 
86  std::vector<WorkflowTask *> getTasksInTopLevelRange(unsigned long min, unsigned long max);
87 
88  std::vector<WorkflowTask *> getReadyTasks();
89 
90  std::map<std::string, std::vector<WorkflowTask *>> getReadyClusters();
91 
92  std::vector<WorkflowTask *> getTasks();
93 
94  std::vector<WorkflowFile *> getFiles();
95 
96  std::vector<WorkflowTask *> getTaskParents(const WorkflowTask *task);
97 
98  std::vector<WorkflowTask *> getTaskChildren(const WorkflowTask *task);
99 
100  /***********************/
102  /***********************/
103 
104 
105  /***********************/
107  /***********************/
108  std::shared_ptr<WorkflowExecutionEvent> waitForNextExecutionEvent();
109  std::shared_ptr<WorkflowExecutionEvent> waitForNextExecutionEvent(double timeout);
110 
111  std::string getCallbackMailbox();
112 
113 // void updateTaskState(WorkflowTask *task, WorkflowTask::State state);
114 
115  /***********************/
117  /***********************/
118 
119  private:
120  friend class WMS;
121 
122  friend class WorkflowTask;
123 
124 // void setNumLevels(unsigned long);
125 
126  std::unique_ptr<lemon::ListDigraph> DAG; // Lemon DiGraph
127  std::unique_ptr<lemon::ListDigraph::NodeMap<WorkflowTask *>> DAG_node_map; // Lemon map
128 
129  std::map<std::string, std::unique_ptr<WorkflowTask>> tasks;
130  std::map<std::string, std::unique_ptr<WorkflowFile>> files;
131 
132 // unsigned long num_levels;
133 
134  bool pathExists(WorkflowTask *, WorkflowTask *);
135 
136  std::string callback_mailbox;
137  ComputeService *parent_compute_service; // The compute service to which the job was submitted, if any
138  Simulation *simulation; // a ptr to the simulation so that the simulation can obtain simulation timestamps for workflow tasks
139  };
140 };
141 
142 #endif //WRENCH_WORKFLOW_H
std::map< std::string, WorkflowFile * > getInputFiles()
Retrieve a map (indexed by file id) of input files for a workflow (i.e., those files that are input t...
Definition: Workflow.cpp:527
void addControlDependency(WorkflowTask *src, WorkflowTask *dest, bool redundant_dependencies=false)
Create a control dependency between two workflow tasks. Will not do anything if there is already a pa...
Definition: Workflow.cpp:173
A computational task in a Workflow.
Definition: WorkflowTask.h:26
std::map< std::string, WorkflowTask * > getEntryTasks() const
Get the exit tasks of the workflow, i.e., those tasks that don&#39;t have parents.
Definition: Workflow.cpp:859
WorkflowFile * addFile(std::string, double)
Add a new file to the workflow.
Definition: Workflow.cpp:203
bool isDone()
Returns whether all tasks are complete.
Definition: Workflow.cpp:350
unsigned long getNumLevels()
Returns the number of levels in the workflow.
Definition: Workflow.cpp:892
WorkflowTask * getTaskByID(const std::string &id)
Find a WorkflowTask based on its ID.
Definition: Workflow.cpp:156
void removeTask(WorkflowTask *task)
Remove a task from the workflow. WARNING: this method de-allocated memory for the task...
Definition: Workflow.cpp:116
A data file used/produced by a WorkflowTask in a Workflow.
Definition: WorkflowFile.h:26
void exportToEPS(std::string)
Output the workflow&#39;s dependency graph to EPS.
Definition: Workflow.cpp:246
A workflow (to be executed by a WMS)
Definition: Workflow.h:30
WorkflowTask * addTask(std::string, double flops, unsigned long min_num_cores, unsigned long max_num_cores, double parallel_efficiency, double memory_requirement)
Create and add a new computational task to the workflow.
Definition: Workflow.cpp:41
double getCompletionDate()
Returns the workflow&#39;s completion date.
Definition: Workflow.cpp:910
A class that provides basic simulation methods. Once the simulation object has been explicitly or imp...
Definition: Simulation.h:45
The compute service base class.
Definition: ComputeService.h:35
void removeFile(WorkflowFile *file)
Remove a file from the workflow. WARNING: this method de-allocated memory for the file...
Definition: Workflow.cpp:91
static double getSumFlops(std::vector< WorkflowTask *> tasks)
Get the total number of flops for a list of tasks.
Definition: Workflow.cpp:545
unsigned long getNumberOfTasks()
Get the number of tasks in the workflow.
Definition: Workflow.cpp:261
A workflow management system (WMS)
Definition: WMS.h:35
WorkflowFile * getFileByID(const std::string &id)
Find a WorkflowFile based on its ID.
Definition: Workflow.cpp:232
Workflow()
Constructor.
Definition: Workflow.cpp:283
std::map< std::string, WorkflowTask * > getExitTasks() const
Get the exit tasks of the workflow, i.e., those tasks that don&#39;t have children.
Definition: Workflow.cpp:876
Definition: Alarm.cpp:19