* ./katabatic:
- Change: In GCell & GCellGrid, unificated way of computing all the GCell's densities. - Change: In GCell::stepDesaturate(), uses shearUp() instead of moveUp(). - Change: In AutoSegment, new method ::shearUp() to avoid moveUp() saturating GCells as side-effect.
This commit is contained in:
parent
c9e1c3101a
commit
629452dcc6
|
@ -1303,8 +1303,9 @@ namespace Katabatic {
|
|||
{
|
||||
ltrace(200) << "AutoSegment::canMoveUp() " << flags << endl;
|
||||
|
||||
if ( isLayerChange() or isFixed() or isTerminal() ) return false;
|
||||
if ( isLocal() and (not (flags & AllowLocal)) ) return false;
|
||||
if ( isLayerChange() or isFixed() ) return false;
|
||||
if ( isTerminal() and (not (flags & AllowTerminal)) ) return false;
|
||||
if ( isLocal() and (not (flags & AllowLocal )) ) return false;
|
||||
|
||||
size_t depth = Session::getRoutingGauge()->getLayerDepth(getLayer()) + 2;
|
||||
if ( depth >= Session::getConfiguration()->getAllowedDepth() ) return false;
|
||||
|
@ -1355,6 +1356,76 @@ namespace Katabatic {
|
|||
}
|
||||
|
||||
|
||||
bool AutoSegment::shearUp ( GCell* upGCell, AutoSegment*& movedUp, float reserve, unsigned int flags )
|
||||
{
|
||||
ltrace(200) << "AutoSegment::shearUp() " << this << endl;
|
||||
|
||||
movedUp = NULL;
|
||||
|
||||
if ( isLayerChange() or isFixed() /*or isTerminal()*/ or isLocal() ) return false;
|
||||
|
||||
size_t upDepth = Session::getRoutingGauge()->getLayerDepth(getLayer()) + 2;
|
||||
if ( upDepth >= Session::getConfiguration()->getAllowedDepth() ) return false;
|
||||
|
||||
vector<GCell*> gcells;
|
||||
getGCells ( gcells );
|
||||
|
||||
size_t iupGCell = 0;
|
||||
for ( ; iupGCell<gcells.size() ; ++iupGCell ) {
|
||||
if ( gcells[iupGCell] == upGCell ) break;
|
||||
}
|
||||
if ( iupGCell == gcells.size() ) {
|
||||
cerr << Warning("Shear start %s not under %s."
|
||||
,getString(upGCell).c_str()
|
||||
,getString(this).c_str()
|
||||
) << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
GCell* rightShear = NULL;
|
||||
for ( size_t i=iupGCell ; i<gcells.size() ; i++ ) {
|
||||
if ( not gcells[i]->hasFreeTrack(upDepth,reserve) ) {
|
||||
ltrace(200) << "Right shearing @ " << gcells[i] << endl;
|
||||
rightShear = gcells[i];
|
||||
}
|
||||
}
|
||||
|
||||
GCell* leftShear = NULL;
|
||||
if ( iupGCell > 0 ) {
|
||||
size_t i = iupGCell;
|
||||
do {
|
||||
--i;
|
||||
if ( not gcells[i]->hasFreeTrack(upDepth,reserve) ) {
|
||||
ltrace(200) << "Left shearing @ " << gcells[i] << endl;
|
||||
leftShear = gcells[i];
|
||||
}
|
||||
} while (i > 0);
|
||||
}
|
||||
|
||||
AutoSegment* before = this;
|
||||
const vector<AutoSegment*>& doglegs = Session::getDogLegs();
|
||||
|
||||
if ( leftShear ) {
|
||||
makeDogLeg ( leftShear, true );
|
||||
movedUp = doglegs[2];
|
||||
} else {
|
||||
before = NULL;
|
||||
movedUp = this;
|
||||
}
|
||||
|
||||
if ( rightShear ) makeDogLeg(rightShear,true);
|
||||
|
||||
if ( movedUp->moveUp(flags) ) {
|
||||
if ( rightShear or leftShear )
|
||||
cinfo << "Shearing Up " << this << "." << endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
movedUp = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool AutoSegment::canDogLeg ( Interval interval )
|
||||
{
|
||||
ltrace(200) << "AutoSegment::canDogLeg(Interval) " << interval << endl;
|
||||
|
|
|
@ -117,8 +117,6 @@ namespace Katabatic {
|
|||
, _cDensity (0.0)
|
||||
, _densities (new float [_depth])
|
||||
, _saturateDensities (new float [_depth])
|
||||
, _segmentCount (0)
|
||||
, _routedSegmentCount(0)
|
||||
, _saturated (false)
|
||||
, _invalid (true)
|
||||
, _key (0.0,_index)
|
||||
|
@ -335,33 +333,15 @@ namespace Katabatic {
|
|||
if (_invalid and update) const_cast<GCell*>(this)->updateDensity();
|
||||
|
||||
float density = 0.0;
|
||||
for ( size_t i=0 ; i<_depth ; i++ )
|
||||
density += _densities[i];
|
||||
|
||||
#if defined(CHECK_DETERMINISM)
|
||||
cerr << "Order: Sum density " << setprecision(9) << density << endl;
|
||||
if ( getGCellGrid()->getDensityMode() == GCellGrid::AverageHVDensity ) {
|
||||
// Average density of all layers mixeds together.
|
||||
for ( size_t i=0 ; i<_depth ; i++ )
|
||||
density += _densities[i];
|
||||
|
||||
density /= (float)(_depth-_pinDepth);
|
||||
cerr << "Order: density " << setprecision(9) << density << endl;
|
||||
|
||||
int intdensity = (int)roundfp(density);
|
||||
cerr << "Order: rounded density *100 " << setprecision(9) << intdensity << endl;
|
||||
|
||||
density = ((float)(intdensity)) / 100.0;
|
||||
cerr << "Order: rounded density /100 " << setprecision(9) << density << endl;
|
||||
|
||||
return density;
|
||||
#else
|
||||
return roundfp ( density/((float)(_depth-_pinDepth)) );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
float GCell::getMaxHVDensity ( bool update ) const
|
||||
{
|
||||
if (_invalid and update) const_cast<GCell*>(this)->updateDensity();
|
||||
|
||||
if ( getGCellGrid()->getDensityMode() == GCellGrid::MaxHVDensity ) {
|
||||
density = roundfp ( density/((float)(_depth-_pinDepth)) );
|
||||
} else if ( getGCellGrid()->getDensityMode() == GCellGrid::MaxHVDensity ) {
|
||||
// Maximum density between all horizontal vs. all vertical layers.
|
||||
size_t hplanes = 0;
|
||||
size_t vplanes = 0;
|
||||
float hdensity = 0.0;
|
||||
|
@ -375,47 +355,54 @@ namespace Katabatic {
|
|||
if (hplanes) hdensity /= hplanes;
|
||||
if (vplanes) vdensity /= vplanes;
|
||||
|
||||
return roundfp ( (hdensity > vdensity) ? hdensity : vdensity );
|
||||
}
|
||||
density = roundfp ( (hdensity > vdensity) ? hdensity : vdensity );
|
||||
} else if ( getGCellGrid()->getDensityMode() == GCellGrid::AverageHDensity ) {
|
||||
// Average density between all horizontal layers.
|
||||
size_t hplanes = 0;
|
||||
float hdensity = 0.0;
|
||||
|
||||
if ( getGCellGrid()->getDensityMode() == GCellGrid::MaxLayerDensity ) {
|
||||
float density = 0.0;
|
||||
for ( size_t i=_pinDepth ; i<_depth ; i++ ) {
|
||||
if ( i%2 ) { hdensity += _densities[i]; ++hplanes; }
|
||||
}
|
||||
if (hplanes) hdensity /= hplanes;
|
||||
|
||||
density = roundfp ( hdensity );
|
||||
} else if ( getGCellGrid()->getDensityMode() == GCellGrid::AverageVDensity ) {
|
||||
// Average density between all vertical layers.
|
||||
size_t vplanes = 0;
|
||||
float vdensity = 0.0;
|
||||
|
||||
for ( size_t i=_pinDepth ; i<_depth ; i++ ) {
|
||||
if ( i%2 == 0 ) { vdensity += _densities[i]; ++vplanes; }
|
||||
}
|
||||
|
||||
if (vplanes) vdensity /= vplanes;
|
||||
|
||||
density = roundfp ( vdensity );
|
||||
} else if ( getGCellGrid()->getDensityMode() == GCellGrid::MaxDensity ) {
|
||||
// Density of the most saturated layer.
|
||||
for ( size_t i=_pinDepth ; i<_depth ; i++ ) {
|
||||
if ( _densities[i] > density ) density = _densities[i];
|
||||
}
|
||||
return roundfp(density);
|
||||
density = roundfp(density);
|
||||
} else if ( getGCellGrid()->getDensityMode() == GCellGrid::MaxHDensity ) {
|
||||
// Density of the most saturated horizontal layer.
|
||||
for ( size_t i=_pinDepth ; i<_depth ; i++ ) {
|
||||
if ( (i%2) and (_densities[i] > density) ) density = _densities[i];
|
||||
}
|
||||
density = roundfp(density);
|
||||
} else if ( getGCellGrid()->getDensityMode() == GCellGrid::MaxVDensity ) {
|
||||
// Density of the most saturated vertical layer.
|
||||
for ( size_t i=_pinDepth ; i<_depth ; i++ ) {
|
||||
if ( (i%2 == 0) and (_densities[i] > density) ) density = _densities[i];
|
||||
}
|
||||
density = roundfp(density);
|
||||
}
|
||||
|
||||
float density = 0.0;
|
||||
for ( size_t i=_pinDepth ; i<_depth ; i++ )
|
||||
density += _densities[i];
|
||||
|
||||
return roundfp ( density/((float)(_depth-_pinDepth)) );
|
||||
}
|
||||
|
||||
|
||||
float GCell::getStiffness () const
|
||||
{
|
||||
if ( _segmentCount == 0 ) return 0.0;
|
||||
return roundfp ( (float)_routedSegmentCount / (float)_segmentCount );
|
||||
}
|
||||
|
||||
|
||||
void GCell::incSegmentCount ( int count )
|
||||
{
|
||||
if ( (count < 0) and ((unsigned int)abs(count) > _segmentCount) )
|
||||
_segmentCount = 0;
|
||||
else
|
||||
_segmentCount += count;
|
||||
}
|
||||
|
||||
|
||||
void GCell::incRoutedCount ( int count )
|
||||
{
|
||||
if ( (count < 0) and ((unsigned int)abs(count) > _routedSegmentCount) )
|
||||
_routedSegmentCount = 0;
|
||||
else
|
||||
_routedSegmentCount += count;
|
||||
#if defined(CHECK_DETERMINISM)
|
||||
cerr << "Order: density " << setprecision(9) << density << endl;
|
||||
#endif
|
||||
return density;
|
||||
}
|
||||
|
||||
|
||||
|
@ -697,7 +684,6 @@ namespace Katabatic {
|
|||
#endif
|
||||
|
||||
//cerr << "updateDensity() " << this << getVectorString(_densities,_depth) << endl;
|
||||
//_segmentCount = _hsegments.size() + _vsegments.size() + processeds.size();
|
||||
|
||||
return ( _saturated ) ? 1 : 0 ;
|
||||
}
|
||||
|
@ -813,7 +799,8 @@ namespace Katabatic {
|
|||
#endif
|
||||
|
||||
updateDensity ();
|
||||
float density = getDensity();
|
||||
//float density = getDensity();
|
||||
moved = NULL;
|
||||
|
||||
//float density = _densities[depth];
|
||||
//float densityUp = _densities[depth+2];
|
||||
|
@ -847,15 +834,16 @@ namespace Katabatic {
|
|||
#if defined(CHECK_DETERMINISM)
|
||||
cerr << "Order: Move up " << (*isegment) << endl;
|
||||
#endif
|
||||
//cerr << "Move up " << (*isegment) << endl;
|
||||
if ( not (*isegment)->canMoveUp(0.5,AutoSegment::Propagate) ) {
|
||||
cinfo << Warning("Shear effect on: %s.",getString(*isegment).c_str()) << endl;
|
||||
return false;
|
||||
}
|
||||
// cerr << "Move up " << (*isegment) << endl;
|
||||
// if ( not (*isegment)->canMoveUp(0.5/*,AutoSegment::Propagate*/) ) {
|
||||
// cinfo << Warning("Shear effect on: %s.",getString(*isegment).c_str()) << endl;
|
||||
// return false;
|
||||
// }
|
||||
|
||||
(*isegment)->changeDepth ( depth+2, false, false );
|
||||
moved = (*isegment);
|
||||
// (*isegment)->changeDepth ( depth+2, false, false );
|
||||
// moved = (*isegment);
|
||||
|
||||
(*isegment)->shearUp ( this, moved, 0.5, AutoSegment::AllowTerminal );
|
||||
updateDensity ();
|
||||
|
||||
//cmess2 << " - GCell [" << getIndex() << "] @" << getColumn() << "x" << getRow()
|
||||
|
@ -865,7 +853,7 @@ namespace Katabatic {
|
|||
// << " displaced:" << (*isegment) << "]."
|
||||
// << endl;
|
||||
|
||||
return true;
|
||||
if ( moved ) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -1019,11 +1007,11 @@ namespace Katabatic {
|
|||
s << "<" << _getTypeName() << " [" << _index << "] "
|
||||
<< DbU::getValueString(box.getXMin()) << ":" << DbU::getValueString(box.getYMin()) << " "
|
||||
<< DbU::getValueString(box.getXMax()) << ":" << DbU::getValueString(box.getYMax()) << " "
|
||||
<< setprecision(9)
|
||||
<< setprecision(3)
|
||||
#if not defined(CHECK_DETERMINISM)
|
||||
<< getDensity(false)
|
||||
<< getDensity(false) << " "
|
||||
#endif
|
||||
<< " S:" << _routedSegmentCount << "/" << _segmentCount
|
||||
<< getVectorString(_densities,_depth)
|
||||
<< ">";
|
||||
|
||||
return s.str();
|
||||
|
@ -1041,8 +1029,6 @@ namespace Katabatic {
|
|||
record->add ( getSlot ( "_box" , &_box ) );
|
||||
record->add ( getSlot ( "_depth" , &_depth ) );
|
||||
record->add ( getSlot ( "_saturated" , _saturated ) );
|
||||
record->add ( getSlot ( "_segmentCount" , _segmentCount ) );
|
||||
record->add ( getSlot ( "_routedSegmentCount", _routedSegmentCount ) );
|
||||
record->add ( getSlot ( "_invalid" , _invalid ) );
|
||||
|
||||
RoutingGauge* rg = getGCellGrid()->getKatabatic()->getRoutingGauge();
|
||||
|
@ -1168,7 +1154,7 @@ namespace Katabatic {
|
|||
{
|
||||
ostringstream s;
|
||||
|
||||
s << setprecision(9);
|
||||
s << setprecision(3);
|
||||
for ( size_t i=0 ; i<size ; i++ ) {
|
||||
if ( !i ) s << "[";
|
||||
else s << " ";
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace Katabatic {
|
|||
GCellGrid::GCellGrid ( KatabaticEngine* ktbt )
|
||||
: Grid<GCell> (ktbt->getCell()->getAbutmentBox())
|
||||
, _katabatic (ktbt)
|
||||
, _densityMode (MaxLayerDensity)
|
||||
, _densityMode (MaxDensity)
|
||||
, _hEdgeCapacity(ktbt->getConfiguration()->getHEdgeCapacity())
|
||||
, _vEdgeCapacity(ktbt->getConfiguration()->getVEdgeCapacity())
|
||||
{ }
|
||||
|
|
|
@ -91,7 +91,7 @@ namespace Katabatic {
|
|||
|
||||
QPainter& painter = widget->getPainter();
|
||||
painter.setBrush
|
||||
( Graphics::getColorScale(ColorScale::Fire).getBrush((size_t)(gcell->getMaxHVDensity()*255.0)
|
||||
( Graphics::getColorScale(ColorScale::Fire).getBrush((size_t)(gcell->getDensity()*255.0)
|
||||
,widget->getDarkening()) );
|
||||
painter.drawRect ( widget->dbuToDisplayRect(gcell->getBoundingBox()) );
|
||||
}
|
||||
|
|
|
@ -109,6 +109,7 @@ namespace Katabatic {
|
|||
|
||||
bool optimized = true;
|
||||
while ( optimized ) {
|
||||
Session::revalidate ();
|
||||
optimized = false;
|
||||
//sort ( gcells.begin(), gcells.end(), GCell::CompareByDensity(depth) );
|
||||
queue.revalidate ();
|
||||
|
|
|
@ -2127,7 +2127,7 @@ namespace {
|
|||
AutoContact* localContact = (_south) ? _southWestContact : _northEastContact;
|
||||
//localContact->setHAlignate ( true );
|
||||
|
||||
bool doTurn = (_topology & GLOBAL_SPLIT) and (_routingPads.size() == 1);
|
||||
bool doTurn = (_topology & GLOBAL_SPLIT) and (_state.fields.Pad == 1);
|
||||
for ( unsigned int i = 0 ; i < _routingPads.size() ; i++ ) {
|
||||
AutoContact* rpContact = _GCell_rp_Access ( _gcell, _routingPads[i], true, false );
|
||||
AutoContact* turn1
|
||||
|
|
|
@ -303,11 +303,18 @@ namespace Katabatic {
|
|||
_autoContacts.clear ();
|
||||
|
||||
ltrace(110) << "AutoSegments Revalidate (after canonize)." << endl;
|
||||
for ( size_t i=0 ; i < _autoSegments.size() ; i++, count++ )
|
||||
_autoSegments[i]->revalidate ();
|
||||
_revalidateds.clear ();
|
||||
_autoSegments.swap ( _revalidateds );
|
||||
|
||||
_dogLegs.clear ();
|
||||
_revalidateds.clear ();
|
||||
for ( size_t i=0 ; i < _autoSegments.size() ; i++, count++ ) {
|
||||
_autoSegments[i]->revalidate ();
|
||||
if ( not _destroyedSegments.empty()
|
||||
and (_destroyedSegments.find(_autoSegments[i]) != _destroyedSegments.end()) )
|
||||
continue;
|
||||
|
||||
_revalidateds.push_back ( _autoSegments[i] );
|
||||
}
|
||||
_autoSegments.clear ();
|
||||
|
||||
ltrace(110) << "AutoSegments/AutoContacts queued deletion." << endl;
|
||||
bool destroySegment = _katabatic->setDestroyBaseSegment ( true );
|
||||
|
|
|
@ -86,7 +86,7 @@ namespace Katabatic {
|
|||
, ParallelOrExpanded = (1<<2)
|
||||
, ParallelAndLayerChange = (1<<3)
|
||||
};
|
||||
enum Flags { Propagate=0x1, AllowLocal=0x2 };
|
||||
enum Flags { Propagate=0x1, AllowLocal=0x2, AllowTerminal=0x4 };
|
||||
|
||||
|
||||
public:
|
||||
|
@ -295,6 +295,10 @@ namespace Katabatic {
|
|||
virtual void _makeDogLeg ( GCell*, bool upLayer ) = 0;
|
||||
virtual void desalignate ( AutoContact* ) = 0;
|
||||
void desalignate ();
|
||||
bool shearUp ( GCell*
|
||||
, AutoSegment*& movedUp
|
||||
, float reserve
|
||||
, unsigned int flags );
|
||||
bool _check () const;
|
||||
// Inspector Management.
|
||||
virtual Record* _getRecord () const = 0;
|
||||
|
|
|
@ -134,11 +134,8 @@ namespace Katabatic {
|
|||
inline float getCDensity ( bool update=true ) const;
|
||||
inline float getDensity ( size_t depth, bool update=true ) const;
|
||||
float getDensity ( bool update=true ) const;
|
||||
float getMaxHVDensity ( bool update=true ) const;
|
||||
inline float getBlockage ( unsigned int depth ) const;
|
||||
float getStiffness () const;
|
||||
inline unsigned int getSegmentCount () const;
|
||||
inline unsigned int getRoutedCount () const;
|
||||
inline vector<AutoSegment*>* getVSegments ();
|
||||
inline vector<AutoSegment*>* getHSegments ();
|
||||
inline vector<AutoContact*>* getContacts ();
|
||||
|
@ -153,8 +150,6 @@ namespace Katabatic {
|
|||
size_t checkDensity () const;
|
||||
bool checkEdgeSaturation ( float threshold ) const;
|
||||
// Modifiers.
|
||||
void incSegmentCount ( int count );
|
||||
void incRoutedCount ( int count );
|
||||
void addBlockage ( unsigned int depth, float );
|
||||
inline void addVSegment ( AutoSegment* );
|
||||
inline void addHSegment ( AutoSegment* );
|
||||
|
@ -193,8 +188,6 @@ namespace Katabatic {
|
|||
float _cDensity;
|
||||
float* _densities;
|
||||
float* _saturateDensities;
|
||||
unsigned int _segmentCount;
|
||||
unsigned int _routedSegmentCount;
|
||||
bool _saturated;
|
||||
bool _invalid;
|
||||
Key _key;
|
||||
|
@ -234,8 +227,6 @@ namespace Katabatic {
|
|||
inline vector<AutoSegment*>* GCell::getVSegments () { return &_vsegments; }
|
||||
inline vector<AutoSegment*>* GCell::getHSegments () { return &_hsegments; }
|
||||
inline vector<AutoContact*>* GCell::getContacts () { return &_contacts; }
|
||||
inline unsigned int GCell::getSegmentCount () const { return _segmentCount; }
|
||||
inline unsigned int GCell::getRoutedCount () const { return _routedSegmentCount; }
|
||||
inline string GCell::_getTypeName () const { return _TName("GCell"); }
|
||||
inline void GCell::invalidate () { _invalid = true; }
|
||||
inline const GCell::Key& GCell::getKey () const { return _key; }
|
||||
|
@ -310,6 +301,9 @@ namespace Katabatic {
|
|||
string getVectorString ( float*, size_t );
|
||||
|
||||
|
||||
typedef std::vector<GCell*> GCellVector;
|
||||
|
||||
|
||||
} // End of Katabatic namespace.
|
||||
|
||||
|
||||
|
|
|
@ -49,9 +49,13 @@ namespace Katabatic {
|
|||
|
||||
class GCellGrid : public Grid<GCell> {
|
||||
public:
|
||||
enum Flags { AverageDensity = 1
|
||||
, MaxHVDensity = 2
|
||||
, MaxLayerDensity = 3
|
||||
enum Flags { AverageHVDensity=1 // Average between all densities.
|
||||
, AverageHDensity =2 // Average between all H densities.
|
||||
, AverageVDensity =3 // Average between all V densities.
|
||||
, MaxHVDensity =4 // Maximum between average H and average V.
|
||||
, MaxVDensity =5 // Maximum of V densities.
|
||||
, MaxHDensity =6 // Maximum of H densities.
|
||||
, MaxDensity =7 // Maximum of H & V densities.
|
||||
};
|
||||
|
||||
public:
|
||||
|
|
Loading…
Reference in New Issue