diff --git a/anabatic/src/AnabaticEngine.cpp b/anabatic/src/AnabaticEngine.cpp index 86f9cd22..400614bb 100644 --- a/anabatic/src/AnabaticEngine.cpp +++ b/anabatic/src/AnabaticEngine.cpp @@ -59,6 +59,7 @@ namespace Anabatic { AnabaticEngine::AnabaticEngine ( Cell* cell ) : Super(cell) + , _timer () , _configuration (new ConfigurationConcrete()) , _matrix () , _gcells () @@ -137,14 +138,14 @@ namespace Anabatic { if (layerGauges[depth]->getDirection() != Constant::Horizontal) continue; capacity += layerGauges[depth]->getTrackNumber( span.getVMin() - ab.getYMin() , span.getVMax() - ab.getYMin() ); - //cdebug.log(110) << "Horizontal edge capacity:" << capacity << endl; + //cdebug_log(110,0) << "Horizontal edge capacity:" << capacity << endl; } if (flags & Flags::Vertical) { if (layerGauges[depth]->getDirection() != Constant::Vertical) continue; capacity += layerGauges[depth]->getTrackNumber( span.getVMin() - ab.getXMin() , span.getVMax() - ab.getXMin() ); - //cdebug.log(110) << "Vertical edge capacity:" << capacity << endl; + //cdebug_log(110,0) << "Vertical edge capacity:" << capacity << endl; } } @@ -163,6 +164,33 @@ namespace Anabatic { } + void AnabaticEngine::startMeasures () + { + _timer.resetIncrease(); + _timer.start(); + } + + + void AnabaticEngine::stopMeasures () + { _timer.stop(); } + + + void AnabaticEngine::printMeasures ( const string& tag ) const + { + ostringstream result; + + result << Timer::getStringTime(_timer.getCombTime()) + << ", " << Timer::getStringMemory(_timer.getIncrease()); + cmess1 << Dots::asString( " - Done in", result.str() ) << endl; + + result.str(""); + result << _timer.getCombTime() + << "s, +" << (_timer.getIncrease()>>10) << "Kb/" + << (_timer.getMemorySize()>>10) << "Kb"; + cmess2 << Dots::asString( " - Raw measurements", result.str() ) << endl; + } + + string AnabaticEngine::_getTypeName () const { return getString(_toolName); } diff --git a/anabatic/src/Configuration.cpp b/anabatic/src/Configuration.cpp index 705ac959..f2fef557 100644 --- a/anabatic/src/Configuration.cpp +++ b/anabatic/src/Configuration.cpp @@ -73,6 +73,8 @@ namespace Anabatic { , _allowedDepth (0) , _edgeLength (DbU::fromLambda(Cfg::getParamInt("anabatic.edgeLength",24)->asInt())) , _edgeWidth (DbU::fromLambda(Cfg::getParamInt("anabatic.edgeWidth" , 4)->asInt())) + , _edgeCostH (Cfg::getParamDouble("anabatic.edgeCostH", 9.0)->asDouble()) + , _edgeCostK (Cfg::getParamDouble("anabatic.edgeCostK",-10.0)->asDouble()) { if (cg == NULL) cg = AllianceFramework::get()->getCellGauge(); if (rg == NULL) rg = AllianceFramework::get()->getRoutingGauge(); @@ -120,6 +122,8 @@ namespace Anabatic { , _rg (NULL) , _extensionCaps(other._extensionCaps) , _allowedDepth (other._allowedDepth) + , _edgeCostH (other._edgeCostH) + , _edgeCostK (other._edgeCostK) { if (other._cg) _cg = other._cg->getClone(); if (other._rg) _rg = other._rg->getClone(); @@ -128,7 +132,7 @@ namespace Anabatic { ConfigurationConcrete::~ConfigurationConcrete () { - cdebug.log(145) << "About to delete attribute _rg (RoutingGauge)." << endl; + cdebug_log(145,0) << "About to delete attribute _rg (RoutingGauge)." << endl; _cg->destroy (); _rg->destroy (); } @@ -284,6 +288,14 @@ namespace Anabatic { { return _edgeWidth; } + float ConfigurationConcrete::getEdgeCostH () const + { return _edgeCostH; } + + + float ConfigurationConcrete::getEdgeCostK () const + { return _edgeCostK; } + + void ConfigurationConcrete::print ( Cell* cell ) const { @@ -317,11 +329,13 @@ namespace Anabatic { Record* ConfigurationConcrete::_getRecord () const { Record* record = new Record ( _getString() ); - record->add ( getSlot( "_rg" , _rg ) ); - record->add ( getSlot( "_gmetalh" , _gmetalh ) ); - record->add ( getSlot( "_gmetalv" , _gmetalv ) ); - record->add ( getSlot( "_gcontact" , _gcontact ) ); - record->add ( getSlot( "_allowedDepth" , _allowedDepth ) ); + record->add ( getSlot( "_rg" , _rg ) ); + record->add ( getSlot( "_gmetalh" , _gmetalh ) ); + record->add ( getSlot( "_gmetalv" , _gmetalv ) ); + record->add ( getSlot( "_gcontact" , _gcontact ) ); + record->add ( getSlot( "_allowedDepth", _allowedDepth ) ); + record->add ( getSlot( "_edgeCostH" , _edgeCostH ) ); + record->add ( getSlot( "_edgeCostK" , _edgeCostK ) ); return ( record ); } diff --git a/anabatic/src/Dijkstra.cpp b/anabatic/src/Dijkstra.cpp index 3088484f..5775f487 100644 --- a/anabatic/src/Dijkstra.cpp +++ b/anabatic/src/Dijkstra.cpp @@ -22,6 +22,7 @@ #include "hurricane/Vertical.h" #include "hurricane/UpdateSession.h" #include "hurricane/DebugSession.h" +#include "crlcore/Utilities.h" #include "anabatic/AnabaticEngine.h" #include "anabatic/Dijkstra.h" @@ -45,7 +46,7 @@ namespace Anabatic { // Class : "Anabatic::Vertex". - float Vertex::unreached = numeric_limits::max(); + DbU::Unit Vertex::unreached = std::numeric_limits::max(); bool Vertex::hasValidStamp () const @@ -63,7 +64,8 @@ namespace Anabatic { + " @(" + DbU::getValueString(_gcell->getXMin()) + "," + DbU::getValueString(_gcell->getYMin()) + ")" + " connexId:" + getString(_connexId) - + " d:" + ((_distance == unreached) ? "unreached" : getString(_distance) ) + + " d:" + ((_distance == unreached) ? "unreached" : DbU::getValueString(_distance) ) + + "+" + getString(_branchId) + " stamp:" + (hasValidStamp() ? "valid" : "outdated") + " from:" + ((_from) ? "set" : "NULL") + ">"; @@ -74,7 +76,7 @@ namespace Anabatic { void Vertex::notify ( Vertex* vertex, unsigned int flags ) { //Vertex* vertex = getOwner(); - cdebug.log(111) << "Vertex::notify() " << vertex << endl; + cdebug_log(111,0) << "Vertex::notify() " << vertex << endl; // Take into account the GCell modification here. } @@ -101,14 +103,14 @@ namespace Anabatic { } - float Dijkstra::getDistance ( const Vertex* a, const Vertex* b, const Edge* e ) + DbU::Unit Dijkstra::_distance ( const Vertex* a, const Vertex* b, const Edge* e ) { - float distance = a->getDistance() + e->getDistance(); + DbU::Unit distance = a->getDistance() + e->getDistance(); - Edge* aFrom = a->getFrom(); - if (aFrom) { - distance += (aFrom->isHorizontal() xor e->isHorizontal()) ? 3.0 : 0.0; - } + // Edge* aFrom = a->getFrom(); + // if (aFrom) { + // distance += (aFrom->isHorizontal() xor e->isHorizontal()) ? 3.0 : 0.0; + // } return distance; } @@ -116,6 +118,7 @@ namespace Anabatic { Dijkstra::Dijkstra ( AnabaticEngine* anabatic ) : _anabatic (anabatic) , _vertexes () + , _distanceCb (_distance) , _mode (Mode::Standart) , _net (NULL) , _stamp (-1) @@ -142,8 +145,8 @@ namespace Anabatic { { _net = net; - DebugSession::open( _net, 110, 120 ); - cdebug.log(111,1) << "Dijkstra::load() " << _net << endl; + DebugSession::open( _net, 112, 120 ); + cdebug_log(112,1) << "Dijkstra::load() " << _net << endl; _sources.clear(); _targets.clear(); @@ -170,11 +173,13 @@ namespace Anabatic { Vertex* vertex = gcell->getObserver(GCell::Observable::Vertex); if (vertex->getConnexId() < 0) { + vertex->setDistance( Vertex::unreached ); vertex->setStamp ( _stamp ); vertex->setConnexId( _targets.size() ); + vertex->setBranchId( 0 ); vertex->setFrom ( NULL ); _targets.insert( vertex ); - cdebug.log(111) << "Add Vertex: " << vertex << endl; + cdebug_log(112,0) << "Add Vertex: " << vertex << endl; } Contact* gcontact = vertex->getGContact( _net ); @@ -182,8 +187,8 @@ namespace Anabatic { rp->getBodyHook()->attach( gcontact->getBodyHook() ); } - cdebug.log(111) << "Search area: " << _searchArea << endl; - cdebug.tabw(111,-1); + cdebug_log(112,0) << "Search area: " << _searchArea << endl; + cdebug_tabw(112,-1); DebugSession::close(); } @@ -191,9 +196,11 @@ namespace Anabatic { void Dijkstra::_selectFirstSource () { if (_targets.empty()) { - cerr << Error( "Dijkstra::_selectFirstSource(): %s has no vertexes to route, ignored." - , getString(_net).c_str() - ) << endl; +#if 0 + cparanoid << Error( "Dijkstra::_selectFirstSource(): %s has no vertexes to route, ignored." + , getString(_net).c_str() + ) << endl; +#endif return; } @@ -236,13 +243,13 @@ namespace Anabatic { _targets.erase ( firstSource ); _sources.insert( firstSource ); - cdebug.log(111) << "Dijkstra::_selectFirstSource() " << *_sources.begin() << endl; + cdebug_log(112,0) << "Dijkstra::_selectFirstSource() " << *_sources.begin() << endl; } bool Dijkstra::_propagate ( Flags enabledSides ) { - cdebug.log(111,1) << "Dijkstra::_propagate() " << _net << endl; + cdebug_log(112,1) << "Dijkstra::_propagate() " << _net << endl; while ( not _queue.empty() ) { _queue.dump(); @@ -260,38 +267,31 @@ namespace Anabatic { if (not _searchArea.contains(vneighbor->getCenter())) continue; - cdebug.log(111) << "| Edge " << edge << endl; - cdebug.log(111) << "+ Neighbor: " << vneighbor << endl; + cdebug_log(111,0) << "| Edge " << edge << endl; + cdebug_log(111,0) << "+ Neighbor: " << vneighbor << endl; - float distance = getDistance( current, vneighbor, edge ); + DbU::Unit distance = _distanceCb( current, vneighbor, edge ); if (vneighbor->getConnexId() == _connectedsId) continue; - if (vneighbor->getConnexId() >= 0) { - vneighbor->setFrom ( edge ); - vneighbor->setDistance( distance ); - cdebug.log(111) << "Push (before): (size:" << _queue.size() << ")" << endl; - _queue.push( vneighbor ); - cdebug.log(111) << "Push (target): (size:" << _queue.size() << ") " << vneighbor << endl; - continue; - } - - if (distance < vneighbor->getDistance()) { - cdebug.log(111) << "Push (before erase): (size:" << _queue.size() << ") " << vneighbor << endl; + if ( (distance < vneighbor->getDistance()) + or ( (distance == vneighbor->getDistance()) + and (current->getBranchId() > vneighbor->getBranchId())) ) { if (vneighbor->getDistance() != Vertex::unreached) { _queue.erase( vneighbor ); - _queue.dump(); } else { - vneighbor->setStamp ( _stamp ); - vneighbor->setConnexId( -1 ); + if (not vneighbor->hasValidStamp()) { + vneighbor->setConnexId( -1 ); + vneighbor->setStamp ( _stamp ); + } } - cdebug.log(111) << "Push (after erase): (size:" << _queue.size() << ")" << endl; + vneighbor->setBranchId( current->getBranchId() ); vneighbor->setDistance( distance ); vneighbor->setFrom ( edge ); _queue.push( vneighbor ); - cdebug.log(111) << "Push: (size:" << _queue.size() << ") " << vneighbor << endl; + cdebug_log(111,0) << "Push: (size:" << _queue.size() << ") " << vneighbor << endl; } } @@ -299,22 +299,24 @@ namespace Anabatic { } // We did reach another target (different ). - // Tag back the path. - cdebug.log(111) << "Trace back" << endl; + // Tag back the path, with a higher . + int branchId = _sources.size(); + cdebug_log(112,0) << "Trace back branchId:" << branchId << endl; _targets.erase( current ); while ( current ) { - cdebug.log(111) << "| " << current << endl; + cdebug_log(112,0) << "| " << current << endl; if (current->getConnexId() == _connectedsId) break; _sources.insert( current ); current->setDistance( 0.0 ); current->setConnexId( _connectedsId ); + current->setBranchId( branchId ); _queue.push( current ); current = current->getPredecessor(); } - cdebug.tabw(111,-1); + cdebug_tabw(112,-1); return true; } @@ -322,22 +324,22 @@ namespace Anabatic { , getString(_net).c_str() ) << endl; - cdebug.tabw(111,-1); + cdebug_tabw(112,-1); return false; } void Dijkstra::run ( Dijkstra::Mode mode ) { - DebugSession::open( _net, 110, 120 ); + DebugSession::open( _net, 112, 120 ); - cdebug.log(111,1) << "Dijkstra::run() on " << _net << " mode:" << mode << endl; + cdebug_log(112,1) << "Dijkstra::run() on " << _net << " mode:" << mode << endl; _mode = mode; _selectFirstSource(); if (_sources.empty()) { - cdebug.log(111) << "No source to start, not routed." << endl; - cdebug.tabw(111,-1); + cdebug_log(112,0) << "No source to start, not routed." << endl; + cdebug_tabw(112,-1); return; } @@ -355,7 +357,7 @@ namespace Anabatic { _connectedsId = source->getConnexId(); source->setDistance( 0.0 ); - cdebug.log(111) << "Push source: (size:" << _queue.size() << ") " + cdebug_log(112,0) << "Push source: (size:" << _queue.size() << ") " << source << " _connectedsId:" << _connectedsId << endl; @@ -364,20 +366,20 @@ namespace Anabatic { _toWires(); _queue.clear(); - cdebug.tabw(111,-1); + cdebug_tabw(112,-1); DebugSession::close(); } void Dijkstra::_toWires () { - cdebug.log(111,1) << "Dijkstra::toWires() " << _net << endl; + cdebug_log(111,1) << "Dijkstra::toWires() " << _net << endl; for ( Vertex* vertex : _sources ) { Edge* from = vertex->getFrom(); if (not from) continue; - cdebug.log(111) << "| " << vertex << endl; + cdebug_log(111,0) << "| " << vertex << endl; from->incRealOccupancy( 1 ); @@ -408,7 +410,7 @@ namespace Anabatic { } } - cdebug.tabw(111,-1); + cdebug_tabw(111,-1); } diff --git a/anabatic/src/Edge.cpp b/anabatic/src/Edge.cpp index 7a8ec234..068bee37 100644 --- a/anabatic/src/Edge.cpp +++ b/anabatic/src/Edge.cpp @@ -85,10 +85,10 @@ namespace Anabatic { Edge* edge = new Edge ( source, target, flags ); edge->_postCreate(); - cdebug.log(110,1) << "Edge::create(): " << (void*)edge << ":" << edge << endl; - cdebug.log(110) << "source:" << (void*)source << ":" << edge->getSource() << endl; - cdebug.log(110) << "target:" << (void*)target << ":" << edge->getTarget() << endl; - cdebug.tabw(110,-1); + cdebug_log(110,1) << "Edge::create(): " << (void*)edge << ":" << edge << endl; + cdebug_log(110,0) << "source:" << (void*)source << ":" << edge->getSource() << endl; + cdebug_log(110,0) << "target:" << (void*)target << ":" << edge->getTarget() << endl; + cdebug_tabw(110,-1); return edge; } @@ -156,14 +156,17 @@ namespace Anabatic { } - float Edge::getDistance () const + DbU::Unit Edge::getDistance () const { Point sourceCenter = getSource()->getBoundingBox().getCenter(); Point targetCenter = getTarget()->getBoundingBox().getCenter(); DbU::Unit dx = targetCenter.getX() - sourceCenter.getX(); DbU::Unit dy = targetCenter.getY() - sourceCenter.getY(); - return (float)( ((dx > 0) ? dx : -dx) + ((dy > 0) ? dy : -dy) ) / (float)unity; + if (dx < 0) dx = -dx; + if (dx) dx += DbU::fromLambda( 0.1 ); + + return dx + ((dy > 0) ? dy : -dy); } @@ -193,7 +196,7 @@ namespace Anabatic { Super::invalidate( false ); _flags.reset( Flags::Invalidated ); - cdebug.log(110) << "Edge::_revalidate() " << this << endl; + cdebug_log(110,0) << "Edge::_revalidate() " << this << endl; } diff --git a/anabatic/src/Edges.cpp b/anabatic/src/Edges.cpp index d3927b89..588f7d0f 100644 --- a/anabatic/src/Edges.cpp +++ b/anabatic/src/Edges.cpp @@ -33,14 +33,14 @@ namespace Anabatic { , _filterFlags(filterFlags) , _iedge (0) { - // cdebug.log(110) << "GCell_Edges::Locator::Locator() " << isValid() << endl; + // cdebug_log(110,0) << "GCell_Edges::Locator::Locator() " << isValid() << endl; if (_gcell->getEastEdges().empty() or not _filterFlags.contains(Flags::EastSide)) progress(); } EdgesHL* GCell_Edges::Locator::getClone () const { - // cdebug.log(110) << "GCell_Edges::Locator::getClone()" << endl; + // cdebug_log(110,0) << "GCell_Edges::Locator::getClone()" << endl; return new Locator (*this); } @@ -61,48 +61,48 @@ namespace Anabatic { void GCell_Edges::Locator::progress () { - // cdebug.log(110) << "GCell_Edges::Locator::progress() [from] " << _stateFlags << " iedge:" << _iedge << endl; - // cdebug.log(110) << " East:" << _gcell->getEastEdges().size() + // cdebug_log(110,0) << "GCell_Edges::Locator::progress() [from] " << _stateFlags << " iedge:" << _iedge << endl; + // cdebug_log(110,0) << " East:" << _gcell->getEastEdges().size() // << " North:" << _gcell->getNorthEdges().size() // << " West:" << _gcell->getWestEdges().size() // << " South:" << _gcell->getSouthEdges().size() << endl; - // cdebug.log(110) << this << endl; + // cdebug_log(110,0) << this << endl; ++_iedge; while (_stateFlags) { if ((_stateFlags & _filterFlags).contains(Flags::EastSide)) { if (_iedge < _gcell->getEastEdges().size()) break; - // cdebug.log(110) << "Switching to North side." << endl; + // cdebug_log(110,0) << "Switching to North side." << endl; _stateFlags = Flags::NorthSide; _iedge = 0; - // cdebug.log(110) << this << endl; + // cdebug_log(110,0) << this << endl; continue; } if ((_stateFlags & _filterFlags).contains(Flags::NorthSide)) { if (_iedge < _gcell->getNorthEdges().size()) break; - // cdebug.log(110) << "Switching to West side." << endl; + // cdebug_log(110,0) << "Switching to West side." << endl; _stateFlags = Flags::WestSide; _iedge = 0; - // cdebug.log(110) << this << endl; + // cdebug_log(110,0) << this << endl; continue; } if ((_stateFlags & _filterFlags).contains(Flags::WestSide)) { if (_iedge < _gcell->getWestEdges().size()) break; - // cdebug.log(110) << "Switching to South side." << endl; + // cdebug_log(110,0) << "Switching to South side." << endl; _stateFlags = Flags::SouthSide; _iedge = 0; continue; } if ((_stateFlags & _filterFlags).contains(Flags::SouthSide)) { if (_iedge < _gcell->getSouthEdges().size()) break; - // cdebug.log(110) << "All edges done." << endl; + // cdebug_log(110,0) << "All edges done." << endl; _stateFlags = 0; _iedge = 0; break;; } } - cdebug.log(110) << "GCell_Edges::Locator::progress() [to] " << _stateFlags << " iedge:" << _iedge << endl; + //cdebug_log(110,0) << "GCell_Edges::Locator::progress() [to] " << _stateFlags << " iedge:" << _iedge << endl; } diff --git a/anabatic/src/GCell.cpp b/anabatic/src/GCell.cpp index 534c4c7d..0314f5af 100644 --- a/anabatic/src/GCell.cpp +++ b/anabatic/src/GCell.cpp @@ -108,59 +108,59 @@ namespace Anabatic { void GCell::_add ( Edge* edge, Flags side ) { - cdebug.log(110,1) << "GCell::_add(side): side:" << side << " " << edge << endl; + cdebug_log(110,1) << "GCell::_add(side): side:" << side << " " << edge << endl; if (side.contains(Flags::WestSide)) { - cdebug.log(110) << "Adding to West side of " << this << endl; + cdebug_log(110,0) << "Adding to West side of " << this << endl; for ( auto iedge=_westEdges.begin() ; iedge != _westEdges.end() ; ++iedge ) if ((*iedge)->getAxisMin() > edge->getAxisMin()) { _westEdges.insert( iedge, edge ); - cdebug.tabw(110,-1); + cdebug_tabw(110,-1); return; } _westEdges.push_back( edge ); } if (side.contains(Flags::EastSide)) { - cdebug.log(110) << "Adding to East side of " << this << endl; + cdebug_log(110,0) << "Adding to East side of " << this << endl; for ( auto iedge=_eastEdges.begin() ; iedge != _eastEdges.end() ; ++iedge ) if ((*iedge)->getAxisMin() > edge->getAxisMin()) { _eastEdges.insert( iedge, edge ); - cdebug.tabw(110,-1); + cdebug_tabw(110,-1); return; } _eastEdges.push_back( edge ); } if (side.contains(Flags::SouthSide)) { - cdebug.log(110) << "Adding to South side of " << this << endl; + cdebug_log(110,0) << "Adding to South side of " << this << endl; for ( auto iedge=_southEdges.begin() ; iedge != _southEdges.end() ; ++iedge ) - cdebug.log(110) << "| @" << DbU::getValueString((*iedge)->getAxisMin()) << " " << *iedge << endl; + cdebug_log(110,0) << "| @" << DbU::getValueString((*iedge)->getAxisMin()) << " " << *iedge << endl; for ( auto iedge=_southEdges.begin() ; iedge != _southEdges.end() ; ++iedge ) if ((*iedge)->getAxisMin() > edge->getAxisMin()) { - cdebug.log(110) << "Insert *before* " << *iedge << endl; + cdebug_log(110,0) << "Insert *before* " << *iedge << endl; _southEdges.insert( iedge, edge ); for ( auto iedge2=_southEdges.begin() ; iedge2 != _southEdges.end() ; ++iedge2 ) - cdebug.log(110) << "| @" << DbU::getValueString((*iedge2)->getAxisMin()) << " " << *iedge2 << endl; - cdebug.tabw(110,-1); + cdebug_log(110,0) << "| @" << DbU::getValueString((*iedge2)->getAxisMin()) << " " << *iedge2 << endl; + cdebug_tabw(110,-1); return; } _southEdges.push_back( edge ); } if (side.contains(Flags::NorthSide)) { - cdebug.log(110) << "Adding to North side of " << this << endl; + cdebug_log(110,0) << "Adding to North side of " << this << endl; for ( auto iedge=_northEdges.begin() ; iedge != _northEdges.end() ; ++iedge ) if ((*iedge)->getAxisMin() > edge->getAxisMin()) { _northEdges.insert( iedge, edge ); - cdebug.tabw(110,-1); + cdebug_tabw(110,-1); return; } _northEdges.push_back( edge ); } - cdebug.tabw(110,-1); + cdebug_tabw(110,-1); } @@ -260,7 +260,7 @@ namespace Anabatic { GCell* GCell::vcut ( DbU::Unit x ) { - cdebug.log(119,1) << "GCell::vcut() @x:" << DbU::getValueString(x) << " " << this << endl; + cdebug_log(119,1) << "GCell::vcut() @x:" << DbU::getValueString(x) << " " << this << endl; if ( (x < getXMin()) or (x > getXMax()) ) throw Error( "GCell::vcut(): Vertical cut axis at %s is outside GCell box,\n" @@ -270,17 +270,17 @@ namespace Anabatic { ); GCell* chunk = _create( x, getYMin() ); - cdebug.log(119) << "New chunk:" << chunk << endl; + cdebug_log(119,0) << "New chunk:" << chunk << endl; _moveEdges( chunk, 0, Flags::EastSide ); Edge::create( this, chunk, Flags::Horizontal ); if (not _southEdges.empty()) { - cdebug.log(110) << "Split/create south edges." << endl; + cdebug_log(110,0) << "Split/create south edges." << endl; size_t iedge = 0; for ( ; (iedge < _southEdges.size()) ; ++iedge ) { - cdebug.log(110) << "[" << iedge << "] xmax of:" + cdebug_log(110,0) << "[" << iedge << "] xmax of:" << _southEdges[iedge]->getOpposite(this) << " " << _southEdges[iedge] << endl; if (x <= _southEdges[iedge]->getOpposite(this)->getXMax()) break; @@ -295,7 +295,7 @@ namespace Anabatic { } if (not _northEdges.empty()) { - cdebug.log(110) << "Split/create north edges." << endl; + cdebug_log(110,0) << "Split/create north edges." << endl; size_t iedge = 0; for ( ; (iedge < _northEdges.size()) ; ++iedge ) @@ -312,7 +312,7 @@ namespace Anabatic { _revalidate(); chunk->_revalidate(); - cdebug.tabw(119,-1); + cdebug_tabw(119,-1); return chunk; } @@ -320,7 +320,7 @@ namespace Anabatic { GCell* GCell::hcut ( DbU::Unit y ) { - cdebug.log(119,1) << "GCell::hcut() @y:" << DbU::getValueString(y) << " " << this << endl; + cdebug_log(119,1) << "GCell::hcut() @y:" << DbU::getValueString(y) << " " << this << endl; if ( (y < getYMin()) or (y > getYMax()) ) throw Error( "GCell::hcut(): Horizontal cut axis at %s is outside GCell box,\n" @@ -330,7 +330,7 @@ namespace Anabatic { ); GCell* chunk = _create( getXMin(), y ); - cdebug.log(119) << "New chunk:" << chunk << endl; + cdebug_log(119,0) << "New chunk:" << chunk << endl; _moveEdges( chunk, 0, Flags::NorthSide ); Edge::create( this, chunk, Flags::Vertical ); @@ -364,7 +364,7 @@ namespace Anabatic { _revalidate(); chunk->_revalidate(); - cdebug.tabw(119,-1); + cdebug_tabw(119,-1); return chunk; } @@ -422,11 +422,11 @@ namespace Anabatic { void GCell::_revalidate () { - cdebug.log(110,1) << "GCell::revalidate() " << this << endl; - cdebug.log(110,1) << "West side." << endl; for ( Edge* edge : _westEdges ) edge->revalidate(); cdebug.tabw(110,-1); - cdebug.log(110,1) << "East side." << endl; for ( Edge* edge : _eastEdges ) edge->revalidate(); cdebug.tabw(110,-1); - cdebug.log(110,1) << "South side." << endl; for ( Edge* edge : _southEdges ) edge->revalidate(); cdebug.tabw(110,-1); - cdebug.log(110,1) << "North side." << endl; for ( Edge* edge : _northEdges ) edge->revalidate(); cdebug.tabw(110,-1); + cdebug_log(110,1) << "GCell::revalidate() " << this << endl; + cdebug_log(110,1) << "West side." << endl; for ( Edge* edge : _westEdges ) edge->revalidate(); cdebug_tabw(110,-1); + cdebug_log(110,1) << "East side." << endl; for ( Edge* edge : _eastEdges ) edge->revalidate(); cdebug_tabw(110,-1); + cdebug_log(110,1) << "South side." << endl; for ( Edge* edge : _southEdges ) edge->revalidate(); cdebug_tabw(110,-1); + cdebug_log(110,1) << "North side." << endl; for ( Edge* edge : _northEdges ) edge->revalidate(); cdebug_tabw(110,-1); if (_xmin > getXMax()+1) cerr << Error( "GCell::_revalidate(): %s, X Min is greater than Max.", getString(this).c_str() ); @@ -434,21 +434,21 @@ namespace Anabatic { cerr << Error( "GCell::_revalidate(): %s, Y Min is greater than Max.", getString(this).c_str() ); _anabatic->_updateLookup( this ); - _anabatic->getMatrix()->show(); - cdebug.tabw(110,-1); + //_anabatic->getMatrix()->show(); + cdebug_tabw(110,-1); } void GCell::_moveEdges ( GCell* dest, size_t ibegin, Flags flags ) { - cdebug.log(110,1) << "GCell::_moveEdges() " << this << endl; - cdebug.log(110) << " toward " << dest << endl; - cdebug.log(110) << " ibegin: " << ibegin << " flags:" << flags << endl; + cdebug_log(110,1) << "GCell::_moveEdges() " << this << endl; + cdebug_log(110,0) << " toward " << dest << endl; + cdebug_log(110,0) << " ibegin: " << ibegin << " flags:" << flags << endl; size_t iclear = ibegin; if (flags.contains(Flags::SouthSide) and not _southEdges.empty()) { - cdebug.log(110) << "South side." << endl; + cdebug_log(110,0) << "South side." << endl; if (iclear < _southEdges.size()) { for ( size_t iedge=ibegin ; (iedge < _southEdges.size()) ; ++iedge ) { @@ -468,7 +468,7 @@ namespace Anabatic { } if (flags.contains(Flags::NorthSide) and not _northEdges.empty()) { - cdebug.log(110) << "North side." << endl; + cdebug_log(110,0) << "North side." << endl; if (iclear < _northEdges.size()) { for ( size_t iedge=ibegin ; (iedge < _northEdges.size()) ; ++iedge ) { @@ -488,7 +488,7 @@ namespace Anabatic { } if (flags.contains(Flags::WestSide) and not _westEdges.empty()) { - cdebug.log(110) << "West side." << endl; + cdebug_log(110,0) << "West side." << endl; if (iclear < _westEdges.size()) { for ( size_t iedge=ibegin ; (iedge < _westEdges.size()) ; ++iedge ) { @@ -508,7 +508,7 @@ namespace Anabatic { } if (flags.contains(Flags::EastSide) and not _eastEdges.empty()) { - cdebug.log(110) << "East side." << endl; + cdebug_log(110,0) << "East side." << endl; if (iclear < _eastEdges.size()) { for ( size_t iedge=ibegin ; (iedge < _eastEdges.size()) ; ++iedge ) { @@ -527,7 +527,7 @@ namespace Anabatic { } } - cdebug.tabw(110,-1); + cdebug_tabw(110,-1); } @@ -536,7 +536,7 @@ namespace Anabatic { for ( Contact* contact : _contacts ) { if (contact->getNet() == net) { - cdebug.log(111) << "GCell::getGContact(): " << contact << endl; + cdebug_log(111,0) << "GCell::getGContact(): " << contact << endl; return contact; } } @@ -549,7 +549,7 @@ namespace Anabatic { , DbU::fromLambda(2.0) , DbU::fromLambda(2.0) ); - cdebug.log(111) << "GCell::getGContact(): " << contact << endl; + cdebug_log(111,0) << "GCell::getGContact(): " << contact << endl; return contact; } diff --git a/anabatic/src/GraphicAnabaticEngine.cpp b/anabatic/src/GraphicAnabaticEngine.cpp index 6a53e357..3708e777 100644 --- a/anabatic/src/GraphicAnabaticEngine.cpp +++ b/anabatic/src/GraphicAnabaticEngine.cpp @@ -14,6 +14,7 @@ // +-----------------------------------------------------------------+ +#include #include #include #include @@ -64,6 +65,43 @@ namespace Anabatic { // ------------------------------------------------------------------- // Test functions. + + class DigitalDistance { + public: + inline DigitalDistance ( float h, float k ); + DbU::Unit operator() ( const Vertex* source ,const Vertex* target,const Edge* edge ) const; + private: + // For an explanation of h & k parameters, see: + // "KNIK, routeur global pour la plateforme Coriolis", p. 52. + float _h; + float _k; + }; + + + inline DigitalDistance::DigitalDistance ( float h, float k ) : _h(h), _k(k) { } + + + DbU::Unit DigitalDistance::operator() ( const Vertex* source ,const Vertex* target,const Edge* edge ) const + { + if (edge->getCapacity() <= 0) return Vertex::unreached; + + float congestion = (float)edge->getRealOccupancy() / (float)edge->getCapacity(); + float congestionCost = 1.0 + _h / (1.0 + std::exp(_k * (congestion - 1.0))); + + float distance = (float)source->getDistance() + congestionCost * (float)edge->getDistance(); + + // Edge* sourceFrom = source->getFrom(); + // if (sourceFrom) { + // distance += ((sourceFrom->isHorizontal() xor edge->isHorizontal()) ? 3.0 : 0.0) * (float)Edge::unity; + // } + cdebug_log(112,0) << "cong:" << congestion + << " ccost:" << congestionCost + << " digitalDistance:" << DbU::getValueString((DbU::Unit)distance) << endl; + + return (DbU::Unit)distance; + } + + void anabaticTest_1 ( AnabaticEngine* engine ) { engine->getSouthWestGCell()->doGrid(); @@ -83,33 +121,33 @@ namespace Anabatic { DbU::Unit xcorner = engine->getCell()->getAbutmentBox().getXMin(); DbU::Unit ycorner = engine->getCell()->getAbutmentBox().getYMin(); - cdebug.log(119,1) << "row0: " << row0 << endl; + cdebug_log(119,1) << "row0: " << row0 << endl; GCell* row1 = row0->hcut( ycorner+DbU::fromLambda(50.0) ); - cdebug.tabw(119,-1); - cdebug.log(119,1) << "row1: " << row1 << endl; + cdebug_tabw(119,-1); + cdebug_log(119,1) << "row1: " << row1 << endl; GCell* row2 = row1->hcut( ycorner+DbU::fromLambda(2*50.0) ); - cdebug.tabw(119,-1); - cdebug.log(119,1) << "row2: " << row2 << endl; + cdebug_tabw(119,-1); + cdebug_log(119,1) << "row2: " << row2 << endl; row0 = row0->vcut( xcorner+DbU::fromLambda(50.0) ); - cdebug.tabw(119,-1); - cdebug.log(119,1) << "row0+1: " << row0 << endl; + cdebug_tabw(119,-1); + cdebug_log(119,1) << "row0+1: " << row0 << endl; row0 = row0->vcut( xcorner+DbU::fromLambda(3*50.0) ); - cdebug.tabw(119,-1); - cdebug.log(119,1) << "row0+2: " << row0 << endl; + cdebug_tabw(119,-1); + cdebug_log(119,1) << "row0+2: " << row0 << endl; row0 = row0->vcut( xcorner+DbU::fromLambda(5*50.0) ); - cdebug.tabw(119,-1); - cdebug.log(119,1) << "row0+3: " << row0 << endl; + cdebug_tabw(119,-1); + cdebug_log(119,1) << "row0+3: " << row0 << endl; row1 = row1->vcut( xcorner+DbU::fromLambda(2*50.0) ); - cdebug.tabw(119,-1); - cdebug.log(119,1) << "row1+1: " << row1 << endl; + cdebug_tabw(119,-1); + cdebug_log(119,1) << "row1+1: " << row1 << endl; - cdebug.tabw(119,-1); + cdebug_tabw(119,-1); UpdateSession::close(); } @@ -118,14 +156,14 @@ namespace Anabatic { void anabaticTest_3 ( AnabaticEngine* engine ) { for ( int i=0 ; i<4 ; ++i ) { - cdebug.log(110,1) << "Running test 3, loop:" << i << " ..." << endl; + cdebug_log(110,1) << "Running test 3, loop:" << i << " ..." << endl; if ( i%2) anabaticTest_1( engine ); else anabaticTest_2( engine ); engine->reset(); - cdebug.log(110,1) << "Test 3, loop:" << i << " completed." << endl; - cdebug.tabw(110,-1); + cdebug_log(110,1) << "Test 3, loop:" << i << " completed." << endl; + cdebug_tabw(110,-1); } } @@ -161,12 +199,28 @@ namespace Anabatic { cell->createRoutingPadRings( Cell::Flags::BuildRings ); //DebugSession::addToTrace( cell->getNet("alu_out(3)") ); - DebugSession::addToTrace( cell->getNet("imuxe.not_aux2") ); + //DebugSession::addToTrace( cell->getNet("imuxe.not_i(1)") ); + DebugSession::addToTrace( cell->getNet("r(0)") ); + DebugSession::addToTrace( cell->getNet("ialu.not_aux104") ); + + engine->startMeasures(); + + cmess1 << " o Building regular grid..." << endl; UpdateSession::open(); engine->getSouthWestGCell()->doGrid(); + UpdateSession::close(); + engine->stopMeasures(); + engine->printMeasures( "Anbatic Grid" ); + engine->startMeasures(); + + cmess1 << " o Running global routing..." << endl; + + UpdateSession::open(); Dijkstra* dijkstra = new Dijkstra ( engine ); + dijkstra->setDistance( DigitalDistance( engine->getConfiguration()->getEdgeCostH() + , engine->getConfiguration()->getEdgeCostK() ) ); for ( Net* net : cell->getNets() ) { if (net->isPower() or net->isClock()) continue; dijkstra->load( net ); @@ -174,6 +228,9 @@ namespace Anabatic { } delete dijkstra; UpdateSession::close(); + + engine->stopMeasures(); + engine->printMeasures( "Dijkstra" ); } @@ -201,29 +258,32 @@ namespace Anabatic { QPainter& painter = widget->getPainter(); QPen pen = Graphics::getPen ("Anabatic::GCell",widget->getDarkening()); - Box bb = gcell->getBoundingBox(); + Box bb = gcell->getBoundingBox(); + QRect pixelBb = widget->dbuToScreenRect(bb); painter.setPen ( pen ); painter.setBrush( Graphics::getBrush("Anabatic::GCell",widget->getDarkening()) ); - painter.drawRect( widget->dbuToScreenRect(bb) ); + painter.drawRect( pixelBb ); if (gcell->isFlat()) return; - QString text = QString("id:%1").arg(gcell->getId()); - QFont font = Graphics::getFixedFont( QFont::Bold ); - painter.setFont(font); + if (pixelBb.width() > 150) { + QString text = QString("id:%1").arg(gcell->getId()); + QFont font = Graphics::getFixedFont( QFont::Bold ); + painter.setFont(font); - pen.setWidth( 1 ); - painter.setPen( pen ); + pen.setWidth( 1 ); + painter.setPen( pen ); - painter.save (); - painter.translate( widget->dbuToScreenPoint(bb.getCenter().getX(), bb.getCenter().getY()) ); - painter.drawRect (QRect( -75, -25, 150, 50 )); - painter.drawText (QRect( -75, -25, 150, 50 ) - , text - , QTextOption(Qt::AlignCenter) - ); - painter.restore (); + painter.save (); + painter.translate( widget->dbuToScreenPoint(bb.getCenter().getX(), bb.getCenter().getY()) ); + painter.drawRect (QRect( -75, -25, 150, 50 )); + painter.drawText (QRect( -75, -25, 150, 50 ) + , text + , QTextOption(Qt::AlignCenter) + ); + painter.restore (); + } } @@ -240,6 +300,9 @@ namespace Anabatic { , const Transformation& transformation ) { + static QFont font = Graphics::getFixedFont( QFont::Bold ); + static int fontHeight = QFontMetrics(font).height(); + const Edge* edge = static_cast(go); if (edge) { @@ -258,13 +321,15 @@ namespace Anabatic { if (edge->getCapacity() > 0.0) brush = Graphics::getColorScale( ColorScale::Fire ).getBrush( occupancy, widget->getDarkening() ); + QRect pixelBb = widget->dbuToScreenRect( bb, false); painter.setPen( Qt::NoPen ); painter.setBrush( brush ); - painter.drawRect( widget->dbuToScreenRect( bb, false) ); + painter.drawRect( pixelBb ); + + if (fontHeight > ((edge->isHorizontal()) ? pixelBb.height() : pixelBb.width()) + 4) return; QString text = QString("%1/%2").arg(edge->getRealOccupancy()).arg(edge->getCapacity()); - QColor color ( Qt::white ); - QFont font = Graphics::getFixedFont( QFont::Bold ); + QColor color ( (occupancy > 170) ? Qt::black : Qt::white ); painter.setPen (DisplayStyle::darken(color,widget->getDarkening())); painter.setFont(font); diff --git a/anabatic/src/Matrix.cpp b/anabatic/src/Matrix.cpp index 6508d227..0de852da 100644 --- a/anabatic/src/Matrix.cpp +++ b/anabatic/src/Matrix.cpp @@ -67,14 +67,14 @@ namespace Anabatic { _jmax = _area.getHeight() / side + ((_area.getHeight() % side) ? 1 : 0); _gcells.resize( _imax*_jmax ); - cdebug.log(110) << "Matrix::setCell(): " << this << endl; + cdebug_log(110,0) << "Matrix::setCell(): " << this << endl; } GCell* Matrix::getUnder ( DbU::Unit x, DbU::Unit y ) const { int index = xy2maxIndex(x,y); - cdebug.log(110) << "Matrix::getUnder() (" + cdebug_log(110,0) << "Matrix::getUnder() (" << DbU::getValueString(x) << " " << DbU::getValueString(y) << ") index:" << index << endl; return (index < 0) ? NULL : _gcells[index]->getUnder(x,y); @@ -83,26 +83,26 @@ namespace Anabatic { void Matrix::updateLookup ( GCell* gcell ) { - cdebug.log(110,1) << "Matrix::updateLookup(): " << gcell << endl; + cdebug_log(110,1) << "Matrix::updateLookup(): " << gcell << endl; if (gcell->isFlat()) { - cdebug.log(110) << " GCell is flat, no update." << endl; - cdebug.tabw(110,-1); + cdebug_log(110,0) << " GCell is flat, no update." << endl; + cdebug_tabw(110,-1); return; } Box gcellBb = gcell->getBoundingBox(); Box updateArea = _area.getIntersection( gcellBb ); - cdebug.log(110) << "_side " << _side << endl; - cdebug.log(110) << "_area.getXMin() " << _area.getXMin() << endl; - cdebug.log(110) << "_area.getYMin() " << _area.getYMin() << endl; - cdebug.log(110) << "_area.getXMax() " << _area.getXMax() << endl; - cdebug.log(110) << "_area.getYMax() " << _area.getYMax() << endl; - cdebug.log(110) << "updateArea.getXMin() " << updateArea.getXMin() << endl; - cdebug.log(110) << "updateArea.getYMin() " << updateArea.getYMin() << endl; - cdebug.log(110) << "updateArea.getXMax() " << updateArea.getXMax() << endl; - cdebug.log(110) << "updateArea.getYMax() " << updateArea.getYMax() << endl; + cdebug_log(110,0) << "_side " << _side << endl; + cdebug_log(110,0) << "_area.getXMin() " << _area.getXMin() << endl; + cdebug_log(110,0) << "_area.getYMin() " << _area.getYMin() << endl; + cdebug_log(110,0) << "_area.getXMax() " << _area.getXMax() << endl; + cdebug_log(110,0) << "_area.getYMax() " << _area.getYMax() << endl; + cdebug_log(110,0) << "updateArea.getXMin() " << updateArea.getXMin() << endl; + cdebug_log(110,0) << "updateArea.getYMin() " << updateArea.getYMin() << endl; + cdebug_log(110,0) << "updateArea.getXMax() " << updateArea.getXMax() << endl; + cdebug_log(110,0) << "updateArea.getYMax() " << updateArea.getYMax() << endl; if (updateArea.isEmpty()) { cerr << Error( "Matrix::updateLookup(): %s is not under area of %s." @@ -118,13 +118,13 @@ namespace Anabatic { DbU::Unit dx = updateArea.getXMin() - _area.getXMin(); DbU::Unit dy = updateArea.getYMin() - _area.getYMin(); - cdebug.log(110) << "raw_i:" << (dx / _side + ((dx%_side) ? 1 : 0)) + cdebug_log(110,0) << "raw_i:" << (dx / _side + ((dx%_side) ? 1 : 0)) << " raw_j:" << (dy / _side + ((dy%_side) ? 1 : 0)) << endl; - cdebug.log(110) << "indexMin:" << indexMin << endl; - cdebug.log(110) << "indexMax:" << indexMax << endl; - cdebug.log(110) << "xspan: " << xspan << endl; + cdebug_log(110,0) << "indexMin:" << indexMin << endl; + cdebug_log(110,0) << "indexMax:" << indexMax << endl; + cdebug_log(110,0) << "xspan: " << xspan << endl; - if (not indexMin.valid() or not indexMax.valid()) { cdebug.tabw(110,-1); return; } + if (not indexMin.valid() or not indexMax.valid()) { cdebug_tabw(110,-1); return; } int index = indexMin.index(); while ( index <= indexMax.index() ) { @@ -134,17 +134,17 @@ namespace Anabatic { else index += _imax - xspan; } - cdebug.tabw(110,-1); + cdebug_tabw(110,-1); } void Matrix::show () const { - cdebug.log(111) << this << endl; + cdebug_log(111,0) << this << endl; for ( size_t i=0 ; i<_gcells.size() ; ++i ) { - cdebug.log(111) << "[" << setw(3) << setfill('0') << i << setfill(' ') << "] (" - << setw(3) << index2i(i) << "," - << setw(3) << index2j(i) << ") " << _gcells[i] << endl; + cdebug_log(111,0) << "[" << setw(3) << setfill('0') << i << setfill(' ') << "] (" + << setw(3) << index2i(i) << "," + << setw(3) << index2j(i) << ") " << _gcells[i] << endl; } } diff --git a/anabatic/src/PyAnabatic.cpp b/anabatic/src/PyAnabatic.cpp index a83f8a4e..ecd8ee3e 100644 --- a/anabatic/src/PyAnabatic.cpp +++ b/anabatic/src/PyAnabatic.cpp @@ -62,7 +62,7 @@ extern "C" { // Module Initialization : "initAnabatic ()" DL_EXPORT(void) initAnabatic () { - cdebug.log(32) << "initAnabatic()" << endl; + cdebug_log(32,0) << "initAnabatic()" << endl; PyAnabaticEngine_LinkPyType(); PyGraphicAnabaticEngine_LinkPyType(); diff --git a/anabatic/src/PyAnabaticEngine.cpp b/anabatic/src/PyAnabaticEngine.cpp index b5ac08e2..1bcf8659 100644 --- a/anabatic/src/PyAnabaticEngine.cpp +++ b/anabatic/src/PyAnabaticEngine.cpp @@ -85,7 +85,7 @@ extern "C" { static PyObject* PyAnabaticEngine_get ( PyObject*, PyObject* args ) { - cdebug.log(32) << "PyAnabaticEngine_get()" << endl; + cdebug_log(32,0) << "PyAnabaticEngine_get()" << endl; AnabaticEngine* engine = NULL; @@ -102,7 +102,7 @@ extern "C" { static PyObject* PyAnabaticEngine_create ( PyObject*, PyObject* args ) { - cdebug.log(32) << "PyAnabaticEngine_create()" << endl; + cdebug_log(32,0) << "PyAnabaticEngine_create()" << endl; AnabaticEngine* engine = NULL; @@ -126,7 +126,7 @@ extern "C" { static PyObject* PyAnabaticEngine_setViewer ( PyAnabaticEngine* self, PyObject* args ) { - cdebug.log(32) << "PyAnabaticEngine_setViewer ()" << endl; + cdebug_log(32,0) << "PyAnabaticEngine_setViewer ()" << endl; HTRY METHOD_HEAD( "AnabaticEngine.setViewer()" ) @@ -148,7 +148,7 @@ extern "C" { #if 0 PyObject* PyAnabaticEngine_runTest ( PyAnabaticEngine* self, PyObject* args ) { - cdebug.log(32) << "PyAnabaticEngine_runTest()" << endl; + cdebug_log(32,0) << "PyAnabaticEngine_runTest()" << endl; HTRY METHOD_HEAD("AnabaticEngine.runTest()") diff --git a/anabatic/src/PyGraphicAnabaticEngine.cpp b/anabatic/src/PyGraphicAnabaticEngine.cpp index da307240..2eb54eb7 100644 --- a/anabatic/src/PyGraphicAnabaticEngine.cpp +++ b/anabatic/src/PyGraphicAnabaticEngine.cpp @@ -48,7 +48,7 @@ extern "C" { static PyObject* PyGraphicAnabaticEngine_grab ( PyObject* ) { - cdebug.log(32) << "PyGraphicAnabaticEngine_grab()" << endl; + cdebug_log(32,0) << "PyGraphicAnabaticEngine_grab()" << endl; PyGraphicAnabaticEngine* pyGraphicAnabaticEngine = NULL; HTRY @@ -64,7 +64,7 @@ extern "C" { static PyObject* PyGraphicAnabaticEngine_getCell ( PyGraphicAnabaticEngine* self ) { - cdebug.log(32) << "PyGraphicAnabaticEngine_getCell ()" << endl; + cdebug_log(32,0) << "PyGraphicAnabaticEngine_getCell ()" << endl; Cell* cell = NULL; diff --git a/anabatic/src/anabatic/AnabaticEngine.h b/anabatic/src/anabatic/AnabaticEngine.h index 8683d40e..19971218 100644 --- a/anabatic/src/anabatic/AnabaticEngine.h +++ b/anabatic/src/anabatic/AnabaticEngine.h @@ -20,6 +20,7 @@ #include #include +#include "hurricane/Timer.h" namespace Hurricane { class Name; class Cell; @@ -37,6 +38,7 @@ namespace Anabatic { using std::string; using std::vector; + using Hurricane::Timer; using Hurricane::Name; using Hurricane::Record; using Hurricane::Interval; @@ -69,6 +71,9 @@ namespace Anabatic { inline const Flags& flags () const; inline Flags& flags (); void reset (); + void startMeasures (); + void stopMeasures (); + void printMeasures ( const string& ) const; inline void _add ( GCell* ); inline void _remove ( GCell* ); inline void _updateLookup ( GCell* ); @@ -88,6 +93,7 @@ namespace Anabatic { AnabaticEngine& operator= ( const AnabaticEngine& ); private: static Name _toolName; + Timer _timer; Configuration* _configuration; Matrix _matrix; vector _gcells; @@ -112,7 +118,7 @@ namespace Anabatic { inline void AnabaticEngine::_add ( GCell* gcell ) { _gcells.push_back( gcell ); - std::sort( _gcells.begin(), _gcells.end(), Entity::CompareById() ); + //std::sort( _gcells.begin(), _gcells.end(), Entity::CompareById() ); } inline void AnabaticEngine::_remove ( GCell* gcell ) diff --git a/anabatic/src/anabatic/Configuration.h b/anabatic/src/anabatic/Configuration.h index fcd88581..0dad59fd 100644 --- a/anabatic/src/anabatic/Configuration.h +++ b/anabatic/src/anabatic/Configuration.h @@ -86,6 +86,8 @@ namespace Anabatic { virtual void setAllowedDepth ( size_t ) = 0; virtual DbU::Unit getEdgeLength () const = 0; virtual DbU::Unit getEdgeWidth () const = 0; + virtual float getEdgeCostH () const = 0; + virtual float getEdgeCostK () const = 0; virtual void print ( Cell* ) const = 0; virtual Record* _getRecord () const = 0; virtual string _getString () const = 0; @@ -139,6 +141,8 @@ namespace Anabatic { virtual void setAllowedDepth ( size_t ); virtual DbU::Unit getEdgeLength () const; virtual DbU::Unit getEdgeWidth () const; + virtual float getEdgeCostH () const; + virtual float getEdgeCostK () const; virtual void print ( Cell* ) const; virtual Record* _getRecord () const; virtual string _getString () const; @@ -154,6 +158,8 @@ namespace Anabatic { size_t _allowedDepth; DbU::Unit _edgeLength; DbU::Unit _edgeWidth; + float _edgeCostH; + float _edgeCostK; private: ConfigurationConcrete ( const ConfigurationConcrete& ); ConfigurationConcrete& operator= ( const ConfigurationConcrete& ); diff --git a/anabatic/src/anabatic/Dijkstra.h b/anabatic/src/anabatic/Dijkstra.h index 721dbd1b..02d496f5 100644 --- a/anabatic/src/anabatic/Dijkstra.h +++ b/anabatic/src/anabatic/Dijkstra.h @@ -45,7 +45,7 @@ namespace Anabatic { inline bool operator() ( const Vertex* lhs, const Vertex* rhs ); }; public: - static float unreached; + static DbU::Unit unreached; public: static void notify ( Vertex*, unsigned flags ); public: @@ -58,14 +58,16 @@ namespace Anabatic { inline Contact* getGContact ( Net* ); bool hasValidStamp () const; inline Point getCenter () const; - inline float getDistance () const; + inline DbU::Unit getDistance () const; inline int getStamp () const; + inline int getBranchId () const; inline int getConnexId () const; inline Edge* getFrom () const; inline Vertex* getPredecessor () const; - inline void setDistance ( float ); + inline void setDistance ( DbU::Unit ); inline void setStamp ( int ); inline void setConnexId ( int ); + inline void setBranchId ( int ); inline void setFrom ( Edge* ); // Inspector support. string _getString () const; @@ -77,8 +79,9 @@ namespace Anabatic { GCell* _gcell; Observer _observer; int _connexId; + int _branchId; int _stamp; - float _distance; + DbU::Unit _distance; Edge* _from; }; @@ -88,6 +91,7 @@ namespace Anabatic { , _gcell (gcell) , _observer(this) , _connexId(-1) + , _branchId( 0) , _stamp (-1) , _distance(unreached) , _from (NULL) @@ -95,15 +99,6 @@ namespace Anabatic { gcell->setObserver( GCell::Observable::Vertex, &_observer ); } - // inline Vertex::Vertex ( size_t id ) - // : _id (id) - // , _gcell (NULL) - // , _observer((Vertex*)0x1) // To trick the NULL detection. - // , _connexId(-1) - // , _stamp (-1) - // , _distance(unreached) - // , _from (NULL) - // { } inline Vertex::~Vertex () { } inline unsigned int Vertex::getId () const { return _id; } @@ -111,14 +106,16 @@ namespace Anabatic { inline AnabaticEngine* Vertex::getAnabatic () const { return _gcell->getAnabatic(); } inline Contact* Vertex::getGContact ( Net* net ) { return _gcell->getGContact(net); } inline Point Vertex::getCenter () const { return _gcell->getBoundingBox().getCenter(); } - inline float Vertex::getDistance () const { return hasValidStamp() ? _distance : unreached; } + inline DbU::Unit Vertex::getDistance () const { return hasValidStamp() ? _distance : unreached; } inline int Vertex::getStamp () const { return _stamp; } inline int Vertex::getConnexId () const { return hasValidStamp() ? _connexId : -1; } + inline int Vertex::getBranchId () const { return hasValidStamp() ? _branchId : 0; } inline Edge* Vertex::getFrom () const { return _from; } - inline void Vertex::setDistance ( float distance ) { _distance=distance; } + inline void Vertex::setDistance ( DbU::Unit distance ) { _distance=distance; } inline void Vertex::setFrom ( Edge* from ) { _from=from; } inline void Vertex::setStamp ( int stamp ) { _stamp=stamp; } inline void Vertex::setConnexId ( int id ) { _connexId=id; } + inline void Vertex::setBranchId ( int id ) { _branchId=id; } inline Vertex* Vertex::getPredecessor () const { return (hasValidStamp() and _from) ? _from->getOpposite(_gcell)->getObserver(GCell::Observable::Vertex) : NULL; } @@ -156,7 +153,10 @@ namespace Anabatic { inline bool PriorityQueue::CompareByDistance::operator() ( const Vertex* lhs, const Vertex* rhs ) - { return lhs->getDistance() < rhs->getDistance(); } + { + if (lhs->getDistance() == rhs->getDistance()) return lhs->getBranchId() > rhs->getBranchId(); + return lhs->getDistance() < rhs->getDistance(); + } inline PriorityQueue::PriorityQueue () : _queue() { } @@ -169,7 +169,7 @@ namespace Anabatic { inline void PriorityQueue::pop () { - cdebug.log(111) << "Pop: (size:" << _queue.size() << ") " << *_queue.begin() << std::endl; + cdebug_log(112,0) << "Pop: (size:" << _queue.size() << ") " << *_queue.begin() << std::endl; _queue.erase(_queue.begin()); } @@ -182,12 +182,12 @@ namespace Anabatic { inline void PriorityQueue::dump () const { - if (cdebug.enabled(111)) { - cdebug.log(111,1) << "PriorityQueue::dump() size:" << size() << std::endl; + if (cdebug.enabled(112)) { + cdebug_log(112,1) << "PriorityQueue::dump() size:" << size() << std::endl; size_t order = 0; for ( Vertex* v : _queue ) - cdebug.log(111) << "[" << std::setw(3) << order++ << "] " << v << std::endl; - cdebug.tabw(111,-1); + cdebug_log(112,0) << "[" << std::setw(3) << order++ << "] " << v << std::endl; + cdebug_tabw(112,-1); } } @@ -211,25 +211,28 @@ namespace Anabatic { virtual std::string _getTypeName () const; virtual std::string _getString () const; }; + public: + typedef std::function distance_t; public: - float getDistance ( const Vertex*, const Vertex*, const Edge* ); - public: - Dijkstra ( AnabaticEngine* ); - ~Dijkstra (); - public: - inline bool isBipoint () const; - void load ( Net* ); - void run ( Mode mode=Mode::Standart ); - private: - Dijkstra ( const Dijkstra& ); - Dijkstra& operator= ( const Dijkstra& ); - bool _propagate ( Flags enabledSides ); - void _selectFirstSource (); - void _toWires (); + Dijkstra ( AnabaticEngine* ); + ~Dijkstra (); + public: + inline bool isBipoint () const; + inline void setDistance ( distance_t ); + void load ( Net* ); + void run ( Mode mode=Mode::Standart ); + private: + Dijkstra ( const Dijkstra& ); + Dijkstra& operator= ( const Dijkstra& ); + static DbU::Unit _distance ( const Vertex*, const Vertex*, const Edge* ); + bool _propagate ( Flags enabledSides ); + void _selectFirstSource (); + void _toWires (); private: AnabaticEngine* _anabatic; vector _vertexes; + distance_t _distanceCb; Mode _mode; Net* _net; int _stamp; @@ -244,7 +247,8 @@ namespace Anabatic { inline Dijkstra::Mode::Mode ( unsigned int flags ) : BaseFlags(flags) { } inline Dijkstra::Mode::Mode ( BaseFlags base ) : BaseFlags(base) { } - inline bool Dijkstra::isBipoint () const { return _net and (_targets.size()+_sources.size() == 2); } + inline bool Dijkstra::isBipoint () const { return _net and (_targets.size()+_sources.size() == 2); } + inline void Dijkstra::setDistance ( distance_t cb ) { _distanceCb = cb; } } // Anabatic namespace. diff --git a/anabatic/src/anabatic/Edge.h b/anabatic/src/anabatic/Edge.h index 2b9fea30..aa2a4db4 100644 --- a/anabatic/src/anabatic/Edge.h +++ b/anabatic/src/anabatic/Edge.h @@ -55,7 +55,7 @@ namespace Anabatic { inline unsigned int getCapacity () const; inline unsigned int getRealOccupancy () const; inline unsigned int getEstimateOccupancy () const; - float getDistance () const; + DbU::Unit getDistance () const; inline GCell* getSource () const; inline GCell* getTarget () const; GCell* getOpposite ( const GCell* ) const; diff --git a/anabatic/src/anabatic/Edges.h b/anabatic/src/anabatic/Edges.h index bd24b229..964b37c0 100644 --- a/anabatic/src/anabatic/Edges.h +++ b/anabatic/src/anabatic/Edges.h @@ -92,7 +92,7 @@ namespace Anabatic { , _filterFlags(locator._filterFlags) , _iedge (locator._iedge) { - // cdebug.log(110) << "GCell_Edges::Locator::Locator(const Locator&)" << std::endl; + // cdebug_log(110,0) << "GCell_Edges::Locator::Locator(const Locator&)" << std::endl; } diff --git a/bootstrap/sprof.py b/bootstrap/sprof.py new file mode 100755 index 00000000..0ad3519b --- /dev/null +++ b/bootstrap/sprof.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python + +import sys +import os.path +import subprocess +import re + + +reSymbol = re.compile(r'(?P.*)(?P_Z\w+)(?P.*)') + +soPathName = sys.argv[1] +soFileName = os.path.basename( soPathName ) +profName = soFileName + '.profile' +if not os.path.isfile(profName): + print '[ERROR] No profile datas <%s>.' % profName + sys.exit( 1 ) + +sprof = subprocess.Popen ( ['sprof' + , soPathName + , profName ] + , stdout=subprocess.PIPE ) + +for line in sprof.stdout.readlines(): + m = reSymbol.match( line[:-1] ) + if m: + cppfilt = subprocess.Popen ( ['c++filt' + , '--no-verbose' + , '--no-params' + , m.group('symbol')] + , stdout=subprocess.PIPE ) + symbol = cppfilt.stdout.readlines()[0][:-1] + + print m.group('head'), symbol + else: + print line[:-1] + +sys.exit( 0 ) diff --git a/crlcore/etc/cmos/kite.conf b/crlcore/etc/cmos/kite.conf index bc1b0b05..46324526 100644 --- a/crlcore/etc/cmos/kite.conf +++ b/crlcore/etc/cmos/kite.conf @@ -23,6 +23,8 @@ parametersTable = \ # Anabatic parameters are temporarily hosted here. , ("anabatic.edgeLength" ,TypeInt ,24 ) , ("anabatic.edgeWidth" ,TypeInt ,4 ) + , ("anabatic.edgeCostH" ,TypeDouble ,9.0 ) + , ("anabatic.edgeCostK" ,TypeDouble ,-10.0 ) ) diff --git a/crlcore/etc/common/display.conf b/crlcore/etc/common/display.conf index f4415a5d..dfb06bc8 100644 --- a/crlcore/etc/common/display.conf +++ b/crlcore/etc/common/display.conf @@ -84,9 +84,8 @@ stylesTable = \ , (Drawing, 'gmetalh' , { 'color':'128,255,200', 'pattern':'light_antihash0.8', 'border':1 }) , (Drawing, 'gmetalv' , { 'color':'200,200,255', 'pattern':'light_antihash1.8', 'border':1 }) , (Drawing, 'gcut' , { 'color':'255,255,190', 'border':1 }) - , (Drawing, 'Anabatic::Edge' , { 'color':'255,255,190', 'pattern':'0000000000000000', 'threshold':0.80*scale, 'border':4 }) - , (Drawing, 'Anabatic::GCell', { 'color':'255,0,0', 'pattern':'0000000000000000', 'threshold':0.80*scale, 'border':4 }) - #, (Drawing, 'Anabatic::GCell', { 'color':'255,255,190', 'pattern':'0000000000000000', 'threshold':0.80*scale, 'border':4 }) + , (Drawing, 'Anabatic::Edge' , { 'color':'255,255,190', 'pattern':'0000000000000000', 'threshold':0.02*scale, 'border':4 }) + , (Drawing, 'Anabatic::GCell', { 'color':'255,0,0' , 'pattern':'0000000000000000', 'threshold':0.80*scale, 'border':4 }) ) # ---------------------------------------------------------------------- @@ -192,8 +191,8 @@ stylesTable = \ , (Drawing, 'gmetalh' , { 'color':'128,255,200', 'pattern':'antislash2.32' , 'border':1 }) , (Drawing, 'gmetalv' , { 'color':'200,200,255', 'pattern':'light_antihash1.8', 'border':1 }) , (Drawing, 'gcut' , { 'color':'255,255,190', 'border':1 }) - , (Drawing, 'Anabatic::Edge' , { 'color':'255,255,190', 'pattern':'0000000000000000', 'border':4 }) - , (Drawing, 'Anabatic::GCell', { 'color':'255,255,190', 'pattern':'0000000000000000', 'border':4, 'threshold':0.40*scale }) + , (Drawing, 'Anabatic::Edge' , { 'color':'255,255,190', 'pattern':'0000000000000000', 'border':4, 'threshold':0.02*scale }) + , (Drawing, 'Anabatic::GCell', { 'color':'255,255,190', 'pattern':'0000000000000000', 'border':4, 'threshold':0.80*scale }) ) # ---------------------------------------------------------------------- diff --git a/unicorn/CMakeLists.txt b/unicorn/CMakeLists.txt index 4d57912a..16ededd9 100644 --- a/unicorn/CMakeLists.txt +++ b/unicorn/CMakeLists.txt @@ -26,6 +26,7 @@ #find_package(NIMBUS REQUIRED) #find_package(METIS REQUIRED) #find_package(MAUKA REQUIRED) + find_package(ANABATIC REQUIRED) find_package(ETESIAN REQUIRED) find_package(KNIK REQUIRED) find_package(KATABATIC REQUIRED) diff --git a/unicorn/src/CMakeLists.txt b/unicorn/src/CMakeLists.txt index 4c739218..506fee88 100644 --- a/unicorn/src/CMakeLists.txt +++ b/unicorn/src/CMakeLists.txt @@ -49,6 +49,8 @@ ${KNIK_LIBRARIES} ${ETESIAN_GRAPHICAL_LIBRARIES} ${ETESIAN_LIBRARIES} + ${ANABATIC_GRAPHICAL_LIBRARIES} + ${ANABATIC_LIBRARIES} ${CORIOLIS_PYTHON_LIBRARIES} ${CORIOLIS_LIBRARIES} ${HURRICANE_PYTHON_LIBRARIES} diff --git a/unicorn/src/CgtMain.cpp b/unicorn/src/CgtMain.cpp index f91c71b2..8160460f 100644 --- a/unicorn/src/CgtMain.cpp +++ b/unicorn/src/CgtMain.cpp @@ -1,4 +1,3 @@ - // -*- C++ -*- // // This file is part of the Coriolis Software. @@ -65,6 +64,8 @@ using namespace CRL; // #include "mauka/GraphicMaukaEngine.h" // using namespace Mauka; +#include "anabatic/GraphicAnabaticEngine.h" + #include "etesian/GraphicEtesianEngine.h" using namespace Etesian; @@ -268,16 +269,17 @@ int main ( int argc, char *argv[] ) cmess1 << UnicornGui::getBanner() << endl; cmess1 << " Tool Credits" << endl; cmess1 << " Hurricane .................... Remy Escassut & Christian Masson" << endl; - cmess1 << " Nimbus - Infrastructure .......................... Hugo Clement" << endl; - cmess1 << " Mauka - Placer ........................... Christophe Alexandre" << endl; + cmess1 << " Etesian - Placer .............................. Gabriel Gouvine" << endl; cmess1 << " Knik - Global Router ............................ Damien Dupuis" << endl; cmess1 << " Kite - Detailed Router ....................... Jean-Paul Chaput" << endl; + cmess1 << " " << endl; + + cmess1 << " Contributors" << endl; + cmess1 << " Sophie Belloeil, Hugo Clement, Marek Sroka, Wu Yifei" << endl; cmess1 << endl; - cout << " hMETIS software credits (used by Mauka)" << endl; - cout << " Author ........................................ Georges Karypis" << endl; - cout << " Prof. Ident. .......................... University of Minnesota" << endl; - cout << " URL .......................... http://glaros.dtc.umn.edu/gkhome" << endl; + cmess1 << " Coloquinte software credits (used by Etesian)" << endl; + cmess1 << " Author ........................................ Gabriel Gouvine" << endl; cout << endl; cout << " FLUTE software credits (used by Knik)" << endl; @@ -329,6 +331,7 @@ int main ( int argc, char *argv[] ) unicorn->setApplicationName ( QObject::tr("cgt") ); //unicorn->registerTool ( Mauka::GraphicMaukaEngine::grab() ); + unicorn->registerTool ( Anabatic::GraphicAnabaticEngine::grab() ); unicorn->registerTool ( Etesian::GraphicEtesianEngine::grab() ); //unicorn->registerTool ( Knik::GraphicKnikEngine::grab() ); unicorn->registerTool ( Kite::GraphicKiteEngine::grab() ); diff --git a/unicorn/src/cgt.py b/unicorn/src/cgt.py index 61560916..efe55c99 100755 --- a/unicorn/src/cgt.py +++ b/unicorn/src/cgt.py @@ -47,6 +47,9 @@ def credits (): s += ' Knik - Global Router ............................ Damien Dupuis\n' s += ' Kite - Detailed Router ....................... Jean-Paul Chaput\n\n' + s += ' Contributors\n' + s += ' Sophie Belloeil, Hugo Clement, Marek Sroka, Wu Yifei\n' + s += ' Coloquinte software credits (used by Etesian)\n' s += ' Author ........................................ Gabriel Gouvine\n' @@ -179,7 +182,7 @@ if __name__ == '__main__': unicorn = Unicorn.UnicornGui.create() unicorn.setApplicationName ('cgt') - #unicorn.registerTool (Anabatic.GraphicAnabaticEngine.grab()) + unicorn.registerTool (Anabatic.GraphicAnabaticEngine.grab()) unicorn.registerTool (Etesian.GraphicEtesianEngine.grab()) unicorn.registerTool (Kite.GraphicKiteEngine.grab()) #unicorn.setAnonNetSelectable(False)