10 #ifndef WRENCH_WORKFLOWTASK_H
11 #define WRENCH_WORKFLOWTASK_H
17 #include "wrench/workflow/job/WorkflowJob.h"
18 #include "wrench/workflow/WorkflowFile.h"
19 #include "wrench/workflow/parallel_model/ParallelModel.h"
20 #include "wrench/workflow/parallel_model/AmdahlParallelModel.h"
21 #include "wrench/workflow/parallel_model/ConstantEfficiencyParallelModel.h"
22 #include "wrench/workflow/parallel_model/CustomParallelModel.h"
24 #include <boost/graph/adjacency_list.hpp>
34 std::string
getID()
const;
54 std::vector<WorkflowTask *>
getParents()
const;
135 struct WorkflowTaskExecution;
165 static std::string
stateToString(WorkflowTask::InternalState state);
167 unsigned long updateTopLevel();
169 void setInternalState(WorkflowTask::InternalState);
177 WorkflowTask::InternalState getInternalState()
const;
179 void setJob(WorkflowJob *job);
181 void setStartDate(
double date);
183 void setEndDate(
double date);
185 void setReadInputStartDate(
double date);
187 void setReadInputEndDate(
double date);
189 void setComputationStartDate(
double date);
191 void setComputationEndDate(
double date);
193 void setWriteOutputStartDate(
double date);
195 void setWriteOutputEndDate(
double date);
197 void setFailureDate(
double date);
199 void setTerminationDate(
double date);
201 void incrementFailureCount();
203 void setExecutionHost(std::string hostname);
205 void setNumCoresAllocated(
unsigned long num_cores);
210 struct WorkflowTaskExecution {
212 double task_start = -1.0;
214 double read_input_start = -1.0;
216 double read_input_end = -1.0;
218 double computation_start = -1.0;
220 double computation_end = -1.0;
222 double write_output_start = -1.0;
224 double write_output_end = -1.0;
226 double task_end = -1.0;
228 double task_failed = -1.0;
230 double task_terminated = -1.0;
233 std::string execution_host =
"";
235 unsigned long num_cores_allocated = 0;
242 WorkflowTaskExecution(
double task_start) : task_start(task_start) {}
253 friend class Workflow;
256 std::string cluster_id;
259 double average_cpu = -1;
260 unsigned long bytes_read = -1;
261 unsigned long bytes_written = -1;
262 unsigned long min_num_cores;
263 unsigned long max_num_cores;
264 std::shared_ptr<ParallelModel> parallel_model;
265 double memory_requirement;
266 unsigned long priority = 0;
267 unsigned long toplevel;
268 unsigned int failure_count = 0;
269 std::string execution_host;
271 State upcoming_visible_state;
272 InternalState internal_state;
276 std::map<std::string, WorkflowFile *> output_files;
277 std::map<std::string, WorkflowFile *> input_files;
280 WorkflowTask(std::string
id,
282 unsigned long min_num_cores,
283 unsigned long max_num_cores,
284 double memory_requirement);
289 std::stack<WorkflowTaskExecution> execution_history;
291 friend class DagOfTasks;
295 #endif //WRENCH_WORKFLOWTASK_H
@ PENDING
Pending (has been submitted to a compute service)
Definition: WorkflowTask.h:74
std::shared_ptr< ParallelModel > getParallelModel()
Get the task's parallel model.
Definition: WorkflowTask.cpp:819
@ READY
Ready (parents have completed)
Definition: WorkflowTask.h:72
double getComputationEndDate()
Get the task's most recent computation end date.
Definition: WorkflowTask.cpp:659
@ UNKNOWN
Some Unknown state (should not happen)
Definition: WorkflowTask.h:78
WorkflowTask::State getState() const
Get the state of the task.
Definition: WorkflowTask.cpp:198
std::string getID() const
Get the id of the task.
Definition: WorkflowTask.cpp:117
State
Task states.
Definition: WorkflowTask.h:68
double getAverageCPU() const
Get the task average CPU usage.
Definition: WorkflowTask.cpp:395
void setClusterID(std::string)
Set the cluster id for the task.
Definition: WorkflowTask.cpp:371
std::vector< WorkflowTask * > getChildren() const
Get the children of a task.
Definition: WorkflowTask.cpp:171
std::vector< WorkflowFile * > getOutputFiles()
Get the list of output WorkflowFile objects for the task.
Definition: WorkflowTask.cpp:622
void addInputFile(WorkflowFile *file)
Add an input file to the task.
Definition: WorkflowTask.cpp:57
unsigned long getMaxNumCores() const
Get the maximum number of cores that the task can use.
Definition: WorkflowTask.cpp:144
unsigned long getNumberOfChildren() const
Get the number of children of a task.
Definition: WorkflowTask.cpp:162
std::string getColor()
Get the task's color ("" if none)
Definition: WorkflowTask.cpp:795
void setBytesWritten(unsigned long)
Set the number of bytes written by the task.
Definition: WorkflowTask.cpp:435
double getWriteOutputStartDate()
Get the task's most recent write output start date.
Definition: WorkflowTask.cpp:683
double getStartDate()
Get the task's most recent start date.
Definition: WorkflowTask.cpp:635
A workflow (to be executed by a WMS)
Definition: Workflow.h:34
@ COMPLETED
Completed (successfully completed)
Definition: WorkflowTask.h:76
static std::string stateToString(WorkflowTask::State state)
Convert task state to a string (useful for output, debugging, logging, etc.)
Definition: WorkflowTask.cpp:225
double getTerminationDate()
Get the tasks's most recent termination date (when it was explicitly requested to be terminated by th...
Definition: WorkflowTask.cpp:707
void setPriority(long)
Set the task priority.
Definition: WorkflowTask.cpp:387
unsigned long getMinNumCores() const
Get the minimum number of cores required for running the task.
Definition: WorkflowTask.cpp:135
unsigned long getBytesWritten() const
Get the number of bytes written by the task.
Definition: WorkflowTask.cpp:427
unsigned long getNumCoresAllocated()
Returns the number of cores allocated for this task's most recent execution or 0 if an execution atte...
Definition: WorkflowTask.cpp:755
Workflow * getWorkflow() const
Get the workflow that contains the task.
Definition: WorkflowTask.cpp:268
double getWriteOutputEndDate()
Get the task's most recent write output end date.
Definition: WorkflowTask.cpp:691
void setParallelModel(std::shared_ptr< ParallelModel > model)
Set the task's parallel model.
Definition: WorkflowTask.cpp:811
A computational task in a Workflow.
Definition: WorkflowTask.h:31
double getEndDate()
Get the task's most recent end date.
Definition: WorkflowTask.cpp:643
unsigned int getFailureCount()
Get the number of times a task has failed.
Definition: WorkflowTask.cpp:594
double getMemoryRequirement() const
Get the memory_manager_service requirement of the task.
Definition: WorkflowTask.cpp:153
Abstraction of a job used for executing tasks in a Workflow.
Definition: WorkflowJob.h:34
void setBytesRead(unsigned long)
Set the number of bytes read by the task.
Definition: WorkflowTask.cpp:419
double getFailureDate()
Get the task's most recent failure date.
Definition: WorkflowTask.cpp:699
std::string getExecutionHost()
Returns the name of the host on which the task has most recently been executed, or "" if the task has...
Definition: WorkflowTask.cpp:747
unsigned long getPriority() const
Get the task priority. By default, priority is 0.
Definition: WorkflowTask.cpp:379
unsigned long getTopLevel()
Returns the task's top level (max number of hops on a reverse path up to an entry task....
Definition: WorkflowTask.cpp:738
std::string getClusterID() const
Get the cluster Id for the task.
Definition: WorkflowTask.cpp:362
unsigned long getBytesRead() const
Get the number of bytes read by the task.
Definition: WorkflowTask.cpp:411
@ NOT_READY
Not ready (parents have not completed)
Definition: WorkflowTask.h:70
double getComputationStartDate()
Get the tasks's most recent computation start date.
Definition: WorkflowTask.cpp:651
std::stack< WorkflowTaskExecution > getExecutionHistory()
Get the execution history of this task.
Definition: WorkflowTask.cpp:585
double getReadInputStartDate()
Get the task's most recent read input start date.
Definition: WorkflowTask.cpp:667
std::vector< WorkflowTask * > getParents() const
Get the parents of a task.
Definition: WorkflowTask.cpp:189
void setAverageCPU(double)
Set the task average CPU usage.
Definition: WorkflowTask.cpp:403
void addOutputFile(WorkflowFile *file)
Add an output file to the task.
Definition: WorkflowTask.cpp:87
WorkflowJob * getJob() const
Get the task's containing job.
Definition: WorkflowTask.cpp:354
unsigned long getNumberOfParents() const
Get the number of parents of a task.
Definition: WorkflowTask.cpp:180
A data file used/produced by a WorkflowTask in a Workflow.
Definition: WorkflowFile.h:26
double getFlops() const
Get the number of flops of the task.
Definition: WorkflowTask.cpp:126
void setColor(std::string)
Set the task's color.
Definition: WorkflowTask.cpp:803
std::vector< WorkflowFile * > getInputFiles()
Get the list of input WorkflowFile objects for the task.
Definition: WorkflowTask.cpp:609
double getReadInputEndDate()
Get the task's most recent read input end date.
Definition: WorkflowTask.cpp:675