11 #include <unordered_map>
27 for(
int l=0;
l<nLinks;
l++) {
38 for(
int i=0;
i<height;
i++) {
39 for(
int j=0;j<width;j++) inFile >>
dummy;
42 int srcvol_id =
src / 1000;
43 int dstvol_id =
src / 1000;
45 bool srcIsStrip = (srcvol_id == 13 || srcvol_id == 12 || srcvol_id == 14);
46 bool dstIsStrip = (dstvol_id == 13 || dstvol_id == 12 || dstvol_id == 14);
48 if ( !srcIsStrip || !dstIsStrip) {
53 if ( srcIsStrip || dstIsStrip) {
62 std::vector<GNN_FASTRACK_CONNECTION*>
v = {pC};
64 }
else (*it).second.push_back(pC);
69 std::list<const GNN_FASTRACK_CONNECTION*> lConns;
71 std::map<int, std::vector<const GNN_FASTRACK_CONNECTION*> > newConnMap;
79 while(!lConns.empty()) {
81 std::unordered_map<unsigned int, std::pair<int, int> > mCounter;
83 for(
const auto&
conn : lConns) {
84 auto entryIt = mCounter.find(
conn->m_dst);
85 if(entryIt != mCounter.end()) {
86 (*entryIt).second.first++;
91 mCounter.insert(std::make_pair(
conn->m_dst, std::make_pair(nDst, nSrc)));
94 entryIt = mCounter.find(
conn->m_src);
95 if(entryIt != mCounter.end()) {
96 (*entryIt).second.second++;
101 mCounter.insert(std::make_pair(
conn->m_src, std::make_pair(nDst, nSrc)));
107 std::set<unsigned int> zeroLayers;
109 for(
const auto& layerCounts : mCounter) {
111 if(layerCounts.second.second!=0)
continue;
113 zeroLayers.insert(layerCounts.first);
118 std::vector<const GNN_FASTRACK_CONNECTION*> theStage;
122 while(cIt!=lConns.end()) {
123 if(zeroLayers.find((*cIt)->m_dst) != zeroLayers.end()) {
124 theStage.push_back(*cIt);
125 cIt = lConns.erase(cIt);
130 newConnMap.insert(std::make_pair(stageCounter, theStage));
136 int currentStage = 0;
140 for(std::map<
int, std::vector<const GNN_FASTRACK_CONNECTION*> >::reverse_iterator
it = newConnMap.rbegin();
it!=newConnMap.rend();++
it, currentStage++) {
142 const std::vector<const GNN_FASTRACK_CONNECTION*> & vConn = (*it).second;
146 std::map<unsigned int, std::vector<const GNN_FASTRACK_CONNECTION*> > l1ConnMap;
148 for(
const auto*
conn : vConn) {
150 unsigned int dst =
conn->m_dst;
152 std::map<unsigned int, std::vector<const GNN_FASTRACK_CONNECTION*> >
::iterator l1MapIt = l1ConnMap.find(dst);
153 if(l1MapIt != l1ConnMap.end())
154 (*l1MapIt).second.push_back(
conn);
156 std::vector<const GNN_FASTRACK_CONNECTION*>
v = {
conn};
157 l1ConnMap.insert(std::make_pair(dst,
v));
161 std::vector<LayerGroup> lgv;
163 lgv.reserve(l1ConnMap.size());
165 for(
const auto& l1Group : l1ConnMap) {
166 lgv.push_back(
LayerGroup(l1Group.first, l1Group.second));
181 for(
auto& link :
conn.second)
delete link;