From 0cced628518dcf568fbee1dc015882a5c5298155 Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Mon, 7 Jul 2014 00:42:38 +0200 Subject: [PATCH] Kite is now deterministic, given a global routing. * Bug: In Kite, in TrackCost, the boolean attribute "_forGlobal" was not initialized in the constructor causing the non-deterministic behavior. Arrrrgggghhhhhh. * Bug: In Kite, in PyKiteEngine, forgot to perform the "balanceGlobalDensity()" in the layer assign Python wrapper, another cause for non-determinism. * Change: In Kite, In KiteEngine, print the configuration at the same point as in the python script (to get identical output). --- katabatic/src/KatabaticEngine.cpp | 2 +- kite/src/DataNegociate.cpp | 2 ++ kite/src/GraphicKiteEngine.cpp | 2 +- kite/src/NegociateWindow.cpp | 9 ++++++++- kite/src/PyKiteEngine.cpp | 6 ++++-- kite/src/RoutingEvent.cpp | 9 ++++++--- kite/src/RoutingEventQueue.cpp | 4 ++-- kite/src/SegmentFsm.cpp | 5 ++++- kite/src/Track.cpp | 2 ++ kite/src/TrackCost.cpp | 1 + kite/src/kite/DataNegociate.h | 2 +- kite/src/kite/TrackCost.h | 2 +- unicorn/src/cgt.py | 2 +- 13 files changed, 34 insertions(+), 14 deletions(-) diff --git a/katabatic/src/KatabaticEngine.cpp b/katabatic/src/KatabaticEngine.cpp index 5ffceefa..374e09dd 100644 --- a/katabatic/src/KatabaticEngine.cpp +++ b/katabatic/src/KatabaticEngine.cpp @@ -387,7 +387,7 @@ namespace Katabatic { << (_timer.getMemorySize()>>10) << "Kb"; cmess2 << Dots::asString( " - Raw measurements", result.str() ) << endl; - if (not tag.empty()) { + if (not tag.empty()) { addMeasure( getCell(), tag+"T", _timer.getCombTime () ); addMeasure( getCell(), tag+"S", (_timer.getMemorySize() >> 20) ); } diff --git a/kite/src/DataNegociate.cpp b/kite/src/DataNegociate.cpp index d985bbca..8d02fcc5 100644 --- a/kite/src/DataNegociate.cpp +++ b/kite/src/DataNegociate.cpp @@ -81,6 +81,7 @@ namespace Kite { { DebugSession::open( _trackSegment->getNet(), 148 ); + //ltrace(500) << "Deter| DataNegociate::update() - " << _trackSegment << endl; ltrace(148) << "DataNegociate::update() - " << _trackSegment << endl; ltracein(148); @@ -97,6 +98,7 @@ namespace Kite { ); _terminals = AutoSegment::getTerminalCount( _trackSegment->base(), collapseds ); + //ltrace(500) << "Deter| Terminals:" << _terminals << endl; _attractors.clear(); _perpandiculars.clear(); _perpandicularFree = Interval(false); diff --git a/kite/src/GraphicKiteEngine.cpp b/kite/src/GraphicKiteEngine.cpp index 89341520..23ea3eaa 100644 --- a/kite/src/GraphicKiteEngine.cpp +++ b/kite/src/GraphicKiteEngine.cpp @@ -124,6 +124,7 @@ namespace Kite { kite = KiteEngine::create( cell ); kite->setPostEventCb( boost::bind(&GraphicKiteEngine::postEvent,this) ); kite->setViewer( _viewer ); + if (cmess1.enabled()) kite->printConfiguration(); } else cerr << Warning( "%s already has a Kite engine.", getString(cell).c_str() ) << endl; @@ -174,7 +175,6 @@ namespace Kite { void GraphicKiteEngine::_loadGlobalRouting () { KiteEngine* kite = getForFramework( NoFlags ); - if (cmess1.enabled()) kite->printConfiguration(); _viewer->clearToolInterrupt(); kite->loadGlobalRouting( Katabatic::EngineLoadGrByNet ); diff --git a/kite/src/NegociateWindow.cpp b/kite/src/NegociateWindow.cpp index 2ab97db4..bfee1d42 100644 --- a/kite/src/NegociateWindow.cpp +++ b/kite/src/NegociateWindow.cpp @@ -52,6 +52,7 @@ namespace { void NegociateOverlapCost ( const TrackElement* segment, TrackCost& cost ) { + ltrace(500) << "Deter| NegociateOverlapCost() " << segment << endl; Interval intersect = segment->getCanonicalInterval(); if (not intersect.intersect(cost.getInterval())) return; @@ -99,8 +100,12 @@ namespace { cost.setOverlap(); if ( segment->isLocal() - or (cost.isForGlobal() and (Session::getRoutingGauge()->getLayerDepth(segment->getLayer()) < 3)) ) + or (cost.isForGlobal() and (Session::getRoutingGauge()->getLayerDepth(segment->getLayer()) < 3)) ) { + ltrace(500) << "Deter| incTerminals() " << boolalpha << cost.isForGlobal() << " " << (data->getTerminals()*100) << endl; cost.incTerminals( data->getTerminals()*100 ); + } else { + ltrace(500) << "Deter| isForGlobal() " << boolalpha << cost.isForGlobal() << endl; + } ltrace(200) << "| Increment Delta: " << DbU::getValueString(intersect.getSize()) << endl; cost.incDelta( intersect.getSize() ); @@ -383,6 +388,8 @@ namespace Kite { _eventHistory.clear(); _eventQueue.load( _segments ); + if (inltrace(500)) _eventQueue.dump(); + size_t count = 0; RoutingEvent::setStage( RoutingEvent::Negociate ); while ( not _eventQueue.empty() and not isInterrupted() ) { diff --git a/kite/src/PyKiteEngine.cpp b/kite/src/PyKiteEngine.cpp index 08b757b7..41706b4c 100644 --- a/kite/src/PyKiteEngine.cpp +++ b/kite/src/PyKiteEngine.cpp @@ -201,9 +201,11 @@ extern "C" { if (PyArg_ParseTuple(args,"I:KiteEngine.layerAssign", &flags)) { if (kite->getViewer()) { - ExceptionWidget::catchAllWrapper( std::bind(&KiteEngine::layerAssign,kite,flags) ); + ExceptionWidget::catchAllWrapper( std::bind(&KiteEngine::balanceGlobalDensity,kite) ); + ExceptionWidget::catchAllWrapper( std::bind(&KiteEngine::layerAssign ,kite,flags) ); } else { - kite->layerAssign(flags); + kite->balanceGlobalDensity(); + kite->layerAssign (flags); } } else { PyErr_SetString(ConstructorError, "KiteEngine.layerAssign(): Invalid number/bad type of parameter."); diff --git a/kite/src/RoutingEvent.cpp b/kite/src/RoutingEvent.cpp index 963764fa..0b680aaf 100644 --- a/kite/src/RoutingEvent.cpp +++ b/kite/src/RoutingEvent.cpp @@ -475,9 +475,7 @@ namespace Kite { _axisHistory = _segment->getAxis(); _eventLevel = 0; - ltrace(500) << "Deter| addInsertEvent()" << endl; - ltrace(500) << "Deter| | " << _segment << endl; - ltrace(500) << "Deter| | " << fsm.getCost(itrack).getTrack() << endl; + ltrace(500) << "Deter| addInsertEvent() @" << fsm.getCost(itrack).getTrack() << endl; Session::addInsertEvent( _segment, fsm.getCost(itrack).getTrack() ); fsm.setState( SegmentFsm::SelfInserted ); } else { @@ -486,6 +484,11 @@ namespace Kite { Manipulator(_segment,fsm).ripupPerpandiculars(); } else { if (Manipulator(_segment,fsm).canRipup(Manipulator::NotOnLastRipup)) { + if (inltrace(500)) { + for ( itrack=0 ; itrack::const_iterator ievent = _events.begin (); for ( ; ievent != _events.end(); ievent++ ) { - cerr << "Order: Queue:" + cerr << "Deter| Queue:" << (*ievent)->getEventLevel() << "," << setw(6) << (*ievent)->getPriority() << " " << setw(6) << DbU::getValueString((*ievent)->getSegment()->getLength()) diff --git a/kite/src/SegmentFsm.cpp b/kite/src/SegmentFsm.cpp index b48d2a66..df061ac8 100644 --- a/kite/src/SegmentFsm.cpp +++ b/kite/src/SegmentFsm.cpp @@ -511,7 +511,10 @@ namespace Kite { _costs.push_back ( itrack->getOverlapCost(segment,costflags) ); _costs.back().setAxisWeight ( _event->getAxisWeight(itrack->getAxis()) ); _costs.back().incDeltaPerpand ( _data->getWiringDelta(itrack->getAxis()) ); - if (segment->isGlobal()) _costs.back().setForGlobal(); + if (segment->isGlobal()) { + ltrace(500) << "Deter| setForGlobal() on " << *itrack << endl; + _costs.back().setForGlobal(); + } if ( inLocalDepth and (_costs.back().getDataState() == DataNegociate::MaximumSlack) ) _costs.back().setInfinite (); diff --git a/kite/src/Track.cpp b/kite/src/Track.cpp index 46c9be43..dbad668a 100644 --- a/kite/src/Track.cpp +++ b/kite/src/Track.cpp @@ -452,6 +452,8 @@ namespace Kite { void Track::insert ( TrackElement* segment ) { + // ltrace(500) << "Deter| Track::insert() " << getLayer()->getName() + // << " @" << DbU::getValueString(getAxis()) << " " << segment << endl; ltrace(200) << "Track::insert() " << getLayer()->getName() << " @" << DbU::getValueString(getAxis()) << " " << segment << endl; diff --git a/kite/src/TrackCost.cpp b/kite/src/TrackCost.cpp index 32977312..f93ab678 100644 --- a/kite/src/TrackCost.cpp +++ b/kite/src/TrackCost.cpp @@ -43,6 +43,7 @@ namespace Kite { , _begin (begin) , _end (end) , _interval (interval) + , _forGlobal (false) , _blockage (false) , _fixed (false) , _infinite (false) diff --git a/kite/src/kite/DataNegociate.h b/kite/src/kite/DataNegociate.h index 352671ae..6f809cf6 100644 --- a/kite/src/kite/DataNegociate.h +++ b/kite/src/kite/DataNegociate.h @@ -1,7 +1,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC 2008-2013, All Rights Reserved +// Copyright (c) UPMC 2008-2014, All Rights Reserved // // +-----------------------------------------------------------------+ // | C O R I O L I S | diff --git a/kite/src/kite/TrackCost.h b/kite/src/kite/TrackCost.h index 7a116b4c..ebf26e6b 100644 --- a/kite/src/kite/TrackCost.h +++ b/kite/src/kite/TrackCost.h @@ -2,7 +2,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC 2008-2013, All Rights Reserved +// Copyright (c) UPMC 2008-2014, All Rights Reserved // // +-----------------------------------------------------------------+ // | C O R I O L I S | diff --git a/unicorn/src/cgt.py b/unicorn/src/cgt.py index a8d27cc7..66c5f840 100755 --- a/unicorn/src/cgt.py +++ b/unicorn/src/cgt.py @@ -223,7 +223,7 @@ if __name__ == '__main__': routingNets = [] kite = Kite.KiteEngine.create(cell) - if options.showConf: kite.printConfiguration() + if options.showConf: kite.printConfiguration() kite.runGlobalRouter(globalFlags) if saveGlobal: kite.saveGlobalSolution()