From 47be174a1e3d767361fe418a2ad7635bd904ddb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Madon?= <mael.madon@irit.fr> Date: Tue, 23 Jan 2024 15:43:10 +0100 Subject: [PATCH] cleaning old schedulers --- .gitignore | 3 +- sched/fcfs.py | 85 -------------------------------------------- sched/fillerSched.py | 63 -------------------------------- 3 files changed, 2 insertions(+), 149 deletions(-) delete mode 100644 sched/fcfs.py delete mode 100644 sched/fillerSched.py diff --git a/.gitignore b/.gitignore index d632079..23ff99e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ out/* !out/example_jobs.csv -*__pycache__* \ No newline at end of file +*__pycache__* +*_perso/* \ No newline at end of file diff --git a/sched/fcfs.py b/sched/fcfs.py deleted file mode 100644 index a5f83ee..0000000 --- a/sched/fcfs.py +++ /dev/null @@ -1,85 +0,0 @@ -""" -This scheduler is a simple FCFS: -- Released jobs are pushed in the back of one single queue -- Two jobs cannot be executed on the same machine at the same time -- Only the job at the head of the queue can be allocated - - - If the job is too big (will never fit the machine), it is rejected - - If the job can fit the machine now, it is allocated (and run) instantly - - If the job cannot fit the machine now, the scheduler will waits for enough available machines - -""" - -from procset import ProcSet -from itertools import islice - -from pybatsim.batsim.batsim import BatsimScheduler - - -class Fcfs2(BatsimScheduler): - def __init__(self, options): - super().__init__(options) - self.logger.info("FCFS init") - - def onSimulationBegins(self): - self.nb_completed_jobs = 0 - - self.sched_delay = 0.5 # Simulates the time spent by the scheduler to take decisions - - self.open_jobs = [] - - self.computing_machines = ProcSet() - self.idle_machines = ProcSet((0,self.bs.nb_compute_resources-1)) - - - def scheduleJobs(self): - print('\n\nopen_jobs = ', self.open_jobs) - - print('computingM = ', self.computing_machines) - print('idleM = ', self.idle_machines) - - scheduled_jobs = [] - loop = True - - # If there is a job to schedule - if len(self.open_jobs) > 0: - - while loop and self.open_jobs: - job = self.open_jobs[0] - nb_res_req = job.requested_resources - - # Job fits now -> allocation - if nb_res_req <= len(self.idle_machines): - res = ProcSet(*islice(self.idle_machines, nb_res_req)) - job.allocation = res - scheduled_jobs.append(job) - - self.computing_machines |= res - self.idle_machines -= res - self.open_jobs.remove(job) - - else: # Job can fit on the machine, but not now - loop = False - - # update time - self.bs.consume_time(self.sched_delay) - - # send decision to batsim - self.bs.execute_jobs(scheduled_jobs) - else: - # No job to schedule - self.logger.info("There is no job to schedule right now") - - - def onJobSubmission(self, job): - if job.requested_resources > self.bs.nb_compute_resources: - self.bs.reject_jobs([job]) # This job requests more resources than the machine has - else: - self.open_jobs.append(job) - - def onJobCompletion(self, job): - self.idle_machines |= job.allocation - self.computing_machines -= job.allocation - - def onNoMoreEvents(self): - self.scheduleJobs() diff --git a/sched/fillerSched.py b/sched/fillerSched.py deleted file mode 100644 index 7b83c48..0000000 --- a/sched/fillerSched.py +++ /dev/null @@ -1,63 +0,0 @@ -from batsim.batsim import BatsimScheduler, Batsim - -import sys -import os -from procset import ProcSet -from itertools import islice - - -class FillerSched(BatsimScheduler): - - def onAfterBatsimInit(self): - self.nb_completed_jobs = 0 - - self.jobs_completed = [] - self.jobs_waiting = [] - - self.sched_delay = 0.005 - - self.openJobs = set() - self.availableResources = ProcSet((0,self.bs.nb_compute_resources-1)) - - - def scheduleJobs(self): - scheduledJobs = [] - - print('openJobs = ', self.openJobs) - print('available = ', self.availableResources) - - # Iterating over a copy to be able to remove jobs from openJobs at traversal - for job in set(self.openJobs): - nb_res_req = job.requested_resources - - if nb_res_req <= len(self.availableResources): - # Retrieve the *nb_res_req* first availables resources - job_alloc = ProcSet(*islice(self.availableResources, nb_res_req)) - job.allocation = job_alloc - scheduledJobs.append(job) - - self.availableResources -= job_alloc - - self.openJobs.remove(job) - - # update time - self.bs.consume_time(self.sched_delay) - - # send to uds - if len(scheduledJobs) > 0: - self.bs.execute_jobs(scheduledJobs) - - print('openJobs = ', self.openJobs) - print('available = ', self.availableResources) - print('') - - def onJobSubmission(self, job): - if job.requested_resources > self.bs.nb_compute_resources: - self.bs.reject_jobs([job]) # This job requests more resources than the machine has - else: - self.openJobs.add(job) - self.scheduleJobs() - - def onJobCompletion(self, job): - self.availableResources |= job.allocation - self.scheduleJobs() -- GitLab