Commit 2da6de0d authored by Jonathon Duerig's avatar Jonathon Duerig
Browse files

Reduced memory consumption. On large topologies, this might be an order of magnitude improvement.

parent fcc5a321
......@@ -33,6 +33,8 @@ void NetRouter::calculateRoutes(void)
size_t j = 0;
size_t k = 0;
list<size_t> obsoleteLans;
setup();
// for each level of the hierarchy, starting at one level above LANs
......@@ -67,7 +69,7 @@ void NetRouter::calculateRoutes(void)
for (j = 0; j < currentLevel.size(); ++j)
{
// Determine the border LANs for that partition
calculateBorders(i, j);
calculateBorders(i, j, obsoleteLans);
// For each border LAN, calculate the routes to all of the other
// border LANs in this partition.
calculateBorderToBorderPaths(i, j);
......@@ -77,6 +79,7 @@ void NetRouter::calculateRoutes(void)
// for each node in the partition, and each subnet in
// the partition, find a route from that node to that subnet
calculatePartitionRoutes(i, j);
removeObsoleteConnections(obsoleteLans);
}
}
}
......@@ -168,10 +171,14 @@ void NetRouter::setup(void)
calculateInterBorders();
}
void NetRouter::calculateBorders(size_t level, size_t partition)
void NetRouter::calculateBorders(size_t level, size_t partition,
list<size_t> & obsoleteLans)
{
obsoleteLans.clear();
// For every element in the sub-partition list of [level][partition]
for (size_t i = 0; i < m_levelMakeup[level][partition].size(); ++i)
{
// oldPartition is the number of a sub-partition
size_t oldPartition = m_levelMakeup[level][partition][i];
for (size_t j = 0; j < oldBorderLans[oldPartition].size(); ++j)
{
......@@ -180,6 +187,10 @@ void NetRouter::calculateBorders(size_t level, size_t partition)
{
newBorderLans[partition].push_back(currentLanIndex);
}
else
{
obsoleteLans.push_back(currentLanIndex);
}
}
}
}
......@@ -449,6 +460,16 @@ void NetRouter::findRouteToPartition(NodeBorderMap::iterator searchPos,
}
}
void NetRouter::removeObsoleteConnections(list<size_t> const & obsoleteLans)
{
list<size_t>::const_iterator pos = obsoleteLans.begin();
list<size_t>::const_iterator limit = obsoleteLans.end();
for ( ; pos != limit; ++pos)
{
removeBorderLan(*pos);
}
}
void NetRouter::calculateInterBorders(void)
{
for (size_t i = 0; i < m_nodeToLevel[0].size(); ++i)
......
......@@ -79,12 +79,16 @@ private:
NodeBorderMap::iterator searchLimit,
size_t sourceNode, size_t newPartition,
size_t destinationLan);
void calculateBorders(size_t level, size_t partition);
void calculateBorders(size_t level, size_t partition,
std::list<size_t> & obsoleteLans);
void calculatePartitionRoutes(size_t level, size_t partition);
void findRouteToPartition(NodeBorderMap::iterator searchPos,
NodeBorderMap::iterator searchLimit,
size_t sourceNode, size_t sourcePartition,
size_t destPartition, size_t level);
// given a list of LANs which we no longer care about, remove all
// connections that involve them from the ConnectionMap.
void removeObsoleteConnections(std::list<size_t> const & obsoleteLans);
void calculateInterBorders(void);
private:
// partition< borderList >
......
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