* ./knik:

- Bug: In MatrixVertex::getLineIndex() and getColumnIndex(), in regular
        mode, when the Y/X coordinate is exactly on the upper right angle,
        return the inferior index (instead of superior which is out of bounds).
    - Change: In MatrixVertex, RoutingGrid & KnikEngine, replace the _lowerLeftX &
        _lowerLeftY by a complete copy of the Cell's abutment box. Makes
        easier for getLineIndex() to find out of bound coordinates.
    - Change: In KnikEngine & LoadSolution add a time/memory measurement,
        for Kite statistics.
This commit is contained in:
Jean-Paul Chaput 2010-04-23 13:13:22 +00:00
parent 448a345a26
commit 92e55924c4
7 changed files with 134 additions and 73 deletions

View File

@ -364,7 +364,7 @@ Vertex* Graph::getVertex ( Point p )
Vertex* Graph::getVertex ( DbU::Unit x, DbU::Unit y ) Vertex* Graph::getVertex ( DbU::Unit x, DbU::Unit y )
// ************************************************** // **************************************************
{ {
return getVertex ( Point ( x, y ) ); return getVertex ( Point(x,y) );
} }
unsigned Graph::getGridLength ( Segment* segment ) unsigned Graph::getGridLength ( Segment* segment )

View File

@ -61,6 +61,7 @@
#include "crlcore/Utilities.h" #include "crlcore/Utilities.h"
#include "crlcore/ToolBox.h" #include "crlcore/ToolBox.h"
#include "crlcore/Measures.h"
#include "knik/Configuration.h" #include "knik/Configuration.h"
#include "knik/Edge.h" #include "knik/Edge.h"
@ -75,6 +76,8 @@
namespace Knik { namespace Knik {
using CRL::addMeasure;
//globale variables //globale variables
unsigned __congestion__; unsigned __congestion__;
unsigned __precongestion__; unsigned __precongestion__;
@ -264,19 +267,24 @@ void KnikEngine::initGlobalRouting()
__initialized__ = true; __initialized__ = true;
} }
void KnikEngine::createRoutingGrid ( unsigned nbXTiles void KnikEngine::createRoutingGrid ( unsigned nbXTiles
, unsigned nbYTiles , unsigned nbYTiles
, DbU::Unit lowerLeftX , const Box& boundingBox
, DbU::Unit lowerLeftY , DbU::Unit tileWidth
, DbU::Unit tileWidth , DbU::Unit tileHeight
, DbU::Unit tileHeight , unsigned hcapacity
, unsigned hcapacity , unsigned vcapacity )
, unsigned vcapacity )
// ******************************************************
{ {
_routingGrid = RoutingGrid::create ( nbXTiles, nbYTiles, lowerLeftX, lowerLeftY, tileWidth, tileHeight, hcapacity, vcapacity ); _routingGrid = RoutingGrid::create ( nbXTiles
, nbYTiles
, boundingBox
, tileWidth
, tileHeight
, hcapacity
, vcapacity );
} }
void KnikEngine::createRoutingGraph() void KnikEngine::createRoutingGraph()
// ********************************** // **********************************
{ {
@ -341,6 +349,7 @@ void KnikEngine::printTime()
<< "s [+" << (_timer.getIncrease()>>10) << "Ko/" << "s [+" << (_timer.getIncrease()>>10) << "Ko/"
<< (_timer.getMemorySize()>>10) << "Ko])" << endl; << (_timer.getMemorySize()>>10) << "Ko])" << endl;
} }
// void KnikEngine::showEstimateOccupancy() // void KnikEngine::showEstimateOccupancy()
// // ************************************* // // *************************************
@ -1011,6 +1020,9 @@ void KnikEngine::run()
reroute(); reroute();
done = analyseRouting(); done = analyseRouting();
} }
addMeasure<double> ( getCell(), "knikT", _timer.getCombTime () );
addMeasure<size_t> ( getCell(), "knikS", (_timer.getMemorySize() >> 20) );
} }
void KnikEngine::Route() void KnikEngine::Route()

View File

@ -37,6 +37,7 @@
#include "hurricane/UpdateSession.h" #include "hurricane/UpdateSession.h"
#include "crlcore/Utilities.h" #include "crlcore/Utilities.h"
#include "crlcore/Measures.h"
#include "knik/Configuration.h" #include "knik/Configuration.h"
#include "knik/Graph.h" #include "knik/Graph.h"
@ -412,6 +413,8 @@ namespace {
namespace Knik { namespace Knik {
using CRL::addMeasure;
void KnikEngine::loadSolution ( const string& fileName ) void KnikEngine::loadSolution ( const string& fileName )
{ {
@ -421,6 +424,9 @@ namespace Knik {
SolutionParser parser ( this, loadFileName ); SolutionParser parser ( this, loadFileName );
parser.load (); parser.load ();
addMeasure<double> ( getCell(), "knikT", 0.0 );
addMeasure<size_t> ( getCell(), "knikS", 0 );
} }

View File

@ -24,8 +24,7 @@ MatrixVertex::MatrixVertex ( Graph* routingGraph )
, _nbYTiles(0) , _nbYTiles(0)
, _tileWidth(0) , _tileWidth(0)
, _tileHeight(0) , _tileHeight(0)
, _lowerLeftX(0) , _boundingBox(0,0,1,1)
, _lowerLeftY(0)
, _routingGraph(routingGraph) , _routingGraph(routingGraph)
{ {
} }
@ -76,7 +75,7 @@ void MatrixVertex::_preDestroy()
//{ //{
// if ( _yInit ) // if ( _yInit )
// throw Error ("MatrixVertex::createYRegular(): cannot initialize Y vector twice."); // throw Error ("MatrixVertex::createYRegular(): cannot initialize Y vector twice.");
// _lowerLeftY = routingGrid->getLowerLeftY(); // _boundingBox.getYMin() = routingGrid->getLowerLeftY();
// _nbYTiles = routingGrid->getNbYTiles(); // _nbYTiles = routingGrid->getNbYTiles();
// _tileHeight = routingGrid->getTileHeight(); // _tileHeight = routingGrid->getTileHeight();
// _yRegular = true; // _yRegular = true;
@ -92,16 +91,15 @@ Vertex* MatrixVertex::createRegularMatrix ( RoutingGrid* routingGrid )
if ( _xInit || _yInit ) if ( _xInit || _yInit )
throw Error ("MatrixVertex::createRegularMatrix(): cannot initialize matrix twice."); throw Error ("MatrixVertex::createRegularMatrix(): cannot initialize matrix twice.");
_lowerLeftX = routingGrid->getLowerLeftX(); _boundingBox = routingGrid->getBoundingBox();
_lowerLeftY = routingGrid->getLowerLeftY(); _nbXTiles = routingGrid->getNbXTiles();
_nbXTiles = routingGrid->getNbXTiles(); _nbYTiles = routingGrid->getNbYTiles();
_nbYTiles = routingGrid->getNbYTiles(); _tileWidth = routingGrid->getTileWidth();
_tileWidth = routingGrid->getTileWidth(); _tileHeight = routingGrid->getTileHeight();
_tileHeight = routingGrid->getTileHeight(); _xInit = true; // XXX Nécessaire pour les fonctions comme getLineIndex
_xInit = true; // XXX Nécessaire pour les fonctions comme getLineIndex _yInit = true;
_yInit = true; _xRegular = true; // XXX Nécessaire pour les fonctions comme getLineIndex
_xRegular = true; // XXX Nécessaire pour les fonctions comme getLineIndex _yRegular = true;
_yRegular = true;
DbU::Unit halfWidth = _tileWidth / 2; DbU::Unit halfWidth = _tileWidth / 2;
DbU::Unit halfHeight = _tileHeight / 2; DbU::Unit halfHeight = _tileHeight / 2;
@ -110,7 +108,7 @@ Vertex* MatrixVertex::createRegularMatrix ( RoutingGrid* routingGrid )
for ( unsigned j = 0 ; j < _nbYTiles ; j++ ) { for ( unsigned j = 0 ; j < _nbYTiles ; j++ ) {
vector<Vertex*> vect; vector<Vertex*> vect;
for ( unsigned i = 0 ; i < _nbXTiles ; i++ ) { for ( unsigned i = 0 ; i < _nbXTiles ; i++ ) {
Point position ( _lowerLeftX+(i*_tileWidth)+halfWidth, _lowerLeftY+(j*_tileHeight)+halfHeight ); Point position ( _boundingBox.getXMin()+(i*_tileWidth)+halfWidth, _boundingBox.getYMin()+(j*_tileHeight)+halfHeight );
// on cree le vertex // on cree le vertex
Vertex* vertex = _routingGraph->createVertex ( position, halfWidth, halfHeight ); Vertex* vertex = _routingGraph->createVertex ( position, halfWidth, halfHeight );
assert ( vertex ); assert ( vertex );
@ -148,8 +146,7 @@ Vertex* MatrixVertex::createRegularMatrix ()
DbU::Unit sliceHeight = AllianceFramework::get()->getCellGauge()->getSliceHeight(); DbU::Unit sliceHeight = AllianceFramework::get()->getCellGauge()->getSliceHeight();
DbU::Unit cellWidth = cell->getAbutmentBox().getWidth(); DbU::Unit cellWidth = cell->getAbutmentBox().getWidth();
DbU::Unit cellHeight = cell->getAbutmentBox().getHeight(); DbU::Unit cellHeight = cell->getAbutmentBox().getHeight();
_lowerLeftX = cell->getAbutmentBox().getXMin(); _boundingBox = cell->getAbutmentBox();
_lowerLeftY = cell->getAbutmentBox().getYMin();
_nbXTiles = (unsigned int)ceil(float(cellWidth) / float(sliceHeight)); _nbXTiles = (unsigned int)ceil(float(cellWidth) / float(sliceHeight));
_nbYTiles = (unsigned int)ceil(float(cellHeight) / float(sliceHeight)); _nbYTiles = (unsigned int)ceil(float(cellHeight) / float(sliceHeight));
_tileWidth = sliceHeight; _tileWidth = sliceHeight;
@ -165,8 +162,7 @@ Vertex* MatrixVertex::createRegularMatrix ()
// << " - this : " << (void*)this << endl // << " - this : " << (void*)this << endl
// << " - cellWidth : " << cellWidth << endl // << " - cellWidth : " << cellWidth << endl
// << " - cellHeight : " << cellHeight << endl // << " - cellHeight : " << cellHeight << endl
// << " - lowerLeftX : " << _lowerLeftX << endl // << " - boundingBox : " << _boundingBox << endl
// << " - lowerLeftY : " << _lowerLeftY << endl
// << " - nbXTiles : " << _nbXTiles << endl // << " - nbXTiles : " << _nbXTiles << endl
// << " - nbYTiles : " << _nbYTiles << endl // << " - nbYTiles : " << _nbYTiles << endl
// << " - tileWidth : " << _tileWidth << endl // << " - tileWidth : " << _tileWidth << endl
@ -181,7 +177,7 @@ Vertex* MatrixVertex::createRegularMatrix ()
for ( unsigned i = 0 ; i < _nbXTiles ; i++ ) { for ( unsigned i = 0 ; i < _nbXTiles ; i++ ) {
DbU::Unit halfWidth = (i == _nbXTiles - 1)?_latestTileWidth/2:_tileWidth/2; DbU::Unit halfWidth = (i == _nbXTiles - 1)?_latestTileWidth/2:_tileWidth/2;
DbU::Unit halfHeight = (j == _nbYTiles - 1)?_latestTileHeight/2:_tileHeight/2; DbU::Unit halfHeight = (j == _nbYTiles - 1)?_latestTileHeight/2:_tileHeight/2;
Point position ( _lowerLeftX+(i*_tileWidth)+halfWidth, _lowerLeftY+(j*_tileHeight)+halfHeight ); Point position ( _boundingBox.getXMin()+(i*_tileWidth)+halfWidth, _boundingBox.getYMin()+(j*_tileHeight)+halfHeight );
// on cree le vertex // on cree le vertex
Vertex* vertex = _routingGraph->createVertex ( position, halfWidth, halfHeight ); Vertex* vertex = _routingGraph->createVertex ( position, halfWidth, halfHeight );
assert ( vertex ); assert ( vertex );
@ -293,24 +289,37 @@ unsigned int MatrixVertex::getLineIndex ( DbU::Unit y )
// *********************************************** // ***********************************************
{ {
assert(_yInit ); assert(_yInit );
if ( _yRegular ) { if ( _yRegular ) {
// cerr << "y:" << DbU::getValueString(y-_lowerLeftY) << "/" << DbU::getValueString(_tileHeight) // cerr << "y:" << DbU::getValueString(y-_boundingBox.getYMin()) << "/" << DbU::getValueString(_tileHeight)
// << "=" << (DbU::getLambda(y-_lowerLeftY)/_tileHeight) // << "=" << (DbU::getLambda(y-_boundingBox.getYMin())/_tileHeight)
// << "<=>" << (unsigned int)floor((y-_lowerLeftY)/_tileHeight) << endl; // << "<=>" << (unsigned int)floor((y-_boundingBox.getYMin())/_tileHeight) << endl;
return (unsigned int)floor((y-_lowerLeftY)/_tileHeight); if ( (y < _boundingBox.getYMin()) or (y > _boundingBox.getYMax()) )
throw Error ("MatrixVertex::getLineIndex(): search value (%s) is out of bounds [%s,%s]."
,DbU::getValueString(y).c_str()
,DbU::getValueString(_boundingBox.getYMin()).c_str()
,DbU::getValueString(_boundingBox.getYMax()).c_str());
unsigned int index = (unsigned int)floor((y-_boundingBox.getYMin())/_tileHeight);
if ( y == _boundingBox.getYMax() ) --index;
return index;
} }
assert(is_sorted(_linesIndexes.begin(), _linesIndexes.end())); assert(is_sorted(_linesIndexes.begin(), _linesIndexes.end()));
if ( y == (*_linesIndexes.rbegin()).first ) if ( _linesIndexes.empty() );
return (*_linesIndexes.rbegin()).second-1; throw Error ( "MatrixVertex::getLineIndex(): Indexes map is empty." );
pair<pairIterator,pairIterator> result = equal_range (_linesIndexes.begin(), _linesIndexes.end() pair<pairIterator,pairIterator> result = equal_range (_linesIndexes.begin(), _linesIndexes.end()
, pair<DbU::Unit,unsigned>(y,0), MatrixVertex::IndexComp()); , pair<DbU::Unit,unsigned>(y,0), MatrixVertex::IndexComp());
if ( result.second == _linesIndexes.begin() ) if ( result.second == _linesIndexes.begin() )
throw Error ("MatrixVertex::getLineIndex(): search value (%s) is lower than lowest bound (%s)." throw Error ("MatrixVertex::getLineIndex(): search value (%s) is lower than lowest bound (%s)."
,getString(y).c_str(),getString((*_linesIndexes.begin()).first).c_str()); ,DbU::getValueString(y).c_str()
,DbU::getValueString((*_linesIndexes.begin()).first).c_str());
if ( result.second == _linesIndexes.end() ) if ( result.second == _linesIndexes.end() )
throw Error ("MatrixVertex::getLineIndex(): search value (%s) is upper than uppest bound (%s)." throw Error ("MatrixVertex::getLineIndex(): search value (%s) is upper than uppest bound (%s)."
,getString(y).c_str(),getString((*_linesIndexes.rbegin()).first).c_str()); ,DbU::getValueString(y).c_str()
,DbU::getValueString((*_linesIndexes.rbegin()).first).c_str());
return ((*result.second).second-1); return ((*result.second).second-1);
} }
@ -319,14 +328,28 @@ unsigned int MatrixVertex::getColumnIndex ( DbU::Unit x )
// ************************************************* // *************************************************
{ {
assert(_xInit ); assert(_xInit );
unsigned int maxIndex = (*_columnsIndexes.rbegin()).second - 1;
if ( _xRegular ) { if ( _xRegular ) {
// cerr << "x:" << DbU::getValueString(x-DbU::lambda(_lowerLeftX)) << "/" << _tileWidth << "=" << (DbU::getLambda(x-DbU::lambda(_lowerLeftX))/_tileWidth) // cerr << "x:" << DbU::getValueString(x-DbU::lambda(_boundingBox.getXMin())) << "/" << _tileWidth << "=" << (DbU::getLambda(x-DbU::lambda(_lowerLeftX))/_tileWidth)
// << "<=>" << (unsigned int)floor(DbU::getLambda(x-DbU::lambda(_lowerLeftX))/_tileWidth) << endl; // << "<=>" << (unsigned int)floor(DbU::getLambda(x-DbU::lambda(_boundingBox.getXMin()))/_tileWidth) << endl;
return (unsigned int)floor((x-_lowerLeftX)/_tileWidth); if ( (x < _boundingBox.getXMin()) or (x > _boundingBox.getXMax()) )
throw Error ("MatrixVertex::getColumnIndex(): search value (%s) is out of bounds [%s,%s]."
,DbU::getValueString(x).c_str()
,DbU::getValueString(_boundingBox.getXMin()).c_str()
,DbU::getValueString(_boundingBox.getXMax()).c_str());
unsigned int index = (unsigned int)floor((x-_boundingBox.getXMin())/_tileWidth);
if ( x == _boundingBox.getXMax() ) --index;
return index;
} }
assert(is_sorted(_columnsIndexes.begin(),_columnsIndexes.end())); assert(is_sorted(_columnsIndexes.begin(),_columnsIndexes.end()));
if ( x == (*_columnsIndexes.rbegin()).first ) if ( _columnsIndexes.empty() );
return (*_columnsIndexes.rbegin()).second-1; throw Error ( "MatrixVertex::getColumnIndex(): Indexes map is empty." );
pair<pairIterator,pairIterator> result = equal_range (_columnsIndexes.begin(), _columnsIndexes.end() pair<pairIterator,pairIterator> result = equal_range (_columnsIndexes.begin(), _columnsIndexes.end()
, pair<DbU::Unit,unsigned>(x,0), MatrixVertex::IndexComp()); , pair<DbU::Unit,unsigned>(x,0), MatrixVertex::IndexComp());
if ( result.second == _columnsIndexes.begin() ) if ( result.second == _columnsIndexes.begin() )

View File

@ -52,6 +52,7 @@ using Hurricane::Timer;
using Hurricane::Name; using Hurricane::Name;
using Hurricane::DbU; using Hurricane::DbU;
using Hurricane::Point; using Hurricane::Point;
using Hurricane::Box;
using Hurricane::Net; using Hurricane::Net;
using Hurricane::Segment; using Hurricane::Segment;
using Hurricane::Contact; using Hurricane::Contact;
@ -168,8 +169,13 @@ typedef vector<NetRecord> NetVector;
void initGlobalRouting(); // Making it public, so it can be called earlier and then capacities on edges can be ajusted void initGlobalRouting(); // Making it public, so it can be called earlier and then capacities on edges can be ajusted
void run(); void run();
void Route(); void Route();
void createRoutingGrid ( unsigned nbXTiles, unsigned nbYTiles void createRoutingGrid ( unsigned nbXTiles
, DbU::Unit lowerLeftX, DbU::Unit lowerLeftY, DbU::Unit tileWidth, DbU::Unit tileHeight, unsigned hcapacity, unsigned vcapacity ); , unsigned nbYTiles
, const Box& boundingBox
, DbU::Unit tileWidth
, DbU::Unit tileHeight
, unsigned hcapacity
, unsigned vcapacity );
void updateEdgeCapacity ( unsigned col1, unsigned row1, unsigned col2, unsigned row2, unsigned capacity ); void updateEdgeCapacity ( unsigned col1, unsigned row1, unsigned col2, unsigned row2, unsigned capacity );
void increaseEdgeCapacity ( unsigned col1, unsigned row1, unsigned col2, unsigned row2, int capacity ); void increaseEdgeCapacity ( unsigned col1, unsigned row1, unsigned col2, unsigned row2, int capacity );
void insertSegment ( Segment* segment ); void insertSegment ( Segment* segment );

View File

@ -38,8 +38,7 @@ namespace Knik {
unsigned _nbYTiles; unsigned _nbYTiles;
DbU::Unit _tileWidth; DbU::Unit _tileWidth;
DbU::Unit _tileHeight; DbU::Unit _tileHeight;
DbU::Unit _lowerLeftX; Box _boundingBox;
DbU::Unit _lowerLeftY;
Graph* _routingGraph; Graph* _routingGraph;
vector< vector<Vertex*> > _matrix; vector< vector<Vertex*> > _matrix;
vector< pair<DbU::Unit,unsigned> > _linesIndexes; vector< pair<DbU::Unit,unsigned> > _linesIndexes;

View File

@ -14,8 +14,7 @@ namespace Knik {
private: private:
unsigned _nbXTiles; unsigned _nbXTiles;
unsigned _nbYTiles; unsigned _nbYTiles;
DbU::Unit _lowerLeftX; Box _boundingBox;
DbU::Unit _lowerLeftY;
DbU::Unit _tileWidth; DbU::Unit _tileWidth;
DbU::Unit _tileHeight; DbU::Unit _tileHeight;
unsigned _hcapacity; unsigned _hcapacity;
@ -24,37 +23,53 @@ namespace Knik {
// Constructors & Destructors // Constructors & Destructors
// ************************** // **************************
protected: protected:
RoutingGrid ( unsigned nbXTiles, unsigned nbYTiles, DbU::Unit lowerLeftX, DbU::Unit lowerLeftY RoutingGrid ( unsigned nbXTiles
, DbU::Unit tileWidth, DbU::Unit tileHeight, unsigned hcapacity, unsigned vcapacity ) , unsigned nbYTiles
: _nbXTiles ( nbXTiles ) , const Box& boundingBox
, _nbYTiles ( nbYTiles ) , DbU::Unit tileWidth
, _lowerLeftX ( lowerLeftX ) , DbU::Unit tileHeight
, _lowerLeftY ( lowerLeftY ) , unsigned hcapacity
, _tileWidth ( tileWidth ) , unsigned vcapacity )
, _tileHeight ( tileHeight ) : _nbXTiles (nbXTiles)
, _hcapacity ( hcapacity ) , _nbYTiles (nbYTiles)
, _vcapacity ( vcapacity ) , _boundingBox(boundingBox)
{}; , _tileWidth (tileWidth)
, _tileHeight (tileHeight)
, _hcapacity (hcapacity)
, _vcapacity (vcapacity)
{ };
~RoutingGrid () {}; ~RoutingGrid () {};
public: public:
static RoutingGrid* create ( unsigned nbXTiles, unsigned nbYTiles, DbU::Unit lowerLeftX static RoutingGrid* create ( unsigned nbXTiles
, DbU::Unit lowerLeftY, DbU::Unit tileWidth, DbU::Unit tileHeight, unsigned hcapacity, unsigned vcapacity ) , unsigned nbYTiles
, const Box& boundingBox
, DbU::Unit tileWidth
, DbU::Unit tileHeight
, unsigned hcapacity
, unsigned vcapacity )
{ {
RoutingGrid* _routingGrid = new RoutingGrid ( nbXTiles, nbYTiles, lowerLeftX, lowerLeftY, tileWidth, tileHeight, hcapacity, vcapacity ); RoutingGrid* _routingGrid = new RoutingGrid ( nbXTiles
return _routingGrid; , nbYTiles
, boundingBox
, tileWidth
, tileHeight
, hcapacity
, vcapacity );
return _routingGrid;
}; };
// Accessors // Accessors
// ********* // *********
public: public:
unsigned getNbXTiles() { return _nbXTiles; }; unsigned getNbXTiles() { return _nbXTiles; };
unsigned getNbYTiles() { return _nbYTiles; }; unsigned getNbYTiles() { return _nbYTiles; };
DbU::Unit getLowerLeftX() { return _lowerLeftX; }; const Box& getBoundingBox() const { return _boundingBox; }
DbU::Unit getLowerLeftY() { return _lowerLeftY; }; DbU::Unit getLowerLeftX() { return _boundingBox.getXMin(); };
DbU::Unit getTileWidth() { return _tileWidth; }; DbU::Unit getLowerLeftY() { return _boundingBox.getYMin(); };
DbU::Unit getTileHeight() { return _tileHeight; }; DbU::Unit getTileWidth() { return _tileWidth; };
unsigned getHCapacity() { return _hcapacity; }; DbU::Unit getTileHeight() { return _tileHeight; };
unsigned getVCapacity() { return _vcapacity; }; unsigned getHCapacity() { return _hcapacity; };
unsigned getVCapacity() { return _vcapacity; };
// Modifiers // Modifiers
// ********* // *********