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

IndepDP2: prepare for generalization

parent 5ad8ea5e
......@@ -11,8 +11,8 @@ extern double lowerBoundTwoResource(Instance& ins, std::vector<int> taskSet,
class IndepDP2 : public IndepAllocator {
protected:
double tryGuess(Instance &, std::vector<int> taskSet, double maxGPUload, double maxlen,
IndepResult & result, bool getResult);
double tryGuess(Instance &, std::vector<int> taskSet, std::vector<double>& loads,
double maxlen, IndepResult & result, bool getResult);
double epsilon = 0.01;
double discretizationConstant = 3.0;
......
......@@ -17,15 +17,19 @@ IndepDP2::IndepDP2(const AlgOptions& opt): IndepAllocator(opt) {
// Arbitrary convention: CPU times are index 0, GPU times are index 1. Just a naming thing.
// returns minimum CPU load
double IndepDP2::tryGuess(Instance& instance, std::vector<int> taskSet, double maxGPUload, double maxlen,
IndepResult &result, bool getResult) {
// returns minimum CPU load, taking into account existing loads
double IndepDP2::tryGuess(Instance& instance, std::vector<int> taskSet, vector<double>& loads,
double maxlen, IndepResult &result, bool getResult) {
// CPUload(i, g) := smallest load on CPU from the first i tasks,
// with at most g load on GPU
// So need to discretize the GPU load ? Yes. Paper says with a ratio of lambda/3n
// For all tasks in taskSet:
// forall g, CPUload(i, g) = min CPUload(i-1, g-T^G_i) CPUload(i-1, g) + T^C_i
double existingCPUload = loads[0];
double existingGPUload = loads[1];
double maxGPUload = maxlen * instance.nbWorkers[1] - existingGPUload;
if(maxGPUload < 0) maxGPUload = 1;
......@@ -118,7 +122,7 @@ double IndepDP2::tryGuess(Instance& instance, std::vector<int> taskSet, double m
delete[] CPUload[0];
delete[] CPUload;
return value;
return value + existingCPUload;
}
......@@ -186,7 +190,7 @@ IndepResult IndepDP2::compute(Instance& instance, vector<int> &taskSet, vector<d
else
target = 1.15*low;
double r = tryGuess(instance, taskSet, target * nbGPU - loads[1], target, result, abs(target - low) <= 3*epsilon*low);
double r = tryGuess(instance, taskSet, loads, target, result, abs(target - low) <= 3*epsilon*low);
if(verbosity >= 6)
cout << "IndepDP2: TARGET = "<< target << ", result = " << r << " mkspan= " << (r+loads[0])/ nbCPU << endl;
if((r != -1) && (r + loads[0]) /nbCPU <= target * (1+ epsilon)) {
......@@ -199,7 +203,7 @@ IndepResult IndepDP2::compute(Instance& instance, vector<int> &taskSet, vector<d
}
if(! haveResult) {
double r = tryGuess(instance, taskSet, up * nbGPU - loads[1], up, result, true);
double r = tryGuess(instance, taskSet, loads, up, result, true);
if(verbosity >= 6)
cout << "IndepDP2: TARGET = "<< up << ", result = " << r << " mkspan= " << (r+loads[0])/ nbCPU << endl;
}
......
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