summaryrefslogtreecommitdiff
path: root/Simulator/include/simulation
diff options
context:
space:
mode:
authorMatthijs Bijman <matthijs@bijman.org>2017-02-27 15:19:15 +0100
committerMatthijs Bijman <matthijs@bijman.org>2017-02-27 15:19:15 +0100
commit34aaaad34e72c921ea72d7b023e5a5270e76dd40 (patch)
tree64c65d557c5323a23f4ce6f31b20da744d44badb /Simulator/include/simulation
parentcc5c5a7eac0ebcf97c283e1e0dd1674c855a261a (diff)
Add tasks that run on 1 machine
Diffstat (limited to 'Simulator/include/simulation')
-rw-r--r--Simulator/include/simulation/Experiment.h2
-rw-r--r--Simulator/include/simulation/schedulers/FirstInFirstOutScheduler.h19
-rw-r--r--Simulator/include/simulation/schedulers/ShortestRemainingTimeScheduler.h22
-rw-r--r--Simulator/include/simulation/workloads/Workload.h10
4 files changed, 44 insertions, 9 deletions
diff --git a/Simulator/include/simulation/Experiment.h b/Simulator/include/simulation/Experiment.h
index 400f418a..54a861e6 100644
--- a/Simulator/include/simulation/Experiment.h
+++ b/Simulator/include/simulation/Experiment.h
@@ -110,7 +110,7 @@ namespace Simulation
/**
* \return The history of this experiment that has no yet been written to the database.
*/
- SimulationHistory getHistory() const
+ SimulationHistory& getHistory()
{
return history;
}
diff --git a/Simulator/include/simulation/schedulers/FirstInFirstOutScheduler.h b/Simulator/include/simulation/schedulers/FirstInFirstOutScheduler.h
index 797eb489..5d277c8d 100644
--- a/Simulator/include/simulation/schedulers/FirstInFirstOutScheduler.h
+++ b/Simulator/include/simulation/schedulers/FirstInFirstOutScheduler.h
@@ -22,8 +22,10 @@ namespace Simulation
// Find the first workload with dependencies finished
int index = 0;
- while(!workloads.at(index)->dependencyFinished)
- index = (++index) % workloads.size();
+
+ 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)
@@ -38,6 +40,19 @@ namespace Simulation
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/ShortestRemainingTimeScheduler.h b/Simulator/include/simulation/schedulers/ShortestRemainingTimeScheduler.h
index 51673fb5..a152c39b 100644
--- a/Simulator/include/simulation/schedulers/ShortestRemainingTimeScheduler.h
+++ b/Simulator/include/simulation/schedulers/ShortestRemainingTimeScheduler.h
@@ -20,6 +20,10 @@ namespace Simulation
if (workloads.size() == 0)
return;
+ std::remove_if(workloads.begin(), workloads.end(), [](Workload* workload) {
+ return !workload->dependencyFinished;
+ });
+
for (auto workload : workloads)
{
workload->setCoresUsed(0);
@@ -34,18 +38,26 @@ namespace Simulation
);
int taskIndex = 0;
-
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();
+ if (!workloads.at(taskIndex)->isParallelizable())
+ {
+ workloads.erase(workloads.begin() + taskIndex);
+ if (workloads.size() == 0)
+ break;
+
+ taskIndex %= workloads.size();
+ }
+ else
+ {
+ taskIndex = (++taskIndex) % workloads.size();
+ }
}
}
};
diff --git a/Simulator/include/simulation/workloads/Workload.h b/Simulator/include/simulation/workloads/Workload.h
index 0371deac..7e391d8d 100644
--- a/Simulator/include/simulation/workloads/Workload.h
+++ b/Simulator/include/simulation/workloads/Workload.h
@@ -12,7 +12,7 @@ namespace Simulation
/*
Initializes the TOTAL_FLOPS and the remainingFlops to the size.
*/
- Workload(int size, int startTick, int dbId, int traceId, int dependency);
+ Workload(int size, int startTick, int dbId, int traceId, int dependency, bool parallel);
/*
Decreases the remainingFlops by the given amount.
@@ -62,6 +62,11 @@ namespace Simulation
*/
uint32_t getCoresUsed();
+ /**
+ * \return Whether this workload can be spread across machines.
+ */
+ bool isParallelizable();
+
// True if the dependency of this workload has finished.
bool dependencyFinished = false;
@@ -89,5 +94,8 @@ namespace Simulation
// The number of cores that this workload is occupying
uint32_t coresUsed = 0;
+
+ // Whether this task can be parallelized across multiple machines.
+ bool isParallel = false;
};
}