Commit bb684889 authored by EYRAUD-DUBOIS Lionel's avatar EYRAUD-DUBOIS Lionel

Dmdas: avoid using ins.getType for better perf

parent 632464a3
...@@ -81,24 +81,32 @@ double Dmdas::compute(Instance &ins, SchedAction* action) { ...@@ -81,24 +81,32 @@ double Dmdas::compute(Instance &ins, SchedAction* action) {
// For now keep the "old" version of dmdas where the assigned load also // For now keep the "old" version of dmdas where the assigned load also
// counts lower priority tasks // counts lower priority tasks
auto getFinishedTime = [&] (int task, int w) { auto getFinishedTime = [&] (int task, int w, int wType) {
if(ins.isValidWorker(w, task)) { double execTime = ins.execType(wType, task);
if(ins.isValidValue(execTime)) {
double s = max(endtimesWorkers[w], currentTime); double s = max(endtimesWorkers[w], currentTime);
return (s + assignedLoad[w] return (s + assignedLoad[w]
+ ins.execWorker(w, task)); + execTime);
} else } else
return std::numeric_limits<double>::infinity(); return std::numeric_limits<double>::infinity();
}; };
auto getBestWorker = [&] (int task) { auto getBestWorker = [&] (int task) {
double bestSoFar = getFinishedTime(task, 0); double bestSoFar = std::numeric_limits<double>::infinity();
int bestWorker = 0; int bestWorker = -1;
for(int i = 1; i < nbWorkers; i++) { int i = 0;
double t = getFinishedTime(task, i); 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) { if(t < bestSoFar) {
bestSoFar = t; bestWorker = i; bestSoFar = t; bestWorker = i;
} }
} }
}
if(bestWorker < 0) {
cerr << "Dmdas: no valid worker for task " << task << endl;
throw(1);
}
return bestWorker; return bestWorker;
}; };
...@@ -115,15 +123,17 @@ double Dmdas::compute(Instance &ins, SchedAction* action) { ...@@ -115,15 +123,17 @@ double Dmdas::compute(Instance &ins, SchedAction* action) {
// int idle = wStartIndex[wTypeOrdering[0]]; // int idle = wStartIndex[wTypeOrdering[0]];
while(tasksToSchedule > 0) { while(tasksToSchedule > 0) {
while(!readyTasks->empty()) while(!readyTasks->empty())
assignFront(); assignFront();
for(int w = 0; w < nbWorkers; w++) { 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())) { if((endtimesWorkers[w] <= currentTime) && (!localQueues[w]->empty())) {
int task = localQueues[w]->front(); int task = localQueues[w]->front();
int wType = ins.getType(w);
double finishTime = currentTime + ins.execType(wType, task); double finishTime = currentTime + ins.execType(wType, task);
if(verbosity >= 1) 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; cout << "dmdas: starting " << task << " of type " << ins.taskTypes[task] << " at " << currentTime << " to end at " << finishTime << " on worker " << w << " of type " << wType << endl;
...@@ -139,6 +149,7 @@ double Dmdas::compute(Instance &ins, SchedAction* action) { ...@@ -139,6 +149,7 @@ double Dmdas::compute(Instance &ins, SchedAction* action) {
currentRunningTask[w] = task; currentRunningTask[w] = task;
} }
} }
}
double nextTime = -1; double nextTime = -1;
for(int w = 0; w < nbWorkers; w++) { for(int w = 0; w < nbWorkers; w++) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment