* ./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:
Jean-Paul Chaput 2010-12-12 21:43:25 +00:00
parent c9e1c3101a
commit 629452dcc6
10 changed files with 167 additions and 100 deletions

View File

@ -1303,8 +1303,9 @@ namespace Katabatic {
{ {
ltrace(200) << "AutoSegment::canMoveUp() " << flags << endl; ltrace(200) << "AutoSegment::canMoveUp() " << flags << endl;
if ( isLayerChange() or isFixed() or isTerminal() ) return false; if ( isLayerChange() or isFixed() ) return false;
if ( isLocal() and (not (flags & AllowLocal)) ) 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; size_t depth = Session::getRoutingGauge()->getLayerDepth(getLayer()) + 2;
if ( depth >= Session::getConfiguration()->getAllowedDepth() ) return false; 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 ) bool AutoSegment::canDogLeg ( Interval interval )
{ {
ltrace(200) << "AutoSegment::canDogLeg(Interval) " << interval << endl; ltrace(200) << "AutoSegment::canDogLeg(Interval) " << interval << endl;

View File

@ -117,8 +117,6 @@ namespace Katabatic {
, _cDensity (0.0) , _cDensity (0.0)
, _densities (new float [_depth]) , _densities (new float [_depth])
, _saturateDensities (new float [_depth]) , _saturateDensities (new float [_depth])
, _segmentCount (0)
, _routedSegmentCount(0)
, _saturated (false) , _saturated (false)
, _invalid (true) , _invalid (true)
, _key (0.0,_index) , _key (0.0,_index)
@ -335,33 +333,15 @@ namespace Katabatic {
if (_invalid and update) const_cast<GCell*>(this)->updateDensity(); if (_invalid and update) const_cast<GCell*>(this)->updateDensity();
float density = 0.0; float density = 0.0;
for ( size_t i=0 ; i<_depth ; i++ )
density += _densities[i];
#if defined(CHECK_DETERMINISM) if ( getGCellGrid()->getDensityMode() == GCellGrid::AverageHVDensity ) {
cerr << "Order: Sum density " << setprecision(9) << density << endl; // Average density of all layers mixeds together.
for ( size_t i=0 ; i<_depth ; i++ )
density += _densities[i];
density /= (float)(_depth-_pinDepth); density = roundfp ( density/((float)(_depth-_pinDepth)) );
cerr << "Order: density " << setprecision(9) << density << endl; } else if ( getGCellGrid()->getDensityMode() == GCellGrid::MaxHVDensity ) {
// Maximum density between all horizontal vs. all vertical layers.
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 ) {
size_t hplanes = 0; size_t hplanes = 0;
size_t vplanes = 0; size_t vplanes = 0;
float hdensity = 0.0; float hdensity = 0.0;
@ -375,47 +355,54 @@ namespace Katabatic {
if (hplanes) hdensity /= hplanes; if (hplanes) hdensity /= hplanes;
if (vplanes) vdensity /= vplanes; 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 ) { for ( size_t i=_pinDepth ; i<_depth ; i++ ) {
float density = 0.0; 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++ ) { for ( size_t i=_pinDepth ; i<_depth ; i++ ) {
if ( _densities[i] > density ) density = _densities[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; #if defined(CHECK_DETERMINISM)
for ( size_t i=_pinDepth ; i<_depth ; i++ ) cerr << "Order: density " << setprecision(9) << density << endl;
density += _densities[i]; #endif
return density;
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;
} }
@ -697,7 +684,6 @@ namespace Katabatic {
#endif #endif
//cerr << "updateDensity() " << this << getVectorString(_densities,_depth) << endl; //cerr << "updateDensity() " << this << getVectorString(_densities,_depth) << endl;
//_segmentCount = _hsegments.size() + _vsegments.size() + processeds.size();
return ( _saturated ) ? 1 : 0 ; return ( _saturated ) ? 1 : 0 ;
} }
@ -813,7 +799,8 @@ namespace Katabatic {
#endif #endif
updateDensity (); updateDensity ();
float density = getDensity(); //float density = getDensity();
moved = NULL;
//float density = _densities[depth]; //float density = _densities[depth];
//float densityUp = _densities[depth+2]; //float densityUp = _densities[depth+2];
@ -847,15 +834,16 @@ namespace Katabatic {
#if defined(CHECK_DETERMINISM) #if defined(CHECK_DETERMINISM)
cerr << "Order: Move up " << (*isegment) << endl; cerr << "Order: Move up " << (*isegment) << endl;
#endif #endif
//cerr << "Move up " << (*isegment) << endl; // cerr << "Move up " << (*isegment) << endl;
if ( not (*isegment)->canMoveUp(0.5,AutoSegment::Propagate) ) { // if ( not (*isegment)->canMoveUp(0.5/*,AutoSegment::Propagate*/) ) {
cinfo << Warning("Shear effect on: %s.",getString(*isegment).c_str()) << endl; // cinfo << Warning("Shear effect on: %s.",getString(*isegment).c_str()) << endl;
return false; // return false;
} // }
(*isegment)->changeDepth ( depth+2, false, false ); // (*isegment)->changeDepth ( depth+2, false, false );
moved = (*isegment); // moved = (*isegment);
(*isegment)->shearUp ( this, moved, 0.5, AutoSegment::AllowTerminal );
updateDensity (); updateDensity ();
//cmess2 << " - GCell [" << getIndex() << "] @" << getColumn() << "x" << getRow() //cmess2 << " - GCell [" << getIndex() << "] @" << getColumn() << "x" << getRow()
@ -865,7 +853,7 @@ namespace Katabatic {
// << " displaced:" << (*isegment) << "]." // << " displaced:" << (*isegment) << "]."
// << endl; // << endl;
return true; if ( moved ) return true;
} }
return false; return false;
@ -1019,11 +1007,11 @@ namespace Katabatic {
s << "<" << _getTypeName() << " [" << _index << "] " s << "<" << _getTypeName() << " [" << _index << "] "
<< DbU::getValueString(box.getXMin()) << ":" << DbU::getValueString(box.getYMin()) << " " << DbU::getValueString(box.getXMin()) << ":" << DbU::getValueString(box.getYMin()) << " "
<< DbU::getValueString(box.getXMax()) << ":" << DbU::getValueString(box.getYMax()) << " " << DbU::getValueString(box.getXMax()) << ":" << DbU::getValueString(box.getYMax()) << " "
<< setprecision(9) << setprecision(3)
#if not defined(CHECK_DETERMINISM) #if not defined(CHECK_DETERMINISM)
<< getDensity(false) << getDensity(false) << " "
#endif #endif
<< " S:" << _routedSegmentCount << "/" << _segmentCount << getVectorString(_densities,_depth)
<< ">"; << ">";
return s.str(); return s.str();
@ -1041,8 +1029,6 @@ namespace Katabatic {
record->add ( getSlot ( "_box" , &_box ) ); record->add ( getSlot ( "_box" , &_box ) );
record->add ( getSlot ( "_depth" , &_depth ) ); record->add ( getSlot ( "_depth" , &_depth ) );
record->add ( getSlot ( "_saturated" , _saturated ) ); record->add ( getSlot ( "_saturated" , _saturated ) );
record->add ( getSlot ( "_segmentCount" , _segmentCount ) );
record->add ( getSlot ( "_routedSegmentCount", _routedSegmentCount ) );
record->add ( getSlot ( "_invalid" , _invalid ) ); record->add ( getSlot ( "_invalid" , _invalid ) );
RoutingGauge* rg = getGCellGrid()->getKatabatic()->getRoutingGauge(); RoutingGauge* rg = getGCellGrid()->getKatabatic()->getRoutingGauge();
@ -1168,7 +1154,7 @@ namespace Katabatic {
{ {
ostringstream s; ostringstream s;
s << setprecision(9); s << setprecision(3);
for ( size_t i=0 ; i<size ; i++ ) { for ( size_t i=0 ; i<size ; i++ ) {
if ( !i ) s << "["; if ( !i ) s << "[";
else s << " "; else s << " ";

View File

@ -56,7 +56,7 @@ namespace Katabatic {
GCellGrid::GCellGrid ( KatabaticEngine* ktbt ) GCellGrid::GCellGrid ( KatabaticEngine* ktbt )
: Grid<GCell> (ktbt->getCell()->getAbutmentBox()) : Grid<GCell> (ktbt->getCell()->getAbutmentBox())
, _katabatic (ktbt) , _katabatic (ktbt)
, _densityMode (MaxLayerDensity) , _densityMode (MaxDensity)
, _hEdgeCapacity(ktbt->getConfiguration()->getHEdgeCapacity()) , _hEdgeCapacity(ktbt->getConfiguration()->getHEdgeCapacity())
, _vEdgeCapacity(ktbt->getConfiguration()->getVEdgeCapacity()) , _vEdgeCapacity(ktbt->getConfiguration()->getVEdgeCapacity())
{ } { }

View File

@ -91,7 +91,7 @@ namespace Katabatic {
QPainter& painter = widget->getPainter(); QPainter& painter = widget->getPainter();
painter.setBrush 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()) ); ,widget->getDarkening()) );
painter.drawRect ( widget->dbuToDisplayRect(gcell->getBoundingBox()) ); painter.drawRect ( widget->dbuToDisplayRect(gcell->getBoundingBox()) );
} }

View File

@ -109,6 +109,7 @@ namespace Katabatic {
bool optimized = true; bool optimized = true;
while ( optimized ) { while ( optimized ) {
Session::revalidate ();
optimized = false; optimized = false;
//sort ( gcells.begin(), gcells.end(), GCell::CompareByDensity(depth) ); //sort ( gcells.begin(), gcells.end(), GCell::CompareByDensity(depth) );
queue.revalidate (); queue.revalidate ();

View File

@ -2127,7 +2127,7 @@ namespace {
AutoContact* localContact = (_south) ? _southWestContact : _northEastContact; AutoContact* localContact = (_south) ? _southWestContact : _northEastContact;
//localContact->setHAlignate ( true ); //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++ ) { for ( unsigned int i = 0 ; i < _routingPads.size() ; i++ ) {
AutoContact* rpContact = _GCell_rp_Access ( _gcell, _routingPads[i], true, false ); AutoContact* rpContact = _GCell_rp_Access ( _gcell, _routingPads[i], true, false );
AutoContact* turn1 AutoContact* turn1

View File

@ -303,11 +303,18 @@ namespace Katabatic {
_autoContacts.clear (); _autoContacts.clear ();
ltrace(110) << "AutoSegments Revalidate (after canonize)." << endl; 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 (); _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; ltrace(110) << "AutoSegments/AutoContacts queued deletion." << endl;
bool destroySegment = _katabatic->setDestroyBaseSegment ( true ); bool destroySegment = _katabatic->setDestroyBaseSegment ( true );

View File

@ -86,7 +86,7 @@ namespace Katabatic {
, ParallelOrExpanded = (1<<2) , ParallelOrExpanded = (1<<2)
, ParallelAndLayerChange = (1<<3) , ParallelAndLayerChange = (1<<3)
}; };
enum Flags { Propagate=0x1, AllowLocal=0x2 }; enum Flags { Propagate=0x1, AllowLocal=0x2, AllowTerminal=0x4 };
public: public:
@ -295,6 +295,10 @@ namespace Katabatic {
virtual void _makeDogLeg ( GCell*, bool upLayer ) = 0; virtual void _makeDogLeg ( GCell*, bool upLayer ) = 0;
virtual void desalignate ( AutoContact* ) = 0; virtual void desalignate ( AutoContact* ) = 0;
void desalignate (); void desalignate ();
bool shearUp ( GCell*
, AutoSegment*& movedUp
, float reserve
, unsigned int flags );
bool _check () const; bool _check () const;
// Inspector Management. // Inspector Management.
virtual Record* _getRecord () const = 0; virtual Record* _getRecord () const = 0;

View File

@ -134,11 +134,8 @@ namespace Katabatic {
inline float getCDensity ( bool update=true ) const; inline float getCDensity ( bool update=true ) const;
inline float getDensity ( size_t depth, bool update=true ) const; inline float getDensity ( size_t depth, bool update=true ) const;
float getDensity ( bool update=true ) const; float getDensity ( bool update=true ) const;
float getMaxHVDensity ( bool update=true ) const;
inline float getBlockage ( unsigned int depth ) const; inline float getBlockage ( unsigned int depth ) const;
float getStiffness () const; float getStiffness () const;
inline unsigned int getSegmentCount () const;
inline unsigned int getRoutedCount () const;
inline vector<AutoSegment*>* getVSegments (); inline vector<AutoSegment*>* getVSegments ();
inline vector<AutoSegment*>* getHSegments (); inline vector<AutoSegment*>* getHSegments ();
inline vector<AutoContact*>* getContacts (); inline vector<AutoContact*>* getContacts ();
@ -153,8 +150,6 @@ namespace Katabatic {
size_t checkDensity () const; size_t checkDensity () const;
bool checkEdgeSaturation ( float threshold ) const; bool checkEdgeSaturation ( float threshold ) const;
// Modifiers. // Modifiers.
void incSegmentCount ( int count );
void incRoutedCount ( int count );
void addBlockage ( unsigned int depth, float ); void addBlockage ( unsigned int depth, float );
inline void addVSegment ( AutoSegment* ); inline void addVSegment ( AutoSegment* );
inline void addHSegment ( AutoSegment* ); inline void addHSegment ( AutoSegment* );
@ -193,8 +188,6 @@ namespace Katabatic {
float _cDensity; float _cDensity;
float* _densities; float* _densities;
float* _saturateDensities; float* _saturateDensities;
unsigned int _segmentCount;
unsigned int _routedSegmentCount;
bool _saturated; bool _saturated;
bool _invalid; bool _invalid;
Key _key; Key _key;
@ -234,8 +227,6 @@ namespace Katabatic {
inline vector<AutoSegment*>* GCell::getVSegments () { return &_vsegments; } inline vector<AutoSegment*>* GCell::getVSegments () { return &_vsegments; }
inline vector<AutoSegment*>* GCell::getHSegments () { return &_hsegments; } inline vector<AutoSegment*>* GCell::getHSegments () { return &_hsegments; }
inline vector<AutoContact*>* GCell::getContacts () { return &_contacts; } 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 string GCell::_getTypeName () const { return _TName("GCell"); }
inline void GCell::invalidate () { _invalid = true; } inline void GCell::invalidate () { _invalid = true; }
inline const GCell::Key& GCell::getKey () const { return _key; } inline const GCell::Key& GCell::getKey () const { return _key; }
@ -310,6 +301,9 @@ namespace Katabatic {
string getVectorString ( float*, size_t ); string getVectorString ( float*, size_t );
typedef std::vector<GCell*> GCellVector;
} // End of Katabatic namespace. } // End of Katabatic namespace.

View File

@ -49,9 +49,13 @@ namespace Katabatic {
class GCellGrid : public Grid<GCell> { class GCellGrid : public Grid<GCell> {
public: public:
enum Flags { AverageDensity = 1 enum Flags { AverageHVDensity=1 // Average between all densities.
, MaxHVDensity = 2 , AverageHDensity =2 // Average between all H densities.
, MaxLayerDensity = 3 , 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: public: