Support for profiling the priority of events in Kite & Katana.

* New: In Katana::Configuration, added "katana.profileEventCosts" to
    triggers the event's profiling.
* New: In Katana::NegociateWindow::_negociate(), save a profiling
    trace of all the events and their priority, separated by metal,
    for later analysis (see doChip.py in alliance-check-toolkit).
* New: In Katana::RoutingEvent::Key::Compare(), start implementing
    new segment freedom degree functions.
* Change: In Hurricane::Net::_getString(), put a more complete
    information about the Net instead of just only it's name.
* Bug: In Katana, reorder the various stages so that they are
    executed in the exact same sequence as in "doChip.py" so now
    routing in graphic mode and text mode gives exactly the same
    results.
* Bug: In Katana::PyKatanaEngine, runGlobalRouter do not take any
    argument.
This commit is contained in:
Jean-Paul Chaput 2017-05-09 18:33:55 +02:00
parent db8e51524f
commit f1b2035cb0
17 changed files with 126 additions and 48 deletions

View File

@ -328,6 +328,8 @@ namespace Anabatic {
void Configuration::print ( Cell* cell ) const
{
if (not cmess1.enabled()) return;
string topLayerName = "UNKOWN";
const Layer* topLayer = _rg->getRoutingLayer( _allowedDepth );
if (topLayer)

View File

@ -748,9 +748,17 @@ void Net::_preDestroy()
string Net::_getString() const
// ***************************
{
string s = Inherit::_getString();
s.insert(s.length() - 1, " " + getString(_name));
return s;
string bs = Inherit::_getString();
string ds = "\"" + getString(_name) + "\" ";
ds += ((_isExternal ) ? "e" : "-");
ds += ((_isGlobal ) ? "g" : "-");
ds += ((_isAutomatic) ? "a" : "-");
ds += " ";
ds += getString(_type ) + " ";
ds += getString(_direction);
bs.insert( bs.length() - 1, " " + ds );
return bs;
}
Record* Net::_getRecord() const

View File

@ -126,12 +126,12 @@ namespace Hurricane {
DebugSession* DebugSession::get () { return _singleton; }
bool DebugSession::isTraced ( const void* symbol ) { return _singleton->_isTraced(symbol); }
void DebugSession::addToTrace ( const void* symbol ) { _singleton->_addToTrace(symbol); }
void DebugSession::addToTrace ( const Net* net ) { _singleton->_addToTrace ( net ); }
void DebugSession::addToTrace ( const Net* net ) { _singleton->_addToTrace(net); }
void DebugSession::addToTrace ( const Cell* cell
, const Name& name ) { _singleton->_addToTrace ( cell, name ); }
, const Name& name ) { _singleton->_addToTrace( cell, name ); }
bool DebugSession::_isTraced ( const void* symbol ) const { return _symbols.find(symbol) != _symbols.end(); }
void DebugSession::_addToTrace ( const void* symbol ) { _symbols.insert ( symbol ); }
void DebugSession::_addToTrace ( const Net* net ) { _addToTrace ( static_cast<const void*>(net) ); }
void DebugSession::_addToTrace ( const void* symbol ) { _symbols.insert( symbol ); }
void DebugSession::_addToTrace ( const Net* net ) { _addToTrace( static_cast<const void*>(net) ); }

View File

@ -40,12 +40,13 @@ namespace Katana {
Configuration::Configuration ()
: Anabatic::Configuration()
, _postEventCb ()
, _hTracksReservedLocal(Cfg::getParamInt("katana.hTracksReservedLocal", 3)->asInt())
, _vTracksReservedLocal(Cfg::getParamInt("katana.vTracksReservedLocal", 3)->asInt())
, _hTracksReservedLocal(Cfg::getParamInt ("katana.hTracksReservedLocal", 3)->asInt())
, _vTracksReservedLocal(Cfg::getParamInt ("katana.vTracksReservedLocal", 3)->asInt())
, _ripupLimits ()
, _ripupCost (Cfg::getParamInt("katana.ripupCost" , 3)->asInt())
, _eventsLimit (Cfg::getParamInt("katana.eventsLimit" ,4000000)->asInt())
, _ripupCost (Cfg::getParamInt ("katana.ripupCost" , 3)->asInt())
, _eventsLimit (Cfg::getParamInt ("katana.eventsLimit" ,4000000)->asInt())
, _flags (0)
, _profileEventCosts (Cfg::getParamBool("katana.profileEventCosts" ,false )->asBool())
{
_ripupLimits[StrapRipupLimit] = Cfg::getParamInt("katana.strapRipupLimit" ,16)->asInt();
_ripupLimits[LocalRipupLimit] = Cfg::getParamInt("katana.localRipupLimit" , 7)->asInt();
@ -81,6 +82,7 @@ namespace Katana {
, _ripupLimits ()
, _ripupCost (other._ripupCost)
, _eventsLimit (other._eventsLimit)
, _profileEventCosts (other._profileEventCosts)
{
_ripupLimits[StrapRipupLimit] = other._ripupLimits[StrapRipupLimit];
_ripupLimits[LocalRipupLimit] = other._ripupLimits[LocalRipupLimit];
@ -142,6 +144,8 @@ namespace Katana {
void Configuration::print ( Cell* cell ) const
{
if (not cmess1.enabled()) return;
cout << " o Configuration of ToolEngine<Katana> for Cell <" << cell->getName() << ">" << endl;
cout << Dots::asUInt (" - Global router H reserved local" ,_hTracksReservedLocal) << endl;
cout << Dots::asUInt (" - Global router V reserved local" ,_vTracksReservedLocal) << endl;

View File

@ -25,6 +25,7 @@ namespace {
using std::cerr;
using std::endl;
using std::setw;
using std::setfill;
using std::left;
using std::right;
using Hurricane::DbU;
@ -162,7 +163,7 @@ namespace Katana {
size_t iteration = 0;
size_t netCount = 0;
do {
cmess2 << " [" << setw(3) << iteration << "] nets:";
cmess2 << " [" << setfill(' ') << setw(3) << iteration << "] nets:";
netCount = 0;
for ( NetData* netData : getNetOrdering() ) {

View File

@ -194,8 +194,8 @@ namespace Katana {
katana = KatanaEngine::create( cell );
katana->setPostEventCb( boost::bind(&GraphicKatanaEngine::postEvent,this) );
katana->setViewer( _viewer );
katana->printConfiguration();
katana->digitalInit();
if (cmess1.enabled()) katana->printConfiguration();
} else
cerr << Warning( "%s already has a Katana engine.", getString(cell).c_str() ) << endl;

View File

@ -16,6 +16,7 @@
#include <vector>
#include <algorithm>
#include <fstream>
#include <iomanip>
#include "hurricane/Warning.h"
#include "hurricane/Bug.h"
@ -137,6 +138,7 @@ namespace {
namespace Katana {
using std::ofstream;
using std::cerr;
using std::endl;
using std::setw;
@ -425,7 +427,11 @@ namespace Katana {
cmess1 << " o Negociation Stage." << endl;
unsigned long limit = _katana->getEventsLimit();
unsigned long limit = _katana->getEventsLimit();
bool profiling = _katana->profileEventCosts();
ofstream ofprofile;
if (profiling) ofprofile.open( "katana.profile.txt" );
_eventHistory.clear();
_eventQueue.load( _segments );
@ -453,6 +459,21 @@ namespace Katana {
cmess2.flush();
}
if (ofprofile.is_open()) {
size_t depth = _katana->getConfiguration()->getLayerDepth( event->getSegment()->getLayer() );
if (depth < 6) {
ofprofile << setw(10) << right << count << " ";
for ( size_t i=0 ; i<6 ; ++i ) {
if (i == depth)
ofprofile << setw(10) << right << setprecision(2) << event->getPriority () << " ";
else
ofprofile << setw(10) << right << setprecision(2) << 0.0 << " ";
}
ofprofile << setw( 2) << right << event->getEventLevel() << endl;
}
}
event->process( _eventQueue, _eventHistory, _eventLoop );
count++;
@ -519,6 +540,7 @@ namespace Katana {
cerr << Bug( "%d events remains after clear.", RoutingEvent::getAllocateds() ) << endl;
}
if (ofprofile.is_open()) ofprofile.close();
_statistics.setEventsCount( eventsCount );
cdebug_tabw(159,-1);

View File

@ -167,25 +167,19 @@ extern "C" {
}
PyObject* PyKatanaEngine_runGlobalRouter ( PyKatanaEngine* self, PyObject* args )
PyObject* PyKatanaEngine_runGlobalRouter ( PyKatanaEngine* self )
{
cdebug_log(40,0) << "PyKatanaEngine_runGlobalRouter()" << endl;
HTRY
METHOD_HEAD("KatanaEngine.runGlobalRouter()")
unsigned int flags = 0;
if (PyArg_ParseTuple(args,"I:KatanaEngine.runGlobalRouter", &flags)) {
if (katana->getViewer()) {
if (ExceptionWidget::catchAllWrapper( std::bind(&KatanaEngine::runGlobalRouter,katana) )) {
PyErr_SetString( HurricaneError, "KatanaEngine::runGlobalrouter() has thrown an exception (C++)." );
return NULL;
}
} else {
katana->runGlobalRouter();
if (katana->getViewer()) {
if (ExceptionWidget::catchAllWrapper( std::bind(&KatanaEngine::runGlobalRouter,katana) )) {
PyErr_SetString( HurricaneError, "KatanaEngine::runGlobalrouter() has thrown an exception (C++)." );
return NULL;
}
} else {
PyErr_SetString(ConstructorError, "KatanaEngine.runGlobalRouter(): Invalid number/bad type of parameter.");
return NULL;
katana->runGlobalRouter();
}
HCATCH
@ -311,7 +305,7 @@ extern "C" {
, "Display on the console the configuration of Katana." }
, { "getToolSuccess" , (PyCFunction)PyKatanaEngine_getToolSuccess , METH_NOARGS
, "Returns True if the detailed routing has been successful." }
, { "runGlobalRouter" , (PyCFunction)PyKatanaEngine_runGlobalRouter , METH_VARARGS
, { "runGlobalRouter" , (PyCFunction)PyKatanaEngine_runGlobalRouter , METH_NOARGS
, "Run the global router (Katana)." }
, { "loadGlobalRouting" , (PyCFunction)PyKatanaEngine_loadGlobalRouting , METH_VARARGS
, "Load global routing into the detailed router." }

View File

@ -15,6 +15,7 @@
#include <cstdlib>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>
@ -79,11 +80,11 @@ namespace Katana {
if (lhs._eventLevel < rhs._eventLevel) return true;
// Process all M2 (terminal access) before any others.
if ((lhs._layerDepth == 1) and (rhs._layerDepth != 1)) return false;
if ((lhs._layerDepth != 1) and (rhs._layerDepth == 1)) return true;
//if ((lhs._layerDepth == 1) and (rhs._layerDepth != 1)) return false;
//if ((lhs._layerDepth != 1) and (rhs._layerDepth == 1)) return true;
if (lhs._priority > rhs._priority) return false;
if (lhs._priority < rhs._priority) return true;
if (lhs._priority > rhs._priority) return true;
if (lhs._priority < rhs._priority) return false;
if (lhs._length > rhs._length) return false;
if (lhs._length < rhs._length) return true;
@ -401,11 +402,11 @@ namespace Katana {
cdebug_tabw(159,1);
cdebug_log(159,0) << "State: *before* "
<< DataNegociate::getStateString(_segment->getDataNegociate())
<< " ripup:" << _segment->getDataNegociate()->getRipupCount()
<< endl;
<< DataNegociate::getStateString(_segment->getDataNegociate())
<< " ripup:" << _segment->getDataNegociate()->getRipupCount()
<< endl;
cdebug_log(159,0) << "Level: " << getEventLevel()
<< ", area: " << _segment->getFreedomDegree() << endl;
<< ", area: " << _segment->getFreedomDegree() << endl;
//_preCheck( _segment );
_eventLevel = 0;
@ -648,10 +649,17 @@ namespace Katana {
_overConstrained = _segment->base()->getAutoSource()->isTerminal()
and _segment->base()->getAutoTarget()->isTerminal();
}
double length = DbU::toLambda(_segment->getLength());
// if (length > 200.0) length = 200.0 - std::log(length)*20.0;
// if (length < 0.0) length = 0.0;
_priority
= (DbU::toLambda(_segment->getLength()) + 1.0)
* (DbU::toLambda(_segment->base()->getSlack()) + 1.0);
_priority = (length + 1.0) * (DbU::toLambda(_segment->base()->getSlack()) + 1.0);
// if (_priority > 10000.0) cerr << "_priority:" << _priority
// << " length:" << DbU::toLambda(_segment->getLength())
// << " slack:" << DbU::toLambda(_segment->base()->getSlack()) << endl;
cdebug_log(159,0) << _segment << " has " << (int)_tracksNb << " choices " << perpandicular << endl;
cdebug_tabw(159,-1);

View File

@ -503,8 +503,10 @@ namespace Katana {
_event2 = _data2->getRoutingEvent();
_event2->setTracksFree( 0 );
cdebug_log(159,1) << "Coupled:" << _event2 << endl;
_data2->update();
_event2->revalidate();
cdebug_tabw(159,-1);
_sameAxis = (segment1->isVertical() xor symData->isSymVertical());
}
@ -639,6 +641,8 @@ namespace Katana {
cdebug_log(159,0) << "TrackCost::Compare() - DiscardGlobals" << endl;
}
// FOR ANALOG ONLY.
//flags |= TrackCost::IgnoreSharedLength;
sort( _costs.begin(), _costs.end(), CompareCostArray(flags) );
size_t i=0;

View File

@ -172,10 +172,8 @@ namespace Katana {
TrackElement* Track::getPrevious ( size_t& index, Net* net ) const
{
for ( index-- ; index != npos ; index-- ) {
if (cdebug.enabled()) {
cerr << tab << index << ":"; cerr.flush();
cerr << _segments[index] << endl;
}
cdebug_log(140,0) << index << ":" << _segments[index] << endl;
if (_segments[index]->getNet() == net) continue;
return _segments[index];
}
@ -437,6 +435,7 @@ namespace Katana {
}
}
}
cdebug_tabw(155,-1);
return Interval( minFree, getMaximalPosition(end,state) );

View File

@ -10,7 +10,7 @@
// | Author : Jean-Paul CHAPUT |
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
// | =============================================================== |
// | C++ Header : "./katana/Configuration.h" |
// | C++ Header : "./katana/Configuration.h" |
// +-----------------------------------------------------------------+
@ -60,6 +60,7 @@ namespace Katana {
~Configuration ();
// Decorateds.
inline bool useClockTree () const;
inline bool profileEventCosts () const;
// Methods.
inline Anabatic::Configuration* base ();
inline const Anabatic::Configuration* base () const;
@ -77,6 +78,7 @@ namespace Katana {
void setVTracksReservedLocal ( size_t );
inline void setFlags ( unsigned int );
inline void unsetFlags ( unsigned int );
inline void setProfileEventCosts ( bool );
virtual void print ( Cell* ) const;
virtual Record* _getRecord () const;
virtual string _getString () const;
@ -90,6 +92,7 @@ namespace Katana {
unsigned int _ripupCost;
unsigned long _eventsLimit;
unsigned int _flags;
bool _profileEventCosts;
private:
Configuration ( const Configuration& other );
Configuration& operator= ( const Configuration& );
@ -108,8 +111,10 @@ namespace Katana {
inline void Configuration::setPostEventCb ( PostEventCb_t cb ) { _postEventCb = cb; }
inline void Configuration::setEventsLimit ( unsigned long limit ) { _eventsLimit = limit; }
inline bool Configuration::useClockTree () const { return _flags & UseClockTree; }
inline bool Configuration::profileEventCosts () const { return _profileEventCosts; }
inline void Configuration::setFlags ( unsigned int flags ) { _flags |= flags; }
inline void Configuration::unsetFlags ( unsigned int flags ) { _flags &= ~flags; }
inline void Configuration::setProfileEventCosts ( bool state ) { _profileEventCosts = state; }

View File

@ -78,6 +78,7 @@ namespace Katana {
inline unsigned int getRipupCost () const;
inline size_t getHTracksReservedLocal () const;
inline size_t getVTracksReservedLocal () const;
inline bool profileEventCosts () const;
virtual const Name& getName () const;
inline Configuration::PostEventCb_t&
getPostEventCb ();
@ -163,6 +164,7 @@ namespace Katana {
inline size_t KatanaEngine::getHTracksReservedLocal () const { return _configuration->getHTracksReservedLocal(); }
inline size_t KatanaEngine::getVTracksReservedLocal () const { return _configuration->getVTracksReservedLocal(); }
inline unsigned int KatanaEngine::getRipupLimit ( unsigned int type ) const { return _configuration->getRipupLimit(type); }
inline bool KatanaEngine::profileEventCosts () const { return _configuration->profileEventCosts(); }
inline const std::map<Net*,DataSymmetric*>&
KatanaEngine::getSymmetrics () const { return _symmetrics; }
inline NegociateWindow* KatanaEngine::getNegociateWindow () { return _negociateWindow; }

View File

@ -41,12 +41,13 @@ namespace Kite {
: Katabatic::Configuration()
, _base (base)
, _postEventCb ()
, _hTracksReservedLocal(Cfg::getParamInt("kite.hTracksReservedLocal", 3)->asInt())
, _vTracksReservedLocal(Cfg::getParamInt("kite.vTracksReservedLocal", 3)->asInt())
, _hTracksReservedLocal(Cfg::getParamInt ("kite.hTracksReservedLocal", 3)->asInt())
, _vTracksReservedLocal(Cfg::getParamInt ("kite.vTracksReservedLocal", 3)->asInt())
, _ripupLimits ()
, _ripupCost (Cfg::getParamInt("kite.ripupCost" , 3)->asInt())
, _eventsLimit (Cfg::getParamInt("kite.eventsLimit" ,4000000)->asInt())
, _ripupCost (Cfg::getParamInt ("kite.ripupCost" , 3)->asInt())
, _eventsLimit (Cfg::getParamInt ("kite.eventsLimit" ,4000000)->asInt())
, _flags (0)
, _profileEventCosts (Cfg::getParamBool("kite.profileEventCosts" ,false )->asBool())
{
_ripupLimits[StrapRipupLimit] = Cfg::getParamInt("kite.strapRipupLimit" ,16)->asInt();
_ripupLimits[LocalRipupLimit] = Cfg::getParamInt("kite.localRipupLimit" , 7)->asInt();
@ -83,6 +84,7 @@ namespace Kite {
, _ripupLimits ()
, _ripupCost (other._ripupCost)
, _eventsLimit (other._eventsLimit)
, _profileEventCosts (other._profileEventCosts)
{
if ( _base == NULL ) _base = other._base->clone();

View File

@ -429,7 +429,11 @@ namespace Kite {
cmess1 << " o Negociation Stage." << endl;
unsigned long limit = _kite->getEventsLimit();
unsigned long limit = _kite->getEventsLimit();
bool profiling = _kite->profileEventCosts();
ofstream ofprofile;
if (profiling) ofprofile.open( "kite.profile.txt" );
_eventHistory.clear();
_eventQueue.load( _segments );
@ -457,6 +461,21 @@ namespace Kite {
cmess2.flush();
}
if (ofprofile.is_open()) {
size_t depth = _kite->getConfiguration()->getLayerDepth( event->getSegment()->getLayer() );
if (depth < 6) {
ofprofile << setw(10) << right << count << " ";
for ( size_t i=0 ; i<6 ; ++i ) {
if (i == depth)
ofprofile << setw(10) << right << setprecision(2) << event->getPriority () << " ";
else
ofprofile << setw(10) << right << setprecision(2) << 0.0 << " ";
}
ofprofile << setw( 2) << right << event->getEventLevel() << endl;
}
}
event->process( _eventQueue, _eventHistory, _eventLoop );
count++;
@ -523,6 +542,7 @@ namespace Kite {
cerr << Bug( "%d events remains after clear.", RoutingEvent::getAllocateds() ) << endl;
}
if (ofprofile.is_open()) ofprofile.close();
_statistics.setEventsCount( eventsCount );
cdebug_tabw(159,-1);

View File

@ -60,6 +60,7 @@ namespace Kite {
virtual bool isGMetal ( const Layer* ) const;
virtual bool isGContact ( const Layer* ) const;
inline bool useClockTree () const;
inline bool profileEventCosts () const;
virtual size_t getDepth () const;
virtual size_t getAllowedDepth () const;
virtual DbU::Unit getSliceHeight () const;
@ -89,6 +90,7 @@ namespace Kite {
virtual void setSaturateRatio ( float );
virtual void setSaturateRp ( size_t );
virtual void setGlobalThreshold ( DbU::Unit );
inline void setProfileEventCosts ( bool );
virtual void print ( Cell* ) const;
// Methods.
inline Katabatic::Configuration* base ();
@ -119,6 +121,7 @@ namespace Kite {
unsigned int _ripupCost;
unsigned long _eventsLimit;
unsigned int _flags;
bool _profileEventCosts;
private:
Configuration ( const Configuration& other, Katabatic::Configuration* base=NULL );
Configuration& operator= ( const Configuration& );
@ -136,8 +139,10 @@ namespace Kite {
inline void Configuration::setPostEventCb ( PostEventCb_t cb ) { _postEventCb = cb; }
inline void Configuration::setEventsLimit ( unsigned long limit ) { _eventsLimit = limit; }
inline bool Configuration::useClockTree () const { return _flags & UseClockTree; }
inline bool Configuration::profileEventCosts () const { return _profileEventCosts; }
inline void Configuration::setFlags ( unsigned int flags ) { _flags |= flags; }
inline void Configuration::unsetFlags ( unsigned int flags ) { _flags &= ~flags; }
inline void Configuration::setProfileEventCosts ( bool state ) { _profileEventCosts = state; }

View File

@ -78,6 +78,7 @@ namespace Kite {
inline unsigned int getRipupCost () const;
inline size_t getHTracksReservedLocal () const;
inline size_t getVTracksReservedLocal () const;
inline bool profileEventCosts () const;
virtual const Name& getName () const;
inline Configuration::PostEventCb_t&
getPostEventCb ();
@ -161,6 +162,7 @@ namespace Kite {
inline unsigned int KiteEngine::getRipupCost () const { return _configuration->getRipupCost(); }
inline size_t KiteEngine::getHTracksReservedLocal () const { return _configuration->getHTracksReservedLocal(); }
inline size_t KiteEngine::getVTracksReservedLocal () const { return _configuration->getVTracksReservedLocal(); }
inline bool KiteEngine::profileEventCosts () const { return _configuration->profileEventCosts(); }
inline unsigned int KiteEngine::getRipupLimit ( unsigned int type ) const { return _configuration->getRipupLimit(type); }
inline NegociateWindow* KiteEngine::getNegociateWindow () { return _negociateWindow; }
inline size_t KiteEngine::getRoutingPlanesSize () const { return _routingPlanes.size(); }