ComputeService.h
1 
10 #ifndef SIMULATION_COMPUTESERVICE_H
11 #define SIMULATION_COMPUTESERVICE_H
12 
13 #include <map>
14 
15 #include <iostream>
16 #include <cfloat>
17 #include <climits>
18 
19 #include "wrench/services/Service.h"
20 #include "wrench/workflow/job/WorkflowJob.h"
21 
22 namespace wrench {
23 
24  class Simulation;
25 
26  class StandardJob;
27 
28  class PilotJob;
29 
30  class StorageService;
31 
35  class ComputeService : public Service {
36 
37  /***********************/
39  /***********************/
40 
41  friend class StandardJobExecutorTest;
42  friend class Simulation;
43 
44  /***********************/
46  /***********************/
47 
48 
49  public:
50 
54  static constexpr unsigned long ALL_CORES = ULONG_MAX;
55 
59  static constexpr double ALL_RAM = DBL_MAX;
60 
61  /***********************/
63  /***********************/
64 
65  virtual ~ComputeService() {}
66 
67  void stop() override;
68 
69 // void submitJob(WorkflowJob *job, const std::map<std::string, std::string>& = {});
70 
71  void terminateJob(WorkflowJob *job);
72 
73  bool supportsStandardJobs();
74 
75  bool supportsPilotJobs();
76 
77  bool hasScratch();
78 
79  unsigned long getNumHosts();
80 
81  std::map<std::string, unsigned long> getPerHostNumCores();
82 
83  unsigned long getTotalNumCores();
84 
85  std::map<std::string, unsigned long> getPerHostNumIdleCores();
86 
87  virtual unsigned long getTotalNumIdleCores();
88 
89  std::map<std::string, double> getMemoryCapacity();
90 
91  std::map<std::string, double> getPerHostAvailableMemoryCapacity();
92 
93  std::map<std::string, double> getCoreFlopRate();
94 
95  double getTTL();
96 
97  double getTotalScratchSpaceSize();
98 
99  double getFreeScratchSpaceSize();
100 
101 
102  /***********************/
104  /***********************/
105 
106  /***********************/
108  /***********************/
109 
116  virtual void
117  submitStandardJob(StandardJob *job, const std::map<std::string, std::string> &service_specific_arguments) = 0;
118 
125  virtual void submitPilotJob(PilotJob *job, const std::map<std::string, std::string> &service_specific_arguments) = 0;
126 
131  virtual void terminateStandardJob(StandardJob *job) = 0;
132 
137  virtual void terminatePilotJob(PilotJob *job) = 0;
138 
143  std::shared_ptr<StorageService> getScratch();
144 
145 
146  ComputeService(const std::string &hostname,
147  std::string service_name,
148  std::string mailbox_name_prefix,
149  std::string scratch_space_mount_point);
150 
151  protected:
152 
153  friend class JobManager;
154 
155  void submitJob(WorkflowJob *job, const std::map<std::string, std::string>& = {});
156 
157  ComputeService(const std::string &hostname,
158  std::string service_name,
159  std::string mailbox_name_prefix,
160  std::shared_ptr<StorageService> scratch_space);
161 
163  std::shared_ptr<StorageService> scratch_space_storage_service;
164 
165  /***********************/
167  /***********************/
168 
169  /***********************/
171  /***********************/
172 
173  std::shared_ptr<StorageService> getScratchSharedPtr();
174 
175  /***********************/
177  /***********************/
178 
179  private:
180 
181 
182  std::shared_ptr<StorageService> scratch_space_storage_service_shared_ptr;
183 
184  std::map<std::string, std::map<std::string, double>> getServiceResourceInformation();
185 
186  };
187 
188 
189 };
190 
191 #endif //SIMULATION_COMPUTESERVICE_H
The compute service base class.
Definition: ComputeService.h:35
Definition: Alarm.cpp:20
static constexpr unsigned long ALL_CORES
A convenient constant to mean "use all cores of a physical host" whenever a number of cores is needed...
Definition: ComputeService.h:54
A class that provides basic simulation methods. Once the simulation object has been explicitly or imp...
Definition: Simulation.h:46
static constexpr double ALL_RAM
A convenient constant to mean "use all ram of a physical host" whenever a ram capacity is needed when...
Definition: ComputeService.h:59
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