Commit 3056ba53 authored by EYRAUD-DUBOIS Lionel's avatar EYRAUD-DUBOIS Lionel

Read Memory Node info from the platform file

parent adfeac20
...@@ -115,12 +115,12 @@ private: ...@@ -115,12 +115,12 @@ private:
throw(1); throw(1);
} }
public:
static int stoi(string s) { static int stoi(string s) {
return std::stoi(s); return std::stoi(s);
} }
public:
recTask(const rec_record_t record, int id) : internalId(id) { recTask(const rec_record_t record, int id) : internalId(id) {
name = recordValueOpt(record, recName); name = recordValueOpt(record, recName);
convertedDeps = false; convertedDeps = false;
...@@ -424,16 +424,60 @@ RecFileInstance::RecFileInstance(const string inputFile, const string platformFi ...@@ -424,16 +424,60 @@ RecFileInstance::RecFileInstance(const string inputFile, const string platformFi
nbWorkerTypes = nbWorkers.size(); nbWorkerTypes = nbWorkers.size();
totalWorkers = getSum(nbWorkers); totalWorkers = getSum(nbWorkers);
int memNodes = 1; rec_rset_t memoryNodesSet = rec_db_get_rset_by_type(platform, "memory_workers");
int workerIndex = 0; if(!memoryNodesSet) {
for(int k = 0; k < nbWorkerTypes; ++k) { /* By default, if no 'memory_workers' record is present, cpus have memory node 0
int memnode = 0; and each other worker has its own memory node */
if(workerNames[k].compare(0, 3, "cpu") != 0) int memNodes = 1;
memnode = memNodes++; int workerIndex = 0;
vector<int> nodes(nbWorkers[k], memnode); for(int k = 0; k < nbWorkerTypes; ++k) {
memoryNodes.push_back(nodes); int memnode = 0;
if(workerNames[k].compare(0, 3, "cpu") != 0)
memnode = memNodes++;
vector<int> nodes(nbWorkers[k], memnode);
memoryNodes.push_back(nodes);
}
nbMemoryNodes = memNodes;
} else {
/* Initialize all memory nodes with -1 */
memoryNodes.resize(nbWorkerTypes);
for(int k = 0; k < nbWorkerTypes; ++k) {
memoryNodes[k].resize(nbWorkers[k], -1);
}
nbMemoryNodes = 0;
/* Read from file */
rec_mset_iterator_t memNodeIt = rec_mset_iterator(rec_rset_mset(memoryNodesSet));
rec_record_t recMemNode;
const char* MemoryNode = rec_parse_field_name_str("MemoryNode");
const char* Workers = rec_parse_field_name_str("Workers");
while(rec_mset_iterator_next(&memNodeIt, MSET_RECORD, (const void**) &recMemNode, NULL)) {
vector<int> workers_in_node;
int memNodeId = stoi(recordValue(recMemNode, MemoryNode));
nbMemoryNodes = max(nbMemoryNodes, memNodeId + 1);
getVector(recMemNode, Workers, workers_in_node, recTask::stoi);
for(int w: workers_in_node) {
int index;
int type = getType(w, &index);
if (memoryNodes[type][index] >= 0) {
cerr << "RecFileInstance: Worker " << w << " appears in two memory nodes: " <<
memoryNodes[type][index] << " and " << memNodeId << endl;
throw(1);
}
memoryNodes[type][index] = memNodeId;
}
}
/* Check that all workers have a memory node */
int wID = 0;
for (int k = 0; k < nbWorkerTypes; ++k) {
for (int j = 0; j < nbWorkers[k]; ++j, ++wID) {
if (memoryNodes[k][j] < 0) {
cerr << "RecFileInstance: Worker " << wID << " does not belong to any memory node" << endl;
throw(1);
}
}
}
} }
nbMemoryNodes = memNodes;
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) {
......
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