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

Wrapper of the Design for placing the design. More...

#include <Placement.hpp>

+ Collaboration diagram for torc::placer::Placement:

Public Member Functions

 Placement (DeviceWrapper &inDevice, DesignSharedPtr inDesign)
 
 ~Placement ()
 
void initialPlacement ()
 
void writePlacementToDesign ()
 
uint32 getCost ()
 
void updateCostFull (bool debug)
 
bool randomMove (bool debug)
 
void undoMove (bool debug)
 
void updateCostRemoveInstances (InstanceSharedPtrVector &inInstances)
 
void updateCostRemovePair (InstanceSharedPtr inInstance1, InstanceSharedPtr inInstance2)
 
void updateCostAddInstances (InstanceSharedPtrVector &inInstances)
 
void updateCostAddPair (InstanceSharedPtr inInstance1, InstanceSharedPtr inInstance2)
 
void updateCostHelper (InstanceSharedPtrVector &inInstances, bool addCost)
 
void updateCostHelper (InstanceSharedPtr inInstance1, InstanceSharedPtr inInstance2, bool addCost)
 
uint32 getNetCost (NetSharedPtr inNet)
 

Protected Types

typedef architecture::DDB DDB
 
typedef architecture::Sites Sites
 
typedef architecture::Site Site
 
typedef std::vector< const Site * > SitePtrVector
 
typedef std::vector
< SitePtrVector
SitePtrVectorVector
 
typedef physical::DesignSharedPtr DesignSharedPtr
 
typedef boost::uint32_t uint32
 
typedef boost::uint64_t uint64
 
typedef physical::ENetType ENetType
 
typedef physical::NetSharedPtr NetSharedPtr
 
typedef
physical::NetSharedPtrVector 
NetSharedPtrVector
 
typedef physical::InstanceSharedPtr InstanceSharedPtr
 
typedef
physical::InstanceSharedPtrVector 
InstanceSharedPtrVector
 
typedef std::vector
< InstanceSharedPtrVector
InstanceSharedPtrVectorVector
 
typedef
physical::InstancePinSharedPtr 
InstancePinSharedPtr
 
typedef
physical::InstancePinSharedPtrVector 
InstancePinSharedPtrVector
 
typedef boost::unordered_map
< const Site *, uint32
SitePtrToIntMap
 
typedef boost::unordered_map
< const Site
*, InstanceSharedPtr
SitePtrToInstanceSharedPtrMap
 
typedef boost::unordered_map
< InstanceSharedPtr, Site * > 
InstanceSharedPtrToSitePtrMap
 
typedef boost::mt19937 mt19937
 
typedef boost::uniform_int
< uint32
uinform_range
 
typedef
boost::variate_generator
< mt19937 &, uinform_range
random_generator
 

Protected Attributes

DeviceWrappermDevice
 
DesignSharedPtr mDesign
 
const architecture::Array
< const Site > & 
mAllSites
 
SitePtrVectorVector mAllSitesByType
 
SitePtrVectorVector mCandidatesByType
 
SitePtrToIntMap mSiteTypeLookup
 
SitePtrToInstanceSharedPtrMap mAssignedSites
 
InstanceSharedPtrVector mAllInstances
 
InstanceSharedPtrVectorVector mAllInstancesByType
 
NetSharedPtrVector mAllNets
 
boost::mt19937 mRandomSource
 
boost::uniform_int< uint32mUniformInstanceRange
 
boost::variate_generator
< mt19937
&, boost::uniform_int< uint32 > > 
mInstanceRandomGen
 
std::vector
< boost::uniform_int< uint32 > > 
mUniformTypeRanges
 
std::vector
< boost::variate_generator
< mt19937
&, boost::uniform_int< uint32 > > * > 
mTypeRandomGen
 
uint32 mCost
 
bool mDebug
 
InstanceSharedPtr mSelectedInstance
 
InstanceSharedPtr mEvictedInstance
 
SitemDepartureSite
 
SitemTargetSite
 

Detailed Description

Wrapper of the Design for placing the design.

Definition at line 39 of file Placement.hpp.

Member Typedef Documentation

Definition at line 42 of file Placement.hpp.

Definition at line 52 of file Placement.hpp.

Definition at line 63 of file Placement.hpp.

Definition at line 57 of file Placement.hpp.

typedef boost::mt19937 torc::placer::Placement::mt19937
protected

Definition at line 65 of file Placement.hpp.

Definition at line 53 of file Placement.hpp.

typedef boost::variate_generator<mt19937&, uinform_range> torc::placer::Placement::random_generator
protected

Definition at line 67 of file Placement.hpp.

Definition at line 44 of file Placement.hpp.

typedef boost::unordered_map<const Site*, InstanceSharedPtr> torc::placer::Placement::SitePtrToInstanceSharedPtrMap
protected

Definition at line 62 of file Placement.hpp.

typedef boost::unordered_map<const Site*, uint32> torc::placer::Placement::SitePtrToIntMap
protected

Definition at line 61 of file Placement.hpp.

typedef std::vector<const Site*> torc::placer::Placement::SitePtrVector
protected

Definition at line 45 of file Placement.hpp.

Definition at line 46 of file Placement.hpp.

Definition at line 43 of file Placement.hpp.

typedef boost::uniform_int<uint32> torc::placer::Placement::uinform_range
protected

Definition at line 66 of file Placement.hpp.

typedef boost::uint32_t torc::placer::Placement::uint32
protected

Definition at line 49 of file Placement.hpp.

typedef boost::uint64_t torc::placer::Placement::uint64
protected

Definition at line 50 of file Placement.hpp.

Constructor & Destructor Documentation

torc::placer::Placement::Placement ( DeviceWrapper inDevice,
DesignSharedPtr  inDesign 
)
inline

Definition at line 126 of file Placement.hpp.

127  : mDevice(inDevice), mDesign(inDesign), mAllSites(mDevice.mSites.getSites()),
128  mRandomSource(42), mUniformInstanceRange(0, mDesign->getInstanceCount() - 1),
130  mCost(0), mDebug(false) {
131 std::cout << "PLACEMENT CONSTRUCTOR" << std::endl;
132  // type preparation
133  for (uint32 t = 0; t < mDevice.mSites.getSiteTypeCount(); t++) {
134  mAllSitesByType.push_back(SitePtrVector());
135  mCandidatesByType.push_back(SitePtrVector());
137  }
138 std::cout << "Prepped for " << mDevice.mSites.getSiteTypeCount() << " types" << std::endl;
139 
140 
141  // instance setup
142  InstanceSharedPtrVector::iterator p = mDesign->instancesBegin();
143  InstanceSharedPtrVector::iterator e = mDesign->instancesEnd();
144  for ( ; p != e; p++) {
145  InstanceSharedPtr instance = *p;
146  uint32 typeIndex = mDevice.mTypeMapping.getTypeIndex(instance->getType());
147  instance->setAnnotation(ePlacerInstanceTypeIndex, typeIndex);
148 
149  mAllInstances.push_back(instance);
150  mAllInstancesByType[typeIndex].push_back(instance);
151  }
152 
153  // net setup
154  NetSharedPtrVector::iterator q = mDesign->netsBegin();
155  NetSharedPtrVector::iterator f = mDesign->netsEnd();
156  for ( ; q != f; q++) {
157  NetSharedPtr net = *q;
158  mAllNets.push_back(net);
159  }
160 
161  uint32 a = 0;
162  for (uint32 i = 0; i < mAllInstancesByType.size(); i++) {
163  uint32 b = mAllInstancesByType[i].size();
164  if (b != 0)
165  std::cout << mDevice.mTypeMapping.getName(i) << ": " << b << std::endl;
166  a += b;
167 
168  }
169  std::cout << "Summary INSTANCES: " << a << " = " << mAllInstances.size() << std::endl;
170 
171  // site population
172 std::cout << "There are " << mAllSites.getSize() << " sites" << std::endl;
173  for (uint32 i = 0; i < mAllSites.getSize(); i++) {
174 
175  const architecture::Site& site = mAllSites[i];
176  //SiteSharedPtr ssp(site);
177  const architecture::PrimitiveDef* siteType = site.getPrimitiveDefPtr();
178  uint32 typeIndex = mDevice.mTypeMapping.getTypeIndex(siteType->getName());
179  std::vector<uint32>& map = mDevice.mTypeMapping.getLegalInstancesForSite(typeIndex);
180 
181  //mAllSites.push_back(site);
182  mAllSitesByType[typeIndex].push_back(&site);
183  mSiteTypeLookup[&site] = typeIndex;
184 
185  // for each instance type that can map to this site, put it in as a candidate
186  for (uint32 j = 0; j < map.size(); j++) {
187  mCandidatesByType[map[j]].push_back(&site);
188  }
189  }
190 
191  //mRandomSource, mUniformInstanceRange, mInstanceRandomGen already set up in init list
192  for (uint32 i = 0; i < mCandidatesByType.size(); i++) {
193  uint32 x = mCandidatesByType[i].size();
194  mUniformTypeRanges.push_back(boost::uniform_int<uint32>(0, x - 1));
195 
196  mTypeRandomGen.push_back(new boost::variate_generator<mt19937&,
197  boost::uniform_int<uint32> >(mRandomSource, mUniformTypeRanges[i]));
198  }
199 
200  for (uint32 t = 0; t < mDevice.mSites.getSiteTypeCount(); t++) {
201  std::cout << mDevice.mTypeMapping.getName(t) << " has "
202  << mAllSitesByType[t].size() << " sites, " << mCandidatesByType[t].size()
203  << " is the candidate count for this type" << std::endl;
204  }
205 
207 
208  }
std::vector< boost::uniform_int< uint32 > > mUniformTypeRanges
Definition: Placement.hpp:109
DesignSharedPtr mDesign
Definition: Placement.hpp:79
const std::string & getName(uint32 inIndex)
std::vector< uint32 > & getLegalInstancesForSite(uint32 inSiteTypeIndex)
SitePtrVectorVector mCandidatesByType
Definition: Placement.hpp:88
physical::NetSharedPtr NetSharedPtr
Definition: Placement.hpp:53
boost::uint32_t uint32
Definition: Placement.hpp:49
boost::mt19937 mRandomSource
Definition: Placement.hpp:105
boost::uniform_int< uint32 > mUniformInstanceRange
Definition: Placement.hpp:106
const Array< const Site > & getSites(void) const
Returns the sites for this family.
Definition: Sites.hpp:127
physical::InstanceSharedPtr InstanceSharedPtr
Definition: Placement.hpp:55
SiteTypeCount getSiteTypeCount(void) const
Returns the site type count for this family.
Definition: Sites.hpp:123
physical::InstanceSharedPtrVector InstanceSharedPtrVector
Definition: Placement.hpp:56
SitePtrVectorVector mAllSitesByType
Definition: Placement.hpp:87
InstanceSharedPtrVector mAllInstances
Definition: Placement.hpp:95
SitePtrToIntMap mSiteTypeLookup
Definition: Placement.hpp:89
std::vector< const Site * > SitePtrVector
Definition: Placement.hpp:45
const architecture::Array< const Site > & mAllSites
Definition: Placement.hpp:86
InstanceSharedPtrVectorVector mAllInstancesByType
Definition: Placement.hpp:96
std::vector< boost::variate_generator< mt19937 &, boost::uniform_int< uint32 > > * > mTypeRandomGen
Definition: Placement.hpp:112
boost::mt19937 mt19937
Definition: Placement.hpp:65
DeviceWrapper & mDevice
Definition: Placement.hpp:73
uint32 getTypeIndex(const std::string &inType)
Get the type index for a given type name, creates a new entry if not found.
PlacementSiteTypeMapping & mTypeMapping
boost::variate_generator< mt19937 &, boost::uniform_int< uint32 > > mInstanceRandomGen
Definition: Placement.hpp:107
NetSharedPtrVector mAllNets
Definition: Placement.hpp:99

+ Here is the call graph for this function:

torc::placer::Placement::~Placement ( )
inline

Definition at line 209 of file Placement.hpp.

209  {
210  }

Member Function Documentation

uint32 torc::placer::Placement::getCost ( )
inline

Definition at line 300 of file Placement.hpp.

300  {
301  return mCost;
302  }

+ Here is the caller graph for this function:

uint32 torc::placer::Placement::getNetCost ( NetSharedPtr  inNet)
inline

Definition at line 517 of file Placement.hpp.

517  {
518  uint32 returnCost = 0;
519 
520  if (mDebug) std::cout << "getNetCost - net : " << inNet->getName() << std::endl;
521  if (inNet->getSourceCount() != 1 || inNet->getSinkCount() < 1) {
522  if (mDebug) std::cout << "\tEmpty!" << std::endl;
523  return returnCost;
524  }
525  if (inNet->getNetType() != physical::eNetTypeNormal) {
526  //std::cout << "Net is not a normal net" << std::endl;
527  return returnCost;
528  }
529  InstancePinSharedPtr pinPtr = *inNet->sourcesBegin();
530  InstanceSharedPtr instance = pinPtr->getInstancePtr().lock();
531  if (mDebug) std::cout << "\tsource instance: " << instance->getName() << std::endl;
532  const Site* site = boost::any_cast<const Site*>(instance->getAnnotation(
534  if (site == NULL) {
535  std::cout << instance->getName() << " doesn't have a site." << std::endl;
536  return returnCost;
537  }
538  if (mDebug) std::cout << "\t\tsource instance site: " << site->getName()
539  << std::endl;
540 
541  uint32 sum = 0;
542 
543  // semiperimeter of bounding rectangle
544  uint32 row1 = mDevice.mDB.getTiles().getTileInfo(site->getTileIndex()).getRow();
545  uint32 col1 = mDevice.mDB.getTiles().getTileInfo(site->getTileIndex()).getCol();
546  uint32 row2 = row1;
547  uint32 col2 = col1;
548  InstancePinSharedPtrVector::iterator p = inNet->sinksBegin();
549  InstancePinSharedPtrVector::iterator e = inNet->sinksEnd();
550  for ( ; p != e; p++) {
551  instance = (*p)->getInstancePtr().lock();
552  if (mDebug) std::cout << "\tsink instance: " << instance->getName() << std::endl;
553  const Site* sinkSite = boost::any_cast<const Site*>(instance->getAnnotation(
555  if (sinkSite == NULL) {
556  std::cout << instance->getName() << " doesn't have a site (sink)."
557  << std::endl;
558  return returnCost;
559  }
560 
561  uint32 trow =
562  mDevice.mDB.getTiles().getTileInfo(sinkSite->getTileIndex()).getRow();
563  uint32 tcol =
564  mDevice.mDB.getTiles().getTileInfo(sinkSite->getTileIndex()).getCol();
565  if (trow < row1) row1 = trow;
566  if (tcol < col1) col1 = tcol;
567  if (trow > row2) row2 = trow;
568  if (tcol > col2) col2 = tcol;
569  }
570  if (mDebug) std::cout << "\t\tcost reported: " << sum << " / " << inNet->getSinkCount()
571  << " = " << ((float)sum / (float)inNet->getSinkCount()) << std::endl;
572  returnCost = (row2 - row1) + (col2 - col1);
573  if (mDebug) std::cout << "\t\t" << mCost << std::endl;
574 
575  return returnCost;
576  }
const Tiles & getTiles(void) const
Returns a constant reference to the family and device tile data.
Definition: DDB.hpp:146
const TileInfo & getTileInfo(TileIndex inTileIndex) const
Returns the TileInfo object for the specified tile.
Definition: Tiles.hpp:137
boost::uint32_t uint32
Definition: Placement.hpp:49
const string & getName(void) const
Returns the site name.
Definition: Site.hpp:79
physical::InstanceSharedPtr InstanceSharedPtr
Definition: Placement.hpp:55
architecture::Site Site
Definition: Placement.hpp:44
physical::InstancePinSharedPtr InstancePinSharedPtr
Definition: Placement.hpp:58
DeviceWrapper & mDevice
Definition: Placement.hpp:73

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::placer::Placement::initialPlacement ( )
inline

Definition at line 211 of file Placement.hpp.

211  {
212  std::cout << "INITIAL PLACEMENT" << std::endl;
213 
214  boost::mt19937 gen;
215 
216  // first place all the instances on
217  // check there are enough
218  // place all instance of site of same type
219  // for overage, check for
220 
221  //std::vector<std::map<uint32, const Site*> > sitesByType;
222  std::vector<std::vector<const Site*> > sitesByType;
223 
224  for (uint32 t = 0; t < mAllSitesByType.size(); t++) {
225  sitesByType.push_back(std::vector<const Site*>());
226  for (uint32 i = 0; i < mAllSitesByType[t].size(); i++) {
227  sitesByType[t].push_back(mAllSitesByType[t][i]);
228  }
229  }
230 
231  // now have a structure with all sites available by type, with easy removal.
232  // THIS IS NOT GOING TO WORK RIGHT FOR VERY FULL DESIGNS!
233  for (uint32 i = 0; i < mAllInstances.size(); i++) {
234  // place each instance
235  InstanceSharedPtr instance = mAllInstances[i];
236 std::cout << "Placing instance: " << instance->getName() << std::endl;
237  //uint32 typeIndex = boost::any_cast<uint32>(
238  // instance->getAnnotation(ePlacerInstanceTypeIndex));
239  uint32 typeIndex = getInstanceTypeIndex(instance);
240 
241 std::cout << "\tInstance type index: " << typeIndex << " ("
242  << mDevice.mTypeMapping.getName(typeIndex) << ")" << std::endl;
243 
244  // check if the instance type index has any sites available, otherwise select from
245  // another site type
246  uint32 siteTypeIndex = typeIndex;
247  if (sitesByType[siteTypeIndex].size() == 0) {
248  //try different legal types until a match is found
249  std::vector<uint32>& map = mDevice.mTypeMapping.getLegalSitesForInstance(
250  siteTypeIndex);
251  for (uint32 j = 0; j < map.size(); j++) {
252  siteTypeIndex = map[j];
253  if (sitesByType[siteTypeIndex].size() > 0) break;
254  }
255  }
256 std::cout << "\tSite type index: " << siteTypeIndex << " ("
257  << mDevice.mTypeMapping.getName(siteTypeIndex) << ")" << std::endl;
258 
259 
260  // get the candidate type indices
261 
262  boost::uniform_int<uint32> range(0, sitesByType[siteTypeIndex].size() - 1);
263  boost::variate_generator<mt19937&, boost::uniform_int<uint32> > random(gen, range);
264 
265  uint32 r = random();
266 std::cout << "\tSelected index " << r << " from " << sitesByType[siteTypeIndex].size() << std::endl;
267 
268  const Site* selectedSite = sitesByType[siteTypeIndex][r];
269 
270 std::cout << "\tSelected Site: " << selectedSite->getName() << std::endl;
271 
272  instance->setAnnotation(ePlacerInstanceSitePtr, selectedSite);
273  mAssignedSites[selectedSite] = instance;
274 //std::cout << "\tSetting: " << instance->getName() << " " << selectedSite->getName() << std::endl;
275 
276 //std::cout << "\tSiteByType size before: " << sitesByType[typeIndex].size() << " ";
277  //sitesByType[siteTypeIndex].erase(r);
278  sitesByType[siteTypeIndex].erase(sitesByType[siteTypeIndex].begin() + r);
279 //std::cout << " and after: " << sitesByType[typeIndex].size() << std::endl;
280 
281  }
282 
283  }
const std::string & getName(uint32 inIndex)
boost::uint32_t uint32
Definition: Placement.hpp:49
const string & getName(void) const
Returns the site name.
Definition: Site.hpp:79
physical::InstanceSharedPtr InstanceSharedPtr
Definition: Placement.hpp:55
SitePtrToInstanceSharedPtrMap mAssignedSites
Definition: Placement.hpp:92
SitePtrVectorVector mAllSitesByType
Definition: Placement.hpp:87
InstanceSharedPtrVector mAllInstances
Definition: Placement.hpp:95
architecture::Site Site
Definition: Placement.hpp:44
DeviceWrapper & mDevice
Definition: Placement.hpp:73
PlacementSiteTypeMapping & mTypeMapping
std::vector< uint32 > & getLegalSitesForInstance(uint32 inInstanceTypeIndex)
boost::uint32_t getInstanceTypeIndex(physical::InstanceSharedPtr inInstance)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool torc::placer::Placement::randomMove ( bool  debug)
inline

Definition at line 365 of file Placement.hpp.

365  {
366  if (debug) std::cout << "randomMove: " << std::endl;
367  // pick a random instance - this will later be weighted
370  if (debug) std::cout << "\tselected inst: "
371  << mSelectedInstance->getName() << std::endl;
372  mDepartureSite = const_cast<Site*>(boost::any_cast<const Site*>(
373  mSelectedInstance->getAnnotation(ePlacerInstanceSitePtr)));
374  if (debug) std::cout << "\tdeparture site: " << mDepartureSite->getName() << std::endl;
376  if (debug) std::cout << "\tinstance type: " << instanceType << std::endl;
377  uint32 s = (*mTypeRandomGen[instanceType])();
378  if (debug) std::cout << "\tselected: " << s << " of "
379  << mCandidatesByType[instanceType].size() << std::endl;
380  mTargetSite = const_cast<Site*>(mCandidatesByType[instanceType][s]);
381  if (debug) std::cout << "\ttarget site: " << mTargetSite->getName() << std::endl;
382  SitePtrToInstanceSharedPtrMap::iterator p = mAssignedSites.find(mTargetSite);
384  if (p != mAssignedSites.end()) {
385  mEvictedInstance = p->second;
386  // we have an evicted instance and it needs to be checked for legal placement
388  uint32 departureSiteType = mSiteTypeLookup[mDepartureSite];
389  bool illegalMapping = true;
390  std::vector<uint32>& v = mDevice.mTypeMapping.getLegalSitesForInstance(evictedType);
391  for (uint32 i = 0; i < v.size(); i++) {
392  if (departureSiteType == v[i]) illegalMapping = false;
393  }
394  if (illegalMapping) return false;
395  }
396  if (debug) mEvictedInstance == 0 ? std::cout << "\tEMPTY " << std::endl
397  : std::cout << "\t" << mEvictedInstance->getName() << std::endl;
398 
399  // 4 things to update
400  if (debug) std::cout << "\tCost before move: " << mCost << std::endl;
402  if (debug) std::cout << "\tCost without instance nets: " << mCost << std::endl;
403 
405  const_cast<const Site*>(mTargetSite));
407  if (mEvictedInstance != 0) {
409  const_cast<const Site*>(mDepartureSite));
411  } else {
413  }
414 
416  if (debug) std::cout << "\tCost after move: " << mCost << std::endl;
417  return true;
418  }
SitePtrVectorVector mCandidatesByType
Definition: Placement.hpp:88
boost::uint32_t uint32
Definition: Placement.hpp:49
InstanceSharedPtr mSelectedInstance
Definition: Placement.hpp:120
InstanceSharedPtr mEvictedInstance
Definition: Placement.hpp:121
const string & getName(void) const
Returns the site name.
Definition: Site.hpp:79
physical::InstanceSharedPtr InstanceSharedPtr
Definition: Placement.hpp:55
void updateCostRemovePair(InstanceSharedPtr inInstance1, InstanceSharedPtr inInstance2)
Definition: Placement.hpp:450
SitePtrToInstanceSharedPtrMap mAssignedSites
Definition: Placement.hpp:92
InstanceSharedPtrVector mAllInstances
Definition: Placement.hpp:95
SitePtrToIntMap mSiteTypeLookup
Definition: Placement.hpp:89
void updateCostAddPair(InstanceSharedPtr inInstance1, InstanceSharedPtr inInstance2)
Definition: Placement.hpp:458
architecture::Site Site
Definition: Placement.hpp:44
std::vector< boost::variate_generator< mt19937 &, boost::uniform_int< uint32 > > * > mTypeRandomGen
Definition: Placement.hpp:112
DeviceWrapper & mDevice
Definition: Placement.hpp:73
PlacementSiteTypeMapping & mTypeMapping
boost::variate_generator< mt19937 &, boost::uniform_int< uint32 > > mInstanceRandomGen
Definition: Placement.hpp:107
std::vector< uint32 > & getLegalSitesForInstance(uint32 inInstanceTypeIndex)
boost::uint32_t getInstanceTypeIndex(physical::InstanceSharedPtr inInstance)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::placer::Placement::undoMove ( bool  debug)
inline

Definition at line 419 of file Placement.hpp.

419  {
420  if (debug) {
421  std::cout << "undoMove: " << std::endl;
422  std::cout << "\tinstance: " << mSelectedInstance->getName() << std::endl;
423  std::cout << "\tdeparturesite: " << mDepartureSite->getName() << std::endl;
424  std::cout << "\ttargetsite: " << mTargetSite->getName() << std::endl;
425  if (mEvictedInstance != 0) std::cout << "\tevictedinstance: "
426  << mEvictedInstance->getName() << std::endl;
427  }
428 
430 
432  const_cast<const Site*>(mDepartureSite));
434 
435  if (mEvictedInstance != 0) {
437  const_cast<const Site*>(mTargetSite));
439  } else {
441  }
442 
444  }
InstanceSharedPtr mSelectedInstance
Definition: Placement.hpp:120
InstanceSharedPtr mEvictedInstance
Definition: Placement.hpp:121
const string & getName(void) const
Returns the site name.
Definition: Site.hpp:79
void updateCostRemovePair(InstanceSharedPtr inInstance1, InstanceSharedPtr inInstance2)
Definition: Placement.hpp:450
SitePtrToInstanceSharedPtrMap mAssignedSites
Definition: Placement.hpp:92
void updateCostAddPair(InstanceSharedPtr inInstance1, InstanceSharedPtr inInstance2)
Definition: Placement.hpp:458

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::placer::Placement::updateCostAddInstances ( InstanceSharedPtrVector inInstances)
inline

Definition at line 454 of file Placement.hpp.

454  {
455  // add cost contributed by all nets touched by the specified instances
456  updateCostHelper(inInstances, true);
457  }
void updateCostHelper(InstanceSharedPtrVector &inInstances, bool addCost)
Definition: Placement.hpp:463

+ Here is the call graph for this function:

void torc::placer::Placement::updateCostAddPair ( InstanceSharedPtr  inInstance1,
InstanceSharedPtr  inInstance2 
)
inline

Definition at line 458 of file Placement.hpp.

458  {
459  // remove cost contributed by all nets touched by the specified instances
460  updateCostHelper(inInstance1, inInstance2, true);
461  }
void updateCostHelper(InstanceSharedPtrVector &inInstances, bool addCost)
Definition: Placement.hpp:463

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::placer::Placement::updateCostFull ( bool  debug)
inline

Definition at line 303 of file Placement.hpp.

303  {
304 
305  mCost = 0;
306  for (uint32 i = 0; i < mAllNets.size(); i++) {
307  NetSharedPtr net = mAllNets[i];
308  if (debug) std::cout << "net : " << net->getName() << std::endl;
309  if (net->getSourceCount() != 1 || net->getSinkCount() < 1) {
310  if (debug) std::cout << "\tEmpty!" << std::endl;
311  continue;
312  }
313  if (net->getNetType() != physical::eNetTypeNormal) {
314  //std::cout << "Net is not a normal net" << std::endl;
315  continue;
316  }
317  InstancePinSharedPtr pinPtr = *net->sourcesBegin();
318  InstanceSharedPtr instance = pinPtr->getInstancePtr().lock();
319  if (debug) std::cout << "\tsource instance: " << instance->getName() << std::endl;
320  const Site* site = boost::any_cast<const Site*>(instance->getAnnotation(
322  if (site == NULL) {
323  std::cout << instance->getName() << " doesn't have a site." << std::endl;
324  continue;
325  }
326  if (debug) std::cout << "\t\tsource instance site: " << site->getName()
327  << std::endl;
328 
329  uint32 sum = 0;
330 
331  // semiperimeter of bounding rectangle
332  uint32 row1 = mDevice.mDB.getTiles().getTileInfo(site->getTileIndex()).getRow();
333  uint32 col1 = mDevice.mDB.getTiles().getTileInfo(site->getTileIndex()).getCol();
334  uint32 row2 = row1;
335  uint32 col2 = col1;
336  InstancePinSharedPtrVector::iterator p = net->sinksBegin();
337  InstancePinSharedPtrVector::iterator e = net->sinksEnd();
338  for ( ; p != e; p++) {
339  instance = (*p)->getInstancePtr().lock();
340  if (debug) std::cout << "\tsink instance: " << instance->getName() << std::endl;
341  const Site* sinkSite = boost::any_cast<const Site*>(instance->getAnnotation(
343  if (sinkSite == NULL) {
344  std::cout << instance->getName() << " doesn't have a site (sink)."
345  << std::endl;
346  return;
347  }
348 
349  uint32 trow =
350  mDevice.mDB.getTiles().getTileInfo(sinkSite->getTileIndex()).getRow();
351  uint32 tcol =
352  mDevice.mDB.getTiles().getTileInfo(sinkSite->getTileIndex()).getCol();
353  if (trow < row1) row1 = trow;
354  if (tcol < col1) col1 = tcol;
355  if (trow > row2) row2 = trow;
356  if (tcol > col2) col2 = tcol;
357  }
358  if (debug) std::cout << "\t\tcost reported: " << sum << " / " << net->getSinkCount()
359  << " = " << ((float)sum / (float)net->getSinkCount()) << std::endl;
360  mCost += (row2 - row1) + (col2 - col1);
361  if (debug) std::cout << "\t\t" << mCost << std::endl;
362  }
363  std::cout << "updateCostFull: " << mCost << std::endl;
364  }
const Tiles & getTiles(void) const
Returns a constant reference to the family and device tile data.
Definition: DDB.hpp:146
const TileInfo & getTileInfo(TileIndex inTileIndex) const
Returns the TileInfo object for the specified tile.
Definition: Tiles.hpp:137
physical::NetSharedPtr NetSharedPtr
Definition: Placement.hpp:53
boost::uint32_t uint32
Definition: Placement.hpp:49
const string & getName(void) const
Returns the site name.
Definition: Site.hpp:79
physical::InstanceSharedPtr InstanceSharedPtr
Definition: Placement.hpp:55
architecture::Site Site
Definition: Placement.hpp:44
physical::InstancePinSharedPtr InstancePinSharedPtr
Definition: Placement.hpp:58
DeviceWrapper & mDevice
Definition: Placement.hpp:73
NetSharedPtrVector mAllNets
Definition: Placement.hpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::placer::Placement::updateCostHelper ( InstanceSharedPtrVector inInstances,
bool  addCost 
)
inline

Definition at line 463 of file Placement.hpp.

463  {
466 
467  std::set<NetSharedPtr> modifiedNets;
468 
469  for ( ; p != e; p++) {
470  if ((*p) != 0) {
473  for ( ; q != f; q++) {
474  NetSharedPtr n = (*q).second->getParentWeakPtr().lock();
475  modifiedNets.insert(n);
476  }
477  }
478  }
479 
480  std::set<NetSharedPtr>::iterator r = modifiedNets.begin();
481  std::set<NetSharedPtr>::iterator g = modifiedNets.end();
482  for ( ; r != g; r++) {
483  addCost ? mCost += getNetCost(*r) : mCost -= getNetCost(*r);
484  }
485  }
InstancePinMap::iterator InstancePinSharedPtrIterator
Non-constant iterator to InstancePin shared pointers.
physical::NetSharedPtr NetSharedPtr
Definition: Placement.hpp:53
uint32 getNetCost(NetSharedPtr inNet)
Definition: Placement.hpp:517
InstanceSharedPtrVector::iterator InstanceSharedPtrIterator
Non-constant iterator to Instance shared pointers.
Definition: Circuit.hpp:74

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::placer::Placement::updateCostHelper ( InstanceSharedPtr  inInstance1,
InstanceSharedPtr  inInstance2,
bool  addCost 
)
inline

Definition at line 486 of file Placement.hpp.

487  {
488 
489  std::set<NetSharedPtr> modifiedNets;
490 
493 
494  if (inInstance1 != 0) {
495  q = inInstance1->pinsBegin();
496  f = inInstance1->pinsEnd();
497  for ( ; q != f; q++) {
498  NetSharedPtr n = (*q).second->getParentWeakPtr().lock();
499  modifiedNets.insert(n);
500  }
501  }
502  if (inInstance2 != 0) {
503  q = inInstance2->pinsBegin();
504  f = inInstance2->pinsEnd();
505  for ( ; q != f; q++) {
506  NetSharedPtr n = (*q).second->getParentWeakPtr().lock();
507  modifiedNets.insert(n);
508  }
509  }
510  std::set<NetSharedPtr>::iterator r = modifiedNets.begin();
511  std::set<NetSharedPtr>::iterator g = modifiedNets.end();
512  for ( ; r != g; r++) {
513  addCost ? mCost += getNetCost(*r) : mCost -= getNetCost(*r);
514  }
515  }
InstancePinMap::iterator InstancePinSharedPtrIterator
Non-constant iterator to InstancePin shared pointers.
physical::NetSharedPtr NetSharedPtr
Definition: Placement.hpp:53
uint32 getNetCost(NetSharedPtr inNet)
Definition: Placement.hpp:517

+ Here is the call graph for this function:

void torc::placer::Placement::updateCostRemoveInstances ( InstanceSharedPtrVector inInstances)
inline

Definition at line 446 of file Placement.hpp.

446  {
447  // remove cost contributed by all nets touched by the specified instances
448  updateCostHelper(inInstances, false);
449  }
void updateCostHelper(InstanceSharedPtrVector &inInstances, bool addCost)
Definition: Placement.hpp:463

+ Here is the call graph for this function:

void torc::placer::Placement::updateCostRemovePair ( InstanceSharedPtr  inInstance1,
InstanceSharedPtr  inInstance2 
)
inline

Definition at line 450 of file Placement.hpp.

450  {
451  // remove cost contributed by all nets touched by the specified instances
452  updateCostHelper(inInstance1, inInstance2, false);
453  }
void updateCostHelper(InstanceSharedPtrVector &inInstances, bool addCost)
Definition: Placement.hpp:463

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::placer::Placement::writePlacementToDesign ( )
inline

Definition at line 284 of file Placement.hpp.

284  {
285  std::cout << "WRITING PLACEMENT TO DESIGN" << std::endl;
286  for (uint32 i = 0; i < mAllInstances.size(); i++) {
287  InstanceSharedPtr instance = mAllInstances[i];
288 //std::cout << "Recording: " << instance->getName() << " ";
289  const Site* site = boost::any_cast<const Site*>(
290  instance->getAnnotation(ePlacerInstanceSitePtr));
291  std::string siteName = site->getName();
293  site->getTileIndex()).getName();
294 //std::cout << siteName << " " << tileName << std::endl;
295  instance->setSite(siteName);
296  instance->setTile(tileName);
297 
298  }
299  }
const Tiles & getTiles(void) const
Returns a constant reference to the family and device tile data.
Definition: DDB.hpp:146
const TileInfo & getTileInfo(TileIndex inTileIndex) const
Returns the TileInfo object for the specified tile.
Definition: Tiles.hpp:137
boost::uint32_t uint32
Definition: Placement.hpp:49
std::string string
physical::InstanceSharedPtr InstanceSharedPtr
Definition: Placement.hpp:55
InstanceSharedPtrVector mAllInstances
Definition: Placement.hpp:95
architecture::Site Site
Definition: Placement.hpp:44
DeviceWrapper & mDevice
Definition: Placement.hpp:73

+ Here is the call graph for this function:

Field Documentation

InstanceSharedPtrVector torc::placer::Placement::mAllInstances
protected

Definition at line 95 of file Placement.hpp.

InstanceSharedPtrVectorVector torc::placer::Placement::mAllInstancesByType
protected

Definition at line 96 of file Placement.hpp.

NetSharedPtrVector torc::placer::Placement::mAllNets
protected

Definition at line 99 of file Placement.hpp.

const architecture::Array<const Site>& torc::placer::Placement::mAllSites
protected

Definition at line 86 of file Placement.hpp.

SitePtrVectorVector torc::placer::Placement::mAllSitesByType
protected

Definition at line 87 of file Placement.hpp.

SitePtrToInstanceSharedPtrMap torc::placer::Placement::mAssignedSites
protected

Definition at line 92 of file Placement.hpp.

SitePtrVectorVector torc::placer::Placement::mCandidatesByType
protected

Definition at line 88 of file Placement.hpp.

uint32 torc::placer::Placement::mCost
protected

Definition at line 114 of file Placement.hpp.

bool torc::placer::Placement::mDebug
protected

Definition at line 117 of file Placement.hpp.

Site* torc::placer::Placement::mDepartureSite
protected

Definition at line 122 of file Placement.hpp.

DesignSharedPtr torc::placer::Placement::mDesign
protected

Definition at line 79 of file Placement.hpp.

DeviceWrapper& torc::placer::Placement::mDevice
protected

Definition at line 73 of file Placement.hpp.

InstanceSharedPtr torc::placer::Placement::mEvictedInstance
protected

Definition at line 121 of file Placement.hpp.

boost::variate_generator<mt19937&, boost::uniform_int<uint32> > torc::placer::Placement::mInstanceRandomGen
protected

Definition at line 107 of file Placement.hpp.

boost::mt19937 torc::placer::Placement::mRandomSource
protected

Definition at line 105 of file Placement.hpp.

InstanceSharedPtr torc::placer::Placement::mSelectedInstance
protected

Definition at line 120 of file Placement.hpp.

SitePtrToIntMap torc::placer::Placement::mSiteTypeLookup
protected

Definition at line 89 of file Placement.hpp.

Site* torc::placer::Placement::mTargetSite
protected

Definition at line 123 of file Placement.hpp.

std::vector<boost::variate_generator<mt19937&, boost::uniform_int<uint32> >* > torc::placer::Placement::mTypeRandomGen
protected

Definition at line 112 of file Placement.hpp.

boost::uniform_int<uint32> torc::placer::Placement::mUniformInstanceRange
protected

Definition at line 106 of file Placement.hpp.

std::vector<boost::uniform_int<uint32> > torc::placer::Placement::mUniformTypeRanges
protected

Definition at line 109 of file Placement.hpp.


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