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

instance: add names to tasks and taskTypes and workers.

Read from .rec files, output in schedule files
parent 539c3f6f
......@@ -19,6 +19,7 @@ public:
static rec_field_name_t recJobId;
static rec_field_name_t recEstimatedTime;
static rec_field_name_t recDependsOn;
static rec_field_name_t recTag;
static int outputCount;
static void recReaderInit() {
if(recName == NULL) {
......@@ -32,6 +33,8 @@ public:
rec_field_name_set(recEstimatedTime, 0, "EstimatedTime");
recDependsOn = rec_field_name_new();
rec_field_name_set(recDependsOn, 0, "DependsOn");
recTag = rec_field_name_new();
rec_field_name_set(recTag, 0, "Tag");
}
outputCount = 0;
}
......@@ -50,6 +53,7 @@ public:
string name;
string footprint;
string taskType;
string tag;
vector<int> dependsOn;
bool convertedDeps;
bool isReal;
......@@ -69,6 +73,7 @@ public:
outputId = outputCount;
++outputCount;
}
tag = recordValue(record, recTag);
jobId = stoi(recordValue(record, recJobId));
string deps = recordValue(record, recDependsOn);
if(deps != "") {
......@@ -104,6 +109,7 @@ rec_field_name_t recTask::recFootprint = NULL;
rec_field_name_t recTask::recJobId = NULL;
rec_field_name_t recTask::recEstimatedTime = NULL;
rec_field_name_t recTask::recDependsOn = NULL;
rec_field_name_t recTask::recTag = NULL;
int recTask::outputCount = 0;
......@@ -149,24 +155,38 @@ void Instance::readFromRecFile(const string inputFile) {
nbWorkers.resize(nbWorkerTypes, 1);
totalWorkers = nbWorkerTypes;
execTimes.resize(nbWorkerTypes);
vector<string> allTypes;
for(auto& pairs : timings) {
allTypes.push_back(pairs.first);
taskTypeNames.push_back(pairs.first);
for(int i = 0; i < nbWorkerTypes; i++)
execTimes[i].push_back(pairs.second[i]);
}
nbTaskTypes = allTypes.size();
nbTaskTypes = taskTypeNames.size();
for(auto& intID: realTasks) {
recTask &t = tasks[intID];
vector<int> deps;
t.getDependencies(jobIdToInternal, tasks, deps);
dependencies.push_back(deps);
int type = 0;
for(; type < nbTaskTypes; type++) if(t.taskType == allTypes[type]) break;
for(; type < nbTaskTypes; type++) if(t.taskType == taskTypeNames[type]) break;
taskTypes.push_back(type);
if(t.tag != "" && t.tag != "0"){
taskIDs.push_back(t.tag);
} else {
taskIDs.push_back(to_string(t.jobId));
}
}
nbTasks = taskTypes.size();
// Cleanup taskTypeNames if possible
for(int i = 0; i < nbTaskTypes; i++) {
string n = split(taskTypeNames[i], ':')[0];
bool other=false;
for(int j = i+1; j < nbTaskTypes; j++)
if(split(taskTypeNames[j], ':')[0] == n) {
other = true; break;
}
if(!other)
taskTypeNames[i] = n;
}
}
......@@ -84,10 +84,13 @@ void Instance::display(int verbosity) {
for(auto it = nbWorkers.begin(); it != nbWorkers.end(); it++)
totalWorkers += *it;
cout << "WPT: " << nbWorkers << "; NBW: " << totalWorkers << "; NBT: " << taskTypes.size() << endl;
cout << taskTypeNames << endl;
for(i = 0; i < (int) nbWorkers.size(); i++)
cout << execTimes[i] << endl;
if(verbosity >= 4)
if(verbosity >= 4) {
cout << taskTypes << endl;
cout << taskIDs << endl;
}
if(verbosity >= 5) {
for(i = 0; i < (int) taskTypes.size(); i++)
cout << i << " " << dependencies[i] << endl;
......
......@@ -19,10 +19,10 @@ public:
std::map<std::string, void*> extraData;
// Those are optional, let's say. To be supported in the next version
/* IloArray<string> workerNames;
IloArray<string> taskTypeNames;
IloArray<string> taskIDs; */
// Those are optional, only printed if available.
std::vector<std::string> workerNames;
std::vector<std::string> taskTypeNames;
std::vector<std::string> taskIDs;
// Computed afterwards
public:
std::vector< std::vector<int> > revDep;
......
......@@ -42,8 +42,12 @@ ExportToFile::ExportToFile(string filename, Instance* ins, bool header, string n
: output(filename), instance(ins), name(name) {
if(name != "")
output << "sched ";
if(header)
output << "Tid worker taskType start duration end" << endl;
if(header) {
output << "Tid worker taskType ";
if(ins->taskIDs.size() > 0)
output << "tag ";
output << "start duration end" << endl;
}
}
void ExportToFile::changeName(string newName) {
......@@ -56,9 +60,15 @@ void ExportToFile::changeName(string newName) {
void ExportToFile::onSchedule(int i, int w, double s, double f) {
if(name != "")
this->output << name << " ";
this->output << i << " " << w << " " << instance->taskTypes[i] << " "
<< s << " " << (f - s) << " " << f << endl;
output << name << " ";
output << i << " " << w << " ";
if(instance->taskTypeNames.size() > 0)
output << instance->taskTypeNames[instance->taskTypes[i]];
else
output << instance->taskTypes[i];
if(instance->taskIDs.size() > 0)
output << " " << instance->taskIDs[i];
output << " " << s << " " << (f - s) << " " << f << endl;
}
ExportToFile::~ExportToFile() {
......
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