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  WorkflowTask::TaskType type = WorkflowTask::TaskType::COMPUTE);
41 
42  void removeTask(WorkflowTask *task);
43 
44  WorkflowTask *getTaskByID(const std::string &id);
45 
46  WorkflowFile *addFile(std::string, double);
47 
48  WorkflowFile *getFileByID(const std::string &id);
49 
50  static double getSumFlops(std::vector<WorkflowTask *> tasks);
51 
52  void addControlDependency(WorkflowTask *src, WorkflowTask *dest, bool redundant_dependencies = false);
53 
54  void loadFromDAX(const std::string &filename,
55  const std::string &reference_flop_rate,
56  bool redundant_dependencies = false);
57 
58  void loadFromJSON(const std::string &filename,
59  const std::string &reference_flop_rate,
60  bool redundant_dependencies = false);
61 
62  void loadFromDAXorJSON(const std::string &filename,
63  const std::string &reference_flop_rate,
64  bool redundant_dependencies = false);
65 
66  unsigned long getNumberOfTasks();
67 
68  unsigned long getNumLevels();
69 
70  double getCompletionDate();
71 
72  void exportToEPS(std::string);
73 
74  std::map<std::string, WorkflowFile *> getInputFiles();
75 
76  bool isDone();
77 
78  /***********************/
80  /***********************/
81 
82  std::vector<WorkflowTask *> getTasksInTopLevelRange(unsigned long min, unsigned long max);
83 
84  std::vector<WorkflowTask *> getReadyTasks();
85 
86  std::map<std::string, std::vector<WorkflowTask *>> getReadyClusters();
87 
88  std::vector<WorkflowTask *> getTasks();
89 
90  std::vector<WorkflowFile *> getFiles();
91 
92  std::vector<WorkflowTask *> getTaskParents(const WorkflowTask *task);
93 
94  std::vector<WorkflowTask *> getTaskChildren(const WorkflowTask *task);
95 
96  /***********************/
98  /***********************/
99 
100 
101  /***********************/
103  /***********************/
104  std::unique_ptr<WorkflowExecutionEvent> waitForNextExecutionEvent();
105 
106  std::string getCallbackMailbox();
107 
108 // void updateTaskState(WorkflowTask *task, WorkflowTask::State state);
109 
110  /***********************/
112  /***********************/
113 
114  private:
115  friend class WMS;
116 
117  friend class WorkflowTask;
118 
119 // void setNumLevels(unsigned long);
120 
121  std::unique_ptr<lemon::ListDigraph> DAG; // Lemon DiGraph
122  std::unique_ptr<lemon::ListDigraph::NodeMap<WorkflowTask *>> DAG_node_map; // Lemon map
123 
124  std::map<std::string, std::unique_ptr<WorkflowTask>> tasks;
125  std::map<std::string, std::unique_ptr<WorkflowFile>> files;
126 
127 // unsigned long num_levels;
128 
129  bool pathExists(WorkflowTask *, WorkflowTask *);
130 
131  std::string callback_mailbox;
132  ComputeService *parent_compute_service; // The compute service to which the job was submitted, if any
133  Simulation *simulation; // a ptr to the simulation so that the simulation can obtain simulation timestamps for workflow tasks
134  };
135 };
136 
137 #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:479
void loadFromJSON(const std::string &filename, const std::string &reference_flop_rate, bool redundant_dependencies=false)
Create a workflow based on a JSON file.
Definition: Workflow.cpp:619
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:135
A computational task in a Workflow.
Definition: WorkflowTask.h:26
WorkflowFile * addFile(std::string, double)
Add a new file to the workflow.
Definition: Workflow.cpp:165
bool isDone()
Returns whether all tasks are complete.
Definition: Workflow.cpp:312
unsigned long getNumLevels()
Returns the number of levels in the workflow.
Definition: Workflow.cpp:801
WorkflowTask * getTaskByID(const std::string &id)
Find a WorkflowTask based on its ID.
Definition: Workflow.cpp:118
void removeTask(WorkflowTask *task)
Remove a task from the workflow. WARNING: this method de-allocated memory for the task...
Definition: Workflow.cpp:86
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:208
A workflow (to be executed by a WMS)
Definition: Workflow.h:30
double getCompletionDate()
Sets the number of levels in the workflow.
Definition: Workflow.cpp:827
A class that provides basic simulation methods.
Definition: Simulation.h:34
void loadFromDAXorJSON(const std::string &filename, const std::string &reference_flop_rate, bool redundant_dependencies=false)
Create a workflow based on a DAX or a JSON file.
Definition: Workflow.cpp:755
WorkflowTask * addTask(std::string, double flops, unsigned long min_num_cores, unsigned long max_num_cores, double parallel_efficiency, double memory_requirement, WorkflowTask::TaskType type=WorkflowTask::TaskType::COMPUTE)
Create and add a new computational task to the workflow.
Definition: Workflow.cpp:42
The compute service base class.
Definition: ComputeService.h:35
static double getSumFlops(std::vector< WorkflowTask *> tasks)
Get the total number of flops for a list of tasks.
Definition: Workflow.cpp:496
void loadFromDAX(const std::string &filename, const std::string &reference_flop_rate, bool redundant_dependencies=false)
Create a workflow based on a DAX file.
Definition: Workflow.cpp:518
unsigned long getNumberOfTasks()
Get the number of tasks in the workflow.
Definition: Workflow.cpp:223
A workflow management system (WMS)
Definition: WMS.h:33
WorkflowFile * getFileByID(const std::string &id)
Find a WorkflowFile based on its ID.
Definition: Workflow.cpp:194
Workflow()
Constructor.
Definition: Workflow.cpp:245
Definition: TerminalOutput.cpp:15