...
 
Commits (2)
......@@ -4,7 +4,6 @@
#include "instance.h"
#include "algorithm.h"
#include "algoptions.h"
#include "listAlgorithm.h"
class Dmdas : public Algorithm {
......
#include "Dmdas.h"
#include "listAlgorithm.h"
#include "util.h"
#include <vector>
......@@ -81,24 +80,32 @@ double Dmdas::compute(Instance &ins, SchedAction* action) {
// For now keep the "old" version of dmdas where the assigned load also
// counts lower priority tasks
auto getFinishedTime = [&] (int task, int w) {
if(ins.isValidWorker(w, task)) {
auto getFinishedTime = [&] (int task, int w, int wType) {
double execTime = ins.execType(wType, task);
if(ins.isValidValue(execTime)) {
double s = max(endtimesWorkers[w], currentTime);
return (s + assignedLoad[w]
+ ins.execWorker(w, task));
+ execTime);
} else
return std::numeric_limits<double>::infinity();
};
auto getBestWorker = [&] (int task) {
double bestSoFar = getFinishedTime(task, 0);
int bestWorker = 0;
for(int i = 1; i < nbWorkers; i++) {
double t = getFinishedTime(task, i);
if(t < bestSoFar) {
bestSoFar = t; bestWorker = i;
double bestSoFar = std::numeric_limits<double>::infinity();
int bestWorker = -1;
int i = 0;
for(int wType = 0; wType < ins.nbWorkerTypes; ++wType) {
for(int j = 0; j < ins.nbWorkers[wType]; ++j, ++i) {
double t = getFinishedTime(task, i, wType);
if(t < bestSoFar) {
bestSoFar = t; bestWorker = i;
}
}
}
if(bestWorker < 0) {
cerr << "Dmdas: no valid worker for task " << task << endl;
throw(1);
}
return bestWorker;
};
......@@ -115,31 +122,34 @@ double Dmdas::compute(Instance &ins, SchedAction* action) {
// int idle = wStartIndex[wTypeOrdering[0]];
while(tasksToSchedule > 0) {
while(!readyTasks->empty())
assignFront();
for(int w = 0; w < nbWorkers; w++) {
if((endtimesWorkers[w] <= currentTime) && (!localQueues[w]->empty())) {
int task = localQueues[w]->front();
int wType = ins.getType(w);
double finishTime = currentTime + ins.execType(wType, task);
if(verbosity >= 1)
cout << "dmdas: starting " << task << " of type " << ins.taskTypes[task] << " at " << currentTime << " to end at " << finishTime << " on worker " << w << " of type " << wType << endl;
int w = 0;
for(int wType = 0; wType < ins.nbWorkerTypes; ++wType) {
for(int j = 0; j < ins.nbWorkers[wType]; ++j, ++w) {
if((endtimesWorkers[w] <= currentTime) && (!localQueues[w]->empty())) {
int task = localQueues[w]->front();
double finishTime = currentTime + ins.execType(wType, task);
if(verbosity >= 1)
cout << "dmdas: starting " << task << " of type " << ins.taskTypes[task] << " at " << currentTime << " to end at " << finishTime << " on worker " << w << " of type " << wType << endl;
tasksToSchedule --;
if(action != NULL)
action->onSchedule(task, w, currentTime, finishTime);
localQueues[w]->eraseFront();
assignedLoad[w] -= ins.execType(wType, task);
endtimesWorkers[w] = finishTime;
endtimesTasks[task] = finishTime;
currentRunningTask[w] = task;
tasksToSchedule --;
if(action != NULL)
action->onSchedule(task, w, currentTime, finishTime);
localQueues[w]->eraseFront();
assignedLoad[w] -= ins.execType(wType, task);
endtimesWorkers[w] = finishTime;
endtimesTasks[task] = finishTime;
currentRunningTask[w] = task;
}
}
}
double nextTime = -1;
for(int w = 0; w < nbWorkers; w++) {
if((endtimesWorkers[w] > currentTime) &&
......@@ -163,8 +173,7 @@ double Dmdas::compute(Instance &ins, SchedAction* action) {
cout << "List: Finishing task " << i << " at time " << currentTime << endl;
finishedTasks[i] = true;
currentRunningTask[j] = -1;
for(int j = 0; j < (int) revDependencies[i].size(); j++) {
int k = revDependencies[i][j];
for(int & k: revDependencies[i]) {
nbDep[k]--;
if(verbosity >= 7)
cout << " Dependent task: " << k << " remaining dependencies: " << nbDep[k] << endl;
......