summaryrefslogtreecommitdiff
path: root/Simulator/include/simulation
diff options
context:
space:
mode:
authorMatthijs Bijman <matthijs@bijman.org>2017-02-27 13:55:50 +0100
committerMatthijs Bijman <matthijs@bijman.org>2017-02-27 13:55:50 +0100
commitcc5c5a7eac0ebcf97c283e1e0dd1674c855a261a (patch)
tree841f95e14a00cb6d23d4e357c9e0cfcbdc3c9a2a /Simulator/include/simulation
parent0709a81231b695caecb2269fe23d8dadeb764892 (diff)
Implement logging of cores_used in task_states
Diffstat (limited to 'Simulator/include/simulation')
-rw-r--r--Simulator/include/simulation/Experiment.h3
-rw-r--r--Simulator/include/simulation/history/WorkloadSnapshot.h3
-rw-r--r--Simulator/include/simulation/schedulers/FirstInFirstOutScheduler.h25
-rw-r--r--Simulator/include/simulation/schedulers/Scheduler.h1
-rw-r--r--Simulator/include/simulation/schedulers/ShortestRemainingTimeScheduler.h30
-rw-r--r--Simulator/include/simulation/workloads/Workload.h15
6 files changed, 52 insertions, 25 deletions
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;
};
}