Commit 540d2ec1 authored by EYRAUD-DUBOIS Lionel's avatar EYRAUD-DUBOIS Lionel

New 'key' option to greedy to replace file=int@

parent 39ac99d9
......@@ -317,7 +317,7 @@ void ProgramOptions::insertComputable(vector< pair<A, AlgOptions> > & elems, str
hlpAlreadyUsed = true;
}
name = "greedy";
additionalOptions = "file=int@depNoHybrid[alloc]";
additionalOptions = "key=depNoHybrid[alloc]";
}
for(AlgOptions options: optList) {
if(!additionalOptions.empty())
......
......@@ -343,14 +343,12 @@ Greedy algorithm with pre-allocated tasks. Requires a `file` option
`heft` and `area`), where task weight is its execution
time on its allocated resource.
+ `file` (required)
Two possibilities:
+ a filename
Reads the pre-allocation in a file, one number of resource type per
Provide the name of a file from which the pre-allocation will be read, one number of resource type per
task, in the order of the instance. CAREFUL of the `-t` option,
which renumbers resources.
+ `int@KEY`
Uses pre-allocation shared with share or export
option. Often `KEY[alloc]` actually.
+ `key`
Uses pre-allocation shared with share or export
option. Often `KEY[alloc]` actually.
+ `stealer` (default -1)
specifies a resource type which is allowed to steal from others,
by number. CAREFUL of `-t` option, which renumbers resources.
......
......@@ -30,6 +30,8 @@ protected:
explicit PreAllocatedGreedy(const AlgOptions & options);
double compute(Instance & instance, SchedAction* action) override;
void onTaskPush(int task, double now) override;
std::string key;
};
......
......@@ -28,35 +28,40 @@ GreedyRanker::GreedyRanker(const AlgOptions &options) : RankComputer(options) {
PreAllocatedGreedy::PreAllocatedGreedy(const AlgOptions& options): GreedyPerType(options), ranker(options) {
file = options.asString("file", "");
key = options.asString("key", "");
if(file.empty()) {
cerr << "PreAllocatedGreedy: option 'file' is mandatory" << endl;
throw(1);
if(key.empty()) {
cerr << "PreAllocatedGreedy: option 'file' or 'key' is mandatory" << endl;
throw(1);
}
} else if(!key.empty()) {
cerr << "PreAllocatedGreedy: both 'file' and 'key' present, using 'key'" << endl;
}
}
double PreAllocatedGreedy::compute(Instance & instance, SchedAction* action) {
if(file.substr(0, 4) == "int@") {
vector<int>* values = (vector<int>*) instance.extraData.get(file.substr(4));
if(!values) {
cerr << "PreAllocatedGreedy: could not find shared allocation " << file << ". Did you really use the share=<...> option in a previous algorithm?" << endl;
throw(1);
}
preAssign.resize(instance.nbTasks);
for(int i = 0; i < instance.nbTasks; i++) {
preAssign[i] = (*values)[i];
}
} else {
ifstream inputStream(file);
if(!inputStream) {
cerr << "PreAllocatedGreedy: cannot open " << file << endl;
throw(1);
if(!key.empty()) {
vector<int> *values = (vector<int> *) instance.extraData.get(key);
if (!values) {
cerr << "PreAllocatedGreedy: could not find shared allocation " << file
<< ". Did you really use the share=<...> option in a previous algorithm?" << endl;
throw (1);
}
for (int i = 0; i < instance.nbTasks; i++) {
preAssign[i] = (*values)[i];
}
} else if(!file.empty()) {
ifstream inputStream(file);
if(!inputStream) {
cerr << "PreAllocatedGreedy: cannot open " << file << endl;
throw(1);
}
for(int i = 0; i < instance.nbTasks; i++) {
inputStream >> preAssign[i] >> ws;
}
}
preAssign.resize(instance.nbTasks);
for(int i = 0; i < instance.nbTasks; i++) {
inputStream >> preAssign[i] >> ws;
}
}
for(int i = 0; i < instance.nbTasks; i++) {
int val = preAssign[i];
......
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