Commit be8f47ac authored by EYRAUD-DUBOIS Lionel's avatar EYRAUD-DUBOIS Lionel
Browse files

Bugfixes. HeteroPrio seems to work

parent 36ff9b2a
......@@ -33,16 +33,16 @@ vector<double> HeteroPrio::computeHEFTRank(Instance &ins) {
void HeteroPrio::init(Instance& ins) {
priorities = computeHEFTRank(ins);
rankCompare taskCmp(priorities);
rankCompare taskCmp(priorities, true);
rankSet protoQueue(taskCmp);
readyQueues.insert(readyQueues.end(), ins.nbTaskTypes, protoQueue);
readyQueues.resize(ins.nbTaskTypes, protoQueue);
revDependencies = ins.getRevDependencies();
vector<double> maxTimings(ins.nbTaskTypes, -1);
vector<double> minTimings(ins.nbTaskTypes, -1);
vector<double> aggregateTimings(ins.nbTaskTypes, 1);
vector<double> aggregateTimings(ins.nbWorkerTypes, 1);
double avgAggregate = 0;
for(int j = 0; j < ins.nbTaskTypes; j++) {
......@@ -67,19 +67,21 @@ void HeteroPrio::init(Instance& ins) {
workerPollOrder.resize(ins.nbWorkerTypes);
int cumulWorkers = 0;
for(int i = 0; i < ins.nbWorkerTypes; i++) {
workers[i].hetFactor.resize(ins.nbTaskTypes);
workers[i].RQorder.resize(ins.nbTaskTypes);
for(int j = 0; j < ins.nbTaskTypes; j++) {
// Compute Het Factor
// TODO: HetFactor based on area distribution
workers[i].hetFactor[j] = (maxTimings[j] * minTimings[j]) / (ins.execTimes[i][j] * ins.execTimes[i][j]);
workers[i].RQorder[j] = j;
}
rankCompare cmp(workers[i].hetFactor);
rankCompare cmp(workers[i].hetFactor, true);
sort(workers[i].RQorder.begin(), workers[i].RQorder.end(), cmp);
workers[i].speedIndex = aggregateTimings[i];
workers[i].isFast = workers[i].speedIndex <= avgAggregate;
workerPollOrder[i] = i;
workers[i].firstID = cumulWorkers;
workers[i].currentTasks.resize(ins.nbWorkers[i]);
workers[i].currentTasks.resize(ins.nbWorkers[i], -1);
workers[i].nbWorkers = ins.nbWorkers[i];
cumulWorkers += ins.nbWorkers[i];
}
......@@ -128,7 +130,7 @@ int HeteroPrio::performSteal(Instance &ins, int wType, int wLocalID, double curr
sort(candidates.begin(), candidates.end(),
[this] (currentInfo a, currentInfo b) {
return (priorities[a.taskID] < priorities[b.taskID]);
return (priorities[a.taskID] > priorities[b.taskID]);
});
for(auto candIt = candidates.begin(); candIt != candidates.end(); candIt++) {
......@@ -164,8 +166,9 @@ double HeteroPrio::compute(Instance& ins, SchedAction* action) {
int nbReadyTasks = getSum<rankSet, int> (readyQueues, [] (rankSet r) -> int { return r.size(); });
double currentTime = 0;
while(nbReadyTasks > 0 && !events.empty() ) {
while(nbReadyTasks > 0 || !events.empty() ) {
// While queue is non empty, or some events are still here.
cout << "HP: starting loop, time= " << currentTime << endl;
for(auto wkPollit = workerPollOrder.begin(); wkPollit != workerPollOrder.end(); wkPollit++) {
workerInfo &w = workers[*wkPollit];
......@@ -186,12 +189,14 @@ double HeteroPrio::compute(Instance& ins, SchedAction* action) {
int idleLocalID = find(w.currentTasks.begin(), w.currentTasks.end(), -1)
- w.currentTasks.begin();
cout << "HP: wType " << *wkPollit << ", nbRun: " << w.runningTasks << " current: " << w.currentTasks << " idle=" << idleLocalID << endl;
int t = -1;
if(chosenQueue == -1) {
if(chosenQueue == -1) { // TOSDO : && w.isFast ??
t = performSteal(ins, *wkPollit, idleLocalID, currentTime);
} else {
readyQueues[chosenQueue].erase(chosenTask);
nbReadyTasks--;
t = *chosenTask;
}
if(t != -1) {
......@@ -203,7 +208,7 @@ double HeteroPrio::compute(Instance& ins, SchedAction* action) {
w.runningTasks ++;
w.currentTasks[idleLocalID] = t;
cout << "HP: start exec of task " << t << " on worker "
<< w.firstID + idleLocalID << " type " << *wkPollit << endl;
<< w.firstID + idleLocalID << " type " << *wkPollit << " to finish at " << endDate << endl;
}
}
}
......@@ -233,6 +238,7 @@ double HeteroPrio::compute(Instance& ins, SchedAction* action) {
cerr << "Task " << *depIt <<" already present in set" << endl;
throw(-1);
}
nbReadyTasks++;
/* if(action != NULL)
action->onTaskPush(*depIt) */
}
......
......@@ -13,6 +13,7 @@
#include "listAlgorithm.h"
#include "HeftAlgorithm.h"
#include "HybridBound.h"
#include "HeteroPrio.h"
#ifdef WITH_CPLEX
#include "AreaBound.h"
......@@ -81,6 +82,8 @@ void displayAlgList() {
cout << " " << " " << "Options: rank, .." << endl;
cout << "heft" << " " << "HEFT-strict algorithm" <<endl;
cout << " " << " " << "Options: rank, .." << endl;
cout << "hetprio" << " " << "HeteroPrio algorithm" <<endl;
cout << " " << " " << "Options: rank, .." << endl;
}
Algorithm* createAlg(const string& name, const algopt& options) {
Algorithm* alg = NULL;
......@@ -88,7 +91,9 @@ Algorithm* createAlg(const string& name, const algopt& options) {
alg = new HeftAlgorithm(options);
if(name == "list")
alg = new ListAlgorithm(options);
if(alg == NULL){
if(name == "hetprio")
alg = new HeteroPrio(options);
if(alg == NULL){
cerr << "Unknown algorithm " << name <<". For a list of algorithms, use --alg show" << endl;
displayAlgList();
exit(-1);
......
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