11 #ifndef WRENCH_BATCH_SERVICE_H
12 #define WRENCH_BATCH_SERVICE_H
14 #include "wrench/services/compute/ComputeService.h"
15 #include "wrench/services/compute/standard_job_executor/StandardJobExecutor.h"
16 #include "wrench/services/compute/batch/BatchJob.h"
17 #include "wrench/services/compute/batch/BatschedNetworkListener.h"
18 #include "wrench/services/compute/batch/BatchComputeServiceProperty.h"
19 #include "wrench/services/compute/batch/BatchComputeServiceMessagePayload.h"
20 #include "wrench/services/helpers/Alarm.h"
21 #include "wrench/workflow/job/StandardJob.h"
22 #include "wrench/workflow/job/WorkflowJob.h"
23 #include "wrench/services/compute/batch/batch_schedulers/BatchScheduler.h"
32 class WorkloadTraceFileReplayer;
56 std::map<std::string, std::string> default_property_values = {
65 #ifdef ENABLE_BATSCHED
85 std::map<std::string, double> default_messagepayload_values = {
106 std::vector<std::string> compute_hosts,
107 std::string scratch_space_mount_point,
108 std::map<std::string, std::string> property_list = {},
109 std::map<std::string, double> messagepayload_list = {}
115 std::map<std::string,double> getStartTimeEstimates(std::set<std::tuple<std::string,unsigned long,unsigned long, double>> resources);
117 std::vector<std::tuple<std::string, std::string, int, int, int, double, double>> getQueue();
133 friend class WorkloadTraceFileReplayer;
134 friend class FCFSBatchScheduler;
135 friend class CONSERVATIVEBFBatchScheduler;
136 friend class CONSERVATIVEBFBatchSchedulerCoreLevel;
137 friend class BatschedBatchScheduler;
140 std::vector<std::string> compute_hosts,
141 unsigned long cores_per_host,
143 std::string scratch_space_mount_point,
144 std::map<std::string, std::string> property_list,
145 std::map<std::string, double> messagepayload_list,
150 static unsigned long parseUnsignedLongServiceSpecificArgument(std::string key,
const std::map<std::string, std::string> &args);
153 void submitWorkflowJob(std::shared_ptr<WorkflowJob> job,
const std::map<std::string, std::string> &batch_job_args);
156 void submitStandardJob(std::shared_ptr<StandardJob> job,
const std::map<std::string, std::string> &batch_job_args)
override;
159 void submitPilotJob(std::shared_ptr<PilotJob> job,
const std::map<std::string, std::string> &batch_job_args)
override;
162 void terminateWorkflowJob(std::shared_ptr<WorkflowJob> job);
165 void terminateStandardJob(std::shared_ptr<StandardJob> job)
override;
168 void terminatePilotJob(std::shared_ptr<PilotJob> job)
override;
170 std::vector<std::tuple<std::string, double, double, double, double, unsigned int, std::string>> workload_trace;
171 std::shared_ptr<WorkloadTraceFileReplayer> workload_trace_replayer;
173 bool clean_exit =
false;
176 bool grid_execution =
false;
177 bool grid_execution_start =
false;
178 bool grid_execution_end =
false;
181 unsigned long random_interval = 10;
184 std::map<std::string,std::shared_ptr<Alarm>> standard_job_alarms;
187 std::map<std::string,std::shared_ptr<Alarm>> pilot_job_alarms;
190 unsigned long total_num_of_nodes;
191 unsigned long num_cores_per_node;
192 std::map<std::string, unsigned long> nodes_to_cores_map;
193 std::vector<double> timeslots;
194 std::map<std::string, unsigned long> available_nodes_to_cores;
195 std::map<unsigned long, std::string> host_id_to_names;
196 std::vector<std::string> compute_hosts;
200 std::set<std::shared_ptr<StandardJobExecutor>> running_standard_job_executors;
203 std::set<std::shared_ptr<StandardJobExecutor>> finished_standard_job_executors;
206 std::set<std::shared_ptr<BatchJob>> all_jobs;
209 std::set<std::shared_ptr<BatchJob>> running_jobs;
212 std::deque<std::shared_ptr<BatchJob>> batch_queue;
216 std::set<std::shared_ptr<BatchJob>> waiting_jobs;
219 std::unique_ptr<BatchScheduler> scheduler;
222 #ifdef ENABLE_BATSCHED
224 std::set<std::string> scheduling_algorithms = {
"conservative_bf",
"crasher",
"easy_bf",
"easy_bf_fast",
225 "easy_bf_plot_liquid_load_horizon",
226 "energy_bf",
"energy_bf_dicho",
"energy_bf_idle_sleeper",
227 "energy_bf_monitoring",
228 "energy_bf_monitoring_inertial",
"energy_bf_subpart_sleeper",
229 "energy_watcher",
"fcfs_fast",
"fast_conservative_bf",
230 "filler",
"killer",
"killer2",
"random",
"rejecter",
231 "sequencer",
"sleeper",
"submitter",
"waiting_time_estimator"
234 std::set<std::string> queue_ordering_options = {
"fcfs",
"lcfs",
"desc_bounded_slowdown",
"desc_slowdown",
235 "asc_size",
"desc_size",
"asc_walltime",
"desc_walltime"
239 std::set<std::string> scheduling_algorithms = {
"fcfs",
"conservative_bf",
"conservative_bf_core_level"
243 std::set<std::string> queue_ordering_options = {
248 unsigned long generateUniqueJobID();
250 void removeJobFromRunningList(std::shared_ptr<BatchJob> job);
252 void removeJobFromBatchQueue(std::shared_ptr<BatchJob> job);
254 void removeBatchJobFromJobsList(std::shared_ptr<BatchJob> job);
258 bool processNextMessage();
260 void startBackgroundWorkloadProcess();
262 void processGetResourceInformation(
const std::string &answer_mailbox);
264 void processStandardJobCompletion(std::shared_ptr<StandardJobExecutor> executor, std::shared_ptr<StandardJob> job);
266 void processStandardJobFailure(std::shared_ptr<StandardJobExecutor> executor,
267 std::shared_ptr<StandardJob> job,
268 std::shared_ptr<FailureCause> cause);
270 void terminateRunningStandardJob(std::shared_ptr<StandardJob> job);
274 void cleanup(
bool has_returned_from_main,
int return_value)
override;
277 void terminateRunningPilotJobs();
280 void failCurrentStandardJobs();
283 void processPilotJobCompletion(std::shared_ptr<PilotJob> job);
286 void processStandardJobTimeout(std::shared_ptr<StandardJob> job);
289 void processStandardJobTerminationRequest(std::shared_ptr<StandardJob> job, std::string answer_mailbox);
292 void processPilotJobTerminationRequest(std::shared_ptr<PilotJob> job, std::string answer_mailbox);
295 void processAlarmJobTimeout(std::shared_ptr<BatchJob>job);
298 void processPilotJobTimeout(std::shared_ptr<PilotJob> job);
301 void freeUpResources(std::map<std::string, std::tuple<unsigned long, double>> resources);
304 void sendPilotJobExpirationNotification(std::shared_ptr<PilotJob> job);
307 void sendStandardJobFailureNotification(std::shared_ptr<StandardJob> job, std::string job_id, std::shared_ptr<FailureCause> cause);
310 void processJobSubmission(std::shared_ptr<BatchJob>job, std::string answer_mailbox);
313 void startJob(std::map<std::string, std::tuple<unsigned long, double>>, std::shared_ptr<WorkflowJob> ,
314 std::shared_ptr<BatchJob>,
unsigned long,
unsigned long,
unsigned long);
317 void processExecuteJobFromBatSched(std::string bat_sched_reply);
323 #endif //WRENCH_BATCH_SERVICE_H
static const std::string SIMULATE_COMPUTATION_AS_SLEEP
Simulate computation as just a sleep instead of an actual compute thread. This is for scalability rea...
Definition: BatchComputeServiceProperty.h:142
static const std::string PILOT_JOB_EXPIRED_MESSAGE_PAYLOAD
The number of bytes in the control message sent by the daemon to state that a pilot job has expired.
Definition: ComputeServiceMessagePayload.h:44
static const std::string TERMINATE_PILOT_JOB_ANSWER_MESSAGE_PAYLOAD
The number of bytes in the control message sent by the daemon to acknowledge a pilot job termination.
Definition: ComputeServiceMessagePayload.h:54
static const std::string SUPPORTS_GRID_UNIVERSE
Indicates batch service being used for grid universe through HTCondor.
Definition: BatchComputeServiceProperty.h:168
static const std::string SUBMIT_STANDARD_JOB_REQUEST_MESSAGE_PAYLOAD
The number of bytes in the control message sent to the daemon to submit a standard job.
Definition: ComputeServiceMessagePayload.h:26
static const std::string DAEMON_STOPPED_MESSAGE_PAYLOAD
The number of bytes in the control message sent by the daemon to confirm it has terminated.
Definition: ServiceMessagePayload.h:33
static const std::string TERMINATE_STANDARD_JOB_ANSWER_MESSAGE_PAYLOAD
The number of bytes in the control message sent by the daemon to acknowledge a standard job terminati...
Definition: ComputeServiceMessagePayload.h:36
static const std::string IGNORE_INVALID_JOBS_IN_WORKLOAD_TRACE_FILE
Whether, when simulating a workload trace file, to abort when there is an invalid job specification (...
Definition: BatchComputeServiceProperty.h:104
static const std::string USE_REAL_RUNTIMES_AS_REQUESTED_RUNTIMES_IN_WORKLOAD_TRACE_FILE
Whether, when simulating a workload trace file, to use the actual runtimes as requested runtimes (i....
Definition: BatchComputeServiceProperty.h:95
static const std::string RESOURCE_DESCRIPTION_REQUEST_MESSAGE_PAYLOAD
The number of bytes in the control message sent to the daemon to ask it for information on its resour...
Definition: ComputeServiceMessagePayload.h:56
static const std::string BATSCHED_CONTIGUOUS_ALLOCATION
Controls Batsched node allocation policy.
Definition: BatchComputeServiceProperty.h:160
static const std::string HOST_SELECTION_ALGORITHM
The host selection algorithm. Can be:
Definition: BatchComputeServiceProperty.h:62
The compute service base class.
Definition: ComputeService.h:33
static const std::string SUBMIT_TIME_OF_FIRST_JOB_IN_WORKLOAD_TRACE_FILE
A specification of the submit time of the first job in a provided trace file.
Definition: BatchComputeServiceProperty.h:111
static const std::string GRID_PRE_EXECUTION_DELAY
Overhead delay in seconds between condor and slurm for the start of execution.
Definition: BatchComputeServiceProperty.h:174
static const std::string SIMULATED_WORKLOAD_TRACE_FILE
Path to a workload trace file to be replayed. The trace file can be be in the SWF format (see http://...
Definition: BatchComputeServiceProperty.h:85
static const std::string TERMINATE_PILOT_JOB_REQUEST_MESSAGE_PAYLOAD
The number of bytes in the control message sent to the daemon to terminate a pilot job.
Definition: ComputeServiceMessagePayload.h:52
A batch-scheduled compute service that manages a set of compute hosts and controls access to their re...
Definition: BatchComputeService.h:49
static const std::string STANDARD_JOB_DONE_MESSAGE_PAYLOAD
The number of bytes in the control message sent by the daemon to state that it has completed a standa...
Definition: ComputeServiceMessagePayload.h:30
static const std::string STANDARD_JOB_FAILED_MESSAGE_PAYLOAD
The number of bytes in the control message sent by the daemon to state that a running standard job ha...
Definition: ComputeServiceMessagePayload.h:32
static const std::string TERMINATE_STANDARD_JOB_REQUEST_MESSAGE_PAYLOAD
The number of bytes in the control message sent to the daemon to terminate a standard job.
Definition: ComputeServiceMessagePayload.h:34
static const std::string SUBMIT_PILOT_JOB_ANSWER_MESSAGE_PAYLOAD
The number of bytes in the control message sent from the daemon to acknowledge a pilot job submission...
Definition: ComputeServiceMessagePayload.h:40
static const std::string TASK_STARTUP_OVERHEAD
The overhead to start a task execution, in seconds.
Definition: BatchComputeServiceProperty.h:27
static const std::string BATSCHED_LOGGING_MUTED
Controls Batsched logging.
Definition: BatchComputeServiceProperty.h:150
static const std::string TASK_SELECTION_ALGORITHM
The algorithm to pick which ready computational task (within a standard job executed by the batch ser...
Definition: BatchComputeServiceProperty.h:72
static const std::string RESOURCE_DESCRIPTION_ANSWER_MESSAGE_PAYLOAD
The number of bytes in the control message sent by the daemon to state information on its resources.
Definition: ComputeServiceMessagePayload.h:58
static const std::string OUTPUT_CSV_JOB_LOG
Path to a to-be-generated Batsim-style CSV trace file (e.g. for b3atch schedule visualization purpose...
Definition: BatchComputeServiceProperty.h:122
static const std::string STOP_DAEMON_MESSAGE_PAYLOAD
The number of bytes in the control message sent to the daemon to terminate it.
Definition: ServiceMessagePayload.h:31
static const std::string PILOT_JOB_STARTED_MESSAGE_PAYLOAD
The number of bytes in the control message sent by the daemon to state that a pilot job has started.
Definition: ComputeServiceMessagePayload.h:42
static const std::string SUBMIT_STANDARD_JOB_ANSWER_MESSAGE_PAYLOAD
The number of bytes in the control message sent by the daemon to acknowledge a standard job submissio...
Definition: ComputeServiceMessagePayload.h:28
static const std::string BATCH_SCHEDULING_ALGORITHM
The batch scheduling algorithm. Can be:
Definition: BatchComputeServiceProperty.h:43
static const std::string SUBMIT_PILOT_JOB_REQUEST_MESSAGE_PAYLOAD
The number of bytes in the control message sent to the daemon to submit a pilot job.
Definition: ComputeServiceMessagePayload.h:38
static const std::string GRID_POST_EXECUTION_DELAY
Overhead delay in seconds between condor and slurm for the completion of execution.
Definition: BatchComputeServiceProperty.h:180
static const std::string SUPPORTS_PILOT_JOBS
Whether the compute service supports pilot jobs (true or false)
Definition: ComputeServiceProperty.h:26
static const std::string BATCH_RJMS_PADDING_DELAY
Integral number of seconds that the Batch Scheduler adds to the runtime of each incoming job....
Definition: BatchComputeServiceProperty.h:132
BatchComputeService(const std::string &hostname, std::vector< std::string > compute_hosts, std::string scratch_space_mount_point, std::map< std::string, std::string > property_list={}, std::map< std::string, double > messagepayload_list={})
Constructor.
Definition: BatchComputeService.cpp:61
static const std::string BATCH_QUEUE_ORDERING_ALGORITHM
The batch queue ordering algorithm. Can be:
Definition: BatchComputeServiceProperty.h:52
static const std::string SUPPORTS_STANDARD_JOBS
Whether the compute service supports standard jobs (true or false)
Definition: ComputeServiceProperty.h:24