From cc5c5a7eac0ebcf97c283e1e0dd1674c855a261a Mon Sep 17 00:00:00 2001 From: Matthijs Bijman Date: Mon, 27 Feb 2017 13:55:50 +0100 Subject: Implement logging of cores_used in task_states --- Simulator/include/simulation/Experiment.h | 3 ++- .../include/simulation/history/WorkloadSnapshot.h | 3 ++- .../schedulers/FirstInFirstOutScheduler.h | 25 +++++++++++------- .../include/simulation/schedulers/Scheduler.h | 1 - .../schedulers/ShortestRemainingTimeScheduler.h | 30 +++++++++++++--------- Simulator/include/simulation/workloads/Workload.h | 15 ++++++++++- 6 files changed, 52 insertions(+), 25 deletions(-) (limited to 'Simulator/include/simulation') diff --git a/Simulator/include/simulation/Experiment.h b/Simulator/include/simulation/Experiment.h index 69c192fa..400f418a 100644 --- a/Simulator/include/simulation/Experiment.h +++ b/Simulator/include/simulation/Experiment.h @@ -60,7 +60,8 @@ namespace Simulation currentTick, WorkloadSnapshot( workload->getId(), - workload->getRemainingOperations() + workload->getRemainingOperations(), + workload->getCoresUsed() ) ); } diff --git a/Simulator/include/simulation/history/WorkloadSnapshot.h b/Simulator/include/simulation/history/WorkloadSnapshot.h index 1e7e2695..30a93898 100644 --- a/Simulator/include/simulation/history/WorkloadSnapshot.h +++ b/Simulator/include/simulation/history/WorkloadSnapshot.h @@ -5,9 +5,10 @@ namespace Simulation class WorkloadSnapshot { public: - WorkloadSnapshot(uint32_t id, uint32_t flopsDone) : flopsDone(flopsDone), id(id) {} + WorkloadSnapshot(uint32_t id, uint32_t flopsDone, uint32_t coresUsed) : flopsDone(flopsDone), id(id), coresUsed(coresUsed) {} uint32_t flopsDone; uint32_t id; + uint32_t coresUsed; }; } \ No newline at end of file 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>& machines, std::vector 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& 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 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>& machines, std::vector 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(); + } } }; } diff --git a/Simulator/include/simulation/workloads/Workload.h b/Simulator/include/simulation/workloads/Workload.h index 9de57990..0371deac 100644 --- a/Simulator/include/simulation/workloads/Workload.h +++ b/Simulator/include/simulation/workloads/Workload.h @@ -47,11 +47,21 @@ namespace Simulation /** * \return The start tick of this workload. */ - uint32_t getStartTick() const + uint32_t getStartTick() { return START_TICK; } + /** + * \brief Sets the coresUsed of this workload to the given number of cores. + */ + void setCoresUsed(uint32_t cores); + + /** + * \return Returns the number of cores used by this workload. + */ + uint32_t getCoresUsed(); + // True if the dependency of this workload has finished. bool dependencyFinished = false; @@ -76,5 +86,8 @@ namespace Simulation // The id of the trace this workload belongs to in the database. uint32_t TRACE_ID; + + // The number of cores that this workload is occupying + uint32_t coresUsed = 0; }; } -- cgit v1.2.3