WRENCH  1.11
Cyberinfrastructure Simulation Workbench
Overview Installation Getting Started WRENCH 101 WRENCH 102
Workflow.h
1 
10 #ifndef WRENCH_WORKFLOW_H
11 #define WRENCH_WORKFLOW_H
12 
13 #include <map>
14 #include <set>
15 
16 #include "wrench/execution_events/ExecutionEvent.h"
17 #include "wrench/data_file/DataFile.h"
18 #include "WorkflowTask.h"
19 #include "DagOfTasks.h"
20 
21 #include <boost/graph/adjacency_list.hpp>
22 #include "wrench/workflow/parallel_model/ParallelModel.h"
23 
24 class WorkflowTask;
25 
26 namespace wrench {
27 
28  class Simulation;
29 
30 
34  class Workflow : public std::enable_shared_from_this<Workflow> {
35 
36  public:
37 
38 
39  static std::shared_ptr<Workflow> createWorkflow();
40  void clear();
41 
46  std::shared_ptr<Workflow> getSharedPtr() { return this->shared_from_this(); }
47 
48 
49  std::shared_ptr<WorkflowTask> addTask(std::string, double flops,
50  unsigned long min_num_cores,
51  unsigned long max_num_cores,
52  double memory_requirement);
53 
54  void removeTask(std::shared_ptr<WorkflowTask>task);
55 
56  void removeFile(std::shared_ptr<DataFile>file);
57  std::map<std::string, std::shared_ptr<DataFile>> &getFileMap();
58  std::shared_ptr<DataFile> addFile(std::string id, double size);
59  std::shared_ptr<DataFile> getFileByID(const std::string &id);
60  std::shared_ptr<WorkflowTask> getTaskByID(const std::string &id);
61 
62 
63  static double getSumFlops(const std::vector<std::shared_ptr<WorkflowTask>> tasks);
64 
65  void addControlDependency(std::shared_ptr<WorkflowTask>src, std::shared_ptr<WorkflowTask>dest, bool redundant_dependencies = false);
66  void removeControlDependency(std::shared_ptr<WorkflowTask>src, std::shared_ptr<WorkflowTask>dest);
67 
68  unsigned long getNumberOfTasks();
69 
70  unsigned long getNumLevels();
71 
72  double getCompletionDate();
73 
74  void exportToEPS(std::string);
75 
76  std::vector<std::shared_ptr<DataFile>> getInputFiles() const;
77  std::map<std::string, std::shared_ptr<DataFile>> getInputFileMap() const;
78  std::vector<std::shared_ptr<DataFile>> getOutputFiles() const;
79  std::map<std::string, std::shared_ptr<DataFile>> getOutputFileMap() const;
80 
81  std::vector<std::shared_ptr<WorkflowTask>> getTasks();
82  std::map<std::string, std::shared_ptr<WorkflowTask>> getTaskMap();
83  std::map<std::string, std::shared_ptr<WorkflowTask>> getEntryTaskMap() const;
84  std::vector<std::shared_ptr<WorkflowTask>> getEntryTasks() const;
85  std::map<std::string, std::shared_ptr<WorkflowTask>> getExitTaskMap() const;
86  std::vector<std::shared_ptr<WorkflowTask>> getExitTasks() const;
87 
88  std::vector<std::shared_ptr<WorkflowTask>> getTaskParents(const std::shared_ptr<WorkflowTask>task);
89  long getTaskNumberOfParents(const std::shared_ptr<WorkflowTask>task);
90  std::vector<std::shared_ptr<WorkflowTask>> getTaskChildren(const std::shared_ptr<WorkflowTask>task);
91  long getTaskNumberOfChildren(const std::shared_ptr<WorkflowTask>task);
92 
93  bool pathExists(const std::shared_ptr<WorkflowTask>src, const std::shared_ptr<WorkflowTask>dst);
94 
95  std::shared_ptr<WorkflowTask> getTaskThatOutputs(std::shared_ptr<DataFile> file);
96  bool isFileOutputOfSomeTask(std::shared_ptr<DataFile> file);
97 
98  std::set<std::shared_ptr<WorkflowTask>> getTasksThatInput(std::shared_ptr<DataFile> file);
99  bool isDone();
100 
101  /***********************/
103  /***********************/
104 
105  std::vector<std::shared_ptr<WorkflowTask>> getTasksInTopLevelRange(unsigned long min, unsigned long max);
106 
107  std::vector<std::shared_ptr<WorkflowTask>> getReadyTasks();
108 
109  std::map<std::string, std::vector<std::shared_ptr<WorkflowTask>>> getReadyClusters();
110 
111  /***********************/
113  /***********************/
114 
115  private:
116  friend class WMS;
117  friend class Simulation;
118  friend class WorkflowTask;
119 
120  Workflow();
121 
122  struct Vertex{ std::shared_ptr<WorkflowTask>task;};
123  typedef boost::adjacency_list<boost::listS, boost::vecS, boost::directedS, Vertex> DAG;
124  typedef boost::graph_traits<DAG>::vertex_descriptor vertex_t;
125 
126  DagOfTasks dag;
127 
128  /* Map to find tasks by name */
129  std::map<std::string, std::shared_ptr<WorkflowTask>> tasks;
130 
131  /* Set of ready tasks */
132  std::set<std::shared_ptr<WorkflowTask>> ready_tasks;
133 
134  /* Map of output files */
135  std::map<std::shared_ptr<DataFile>, std::shared_ptr<WorkflowTask>> task_output_files;
136  std::map<std::shared_ptr<DataFile>, std::set<std::shared_ptr<WorkflowTask>>> task_input_files;
137 
138  /* Set of files (also kept track by the simulation!) */
139  std::set<std::shared_ptr<DataFile>> data_files;
140 
141  };
142 };
143 
144 #endif //WRENCH_WORKFLOW_H
wrench::Workflow::removeTask
void removeTask(std::shared_ptr< WorkflowTask >task)
Remove a task from the workflow.
Definition: Workflow.cpp:118
wrench::Workflow::getTaskByID
std::shared_ptr< WorkflowTask > getTaskByID(const std::string &id)
Find a WorkflowTask based on its ID.
Definition: Workflow.cpp:165
wrench::Workflow::getInputFileMap
std::map< std::string, std::shared_ptr< DataFile > > getInputFileMap() const
Retrieve the list of the input files of the workflow (i.e., those files that are input to some tasks ...
Definition: Workflow.cpp:443
wrench::Workflow::getOutputFileMap
std::map< std::string, std::shared_ptr< DataFile > > getOutputFileMap() const
Retrieve a list of the output files of the workflow (i.e., those files that are output from some task...
Definition: Workflow.cpp:487
wrench::Workflow::addFile
std::shared_ptr< DataFile > addFile(std::string id, double size)
Add a file to the workflow.
Definition: Workflow.cpp:702
wrench::Workflow::isFileOutputOfSomeTask
bool isFileOutputOfSomeTask(std::shared_ptr< DataFile > file)
Determine whether a file is output of some task.
Definition: Workflow.cpp:678
wrench::Workflow::getTaskParents
std::vector< std::shared_ptr< WorkflowTask > > getTaskParents(const std::shared_ptr< WorkflowTask >task)
Get the list of parents for a task.
Definition: Workflow.cpp:410
wrench::Workflow::getExitTaskMap
std::map< std::string, std::shared_ptr< WorkflowTask > > getExitTaskMap() const
Get the exit tasks of the workflow, i.e., those tasks that don't have children.
Definition: Workflow.cpp:595
wrench::Workflow::removeFile
void removeFile(std::shared_ptr< DataFile >file)
Remove a file from the workflow.
Definition: Workflow.cpp:88
wrench::Workflow::addControlDependency
void addControlDependency(std::shared_ptr< WorkflowTask >src, std::shared_ptr< 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:182
wrench::Workflow::getTaskThatOutputs
std::shared_ptr< WorkflowTask > getTaskThatOutputs(std::shared_ptr< DataFile > file)
Get the workflow task for which a file is an output.
Definition: Workflow.cpp:665
wrench::Workflow::addTask
std::shared_ptr< WorkflowTask > addTask(std::string, double flops, unsigned long min_num_cores, unsigned long max_num_cores, double memory_requirement)
Create and add a new computational task to the workflow.
Definition: Workflow.cpp:49
wrench::Workflow::getReadyClusters
std::map< std::string, std::vector< std::shared_ptr< WorkflowTask > > > getReadyClusters()
Get a map of clusters composed of ready tasks.
Definition: Workflow.cpp:301
wrench::Workflow::getTaskNumberOfChildren
long getTaskNumberOfChildren(const std::shared_ptr< WorkflowTask >task)
Get the number of children for a task.
Definition: Workflow.cpp:396
wrench::Workflow::getFileByID
std::shared_ptr< DataFile > getFileByID(const std::string &id)
Get a file based on its ID.
Definition: Workflow.cpp:723
wrench::Workflow::getTaskNumberOfParents
long getTaskNumberOfParents(const std::shared_ptr< WorkflowTask >task)
Get the number of parents for a task.
Definition: Workflow.cpp:430
wrench::Workflow::getSharedPtr
std::shared_ptr< Workflow > getSharedPtr()
Get the shared pointer for this object.
Definition: Workflow.h:46
wrench::Workflow::exportToEPS
void exportToEPS(std::string)
Output the workflow's dependency graph to EPS.
Definition: Workflow.cpp:254
wrench::Workflow::getSumFlops
static double getSumFlops(const std::vector< std::shared_ptr< WorkflowTask >> tasks)
Get the total number of flops for a list of tasks.
Definition: Workflow.cpp:532
wrench
Definition: Action.cpp:28
wrench::Workflow::getEntryTaskMap
std::map< std::string, std::shared_ptr< WorkflowTask > > getEntryTaskMap() const
Get the list of exit tasks of the workflow, i.e., those tasks that don't have parents.
Definition: Workflow.cpp:561
wrench::Workflow::createWorkflow
static std::shared_ptr< Workflow > createWorkflow()
Create a workflow instance.
Definition: Workflow.cpp:731
wrench::Workflow
A workflow (to be executed by a WMS)
Definition: Workflow.h:34
wrench::Workflow::getTasksInTopLevelRange
std::vector< std::shared_ptr< WorkflowTask > > getTasksInTopLevelRange(unsigned long min, unsigned long max)
Returns all tasks with top-levels in a range.
Definition: Workflow.cpp:546
wrench::Workflow::clear
void clear()
Method that will delete all workflow tasks and all files used by these tasks.
Definition: Workflow.cpp:27
wrench::Workflow::getTasksThatInput
std::set< std::shared_ptr< WorkflowTask > > getTasksThatInput(std::shared_ptr< DataFile > file)
Find which tasks use a file as input.
Definition: Workflow.cpp:687
wrench::Workflow::pathExists
bool pathExists(const std::shared_ptr< WorkflowTask >src, const std::shared_ptr< WorkflowTask >dst)
Determine whether one source is an ancestor of a destination task.
Definition: Workflow.cpp:275
wrench::Workflow::getFileMap
std::map< std::string, std::shared_ptr< DataFile > > & getFileMap()
Get the list of all files in the workflow/simulation.
Definition: Workflow.cpp:714
wrench::Workflow::getEntryTasks
std::vector< std::shared_ptr< WorkflowTask > > getEntryTasks() const
Get the list of exit tasks of the workflow, i.e., those tasks that don't have parents.
Definition: Workflow.cpp:578
wrench::WorkflowTask
A computational task in a Workflow.
Definition: WorkflowTask.h:33
wrench::Workflow::getReadyTasks
std::vector< std::shared_ptr< WorkflowTask > > getReadyTasks()
Get a vector of ready tasks.
Definition: Workflow.cpp:290
wrench::Workflow::isDone
bool isDone()
Returns whether all tasks are complete.
Definition: Workflow.cpp:335
wrench::Workflow::getTasks
std::vector< std::shared_ptr< WorkflowTask > > getTasks()
Get the list of all tasks in the workflow.
Definition: Workflow.cpp:359
wrench::Workflow::getCompletionDate
double getCompletionDate()
Returns the workflow's completion date.
Definition: Workflow.cpp:647
wrench::Workflow::getTaskMap
std::map< std::string, std::shared_ptr< WorkflowTask > > getTaskMap()
Get the list of all tasks in the workflow.
Definition: Workflow.cpp:350
wrench::Workflow::getExitTasks
std::vector< std::shared_ptr< WorkflowTask > > getExitTasks() const
Get the exit tasks of the workflow, i.e., those tasks that don't have children.
Definition: Workflow.cpp:612
wrench::Workflow::getNumberOfTasks
unsigned long getNumberOfTasks()
Get the number of tasks in the workflow.
Definition: Workflow.cpp:263
wrench::Workflow::getTaskChildren
std::vector< std::shared_ptr< WorkflowTask > > getTaskChildren(const std::shared_ptr< WorkflowTask >task)
Get the list of children for a task.
Definition: Workflow.cpp:375
wrench::Workflow::removeControlDependency
void removeControlDependency(std::shared_ptr< WorkflowTask >src, std::shared_ptr< WorkflowTask >dest)
Remove a control dependency between tasks (does nothing if none)
Definition: Workflow.cpp:212
wrench::Simulation
A class that provides basic simulation methods. Once the simulation object has been explicitly or imp...
Definition: Simulation.h:48
wrench::Workflow::getInputFiles
std::vector< std::shared_ptr< DataFile > > getInputFiles() const
Retrieve the list of the input files of the workflow (i.e., those files that are input to some tasks ...
Definition: Workflow.cpp:465
wrench::Workflow::getOutputFiles
std::vector< std::shared_ptr< DataFile > > getOutputFiles() const
Retrieve a list of the output files of the workflow (i.e., those files that are output from some task...
Definition: Workflow.cpp:509
wrench::Workflow::getNumLevels
unsigned long getNumLevels()
Returns the number of levels in the workflow.
Definition: Workflow.cpp:629