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) {
// 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);
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,15 +123,17 @@ 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++) {
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();
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;
......@@ -139,6 +149,7 @@ double Dmdas::compute(Instance &ins, SchedAction* action) {
currentRunningTask[w] = task;
}
}
}
double nextTime = -1;
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