diff options
| author | Matthijs Bijman <matthijs@bijman.org> | 2017-02-27 13:55:50 +0100 |
|---|---|---|
| committer | Matthijs Bijman <matthijs@bijman.org> | 2017-02-27 13:55:50 +0100 |
| commit | cc5c5a7eac0ebcf97c283e1e0dd1674c855a261a (patch) | |
| tree | 841f95e14a00cb6d23d4e357c9e0cfcbdc3c9a2a /Simulator/include/simulation/schedulers | |
| parent | 0709a81231b695caecb2269fe23d8dadeb764892 (diff) | |
Implement logging of cores_used in task_states
Diffstat (limited to 'Simulator/include/simulation/schedulers')
3 files changed, 34 insertions, 22 deletions
diff --git a/Simulator/include/simulation/schedulers/FirstInFirstOutScheduler.h b/Simulator/include/simulation/schedulers/FirstInFirstOutScheduler.h index 0cac0dfa..797eb489 100644 --- a/Simulator/include/simulation/schedulers/FirstInFirstOutScheduler.h +++ b/Simulator/include/simulation/schedulers/FirstInFirstOutScheduler.h @@ -12,8 +12,8 @@ namespace Simulation } public: - /* - Distribute workloads according to the FIFO principle + /** + * \brief Distribute workloads according to the FIFO principle. */ void schedule(std::vector<std::reference_wrapper<Modeling::Machine>>& machines, std::vector<Workload*> workloads) override { @@ -25,13 +25,20 @@ namespace Simulation while(!workloads.at(index)->dependencyFinished) index = (++index) % workloads.size(); - std::for_each( - machines.begin(), - machines.end(), - [index, &workloads](std::reference_wrapper<Modeling::Machine>& machine) { - machine.get().giveTask(workloads.at(index)); - } - ); + // 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() + ); + } } }; } diff --git a/Simulator/include/simulation/schedulers/Scheduler.h b/Simulator/include/simulation/schedulers/Scheduler.h index b084e8f6..69e20d01 100644 --- a/Simulator/include/simulation/schedulers/Scheduler.h +++ b/Simulator/include/simulation/schedulers/Scheduler.h @@ -1,5 +1,4 @@ #pragma once -#include "simulation/workloads/Workload.h" #include "modeling/machine/Machine.h" #include <vector> diff --git a/Simulator/include/simulation/schedulers/ShortestRemainingTimeScheduler.h b/Simulator/include/simulation/schedulers/ShortestRemainingTimeScheduler.h index 15265985..51673fb5 100644 --- a/Simulator/include/simulation/schedulers/ShortestRemainingTimeScheduler.h +++ b/Simulator/include/simulation/schedulers/ShortestRemainingTimeScheduler.h @@ -12,14 +12,19 @@ namespace Simulation } public: - /* - Distribute workloads according to the srtf principle + /** + * \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; + for (auto workload : workloads) + { + workload->setCoresUsed(0); + } + std::sort( workloads.begin(), workloads.end(), @@ -30,17 +35,18 @@ namespace Simulation int taskIndex = 0; - std::for_each( - machines.begin(), - machines.end(), - [&workloads, &taskIndex](Modeling::Machine& machine) { - while (!workloads.at(taskIndex)->dependencyFinished) - taskIndex = (++taskIndex) % workloads.size(); - - machine.giveTask(workloads.at(taskIndex)); + for (auto machine : machines) + { + while (!workloads.at(taskIndex)->dependencyFinished) taskIndex = (++taskIndex) % workloads.size(); - } - ); + + machine.get().giveTask(workloads.at(taskIndex)); + workloads.at(taskIndex)->setCoresUsed( + workloads.at(taskIndex)->getCoresUsed() + machine.get().getNumberOfCores() + ); + + taskIndex = (++taskIndex) % workloads.size(); + } } }; } |
