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 
43  /***********************/
45  /***********************/
46 
47  friend class Simulation;
48 
49  public:
50 
54  static constexpr unsigned long ALL_CORES = ULONG_MAX;
55 
59  static constexpr double ALL_RAM = DBL_MAX;
60 
61 
62  /***********************/
64  /***********************/
65 
68  static StorageService *SCRATCH;
69 
70  virtual ~ComputeService() {}
71 
72  void stop() override;
73 
74  void submitJob(WorkflowJob *job, std::map<std::string, std::string> = {});
75 
76  void terminateJob(WorkflowJob *job);
77 
78  bool supportsStandardJobs();
79 
80  bool supportsPilotJobs();
81 
82  bool hasScratch();
83 
84  unsigned long getNumHosts();
85 
86  std::map<std::string, unsigned long> getNumCores();
87 
88  std::map<std::string, unsigned long> getNumIdleCores();
89 
90  unsigned long getTotalNumCores();
91 
92  unsigned long getTotalNumIdleCores();
93 
94  std::map<std::string, double> getMemoryCapacity();
95 
96  std::map<std::string, double> getCoreFlopRate();
97 
98  double getTTL();
99 
100  double getTotalScratchSpaceSize();
101 
102  double getFreeScratchSpaceSize();
103 
104  /***********************/
106  /***********************/
107 
108  /***********************/
110  /***********************/
111 
112  virtual void
113  submitStandardJob(StandardJob *job, std::map<std::string, std::string> &service_specific_arguments) = 0;
114 
115  virtual void submitPilotJob(PilotJob *job, std::map<std::string, std::string> &service_specific_arguments) = 0;
116 
117  virtual void terminateStandardJob(StandardJob *job) = 0;
118 
119  virtual void terminatePilotJob(PilotJob *job) = 0;
120 
121  ComputeService(const std::string &hostname,
122  std::string service_name,
123  std::string mailbox_name_prefix,
124  double scratch_space_size);
125 
126 
127 
128  protected:
129 
130  ComputeService(const std::string &hostname,
131  std::string service_name,
132  std::string mailbox_name_prefix,
133  StorageService *scratch_space);
134 
136  StorageService *scratch_space_storage_service;
137  std::shared_ptr<StorageService> scratch_space_storage_service_shared_ptr;
138 
139  /***********************/
141  /***********************/
142 
143  /***********************/
145  /***********************/
146 
147  StorageService *getScratch();
148  std::shared_ptr<StorageService> getScratchSharedPtr();
149 
150  /***********************/
152  /***********************/
153 
154  private:
155 
156  std::map<std::string, std::map<std::string, double>> getServiceResourceInformation();
157 
158  };
159 
160 
161 };
162 
163 #endif //SIMULATION_COMPUTESERVICE_H
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
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
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.
Definition: Simulation.h:34
The compute service base class.
Definition: ComputeService.h:35
The storage service base class.
Definition: StorageService.h:35
Definition: TerminalOutput.cpp:15