torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
torc::router::PathFinder Class Reference

#include <PathFinder.hpp>

+ Inheritance diagram for torc::router::PathFinder:
+ Collaboration diagram for torc::router::PathFinder:

Public Member Functions

 PathFinder (DDB &inDB, NetVectorRouterHeuristicBase *inHeuristic, NetRouterBase *inNetRouter)
 Pathfinder constructor. More...
 
 ~PathFinder ()
 Destructor. More...
 
void routeNets (RouteNetVector &nets)
 
void unrouteNet (RouteNodePtrVector &routeVector, const string &netname)
 
void updateSharing (RouteNodePtrVector &outRoute)
 
void updateSharing (const Tilewire &inTilewire)
 
void recordResult (std::vector< RouteNodePtrVector > &outRoutes, std::vector< RouteNodePtrVector > &tempRoutes, std::vector< unsigned int > &priorities, unsigned int plevel)
 
void recordResult (RouteNodePtrVector &outRoute, RouteNodePtrVector &tempRoute)
 
bool testReroute (RouteNodePtrVector &currentRoute)
 
void unmarkSourcesAndSinks (RouteNet &net)
 
void markSourcesAndSinks (RouteNet &net)
 
void route (RouteNetVector &inNets)
 Primary route call. More...
 
NetVectorRouterHeuristicBasegetHeuristic ()
 Accessor for the heuristic. More...
 
void setHeuristic (NetVectorRouterHeuristicBase *inHeuristic)
 Set method for the heuristic. More...
 
NetRouterBasegetNetRouter ()
 Accessor for the underlying Net Router. More...
 
void setNetRouter (NetRouterBase *inNetRouter)
 Set method for the net router. More...
 

Protected Attributes

PathFinderSharingMap mConflicts
 
WireUsage mConflictWireUsage
 
TilewireVector mTempWireSources
 
TilewireVector mTempWireSinks
 
boost::timer routetimer
 
boost::timer iterationtimer
 
boost::timer totaltimer
 
boost::timer updatetimer
 
long deleteCount
 
DDBmDB
 Database reference. More...
 
NetVectorRouterHeuristicBasemHeuristic
 Pointer to the heuristic for making routing decisions. More...
 
NetRouterBasemNetRouter
 Pointer to the underlying net router. More...
 
boost::timer mRouteTimer
 Timer object for performance analysis. More...
 
double mTotalRouteTime
 Total routing time since construction. More...
 

Private Types

typedef std::string string
 
typedef architecture::DDB DDB
 
typedef architecture::WireUsage WireUsage
 
typedef architecture::Tilewire Tilewire
 
typedef architecture::Arc Arc
 
typedef
architecture::TilewireVector 
TilewireVector
 
typedef
TilewireVector::const_iterator 
TilewireConstIterator
 
typedef boost::unordered_map
< Tilewire, TilewireData
PathFinderSharingMap
 

Detailed Description

Definition at line 50 of file PathFinder.hpp.

Member Typedef Documentation

Definition at line 56 of file PathFinder.hpp.

Definition at line 53 of file PathFinder.hpp.

Definition at line 60 of file PathFinder.hpp.

typedef std::string torc::router::PathFinder::string
private

Definition at line 52 of file PathFinder.hpp.

Definition at line 55 of file PathFinder.hpp.

typedef TilewireVector::const_iterator torc::router::PathFinder::TilewireConstIterator
private

Definition at line 58 of file PathFinder.hpp.

Constructor & Destructor Documentation

torc::router::PathFinder::PathFinder ( DDB inDB,
NetVectorRouterHeuristicBase inHeuristic,
NetRouterBase inNetRouter 
)
inline

Pathfinder constructor.

Definition at line 79 of file PathFinder.hpp.

80  : NetVectorRouterBase(inDB, inHeuristic, inNetRouter),
82 
83  mTempWireSources.reserve(200);
84  mTempWireSinks.reserve(200);
85  mTempWireSources.clear();
86  mTempWireSinks.clear();
87  deleteCount = 0;
88 
92  }
TilewireVector mTempWireSinks
Definition: PathFinder.hpp:68
TilewireVector mTempWireSources
Definition: PathFinder.hpp:67
const Tiles & getTiles(void) const
Returns a constant reference to the family and device tile data.
Definition: DDB.hpp:146
NetRouterBase * mNetRouter
Pointer to the underlying net router.
void setParameter(boost::uint32_t index, boost::any inParameter)
Set a parameter.
NetRouterHeuristicBase * getHeuristic()
Get the current heuristic.
virtual void processParameters()
Do something with the parameters.
PathFinderSharingMap mConflicts
Definition: PathFinder.hpp:64
NetVectorRouterBase(DDB &inDB, NetVectorRouterHeuristicBase *inHeuristic, NetRouterBase *inNetRouter)
Public Constructor.
void autosize(void)
Size the wire usage according to the number of device tiles.
Definition: WireUsage.hpp:68

+ Here is the call graph for this function:

torc::router::PathFinder::~PathFinder ( )
inline

Destructor.

Definition at line 95 of file PathFinder.hpp.

95 {}

Member Function Documentation

NetVectorRouterHeuristicBase* torc::router::NetVectorRouterBase::getHeuristic ( )
inlineinherited

Accessor for the heuristic.

Definition at line 78 of file NetVectorRouterBase.hpp.

78 { return mHeuristic; }
NetVectorRouterHeuristicBase * mHeuristic
Pointer to the heuristic for making routing decisions.
NetRouterBase* torc::router::NetVectorRouterBase::getNetRouter ( )
inlineinherited

Accessor for the underlying Net Router.

Definition at line 82 of file NetVectorRouterBase.hpp.

82 { return mNetRouter; }
NetRouterBase * mNetRouter
Pointer to the underlying net router.
void torc::router::PathFinder::markSourcesAndSinks ( RouteNet net)
inline

Definition at line 355 of file PathFinder.hpp.

356  {
357  mDB.useSegment(*net.sourcesBegin());
359  RouteNet::TilewireConstIterator e = net.sinksEnd();
360  for (p = net.sinksBegin(); p != e; p++) {
361  mDB.useSegment(*p);
362  }
363  }
TilewireVector::const_iterator TilewireConstIterator
Definition: RouteNet.hpp:51
void useSegment(const Tilewire &inTilewire)
Marks all wires on the segment as used.
Definition: DDB.hpp:185

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::router::PathFinder::recordResult ( std::vector< RouteNodePtrVector > &  outRoutes,
std::vector< RouteNodePtrVector > &  tempRoutes,
std::vector< unsigned int > &  priorities,
unsigned int  plevel 
)
inline

Definition at line 317 of file PathFinder.hpp.

319  {
320  if (outRoutes.size() != tempRoutes.size()) {
321  std::cout << "BAD SIZE: " << outRoutes.size() << " " << tempRoutes.size() << std::endl;
322  return;
323  }
324  for (unsigned int i = 0; i < outRoutes.size(); i++) {
325  recordResult(outRoutes[i], tempRoutes[i]);
326  }
327  }
void recordResult(std::vector< RouteNodePtrVector > &outRoutes, std::vector< RouteNodePtrVector > &tempRoutes, std::vector< unsigned int > &priorities, unsigned int plevel)
Definition: PathFinder.hpp:317
void torc::router::PathFinder::recordResult ( RouteNodePtrVector outRoute,
RouteNodePtrVector tempRoute 
)
inline

Definition at line 328 of file PathFinder.hpp.

328  {
329  Arc arc;
330  for (unsigned int i = 0; i < tempRoute.size(); i++) {
331  outRoute.push_back(tempRoute[i]);
332  arc = tempRoute[i]->getArc();
333  mDB.useArc(arc);
334  }
335  }
void useArc(const Arc &inArc)
Marks the arc and all of its source and sink segment wires as used.
Definition: DDB.hpp:173
architecture::Arc Arc
Definition: PathFinder.hpp:56

+ Here is the call graph for this function:

void torc::router::NetVectorRouterBase::route ( RouteNetVector inNets)
inlineinherited

Primary route call.

Definition at line 72 of file NetVectorRouterBase.hpp.

72  {
73  mRouteTimer.restart();
74  routeNets(inNets);
75  mTotalRouteTime += mRouteTimer.elapsed();
76  }
boost::timer mRouteTimer
Timer object for performance analysis.
virtual void routeNets(RouteNetVector &inNets)=0
brief protected routing call
double mTotalRouteTime
Total routing time since construction.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::router::PathFinder::routeNets ( RouteNetVector nets)
inlinevirtual

Implements torc::router::NetVectorRouterBase.

Definition at line 97 of file PathFinder.hpp.

97  {
98 
99  bool flag_resources = true;
100 
101  unsigned int numNets = nets.size();
102 
103  flag_resources = true;
104 
105  int routingPasses = 0;
106 
107 
108  // Initial Routes
109  totaltimer.restart();
110  double updatetime = 0;
111  iterationtimer.restart();
112  for (unsigned int i = 0; i < numNets; i++) {
113  RouteNet& net = nets[i];
114 
115  //double routetime;
116  if (!(net.hasOneSource() && net.hasAnySinks())) {
117  std::cout << "BAD NET: " << net.getName() << std::endl;
118  continue;
119  }
120  try {
121  //std::cout << "### Routing net " << net.getName() << " "
122  // << " index: " << i << " of " << numNets
123  // << std::endl;
124  routetimer.restart();
126  mNetRouter->route(net);
127  markSourcesAndSinks(net);
128  updateSharing(net.routeNodes());
129  //routetime = routetimer.elapsed();
130  }
131  catch (...) {
132  std::cout << "Failed routing net " << i << ": " << std::endl;
133  throw;
134  }
136  }
137 
138  mConflicts.clear();
139  std::cout << "Initial routes time: " << iterationtimer.elapsed() << std::endl;
140 
141  for (unsigned int i = 0; i < numNets; i++) {
142  for (unsigned int j = 0; j < nets[i].routeNodes().size(); j++) {
143  updateSharing(nets[i].routeNodes()[j]->getSinkTilewire());
144  }
145  }
146 
147  // Main Loop
148  while (flag_resources) { // while shared resources exist
149  iterationtimer.restart();
150  std::cout << "." << std::flush;
151 
152  double avgroutetime = 0;
153  double minroutetime = std::numeric_limits<double>::max();
154  double maxroutetime = std::numeric_limits<double>::min();
155  double routetime;
156  int netsRouted = 0;
157 
158  for (unsigned int n = 0; n < numNets; n++) { //for each net
159  RouteNet& net = nets[n];
160  routetimer.restart();
161  //if (testReroute(nets[n].routeNodes())) {
162  if (true) {
163 
164  unrouteNet(net.routeNodes(), net.getName());
165 
166  try {
168  mNetRouter->route(net);
169  markSourcesAndSinks(net);
170  updateSharing(net.routeNodes());
171  }
172  catch (...) {
173  std::cout << "Failed routing net " << net.getName() << " index: "
174  << n << " of " << nets.size() << std::endl;
175  throw;
176  }
177 
178  routetime = routetimer.elapsed();
179 
180  if (routetime < minroutetime)
181  minroutetime = routetime;
182  if (routetime > maxroutetime)
183  maxroutetime = routetime;
184  avgroutetime += routetime;
185  netsRouted++;
186  }
187  }
188  avgroutetime = avgroutetime / netsRouted;
189 
190  updatetimer.restart();
191  PathFinderSharingMap::iterator p;
192  unsigned int conflicts = 0;
193  unsigned int maxpresent = 0;
194  unsigned int maxhistory = 0;
195  Tilewire maxPresentTilewire;
196  Tilewire maxHistoryTilewire;
197  for (p = mConflicts.begin(); p != mConflicts.end(); p++)
198  {
199  if ((*p).second.mPresentSharing > 1)
200  {
201  (*p).second.mHistorySharing += (*p).second.mPresentSharing;
202  conflicts++;
203  }
204 
205  if ((*p).second.mPresentSharing > maxpresent)
206  {
207  maxpresent = (*p).second.mPresentSharing;
208  maxPresentTilewire = (*p).first;
209  }
210  if ((*p).second.mHistorySharing > maxhistory)
211  {
212  maxhistory = (*p).second.mHistorySharing;
213  maxHistoryTilewire = (*p).first;
214  }
215  }
216  updatetime += updatetimer.elapsed();
217 
218 // std::cout << "Conflicts this iteration: " << conflicts << " max present: "
219 // << maxpresent << " max history: " << maxhistory << std::endl;
220 // std::cout << "Total conflict records: " << mConflicts.size() << std::endl;
221 // std::cout << "Nets rerouted: " << netsRouted << "/" << numNets << std::endl;
222 // std::cout << "Total time: " << totaltimer.elapsed()
223 // << " iteration time: " << iterationtimer.elapsed()
224 // << " average route time: " << avgroutetime
225 // << " total update time: " << updatetime
226 // << std::endl;
227 
228  if (netsRouted == 1) {
229  flag_resources = false;
230  for (unsigned int i = 0; i < numNets; i++) {
231  RouteNet& net = nets[i];
232  if (testReroute(net.routeNodes())) {
233  std::cout << "FOUND SELF CONFLICT NET: " << net.getName() << std::endl;
234  std::cout << mDB;
235  for (unsigned int j = 0; j < net.routeNodes().size(); j++) {
236  std::cout << "\t" << net.routeNodes()[j]->getArc() << std::endl;
237  }
238  }
239  }
240  }
241 
242 // std::cout << "Max Present Tilewire: " << maxPresentTilewire
243 // << " Max History Tilewire: " << maxHistoryTilewire << std::endl;
244 
245  if (conflicts == 0) flag_resources = false;
246  routingPasses++;
247  } // end iteraton while loop
248  std::cout << std::endl;
249  std::cout << "Total time: " << totaltimer.elapsed() << " Update time: " << updatetime
250  << std::endl;
251 
252 // std::cout << "RECORD RESULT" << std::endl;
253  } // end of function
boost::timer updatetimer
Definition: PathFinder.hpp:73
bool testReroute(RouteNodePtrVector &currentRoute)
Definition: PathFinder.hpp:337
NetRouterBase * mNetRouter
Pointer to the underlying net router.
void unmarkSourcesAndSinks(RouteNet &net)
Definition: PathFinder.hpp:347
void clear(void)
Marks all wires as being unused, without releasing the bitset objects.
Definition: WireUsage.hpp:121
boost::timer iterationtimer
Definition: PathFinder.hpp:71
void updateSharing(RouteNodePtrVector &outRoute)
Definition: PathFinder.hpp:289
PathFinderSharingMap mConflicts
Definition: PathFinder.hpp:64
architecture::Tilewire Tilewire
Definition: PathFinder.hpp:55
void route(RouteNet &inNet)
Primary route call.
void unrouteNet(RouteNodePtrVector &routeVector, const string &netname)
Definition: PathFinder.hpp:255
void markSourcesAndSinks(RouteNet &net)
Definition: PathFinder.hpp:355

+ Here is the call graph for this function:

void torc::router::NetVectorRouterBase::setHeuristic ( NetVectorRouterHeuristicBase inHeuristic)
inlineinherited

Set method for the heuristic.

Definition at line 80 of file NetVectorRouterBase.hpp.

80 { mHeuristic = inHeuristic; }
NetVectorRouterHeuristicBase * mHeuristic
Pointer to the heuristic for making routing decisions.
void torc::router::NetVectorRouterBase::setNetRouter ( NetRouterBase inNetRouter)
inlineinherited

Set method for the net router.

Definition at line 84 of file NetVectorRouterBase.hpp.

84 { mNetRouter = inNetRouter; }
NetRouterBase * mNetRouter
Pointer to the underlying net router.
bool torc::router::PathFinder::testReroute ( RouteNodePtrVector currentRoute)
inline

Definition at line 337 of file PathFinder.hpp.

337  {
338  for (unsigned int i = 0; i < currentRoute.size(); i++) {
339  if (mConflicts.find(currentRoute[i]->getSinkTilewire()) != mConflicts.end()
340  && mConflicts[currentRoute[i]->getSinkTilewire()].mPresentSharing > 1) {
341  return true;
342  }
343  }
344  return false;
345  }
PathFinderSharingMap mConflicts
Definition: PathFinder.hpp:64

+ Here is the caller graph for this function:

void torc::router::PathFinder::unmarkSourcesAndSinks ( RouteNet net)
inline

Definition at line 347 of file PathFinder.hpp.

347  {
348  mDB.releaseSegment(*net.sourcesBegin());
350  RouteNet::TilewireConstIterator e = net.sinksEnd();
351  for (p = net.sinksBegin(); p != e; p++) {
352  mDB.releaseSegment(*p);
353  }
354  }
TilewireVector::const_iterator TilewireConstIterator
Definition: RouteNet.hpp:51
void releaseSegment(const Tilewire &inTilewire)
Marks all wires on the segment as unused.
Definition: DDB.hpp:193

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::router::PathFinder::unrouteNet ( RouteNodePtrVector routeVector,
const string netname 
)
inline

Definition at line 255 of file PathFinder.hpp.

256  {
257  int rVecSize = routeVector.size();
258  for (int x = 0; x < rVecSize; x++)
259  {
260  mTempWireSources.clear();
261  mDB.expandSegment(routeVector[x]->getSinkTilewire(), mTempWireSources);
262  int numWireSources = mTempWireSources.size();
263  for (int i = 0; i < numWireSources; i++)
264  {
265  Tilewire tw = mTempWireSources[i];
266  if (mConflicts.find(tw) != mConflicts.end())
267  {
268  mConflicts[tw].mPresentSharing--;
269  if (mConflicts[tw].mPresentSharing == 0)
270  {
272  }
273  if (mConflicts[tw].mPresentSharing < 0)
274  {
275  std::cout << "ERROR PRESENT: " << tw << " net " << netname << std::endl;
276  throw;
277  }
278  }
279  else
280  {
282  }
283  }
284  delete routeVector[x];
285  deleteCount++;
286  }
287  routeVector.clear();
288  }
TilewireVector mTempWireSources
Definition: PathFinder.hpp:67
PathFinderSharingMap mConflicts
Definition: PathFinder.hpp:64
architecture::Tilewire Tilewire
Definition: PathFinder.hpp:55
void release(const Tilewire &inTilewire)
Marks the specified tilewire as being unused.
Definition: WireUsage.hpp:104
void expandSegment(const Tilewire &inTilewire, TilewireVector &outTilewires, EExpandDirection inExpandDirection=eExpandDirectionNone)
Expands the given tilewire's segment.
Definition: DDB.cpp:154

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::router::PathFinder::updateSharing ( RouteNodePtrVector outRoute)
inline

Definition at line 289 of file PathFinder.hpp.

289  {
290  for (unsigned int i = 0; i < outRoute.size(); i++) {
291  updateSharing(outRoute[i]->getSinkTilewire());
292  }
293  }
void updateSharing(RouteNodePtrVector &outRoute)
Definition: PathFinder.hpp:289

+ Here is the caller graph for this function:

void torc::router::PathFinder::updateSharing ( const Tilewire inTilewire)
inline

Definition at line 294 of file PathFinder.hpp.

294  {
295  mTempWireSources.clear();
296  mDB.expandSegment(inTilewire, mTempWireSources);
297  int numWireSources = mTempWireSources.size();
298  for (int i = 0; i < numWireSources; i++) {
299  Tilewire tw = mTempWireSources[i];
300  if (mConflictWireUsage.isUsed(tw)) {
301  if (mConflicts.find(tw) != mConflicts.end()) {
302  mConflicts[tw].mPresentSharing++;
303  } else {
304  mConflicts[tw].mPresentSharing = 2;
305  mConflicts[tw].mHistorySharing = 0;
306  }
307  } else {
308  if (mConflicts.find(tw) != mConflicts.end()) {
309  mConflicts[tw].mPresentSharing++;
310  }
312  }
313  }
314 
315  }
TilewireVector mTempWireSources
Definition: PathFinder.hpp:67
void use(const Tilewire &inTilewire)
Marks the specified tilewire as being used.
Definition: WireUsage.hpp:81
PathFinderSharingMap mConflicts
Definition: PathFinder.hpp:64
architecture::Tilewire Tilewire
Definition: PathFinder.hpp:55
bool isUsed(const Tilewire &inTilewire)
Determines whether the specified tilewire is in use.
Definition: WireUsage.hpp:138
void expandSegment(const Tilewire &inTilewire, TilewireVector &outTilewires, EExpandDirection inExpandDirection=eExpandDirectionNone)
Expands the given tilewire's segment.
Definition: DDB.cpp:154

+ Here is the call graph for this function:

Field Documentation

long torc::router::PathFinder::deleteCount
protected

Definition at line 75 of file PathFinder.hpp.

boost::timer torc::router::PathFinder::iterationtimer
protected

Definition at line 71 of file PathFinder.hpp.

PathFinderSharingMap torc::router::PathFinder::mConflicts
protected

Definition at line 64 of file PathFinder.hpp.

WireUsage torc::router::PathFinder::mConflictWireUsage
protected

Definition at line 65 of file PathFinder.hpp.

DDB& torc::router::NetVectorRouterBase::mDB
protectedinherited

Database reference.

Definition at line 50 of file NetVectorRouterBase.hpp.

NetVectorRouterHeuristicBase* torc::router::NetVectorRouterBase::mHeuristic
protectedinherited

Pointer to the heuristic for making routing decisions.

Definition at line 52 of file NetVectorRouterBase.hpp.

NetRouterBase* torc::router::NetVectorRouterBase::mNetRouter
protectedinherited

Pointer to the underlying net router.

Definition at line 54 of file NetVectorRouterBase.hpp.

boost::timer torc::router::NetVectorRouterBase::mRouteTimer
protectedinherited

Timer object for performance analysis.

Definition at line 56 of file NetVectorRouterBase.hpp.

TilewireVector torc::router::PathFinder::mTempWireSinks
protected

Definition at line 68 of file PathFinder.hpp.

TilewireVector torc::router::PathFinder::mTempWireSources
protected

Definition at line 67 of file PathFinder.hpp.

double torc::router::NetVectorRouterBase::mTotalRouteTime
protectedinherited

Total routing time since construction.

Definition at line 58 of file NetVectorRouterBase.hpp.

boost::timer torc::router::PathFinder::routetimer
protected

Definition at line 70 of file PathFinder.hpp.

boost::timer torc::router::PathFinder::totaltimer
protected

Definition at line 72 of file PathFinder.hpp.

boost::timer torc::router::PathFinder::updatetimer
protected

Definition at line 73 of file PathFinder.hpp.


The documentation for this class was generated from the following file: