10 #ifndef WRENCH_WORKFLOW_H
11 #define WRENCH_WORKFLOW_H
16 #include "wrench/execution_events/ExecutionEvent.h"
17 #include "wrench/data_file/DataFile.h"
18 #include "WorkflowTask.h"
19 #include "DagOfTasks.h"
21 #include <boost/graph/adjacency_list.hpp>
22 #include "wrench/workflow/parallel_model/ParallelModel.h"
34 class Workflow :
public std::enable_shared_from_this<Workflow> {
46 std::shared_ptr<Workflow>
getSharedPtr() {
return this->shared_from_this(); }
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);
54 void removeTask(std::shared_ptr<WorkflowTask>task);
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);
63 static double getSumFlops(
const std::vector<std::shared_ptr<WorkflowTask>> tasks);
65 void addControlDependency(std::shared_ptr<WorkflowTask>src, std::shared_ptr<WorkflowTask>dest,
bool redundant_dependencies =
false);
77 std::map<std::string, std::shared_ptr<DataFile>>
getInputFileMap()
const;
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;
88 std::vector<std::shared_ptr<WorkflowTask>>
getTaskParents(
const std::shared_ptr<WorkflowTask>task);
90 std::vector<std::shared_ptr<WorkflowTask>>
getTaskChildren(
const std::shared_ptr<WorkflowTask>task);
93 bool pathExists(
const std::shared_ptr<WorkflowTask>src,
const std::shared_ptr<WorkflowTask>dst);
98 std::set<std::shared_ptr<WorkflowTask>>
getTasksThatInput(std::shared_ptr<DataFile> file);
109 std::map<std::string, std::vector<std::shared_ptr<WorkflowTask>>>
getReadyClusters();
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;
129 std::map<std::string, std::shared_ptr<WorkflowTask>> tasks;
132 std::set<std::shared_ptr<WorkflowTask>> ready_tasks;
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;
139 std::set<std::shared_ptr<DataFile>> data_files;
144 #endif //WRENCH_WORKFLOW_H
void removeTask(std::shared_ptr< WorkflowTask >task)
Remove a task from the workflow.
Definition: Workflow.cpp:118
std::shared_ptr< WorkflowTask > getTaskByID(const std::string &id)
Find a WorkflowTask based on its ID.
Definition: Workflow.cpp:165
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
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
std::shared_ptr< DataFile > addFile(std::string id, double size)
Add a file to the workflow.
Definition: Workflow.cpp:702
bool isFileOutputOfSomeTask(std::shared_ptr< DataFile > file)
Determine whether a file is output of some task.
Definition: Workflow.cpp:678
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
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
void removeFile(std::shared_ptr< DataFile >file)
Remove a file from the workflow.
Definition: Workflow.cpp:88
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
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
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
std::map< std::string, std::vector< std::shared_ptr< WorkflowTask > > > getReadyClusters()
Get a map of clusters composed of ready tasks.
Definition: Workflow.cpp:301
long getTaskNumberOfChildren(const std::shared_ptr< WorkflowTask >task)
Get the number of children for a task.
Definition: Workflow.cpp:396
std::shared_ptr< DataFile > getFileByID(const std::string &id)
Get a file based on its ID.
Definition: Workflow.cpp:723
long getTaskNumberOfParents(const std::shared_ptr< WorkflowTask >task)
Get the number of parents for a task.
Definition: Workflow.cpp:430
std::shared_ptr< Workflow > getSharedPtr()
Get the shared pointer for this object.
Definition: Workflow.h:46
void exportToEPS(std::string)
Output the workflow's dependency graph to EPS.
Definition: Workflow.cpp:254
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
Definition: Action.cpp:28
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
static std::shared_ptr< Workflow > createWorkflow()
Create a workflow instance.
Definition: Workflow.cpp:731
A workflow (to be executed by a WMS)
Definition: Workflow.h:34
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
void clear()
Method that will delete all workflow tasks and all files used by these tasks.
Definition: Workflow.cpp:27
std::set< std::shared_ptr< WorkflowTask > > getTasksThatInput(std::shared_ptr< DataFile > file)
Find which tasks use a file as input.
Definition: Workflow.cpp:687
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
std::map< std::string, std::shared_ptr< DataFile > > & getFileMap()
Get the list of all files in the workflow/simulation.
Definition: Workflow.cpp:714
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
A computational task in a Workflow.
Definition: WorkflowTask.h:33
std::vector< std::shared_ptr< WorkflowTask > > getReadyTasks()
Get a vector of ready tasks.
Definition: Workflow.cpp:290
bool isDone()
Returns whether all tasks are complete.
Definition: Workflow.cpp:335
std::vector< std::shared_ptr< WorkflowTask > > getTasks()
Get the list of all tasks in the workflow.
Definition: Workflow.cpp:359
double getCompletionDate()
Returns the workflow's completion date.
Definition: Workflow.cpp:647
std::map< std::string, std::shared_ptr< WorkflowTask > > getTaskMap()
Get the list of all tasks in the workflow.
Definition: Workflow.cpp:350
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
unsigned long getNumberOfTasks()
Get the number of tasks in the workflow.
Definition: Workflow.cpp:263
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
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
A class that provides basic simulation methods. Once the simulation object has been explicitly or imp...
Definition: Simulation.h:48
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
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
unsigned long getNumLevels()
Returns the number of levels in the workflow.
Definition: Workflow.cpp:629