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

Explicit memory nodes for workers

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