summaryrefslogtreecommitdiff
path: root/Simulator/include/simulation/schedulers
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2017-07-09 23:48:06 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2017-07-09 23:48:06 +0200
commitc94d0c347fdbd8acc774df4ac17617a3f63e4507 (patch)
tree4b825dc642cb6eb9a060e54bf8d69288fbee4904 /Simulator/include/simulation/schedulers
parentbc4c41e21a64b444bdbab3b6d1d407fd5d919419 (diff)
Delete old codebase
This change removes version 1 of the OpenDC simulator codebase as it will be replaced by a complete rewrite in the Kotlin language.
Diffstat (limited to 'Simulator/include/simulation/schedulers')
-rw-r--r--Simulator/include/simulation/schedulers/FirstInFirstOutScheduler.h59
-rw-r--r--Simulator/include/simulation/schedulers/Scheduler.h24
-rw-r--r--Simulator/include/simulation/schedulers/ShortestRemainingTimeScheduler.h64
3 files changed, 0 insertions, 147 deletions
diff --git a/Simulator/include/simulation/schedulers/FirstInFirstOutScheduler.h b/Simulator/include/simulation/schedulers/FirstInFirstOutScheduler.h
deleted file mode 100644
index 5d277c8d..00000000
--- a/Simulator/include/simulation/schedulers/FirstInFirstOutScheduler.h
+++ /dev/null
@@ -1,59 +0,0 @@
-#pragma once
-#include "Scheduler.h"
-#include <algorithm>
-
-namespace Simulation
-{
- class FirstInFirstOutScheduler : public Scheduler
- {
- protected:
- ~FirstInFirstOutScheduler()
- {
- }
-
- public:
- /**
- * \brief Distribute workloads according to the FIFO principle.
- */
- void schedule(std::vector<std::reference_wrapper<Modeling::Machine>>& machines, std::vector<Workload*> workloads) override
- {
- if (workloads.size() == 0)
- return;
-
- // Find the first workload with dependencies finished
- int index = 0;
-
- std::remove_if(workloads.begin(), workloads.end(), [](Workload* workload) {
- return !workload->dependencyFinished;
- });
-
- // Reset the number of cores used for each workload
- for (auto workload : workloads)
- {
- workload->setCoresUsed(0);
- }
-
- // Distribute tasks across machines and set cores used of workloads
- for (auto machine : machines)
- {
- machine.get().giveTask(workloads.at(index));
- workloads.at(index)->setCoresUsed(
- workloads.at(index)->getCoresUsed() + machine.get().getNumberOfCores()
- );
-
- if (!workloads.at(index)->isParallelizable())
- {
- workloads.erase(workloads.begin() + index);
- if (workloads.size() == 0)
- break;
-
- index %= workloads.size();
- }
- else
- {
- index = (++index) % workloads.size();
- }
- }
- }
- };
-}
diff --git a/Simulator/include/simulation/schedulers/Scheduler.h b/Simulator/include/simulation/schedulers/Scheduler.h
deleted file mode 100644
index 69e20d01..00000000
--- a/Simulator/include/simulation/schedulers/Scheduler.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#pragma once
-#include "modeling/machine/Machine.h"
-
-#include <vector>
-
-namespace Simulation
-{
- /*
- Provides a strategy for load balancing.
- */
- class Scheduler
- {
- public:
- virtual ~Scheduler()
- {
-
- }
-
- /*
- Divides the workloads over the given machines.
- */
- virtual void schedule(std::vector<std::reference_wrapper<Modeling::Machine>>& machines, std::vector<Workload*> workloads) = 0;
- };
-}
diff --git a/Simulator/include/simulation/schedulers/ShortestRemainingTimeScheduler.h b/Simulator/include/simulation/schedulers/ShortestRemainingTimeScheduler.h
deleted file mode 100644
index a152c39b..00000000
--- a/Simulator/include/simulation/schedulers/ShortestRemainingTimeScheduler.h
+++ /dev/null
@@ -1,64 +0,0 @@
-#pragma once
-#include "Scheduler.h"
-#include <algorithm>
-
-namespace Simulation
-{
- class ShortestRemainingTimeScheduler : public Scheduler
- {
- protected:
- ~ShortestRemainingTimeScheduler()
- {
- }
-
- public:
- /**
- * \brief Distribute workloads according to the srtf principle.
- */
- void schedule(std::vector<std::reference_wrapper<Modeling::Machine>>& machines, std::vector<Workload*> workloads) override
- {
- if (workloads.size() == 0)
- return;
-
- std::remove_if(workloads.begin(), workloads.end(), [](Workload* workload) {
- return !workload->dependencyFinished;
- });
-
- for (auto workload : workloads)
- {
- workload->setCoresUsed(0);
- }
-
- std::sort(
- workloads.begin(),
- workloads.end(),
- [](Workload* a, Workload* b) -> bool {
- return a->getRemainingOperations() < b->getRemainingOperations();
- }
- );
-
- int taskIndex = 0;
- for (auto machine : machines)
- {
- machine.get().giveTask(workloads.at(taskIndex));
-
- workloads.at(taskIndex)->setCoresUsed(
- workloads.at(taskIndex)->getCoresUsed() + machine.get().getNumberOfCores()
- );
-
- if (!workloads.at(taskIndex)->isParallelizable())
- {
- workloads.erase(workloads.begin() + taskIndex);
- if (workloads.size() == 0)
- break;
-
- taskIndex %= workloads.size();
- }
- else
- {
- taskIndex = (++taskIndex) % workloads.size();
- }
- }
- }
- };
-}