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 | |
| parent | 0709a81231b695caecb2269fe23d8dadeb764892 (diff) | |
Implement logging of cores_used in task_states
Diffstat (limited to 'Simulator/include')
9 files changed, 75 insertions, 40 deletions
diff --git a/Simulator/include/database/Queries.h b/Simulator/include/database/Queries.h index 33e8cdb9..59133058 100644 --- a/Simulator/include/database/Queries.h +++ b/Simulator/include/database/Queries.h @@ -118,11 +118,11 @@ namespace Database /* Inserts the state of a workload into the task_state table. Returns: <> - Binds: <int : task_id, int : experiment_id, int : tick, int : flops_left> + Binds: <int : task_id, int : experiment_id, int : tick, int : flops_left, int : cores_used> */ Query<> WRITE_WORKLOAD_STATE(std::string(R"query( - INSERT INTO task_states (task_id, experiment_id, tick, flops_left) - VALUES ($tid, $ssid, $tick, $flops); + INSERT INTO task_states (task_id, experiment_id, tick, flops_left, cores_used) + VALUES ($tid, $ssid, $tick, $flops, $cores_used); )query")); /* diff --git a/Simulator/include/modeling/machine/CPU.h b/Simulator/include/modeling/machine/CPU.h index dce4d2c5..95af1c86 100644 --- a/Simulator/include/modeling/machine/CPU.h +++ b/Simulator/include/modeling/machine/CPU.h @@ -5,27 +5,30 @@ namespace Modeling class CPU { public: + /** + * \brief Creates a CPU with the given speed/core, number of cores, energy consumption, and failure model id. + */ CPU(int speed, int cores, int energyConsumption, int failureModelId); - /* - Returns the speed of this CPU. + /** + * \return the speed of this CPU. */ - int getSpeed(); + int getSpeed() const; - /* - Returns the nr of cores of this CPU. + /** + * \return The nr of cores of this CPU. */ - int getCores(); + int getCores() const; - /* - Returns the energy consumed by this CPU. + /** + * \return The energy consumed by this CPU. */ - int getEnergyConsumption(); + int getEnergyConsumption() const; - /* - Returns the failure model id of this CPU. + /** + * \return The failure model id of this CPU. */ - int getFailureModelId(); + int getFailureModelId() const; private: diff --git a/Simulator/include/modeling/machine/Machine.h b/Simulator/include/modeling/machine/Machine.h index c89d32d1..f18f8352 100644 --- a/Simulator/include/modeling/machine/Machine.h +++ b/Simulator/include/modeling/machine/Machine.h @@ -76,6 +76,11 @@ namespace Modeling */ float getLoad() const; + /** + * \return The number of cores in this machine. + */ + uint32_t getNumberOfCores() const; + private: // A list of cpus in this machine. std::vector<CPU> cpus; 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<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(); + } } }; } 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; }; } |
