WorkunitExecutor.h
1 
11 #ifndef WRENCH_WORKUNITMULTICOREEXECUTOR_H
12 #define WRENCH_WORKUNITMULTICOREEXECUTOR_H
13 
14 
15 #include "wrench/services/Service.h"
16 #include <set>
17 #include "wrench/services/compute/workunit_executor/Workunit.h"
18 
19 namespace wrench {
20 
21  class Simulation;
22  class StorageService;
23  class WorkflowFile;
24  class WorkflowTask;
25  class StorageService;
26  class StandardJob;
27  class WorkerThreadWork;
28  class Workunit;
29  class ComputeThread;
30  class WorkflowJob;
31  class SimulationTimestampTaskFailure;
32 
33  /***********************/
35  /***********************/
36 
40  class WorkunitExecutor : public Service {
41 
42  public:
43 
45  std::string hostname,
46  unsigned long num_cores,
47  double ram_utilization,
48  std::string callback_mailbox,
49  std::shared_ptr<Workunit> workunit,
50  std::shared_ptr<StorageService> scratch_space,
51  std::shared_ptr<StandardJob> job,
52  double thread_startup_overhead,
53  bool simulate_computation_as_sleep);
54 
55  void kill(bool job_termination);
56 
57  unsigned long getNumCores();
58  std::shared_ptr<StandardJob> getJob();
59  double getMemoryUtilization();
60  std::set<WorkflowFile*> getFilesStoredInScratch();
61 
63  std::shared_ptr<Workunit> workunit;
64 
65  private:
66 
67  bool failure_timestamp_should_be_generated = false;
68  bool task_completion_timestamp_should_be_generated = false;
69  bool terminated_due_job_being_forcefully_terminated = false;
70  bool task_start_timestamp_has_been_inserted = false;
71  bool task_failure_time_stamp_has_already_been_generated = false;
72 
74  int main() override;
75  void cleanup(bool has_returned_from_main, int return_value) override;
76 
77  void performWork(Workunit *work);
78 
79  void runMulticoreComputationForTask(WorkflowTask *task, bool simulate_computation_as_sleep);
80 
81  std::string callback_mailbox;
82  unsigned long num_cores;
83  double ram_utilization;
84  double thread_startup_overhead;
85  bool simulate_computation_as_sleep;
86 
87  std::shared_ptr<StorageService> scratch_space;
88 
89  std::set<WorkflowFile* > files_stored_in_scratch;
90  std::vector<std::shared_ptr<ComputeThread>> compute_threads;
91 
92  // a reference to the job it is a part of (currently required for creating the /tmp directory in scratch space)
93  std::shared_ptr<StandardJob> job;
94 
95  };
96 
97  /***********************/
99  /***********************/
100 
101 };
102 
103 
104 #endif //WRENCH_WORKUNITEXECUTOR_H
std::set< WorkflowFile * > getFilesStoredInScratch()
Retrieve the list of files stored in scratch space storage.
Definition: WorkunitExecutor.cpp:660
unsigned long getNumCores()
Returns the number of cores the service has been allocated.
Definition: WorkunitExecutor.cpp:644
std::shared_ptr< Workunit > workunit
The Workunit this WorkunitExecutor is supposed to perform.
Definition: WorkunitExecutor.h:63
A class to describe a unit of work that's a sub-component of a StandardJob.
Definition: Workunit.h:35
An service that performs a WorkUnit.
Definition: WorkunitExecutor.h:40
double getMemoryUtilization()
Returns the RAM the service has been allocated.
Definition: WorkunitExecutor.cpp:652
Definition: Alarm.cpp:20
A computational task in a Workflow.
Definition: WorkflowTask.h:31
std::shared_ptr< StandardJob > getJob()
Retrieve the job the WorkunitExecutor is working for.
Definition: WorkunitExecutor.cpp:668
std::string hostname
The name of the host on which the daemon is running.
Definition: S4U_Daemon.h:51
void kill(bool job_termination)
Kill the worker thread.
Definition: WorkunitExecutor.cpp:135
A service that can be added to the simulation and that can be used by a WMS when executing a workflow...
Definition: Service.h:26
A simulation timestamp class for WorkflowTask failure times.
Definition: SimulationTimestampTypes.h:135
WorkunitExecutor(std::string hostname, unsigned long num_cores, double ram_utilization, std::string callback_mailbox, std::shared_ptr< Workunit > workunit, std::shared_ptr< StorageService > scratch_space, std::shared_ptr< StandardJob > job, double thread_startup_overhead, bool simulate_computation_as_sleep)
Constructor.
Definition: WorkunitExecutor.cpp:58