Commit 4c8b7027 authored by EYRAUD-DUBOIS Lionel's avatar EYRAUD-DUBOIS Lionel

New indep algorithm: CLB2C. Does not exactly code CLB2C asis, because this...

New indep algorithm: CLB2C. Does not exactly code CLB2C asis, because this would require to consider individual resources rather than resource types
parent 92b5a61a
......@@ -318,7 +318,11 @@ resources. All of these only work with two types of resources.
+ `round`
Rounds the solution of the linear problem, as proposed in [Scalable linear programming based resource allocation for makespan minimization in heterogeneous computing systems](http://www.engr.colostate.edu/~ktarplee/pdf/jpdc_makespan.pdf),
[(DOI) 10.1016/j.jpdc.2015.07.002](https://doi.org/10.1016/j.jpdc.2015.07.002). This algorithm
sorts the tasks by LPT order, needs to use `dosort=no` to keep this ordering.
sorts the tasks by LPT order, needs to use `dosort=no` to keep this ordering.
+ `clb2c`
Implements the CLB2C strategy (see [Considerations on distributed load balancing for fully heterogeneous machines: Two particular cases.](https://doi.org/10.1109/IPDPSW.2015.36)).
Not exactly equivalent to this strategy, since `indep` performs list scheduling based only on the
assignment to different types of resources.
+ `rank` (except for style `strict`)
as for the previous algorithms
+ `dosort` (except for `strict`, default `yes`)
......
//
// Created by eyraud on 18/09/18.
//
#ifndef PMTOOL_INDEPCLB2C_H
#define PMTOOL_INDEPCLB2C_H
#include "IndepAllocator.h"
class IndepCLB2C : public IndepAllocator {
public:
IndepCLB2C(const AlgOptions &opt);
IndepResult compute(Instance &ins, std::vector<int> &taskSet, std::vector<double> &loads) override;
};
#endif //PMTOOL_INDEPCLB2C_H
......@@ -15,7 +15,7 @@ set(SCHED_SRC
availSequence.cpp
GreedyAlgorithm.cpp
HeftAlgorithm.cpp
OnlineZhang.cpp ../include/OnlineZhang.h GreedyPerType.cpp ../include/GreedyPerType.h TrueHeteroPrio.cpp ../include/TrueHeteroPrio.h OnlineGeneric.cpp ../include/OnlineGeneric.h OnlineQA.cpp ../include/OnlineQA.h OnlineECT.cpp ../include/OnlineECT.h OnlineERLS.cpp ../include/OnlineERLS.h)
OnlineZhang.cpp ../include/OnlineZhang.h GreedyPerType.cpp ../include/GreedyPerType.h TrueHeteroPrio.cpp ../include/TrueHeteroPrio.h OnlineGeneric.cpp ../include/OnlineGeneric.h OnlineQA.cpp ../include/OnlineQA.h OnlineECT.cpp ../include/OnlineECT.h OnlineERLS.cpp ../include/OnlineERLS.h IndepCLB2C.cpp ../include/IndepCLB2C.h)
if(CPLEX_FOUND)
set(SCHED_SRC ${SCHED_SRC} SchedLPIndep.cpp ../include/SchedLPIndep.h AreaRound.cpp ../include/AreaRound.h)
......
//
// Created by eyraud on 18/09/18.
//
#include <util.h>
#include <iostream>
#include "IndepCLB2C.h"
using namespace std;
IndepCLB2C::IndepCLB2C(const AlgOptions &opt) : IndepAllocator(opt) {
needsPreciseLoads = true;
}
int getEarliestWorker(vector<double> loads, int from, int to) {
int best = from;
for(int i = from+1; i < to; ++i){
if(loads[i] < loads[best])
best = i;
}
return best;
}
IndepResult IndepCLB2C::compute(Instance &ins, std::vector<int> &taskSet, std::vector<double> &loads) {
if(ins.nbWorkerTypes != 2) {
cerr << "IndepCLB2C: only implemented for instances with 2 worker types" << endl;
throw(1);
}
IndepResult result(2);
if(taskSet.empty())
return result;
vector<double> accelFactors(taskSet.size());
for(int i = 0; i < taskSet.size(); i++)
accelFactors[i] = ins.execType(0, taskSet[i]) / ins.execType(1, taskSet[i]);
rankCompare compareByAccelFactor = rankCompare(accelFactors);
strictCompare strict(&compareByAccelFactor, true);
int midPointWorker = ins.nbWorkers[0];
auto tasks = new set<int, strictCompare>(strict);
for(int i = 0; i < taskSet.size(); i++)
tasks->insert(i);
auto posMin = tasks->begin();
auto posMax = tasks->end(); --posMax;
int bestWorkerZero = getEarliestWorker(loads, 0, midPointWorker);
int bestWorkerOne = getEarliestWorker(loads, midPointWorker, ins.totalWorkers);
int taskZero = taskSet[*posMin];
int taskOne = taskSet[*posMax];
while (posMin != posMax) {
if(loads[bestWorkerZero] + ins.execType(0, taskZero) <= loads[bestWorkerOne] + ins.execType(1, taskOne)) {
result[0].push_back(taskZero);
++posMin;
loads[bestWorkerZero] += ins.execType(0, taskZero);
taskZero = taskSet[*posMin];
bestWorkerZero = getEarliestWorker(loads, 0, midPointWorker);
} else {
result[1].push_back(taskOne);
--posMax;
loads[bestWorkerOne] += ins.execType(1, taskOne);
taskOne = taskSet[*posMax];
bestWorkerOne = getEarliestWorker(loads, midPointWorker, ins.totalWorkers);
}
}
if(loads[bestWorkerZero] + ins.execType(0, taskZero) <= loads[bestWorkerOne] + ins.execType(1, taskOne)) {
result[0].push_back(taskZero);
} else {
result[1].push_back(taskOne);
}
return result;
}
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