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

Use new SynchroMap instead of std::map everywhere

parent c44da976
......@@ -89,7 +89,7 @@ double AreaBound::compute() {
(*shared)[i][j] = values[i][j] / countTasks[i];
}
ins->extraData[share + "[repart]"] = (void*) shared;
ins->extraData.insert(share + "[repart]", (void*) shared);
}
double result = indepCplex.getObjValue();
......
......@@ -152,11 +152,9 @@ double DepBound::compute () {
// TODO: include the threshold in the share name
vector<int> DepBound::getAllocTasks(double threshold) {
vector<int>* values = (vector<int>*) instance->extraData["dep[alloc]"];
if(values != NULL)
return (*values);
if(instance->extraData.hasValue("dep[alloc]")) {
return * ((vector<int>*) instance->extraData.get("dep[alloc]"));
}
vector<int> result(nbTasks, -1);
if(threshold == -1)
......@@ -169,9 +167,9 @@ vector<int> DepBound::getAllocTasks(double threshold) {
continue;
}
}
instance->extraData["dep[alloc]"] = new vector<int>(result);
instance->extraData.insert("dep[alloc]", new vector<int>(result));
return result;
}
......
......@@ -44,7 +44,7 @@ double GreedyFile::compute(Instance & instance, SchedAction* action) {
ins = &instance;
if(file.substr(0, 4) == "int@") {
vector<int>* values = (vector<int>*) ins->extraData[file.substr(4)];
vector<int>* values = (vector<int>*) ins->extraData.get(file.substr(4));
if(!values) {
cerr << "GreedyFile: could not find shared allocation " << file << ". Did you really use the share=<...> option in a previous algorithm?" << endl;
throw(1);
......
......@@ -74,10 +74,9 @@ double computeLambda(vector<double> & w, vector<double> &m) {
vector<vector<int> >* getSortedByLength(Instance & ins) {
string key = "IB-length";
auto found = ins.extraData.find(key);
if(found != ins.extraData.end()) {
return (vector<vector<int> >*) found->second;
}
if(ins.extraData.hasValue(key))
return (vector<vector<int> >*) ins.extraData.get(key);
auto result = new vector<vector<int> >(2);
for(unsigned int i = 0; i < 2; i++) {
......@@ -88,7 +87,7 @@ vector<vector<int> >* getSortedByLength(Instance & ins) {
return ins.execTimes[i][a] > ins.execTimes[i][b];
});
}
ins.extraData[key] = (void*) result;
ins.extraData.insert(key, (void*) result);
return result;
}
......
......@@ -331,9 +331,9 @@ double IntervalBound::compute(Instance & ins) {
}
if(shareName != "") {
instance->extraData[shareName + "[alloc]"] = new vector<int>(alloc);
instance->extraData[shareName + "[med]"] = new vector<double>(medianInterval);
instance->extraData[shareName + "[avg]"] = new vector<double>(averageInterval);
instance->extraData.insert(shareName + "[alloc]", new vector<int>(alloc));
instance->extraData.insert(shareName + "[med]", new vector<double>(medianInterval));
instance->extraData.insert(shareName + "[avg]", new vector<double>(averageInterval));
}
if(saveName != "") {
......
......@@ -10,7 +10,7 @@ LNFLAGS=-lrec -lgcrypt -lgpg-error
ALGS=listAlgorithm.o HeftAlgorithm.o HeteroPrio.o Dmdas.o GreedyAlgorithm.o IndepBased.o GreedyFile.o ReproduceAlgorithm.o
INDEPALGS = IndepDP2.o IndepAccel.o IndepDualHP.o IndepImreh.o IndepBalanced.o IndepZhang.o
OBJS = ProgramOptions.o pmtool.o algoptions.o algorithm.o schedAction.o instance.o util.o availSequence.o HybridBound.o RecFileReader.o ${ALGS} ${INDEPALGS}
OBJS = SynchroMap.o ProgramOptions.o pmtool.o algoptions.o algorithm.o schedAction.o instance.o util.o availSequence.o HybridBound.o RecFileReader.o ${ALGS} ${INDEPALGS}
CPLEX_OBJS = AreaBound.o DepBound.o IterDepBound.o AreaStart.o IntervalBound.o
......
......@@ -5,9 +5,9 @@
using namespace std;
double ReproduceAlgorithm::compute(Instance& ins, SchedAction * action) {
vector<int>* allocP = (vector<int>*) ins.extraData[shareKey + "[worker]"];
vector<double>* startP = (vector<double>*) ins.extraData[shareKey + "[start]"];
vector<double>* endP = (vector<double>*) ins.extraData[shareKey + "[end]"];
vector<int>* allocP = (vector<int>*) ins.extraData.get(shareKey + "[worker]");
vector<double>* startP = (vector<double>*) ins.extraData.get(shareKey + "[start]");
vector<double>* endP = (vector<double>*) ins.extraData.get(shareKey + "[end]");
if(!allocP || !startP || !endP) {
cerr << "ReproduceAlgorithm: data associated with key " << shareKey
<< " is not complete" << endl;
......
......@@ -30,13 +30,13 @@ intCompare* RankComputer::oneCmp(Instance& ins, string subRankOpt) {
#ifdef WITH_CPLEX
else if(subRankOpt == "area") {
vector<vector<double> >* repartition;
if(ins.extraData.find("area") == ins.extraData.end()) {
if(! ins.extraData.hasValue("area")) {
AlgOptions o;
o.insert("share", "area");
AreaBound bound(o);
((ModifiableBound*)(& bound))->compute(ins);
}
repartition = ( vector<vector<double>>*) ins.extraData["area[repart]"];
repartition = ( vector<vector<double>>*) ins.extraData.get("area[repart]");
vector<double> wbarType(ins.nbTaskTypes, 0);
vector<double> wbar(ins.nbTasks, 0);
for(int i = 0; i < ins.nbTaskTypes; i++)
......@@ -66,7 +66,7 @@ intCompare* RankComputer::oneCmp(Instance& ins, string subRankOpt) {
// Those files give lower values to higher priority tasks
} else if(subRankOpt.substr(0, 4) == "int@") {
string key = subRankOpt.substr(4);
w = * ((vector<double>*) ins.extraData.at(key));
w = * ((vector<double>*) ins.extraData.get(key));
// reverse = true;
}
else {
......
......@@ -4,9 +4,10 @@
#include <vector>
#include <string>
#include <limits>
#include <map>
#include "SynchroMap.h"
#include <unordered_map>
class Instance {
public:
std::vector<int> nbWorkers;
......@@ -18,7 +19,7 @@ public:
int nbTaskTypes;
int nbWorkerTypes;
std::map<std::string, void*> extraData;
SynchroMap extraData;
// Those are optional, only printed if available.
std::vector<std::string> workerNames;
......
......@@ -171,10 +171,10 @@ void InternalShare::onSchedule(int i, int w, double s, double f) {
}
void InternalShare::finish() {
instance->extraData[shareName + "[worker]"] = new vector<int>(worker);
instance->extraData[shareName + "[alloc]"] = new vector<int>(allocation);
instance->extraData[shareName + "[start]"] = new vector<double>(startTimes);
instance->extraData[shareName + "[end]"] = new vector<double>(endTimes);
instance->extraData.insert(shareName + "[worker]", new vector<int>(worker));
instance->extraData.insert(shareName + "[alloc]", new vector<int>(allocation));
instance->extraData.insert(shareName + "[start]", new vector<double>(startTimes));
instance->extraData.insert(shareName + "[end]", new vector<double>(endTimes));
}
ExportBubble::ExportBubble(string filename, Instance* ins, int btt) :
......
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