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

Reproducing the real-life schedule contained in tasks.rec no longer requires to use the -t option

Thanks to Vinícius Garcia Pinto for the report
parent d4fa0525
......@@ -398,7 +398,7 @@ void RecFileInstance::readFromFile(const string inputFile, unordered_map<string,
execStart = s;
for(auto&& s: schedStartTimes) s -= execStart;
for(auto&& s: schedEndTimes) s -= execStart;
extraData.insert("rl[workerid]", new vector<int>(schedWorkerIDs));
extraData.insert("rl[worker]", new vector<int>(schedWorkerIDs));
extraData.insert("rl[start]", new vector<double>(schedStartTimes));
extraData.insert("rl[end]", new vector<double>(schedEndTimes));
}
......
#include <iostream>
#include <assert.h>
#include "SynchroMap.h"
using namespace std;
......@@ -31,6 +32,21 @@ void SynchroMap::insert(const string &key, void* value) {
}
}
void SynchroMap::replace(const string &key, void* value) {
{
lock_guard<mutex> lock(mtx);
auto iterator = dict.find(key);
assert(iterator != dict.end());
assert(!iterator->second.first);
link(key);
auto &pair = dict[key];
pair.first->set_value(value);
free(pair.first);
pair.first = NULL;
}
}
void* SynchroMap::get(const string & key) {
std::pair< std::promise<void*>*, std::shared_future<void*> > pair;
{
......
......@@ -282,14 +282,14 @@ void Instance::mergeWorkerTypes(const vector<int> indicesToMerge) {
workerNames = newWorkerNames;
}
if(extraData.isPresent("rl[workerid]")) {
if(extraData.isPresent("rl[worker]")) {
cerr << "Converting worker IDs" << endl;
vector<int>* allocP = (vector<int>*) extraData.get("rl[workerid]");
vector<int>* allocP = (vector<int>*) extraData.get("rl[worker]");
vector<int>* allocWorkers = new vector<int>();
for(unsigned int i = 0; i < nbTasks; i++) {
allocWorkers->push_back(getWorkerWithWorkerID((*allocP)[i]));
}
extraData.insert("rl[worker]", allocWorkers);
extraData.replace("rl[worker]", allocWorkers);
}
}
......
......@@ -17,6 +17,9 @@ class SynchroMap {
SynchroMap();
// Inserts a value in the map
void insert(const std::string & key, void* value);
// Replaces an already present value -- should only be called for a key which "hasValue()",
// otherwise use insert() directly
void replace(const std::string & key, void* value);
// gets a value. If not already present, blocks until the value has been pushed.
// This gets dangerous if user misbehaves: leads to deadlock since no one will ever wake me up.
// Solving it would require bounds & algs to declare what keys they will write to.
......
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