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

Explicit memory nodes for workers

parent 2c2f2b67
......@@ -5,7 +5,7 @@
using namespace std;
CommSequence::CommSequence(Instance &ins): bandwidth(ins.bandwidth), nbWT(ins.nbWorkerTypes),
CommSequence::CommSequence(Instance &ins): bandwidth(ins.bandwidth), nbWT(ins.totalWorkers),
outgoing(nbWT), incoming(nbWT) {
}
......
......@@ -423,6 +423,16 @@ RecFileInstance::RecFileInstance(const string inputFile, const string platformFi
}
nbWorkerTypes = nbWorkers.size();
totalWorkers = getSum(nbWorkers);
int memNodes = 1;
int workerIndex = 0;
for(int k = 0; k < nbWorkerTypes; ++k) {
int memnode = 0;
if(workerNames[k].compare(0, 3, "cpu") != 0)
memnode = memNodes++;
vector<int> nodes(nbWorkers[k], memnode);
memoryNodes.push_back(nodes);
}
rec_rset_t timingSet = rec_db_get_rset_by_type(platform, "timing");
if(!timingSet) {
......
......@@ -47,12 +47,16 @@ Instance::Instance(const string input_file, int convertIndices) {
}
totalWorkers = static_cast<unsigned int>(s);
int v = 0;
for(int n: nbWorkers) {
for(int k = 0; k < nbWorkerTypes; k++) {
int n = nbWorkers[k];
vector<int> ids;
for(int i = 0; i < n; i++)
vector<int> nodes(n, k); // Size n, all equal to k
for(int i = 0; i < n; i++) {
ids.push_back(v + i);
}
v += n;
workerIDs.push_back(ids);
memoryNodes.push_back(nodes);
}
execTimes.resize(nbWorkerTypes);
......@@ -125,7 +129,7 @@ void Instance::display(int verbosity) {
cout << taskTypeNames << endl;
for(i = 0; i < (int) nbWorkers.size(); i++){
if(workerNames.size() > 0) cout << workerNames[i] << " \t";
cout << execTimes[i] << " " << workerIDs[i] << endl;
cout << execTimes[i] << " " << workerIDs[i] << " " << memoryNodes[i] << endl;
}
if(verbosity >= 4) {
cout << taskTypes << endl;
......@@ -199,7 +203,8 @@ void Instance::mergeWorkerTypes(const vector<int> indicesToMerge) {
vector<int> newNbWorkers;
vector< vector<double> > newExecTimes;
vector<vector<int> > newWorkerIDs;
vector<vector<int> > newMemoryNodes;
int replacementNB = 0;
vector<double> replacementExecTimes(nbTaskTypes, 0);
......@@ -222,21 +227,25 @@ void Instance::mergeWorkerTypes(const vector<int> indicesToMerge) {
newNbWorkers.push_back(nbWorkers[i]);
newExecTimes.push_back(execTimes[i]);
newWorkerIDs.push_back(workerIDs[i]);
newMemoryNodes.push_back(memoryNodes[i]);
}
}
vector<int> replacementIDs;
vector<int> replacementMemNodes;
for(int i = 0; i < (int) indicesToMerge.size(); i++) {
replacementIDs.insert(replacementIDs.end(), workerIDs[i].begin(), workerIDs[i].end());
replacementMemNodes.insert(replacementMemNodes.end(), memoryNodes[i].begin(), memoryNodes[i].end());
}
newWorkerIDs.push_back(replacementIDs);
newMemoryNodes.push_back(replacementMemNodes);
newNbWorkers.push_back(replacementNB);
newExecTimes.push_back(replacementExecTimes);
nbWorkers = newNbWorkers;
execTimes = newExecTimes;
workerIDs = newWorkerIDs;
memoryNodes = newMemoryNodes;
nbWorkerTypes = nbWorkers.size();
......
......@@ -65,6 +65,10 @@ public:
std::vector<std::vector<int> > itemsProduced;
// itemsProduced[i][j] = index of jth item that task i produces
std::vector<std::vector<int>> memoryNodes;
// This vector works like workerIDs: length is nbWorkerTypes, memoryNodes[t] specifies
// the memory nodes of all workers of type t
double bandwidth;
std::string inputFile;
......
......@@ -85,14 +85,15 @@ double GreedyAlgorithm::compute(Instance& ins, SchedAction* action) {
if(doComms) {
// Compute a finish time which takes communication into account.
for(int &item: ins.itemsRequired[chosenTask]) {
int src = locations[item];
if(src != t) {
double commEndTime = comms.newTransfer(dataAvailTimes[item], src, t, ins.itemSizes[item], currentTime);
int src = locations[item];
int dst = ins.memoryNodes[t][index];
if(src != dst) {
double commEndTime = comms.newTransfer(dataAvailTimes[item], src, dst, ins.itemSizes[item], currentTime);
startTime = max(startTime, commEndTime);
if(verbosity >= 4)
cout << "Greedy: for task " << chosenTask << " on " << idle << " node " << t
cout << "Greedy: for task " << chosenTask << " on " << idle << " node " << dst
<< ": item " << ins.itemNames[item] << " is on " << src << " at "
<< dataAvailTimes[item] << ", comm. end delay is " << commEndTime << endl;
<< dataAvailTimes[item] << ", comm. end delay is " << commEndTime << endl;
}
}
}
......@@ -143,15 +144,19 @@ double GreedyAlgorithm::compute(Instance& ins, SchedAction* action) {
for(int w = 0; w < nbWorkers; w++)
if((runningTasks[w] != -1) && (endTimesWorkers[w] <= currentTime)) {
int i = runningTasks[w];
int wType = ins.getType(w);
int index;
int wType = ins.getType(w, &index);
if(verbosity >= 4)
cout << "Greedy: Finishing task " << i << " on worker " << w << " at time " << currentTime << endl;
if(action != NULL)
action->onSchedule(runningTasks[w], w,
endTimesWorkers[w] - ins.execWorker(w, runningTasks[w]), endTimesWorkers[w]);
for(int& item: ins.itemsProduced[i]) {
locations[item] = wType;
dataAvailTimes[item] = currentTime;
if(doComms) {
for(int& item: ins.itemsProduced[i]) {
locations[item] = ins.memoryNodes[wType][index];
dataAvailTimes[item] = currentTime;
cout << ins.itemNames[item] << " " << locations[item] << " " << locations[item] << " " << currentTime << " " << currentTime << " " << i << endl;
}
}
runningTasks[w] = -1;
if(finishedTasks[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