enables a empty abox for preplacement ...

This commit is contained in:
Christophe Alexandre 2005-12-16 15:33:18 +00:00
parent 6352ba5a46
commit 61824315e8
11 changed files with 344 additions and 128 deletions

View File

@ -151,9 +151,9 @@ main(int argc, char **argv)
bool VerboseFlg = false; // verbose mode bool VerboseFlg = false; // verbose mode
bool EqMarginFlg = false; // don't try to maximise bool EqMarginFlg = false; // don't try to maximise
// 2-pitch cells // 2-pitch cells
double NetMult = 0.8 ; double NetMult = 1.0 ;
double BinMult = 0.1 ; double BinMult = 0 ;
double RowMult = 0.1 ; double RowMult = 0 ;
/* ###------------------------------------------------------### */ /* ###------------------------------------------------------### */
/* analyse the command line, set option flags and find the */ /* analyse the command line, set option flags and find the */

View File

@ -26,6 +26,7 @@
// Authors-Tag // Authors-Tag
#include <stdio.h> #include <stdio.h>
#include <iomanip> #include <iomanip>
#include <assert.h>
using namespace std; using namespace std;
#include "PToPlaceIns.h" #include "PToPlaceIns.h"
@ -33,16 +34,16 @@ using namespace std;
#include "PBin.h" #include "PBin.h"
PBin::PBin() PBin::PBin()
: PContainer(), _toPlaceInss(), _nHits(0) : PContainer(), _toPlaceInss(), _sourceHits(0), _targetHits(0)
{ {
} }
void void
PBin::Init(const PBBox bbox, const double capa, PSubRow &row) PBin::Init(const PBBox& bbox, double margin, PSubRow &row)
{ {
_bBox = bbox; _bBox = bbox;
_pos = _bBox.GetCenter(); _pos = _bBox.GetCenter();
_capa = capa; _capa = bbox.GetWidth() * (1.0 - margin);
_size = 0.0; _size = 0.0;
_subRow = &row; _subRow = &row;
} }
@ -66,20 +67,29 @@ PBin::AddIns(PToPlaceIns *ins)
ins->SetBin(this); ins->SetBin(this);
} }
void void PBin::RemoveIns(PToPlaceIns* ins)
PBin::IncrNbHits()
{
_nHits++;
}
void
PBin::RemoveIns(PToPlaceIns* ins)
{ {
_toPlaceInss.remove(ins); _toPlaceInss.remove(ins);
AddSize(-ins->GetWidth()); AddSize(-ins->GetWidth());
ins->SetBin(NULL); ins->SetBin(NULL);
} }
void PBin::RemoveBackIns(PToPlaceIns* ins)
{
assert(_toPlaceInss.back() == ins);
_toPlaceInss.pop_back();
AddSize(-ins->GetWidth());
ins->SetBin(NULL);
}
void PBin::RemoveFrontIns(PToPlaceIns* ins)
{
assert(_toPlaceInss.front() == ins);
_toPlaceInss.pop_front();
AddSize(-ins->GetWidth());
ins->SetBin(NULL);
}
ostream& ostream&
PBin::Print(ostream& os) const PBin::Print(ostream& os) const
{ {
@ -109,7 +119,7 @@ PBin::PlotLabel(ofstream& out, unsigned totalMoves) const
double percent; double percent;
if (totalMoves != 0) if (totalMoves != 0)
{ {
percent = (_nHits * 100.0) / totalMoves; percent = (_sourceHits * 100.0) / totalMoves;
out << "set label \"" out << "set label \""
<< percent << "%\" at " << x << "," << y << " center" << percent << "%\" at " << x << "," << y << " center"
<< endl; << endl;

View File

@ -47,12 +47,13 @@ class PBin : public PContainer{
double _size; // Sum of instances widths double _size; // Sum of instances widths
PToPlaceInss _toPlaceInss; // Instances of bin. PToPlaceInss _toPlaceInss; // Instances of bin.
PPos _pos; // Position of the center of the bin PPos _pos; // Position of the center of the bin
unsigned _nHits; unsigned _sourceHits;
unsigned _targetHits;
public: public:
PBin(); PBin();
void Init(const PBBox bbox, const double capacity, PSubRow &subrow); void Init(const PBBox& bbox, double margin, PSubRow &subrow);
PSubRow* GetSubRow() const { return _subRow; } PSubRow* GetSubRow() const { return _subRow; }
bool GetOrientation() const { return _subRow->GetOrientation(); } bool GetOrientation() const { return _subRow->GetOrientation(); }
@ -61,13 +62,16 @@ class PBin : public PContainer{
PToPlaceInss& GetToPlaceInss() { return _toPlaceInss; } PToPlaceInss& GetToPlaceInss() { return _toPlaceInss; }
unsigned GetNIns() const { return _toPlaceInss.size(); } unsigned GetNIns() const { return _toPlaceInss.size(); }
PPos GetPos() const { return _pos; } PPos GetPos() const { return _pos; }
void IncrNbHits(); void IncrementSourceHits() { ++_sourceHits; }
void IncrementTargetHits() { ++_targetHits; }
void AddSize(const double value) { _size += value; _subRow->AddSize(value); } void AddSize(const double value) { _size += value; _subRow->AddSize(value); }
bool UnderOccupied(const double margin) const; bool UnderOccupied(const double margin) const;
void AddIns(PToPlaceIns *ins); void AddIns(PToPlaceIns *ins);
void RemoveIns(PToPlaceIns *ins); void RemoveIns(PToPlaceIns *ins);
void RemoveFrontIns(PToPlaceIns *ins);
void RemoveBackIns(PToPlaceIns *ins);
ostream& Print(ostream& os) const; ostream& Print(ostream& os) const;
ofstream& Plot(ofstream& out) const; ofstream& Plot(ofstream& out) const;

View File

@ -85,6 +85,16 @@ PMove::GetDeltaBinCost()
DeltaBinCost -= _dstBinInitCost; DeltaBinCost -= _dstBinInitCost;
DeltaBinCost += Abs(_srcBin->GetCapa() - _srcBin->GetSize()); DeltaBinCost += Abs(_srcBin->GetCapa() - _srcBin->GetSize());
DeltaBinCost += Abs(_dstBin->GetCapa() - _dstBin->GetSize()); DeltaBinCost += Abs(_dstBin->GetCapa() - _dstBin->GetSize());
#if 0
cerr << "hi" << endl;
cerr << _srcBinInitCost << endl;
cerr << _dstBinInitCost << endl;
cerr << DeltaBinCost << endl;
cerr << _srcBin->GetCapa() << endl;
cerr << _srcBin->GetSize() << endl;
cerr << _srcWidth << endl;
cerr << _dstWidth << endl;
#endif
return DeltaBinCost; return DeltaBinCost;
} }
@ -200,7 +210,7 @@ PMove::Move()
} else { } else {
_srcBin->RemoveIns(_srcIns); _srcBin->RemoveIns(_srcIns);
_dstBin->AddIns(_srcIns); _dstBin->AddIns(_srcIns);
_dstBin->RemoveIns(_dstIns); _dstBin->RemoveFrontIns(_dstIns);
_srcBin->AddIns(_dstIns); _srcBin->AddIns(_dstIns);
} }
} }
@ -240,20 +250,35 @@ PMove::Next(double Dist)
_dstRowInitCost = Abs(_dstSubRow->GetCapa() - _dstSubRow->GetSize()); _dstRowInitCost = Abs(_dstSubRow->GetCapa() - _dstSubRow->GetSize());
if (_dstBin == _srcBin) if (_dstBin == _srcBin)
{
MoveCondition = false; MoveCondition = false;
_placement.IncrSourceEqualTargetMovementNumber();
}
if (_dstBin->UnderOccupied(_placement.GetMargin())) { if (_dstBin->UnderOccupied(_placement.GetMargin()))
{
// Le bin destination est sous-occupé // Le bin destination est sous-occupé
// On déplace l'instance // On déplace l'instance
if (_dstSubRow->GetMax() - _dstSubRow->GetSize() < _srcWidth) if (_dstSubRow->GetMax() - _dstSubRow->GetSize() < _srcWidth)
{
MoveCondition = false; MoveCondition = false;
} else { _placement.IncrSurOccupationTargetMovementNumber();
}
}
else
{
_dstIns = _dstBin->GetToPlaceInss().front(); _dstIns = _dstBin->GetToPlaceInss().front();
_dstWidth = _dstIns->GetWidth(); _dstWidth = _dstIns->GetWidth();
if (_srcSubRow->GetMax() - _srcSubRow->GetSize() < _dstWidth - _srcWidth) if (_srcSubRow->GetMax() - _srcSubRow->GetSize() < _dstWidth - _srcWidth)
{
MoveCondition = false; MoveCondition = false;
_placement.IncrImpossibleExchangeMovementNumber();
}
if (_dstSubRow->GetMax() - _dstSubRow->GetSize() < _srcWidth - _dstWidth) if (_dstSubRow->GetMax() - _dstSubRow->GetSize() < _srcWidth - _dstWidth)
{
MoveCondition = false; MoveCondition = false;
_placement.IncrImpossibleExchangeMovementNumber();
}
} }
if (!MoveCondition) if (!MoveCondition)
++nbrefused; ++nbrefused;
@ -263,7 +288,8 @@ PMove::Next(double Dist)
// Deplace les instances // Deplace les instances
// ===================== // =====================
_dstBin->IncrNbHits(); _srcBin->IncrementSourceHits();
_dstBin->IncrementTargetHits();
Move(); Move();
return true; return true;
@ -273,6 +299,10 @@ PMove::Next(double Dist)
void void
PMove::Accept() PMove::Accept()
{ {
if (_dstIns == NULL)
_placement.IncrAcceptedMoveNumber();
else
_placement.IncrAcceptedExchangeNumber();
// Sauvegarde des cout des nets // Sauvegarde des cout des nets
for (map<PONet*, unsigned>::iterator it = _affectedNets.begin(); it != _affectedNets.end(); ++it) { for (map<PONet*, unsigned>::iterator it = _affectedNets.begin(); it != _affectedNets.end(); ++it) {
PONet* net = (*it).first; PONet* net = (*it).first;
@ -288,12 +318,14 @@ void
PMove::Reject() PMove::Reject()
{ {
if (_dstIns == NULL) { if (_dstIns == NULL) {
_dstBin->RemoveIns(_srcIns); _placement.IncrRejectedMoveNumber();
_dstBin->RemoveBackIns(_srcIns);
_srcBin->AddIns(_srcIns); _srcBin->AddIns(_srcIns);
} else { } else {
_srcBin->RemoveIns(_dstIns); _placement.IncrRejectedExchangeNumber();
_srcBin->RemoveBackIns(_dstIns);
_dstBin->RemoveBackIns(_srcIns);
_dstBin->AddIns(_dstIns); _dstBin->AddIns(_dstIns);
_dstBin->RemoveIns(_srcIns);
_srcBin->AddIns(_srcIns); _srcBin->AddIns(_srcIns);
} }
} }

View File

@ -388,6 +388,11 @@ PPlacement::Init(lofig* fig, int NbRows)
_biggestToPlaceInsWidth = inswidth; _biggestToPlaceInsWidth = inswidth;
_sumToPlaceInssWidth += inswidth; _sumToPlaceInssWidth += inswidth;
} }
if (_verbose)
{
cout << " o Sum of instances to place widths is ... " << _sumToPlaceInssWidth << endl;
}
_binsMaxWidth = (double)(int)(2.0 * _biggestToPlaceInsWidth * (1.0 + _margin) + 0.5); _binsMaxWidth = (double)(int)(2.0 * _biggestToPlaceInsWidth * (1.0 + _margin) + 0.5);
_binsMinWidth = (double)(int)(_binsMaxWidth / 2); _binsMinWidth = (double)(int)(_binsMaxWidth / 2);
@ -1289,7 +1294,7 @@ PPlacement::InitPlace(int NbRows)
if (_verbose) if (_verbose)
{ {
cout << " o User Margin : " << _margin << endl; cout << " o User Margin : " << 100.0 * _margin << "%" << endl;
} }
double rowwidth = SquareShape(_margin, _sumToPlaceInssWidth, double rowwidth = SquareShape(_margin, _sumToPlaceInssWidth,
@ -1301,6 +1306,14 @@ PPlacement::InitPlace(int NbRows)
} }
// computing Effective Margin // computing Effective Margin
double realSurface = NRows * rowwidth;
_realMargin = 1.0 - _sumToPlaceInssWidth / realSurface;
if (_verbose)
{
cout << " o Real Margin : " << 100.0 * _realMargin << "%" << endl;
}
_rows.reserve(NRows); _rows.reserve(NRows);
double Y = 0.0; double Y = 0.0;
@ -1316,8 +1329,7 @@ PPlacement::InitPlace(int NbRows)
_rowsYMinInv[Y] = rowidx; _rowsYMinInv[Y] = rowidx;
++rowidx; ++rowidx;
PSubRow& subrow = *(_rows.back()->_subRows[0]); PSubRow& subrow = *(_rows.back()->_subRows[0]);
subrow.Init(_rows.back(), Y, XMin, rowwidth, _margin, subrow.Init(_rows.back(), Y, XMin, rowwidth, _realMargin, _binsMaxWidth, _binsMinWidth);
_binsMaxWidth, _binsMinWidth);
_rows.back()->_subRowsXMax[rowwidth + XMin] = 0; _rows.back()->_subRowsXMax[rowwidth + XMin] = 0;
_rows.back()->_subRowsXMaxInv[rowwidth + XMin] = 0; _rows.back()->_subRowsXMaxInv[rowwidth + XMin] = 0;
Y += ROWHEIGHT; Y += ROWHEIGHT;
@ -1382,98 +1394,101 @@ PPlacement::InitPlaceWithPrePlace()
// find the orientation of the first row. // find the orientation of the first row.
phins* refpins = _prePlaceFig->PHINS; phins* refpins = _prePlaceFig->PHINS;
int ycoord = (int)((refpins->YINS - _dy) / (ROWHEIGHT * PITCH)); if (refpins)
phfig* refpinsmodel = getphfig(refpins->FIGNAME, 'P');
int refpinsheight = (int)((refpinsmodel->YAB2 - refpinsmodel->YAB1)
/ (ROWHEIGHT * PITCH));
char transf = refpins->TRANSF;
if (ycoord % 2 == 0)
{ {
if ((refpinsheight == 2) || (transf == NOSYM) || (transf == SYM_X)) int ycoord = (int)((refpins->YINS - _dy) / (ROWHEIGHT * PITCH));
_rowZeroOrientation = true; phfig* refpinsmodel = getphfig(refpins->FIGNAME, 'P');
else int refpinsheight = (int)((refpinsmodel->YAB2 - refpinsmodel->YAB1)
_rowZeroOrientation = false; / (ROWHEIGHT * PITCH));
} else { char transf = refpins->TRANSF;
if ((refpinsheight == 2) || (transf == NOSYM) || (transf == SYM_X))
_rowZeroOrientation = false;
else
_rowZeroOrientation = true;
}
// tests for each instance if (ycoord % 2 == 0)
for (phins* pins = _prePlaceFig->PHINS; pins; pins = pins->NEXT) {
{ if ((refpinsheight == 2) || (transf == NOSYM) || (transf == SYM_X))
phfig_list* phmodel = getphfig(pins->FIGNAME, '0'); _rowZeroOrientation = true;
int pinswidth = phmodel->XAB2 - phmodel->XAB1; else
int pinsheight = phmodel->YAB2 - phmodel->YAB1; _rowZeroOrientation = false;
} else {
pinswidth = (int)(pinswidth / PITCH); // largeur ramene au pitch if ((refpinsheight == 2) || (transf == NOSYM) || (transf == SYM_X))
pinsheight = (int)(pinsheight / PITCH); // hauteur ramene au pitch _rowZeroOrientation = false;
int pinsheightrow = (int)(pinsheight / ROWHEIGHT); // hauteur ramene a l'unite else
// (taille des lignes) _rowZeroOrientation = true;
int ypos = (int)((pins->YINS - _dy) / PITCH); // position en y ramene au pitch }
int xpos = (int)((pins->XINS - _dx) / PITCH); // position en x ramene au pitch
int ycoord = (int)(ypos / ROWHEIGHT); // position en y ramene a l'unite
if ((pins->YINS - _dy) % 50 != 0) // tests for each instance
{ for (phins* pins = _prePlaceFig->PHINS; pins; pins = pins->NEXT)
cerr << " o ERROR : in preplacement file : y position of " {
<< pins->INSNAME << " is incorrect" << endl; phfig_list* phmodel = getphfig(pins->FIGNAME, '0');
exit (1); int pinswidth = phmodel->XAB2 - phmodel->XAB1;
} int pinsheight = phmodel->YAB2 - phmodel->YAB1;
pinswidth = (int)(pinswidth / PITCH); // largeur ramene au pitch
pinsheight = (int)(pinsheight / PITCH); // hauteur ramene au pitch
int pinsheightrow = (int)(pinsheight / ROWHEIGHT); // hauteur ramene a l'unite
// (taille des lignes)
int ypos = (int)((pins->YINS - _dy) / PITCH); // position en y ramene au pitch
int xpos = (int)((pins->XINS - _dx) / PITCH); // position en x ramene au pitch
int ycoord = (int)(ypos / ROWHEIGHT); // position en y ramene a l'unite
if ((pins->XINS - _dx) % 5 != 0) if ((pins->YINS - _dy) % 50 != 0)
{ {
cerr << " o ERROR : in preplacement file : x position of " cerr << " o ERROR : in preplacement file : y position of "
<< pins->INSNAME << " is incorrect" << endl; << pins->INSNAME << " is incorrect" << endl;
exit (1); exit (1);
} }
if ( (pins->TRANSF == ROT_P) || (pins->TRANSF == ROT_M) if ((pins->XINS - _dx) % 5 != 0)
|| (pins->TRANSF == SY_RP) || (pins->TRANSF == SY_RM) ) {
{ cerr << " o ERROR : in preplacement file : x position of "
cerr << " o ERROR : " << pins->INSNAME << " : incorrect rotation" << endl; << pins->INSNAME << " is incorrect" << endl;
exit(1); exit (1);
} }
// check if orientation of instance matches
bool insOrient;
if ((pinsheightrow == 2) || (pins->TRANSF == NOSYM) || (pins->TRANSF == SYM_X))
insOrient = true;
else
insOrient = false;
if ( ((ycoord % 2 == 0) && (insOrient != _rowZeroOrientation)) if ( (pins->TRANSF == ROT_P) || (pins->TRANSF == ROT_M)
|| ((ycoord % 2 != 0) && (insOrient == _rowZeroOrientation)) ) || (pins->TRANSF == SY_RP) || (pins->TRANSF == SY_RM) )
{ {
cerr << " o ERROR : " << pins->INSNAME << " badly oriented" << endl cerr << " o ERROR : " << pins->INSNAME << " : incorrect rotation" << endl;
<< " Incoherence with " << refpins->INSNAME << endl; exit(1);
exit(1); }
}
// check if orientation of instance matches
for (int yit = ycoord; yit < ycoord + pinsheightrow; yit++) bool insOrient;
{ if ((pinsheightrow == 2) || (pins->TRANSF == NOSYM) || (pins->TRANSF == SYM_X))
for (int xit = xpos; xit < xpos + pinswidth; xit++) insOrient = true;
{ else
if ( (xit > Width - 1) || (yit > Height - 1) insOrient = false;
|| (xit < 0 ) || (yit < 0 ) )
{ if ( ((ycoord % 2 == 0) && (insOrient != _rowZeroOrientation))
cerr << " o ERROR : " << pins->INSNAME || ((ycoord % 2 != 0) && (insOrient == _rowZeroOrientation)) )
<< " out of the abutment box" << endl; {
exit(1); cerr << " o ERROR : " << pins->INSNAME << " badly oriented" << endl
} << " Incoherence with " << refpins->INSNAME << endl;
exit(1);
if (tabpreplace[yit][xit] == false) }
{
tabpreplace[yit][xit] = true; for (int yit = ycoord; yit < ycoord + pinsheightrow; yit++)
} {
else{ for (int xit = xpos; xit < xpos + pinswidth; xit++)
cerr << " o ERROR : " << pins->INSNAME << " badly placed .... There is already an instance at its position ...." << endl; {
exit (1); if ( (xit > Width - 1) || (yit > Height - 1)
} || (xit < 0 ) || (yit < 0 ) )
} {
} cerr << " o ERROR : " << pins->INSNAME
<< " out of the abutment box" << endl;
exit(1);
}
if (tabpreplace[yit][xit] == false)
{
tabpreplace[yit][xit] = true;
}
else{
cerr << " o ERROR : " << pins->INSNAME << " badly placed .... There is already an instance at its position ...." << endl;
exit (1);
}
}
}
}
} }
// create rows and subrows // create rows and subrows
@ -1616,3 +1631,33 @@ PPlacement::GetRow(const PRow* row, const double dist)
unsigned randidx = rinf->second + (unsigned)((double)(rsup->second - rinf->second + 1) * (rand() / (RAND_MAX+1.0))); unsigned randidx = rinf->second + (unsigned)((double)(rsup->second - rinf->second + 1) * (rand() / (RAND_MAX+1.0)));
return *_rows[randidx]; return *_rows[randidx];
} }
double PPlacement::GetBinsCapa() const
{
double binsCapa = 0.0;
for (PRows::const_iterator rit = _rows.begin(); rit != _rows.end(); rit++)
{
binsCapa += (*rit)->GetBinsCapa();
}
return binsCapa;
}
double PPlacement::GetSubRowsCapa() const
{
double subRowsCapa = 0.0;
for (PRows::const_iterator rit = _rows.begin(); rit != _rows.end(); rit++)
{
subRowsCapa += (*rit)->GetSubRowsCapa();
}
return subRowsCapa;
}
double PPlacement::GetBinsSize() const
{
double binsSize = 0.0;
for (PRows::const_iterator rit = _rows.begin(); rit != _rows.end(); rit++)
{
binsSize += (*rit)->GetBinsSize();
}
return binsSize;
}

View File

@ -110,6 +110,7 @@ class PPlacement {
// parametres // parametres
double _margin; double _margin;
double _realMargin;
int _maxDetLoop; // Maximum nb of loops for detailed placement int _maxDetLoop; // Maximum nb of loops for detailed placement
double RowMult; double RowMult;
double BinMult; double BinMult;
@ -124,6 +125,13 @@ class PPlacement {
bool _prePlace; bool _prePlace;
bool _eqMargin; bool _eqMargin;
unsigned _totalMoves; unsigned _totalMoves;
unsigned _sourceEqualTargetMovementNumber;
unsigned _surOccupationTargetMovementNumber;
unsigned _impossibleExchangeMovementNumber;
unsigned _acceptedMoveNumber;
unsigned _acceptedExchangeNumber;
unsigned _rejectedMoveNumber;
unsigned _rejectedExchangeNumber;
// Placement caracteristics // Placement caracteristics
char* _fileName; char* _fileName;
@ -155,7 +163,15 @@ class PPlacement {
RowMult(rowmult), BinMult(binmult), NetMult(netmult), RowMult(rowmult), BinMult(binmult), NetMult(netmult),
_placeCons(conflg), _ringPlaceCons(ringflg), _iocFile(iocfile), _iocFileName(iocfilename), _placeCons(conflg), _ringPlaceCons(ringflg), _iocFile(iocfile), _iocFileName(iocfilename),
_boolPlot(plotflg), _verbose(verbose), _prePlace(preflg), _eqMargin(eqmargin), _boolPlot(plotflg), _verbose(verbose), _prePlace(preflg), _eqMargin(eqmargin),
_totalMoves(0),_fileName(filename) _totalMoves(0)
, _sourceEqualTargetMovementNumber(0)
, _surOccupationTargetMovementNumber(0)
, _impossibleExchangeMovementNumber(0)
, _acceptedMoveNumber(0)
, _acceptedExchangeNumber(0)
, _rejectedMoveNumber(0)
, _rejectedExchangeNumber(0)
, _fileName(filename)
{} {}
~PPlacement(); ~PPlacement();
@ -177,6 +193,10 @@ class PPlacement {
void PlotStat(); void PlotStat();
void PlotOnlyBins(char* output) const; void PlotOnlyBins(char* output) const;
double GetBinsSize() const;
double GetBinsCapa() const;
double GetSubRowsCapa() const;
double GetMinX() const { return BBox.GetMinX(); } double GetMinX() const { return BBox.GetMinX(); }
double GetMinY() const { return BBox.GetMinY(); } double GetMinY() const { return BBox.GetMinY(); }
double GetMaxX() const { return BBox.GetMaxX(); } double GetMaxX() const { return BBox.GetMaxX(); }
@ -188,6 +208,21 @@ class PPlacement {
bool GetBoolPlot() const { return _boolPlot; } bool GetBoolPlot() const { return _boolPlot; }
void SetBoolPlot(bool value) { _boolPlot = value; } void SetBoolPlot(bool value) { _boolPlot = value; }
void IncrImpossibleExchangeMovementNumber()
{ ++_impossibleExchangeMovementNumber; }
void IncrSourceEqualTargetMovementNumber()
{ ++_sourceEqualTargetMovementNumber; }
void IncrSurOccupationTargetMovementNumber()
{ ++_surOccupationTargetMovementNumber; }
void IncrAcceptedMoveNumber()
{ ++_acceptedMoveNumber; }
void IncrAcceptedExchangeNumber()
{ ++_acceptedExchangeNumber; }
void IncrRejectedMoveNumber()
{ ++_rejectedMoveNumber; }
void IncrRejectedExchangeNumber()
{ ++_rejectedExchangeNumber; }
double GetOccCost() const; double GetOccCost() const;
void InitBBoxCost(); void InitBBoxCost();
double TempBBoxCost(); double TempBBoxCost();

View File

@ -228,6 +228,9 @@ PPlacement::PlaceGlobal()
cout << " o Initial NetCost = " << NetCost << endl; cout << " o Initial NetCost = " << NetCost << endl;
cout << " o Initial Cost = " << Cost << endl; cout << " o Initial Cost = " << Cost << endl;
cout << " o Computing Initial Temperature ..." << endl; cout << " o Computing Initial Temperature ..." << endl;
cout << " o bins size " << GetBinsSize() << endl;
cout << " o bins capa " << GetBinsCapa() << endl;
cout << " o subrows capa " << GetSubRowsCapa() << endl;
} }
// Calcul de la temperature initiale // Calcul de la temperature initiale
for (int i = 0; i < GetNInsToPlace(); ++i) { for (int i = 0; i < GetNInsToPlace(); ++i) {
@ -348,6 +351,18 @@ PPlacement::PlaceGlobal()
cout << "Loop = " << Loop << ", Temperature = " << Temperature << ", Cost = " << Cost << endl; cout << "Loop = " << Loop << ", Temperature = " << Temperature << ", Cost = " << Cost << endl;
cout << " RowCost = " << RowCost << ", BinCost = " << BinCost << ", NetCost = " << NetCost << endl; cout << " RowCost = " << RowCost << ", BinCost = " << BinCost << ", NetCost = " << NetCost << endl;
cout << " Success Ratio = " << SucRatio * 100.0 << "%, Dist = " << Dist << ", Delta = " << Temperature / OldTemperature << endl; cout << " Success Ratio = " << SucRatio * 100.0 << "%, Dist = " << Dist << ", Delta = " << Temperature / OldTemperature << endl;
unsigned totalImpossibleMovements =
_impossibleExchangeMovementNumber
+ _sourceEqualTargetMovementNumber
+ _surOccupationTargetMovementNumber;
cout << " o Total impossible movements = " << totalImpossibleMovements << endl;
cout << " o " << 100.0 * _surOccupationTargetMovementNumber / totalImpossibleMovements
<< " % suroccupied target" << endl;
cout << " o " << 100.0 * _sourceEqualTargetMovementNumber / totalImpossibleMovements
<< " % source equal target" << endl;
cout << " o " << 100.0 * _impossibleExchangeMovementNumber / totalImpossibleMovements
<< " % impossible exchange" << endl;
} }
else cerr << "."; else cerr << ".";
@ -429,18 +444,40 @@ PPlacement::PlaceGlobal()
} else { } else {
Move.Reject(); Move.Reject();
} }
_totalMoves += 1; _totalMoves += 1;
} }
} }
if (_verbose) if (_verbose)
{ {
unsigned totalImpossibleMovements =
_impossibleExchangeMovementNumber
+ _sourceEqualTargetMovementNumber
+ _surOccupationTargetMovementNumber;
cout << " o Global Placement finished ....." << endl; cout << " o Global Placement finished ....." << endl;
cout << " o Gain for RowCost = " << 100.0 * (_initRowCost - RowCost) / _initRowCost << "%" << endl; cout << " o Gain for RowCost = " << 100.0 * (_initRowCost - RowCost) / _initRowCost << "%" << endl;
cout << " o Gain for BinCost = " << 100.0 * (_initBinCost - BinCost) / _initBinCost << "%" << endl; cout << " o Gain for BinCost = " << 100.0 * (_initBinCost - BinCost) / _initBinCost << "%" << endl;
cout << " o Gain for NetCost = " << 100.0 * (_initNetCost - NetCost) / _initNetCost << "%" << endl; cout << " o Gain for NetCost = " << 100.0 * (_initNetCost - NetCost) / _initNetCost << "%" << endl;
cout << " o NetCost Estimated = " << NetCost << endl; cout << " o NetCost Estimated = " << NetCost << endl;
cout << " o Movements Stats ?! " << endl;
cout << " o " << _totalMoves << " Tried Moves" << endl;
cout << " o " << 100.0 * _acceptedMoveNumber / _totalMoves
<< " % of accepted simple instance move" << endl;
cout << " o " << 100.0 * _acceptedExchangeNumber / _totalMoves
<< " % of accepted instance exchange" << endl;
cout << " o " << 100.0 * _rejectedMoveNumber / _totalMoves
<< " % of rejected simple instance move" << endl;
cout << " o " << 100.0 * _rejectedExchangeNumber / _totalMoves
<< " % of rejected instance exchange" << endl;
cout << " o Impossible Movements Stats .... "<< endl;
cout << " o If you find those value interesting, look for a doctor ..." << endl;
cout << " o Total impossible movements = " << totalImpossibleMovements << endl;
cout << " o " << 100.0 * _surOccupationTargetMovementNumber / totalImpossibleMovements
<< " % suroccupied target" << endl;
cout << " o " << 100.0 * _sourceEqualTargetMovementNumber / totalImpossibleMovements
<< " % source equal target" << endl;
cout << " o " << 100.0 * _impossibleExchangeMovementNumber / totalImpossibleMovements
<< " % impossible exchange" << endl;
} }
} }

View File

@ -173,8 +173,38 @@ PRow::PlotLabel(ofstream& out, unsigned TotalMoves) const
} }
return out; return out;
} }
ostream&
PRow::Print(ostream& os) const double PRow::GetBinsSize() const
{
double binsSize = 0.0;
for (PSubRows::const_iterator srit=_subRows.begin(); srit!=_subRows.end(); srit++)
{
binsSize += (*srit)->GetBinsSize();
}
return binsSize;
}
double PRow::GetBinsCapa() const
{
double binsCapa = 0.0;
for (PSubRows::const_iterator srit=_subRows.begin(); srit!=_subRows.end(); srit++)
{
binsCapa += (*srit)->GetBinsCapa();
}
return binsCapa;
}
double PRow::GetSubRowsCapa() const
{
double subRowsCapa = 0.0;
for (PSubRows::const_iterator srit=_subRows.begin(); srit!=_subRows.end(); srit++)
{
subRowsCapa += (*srit)->GetCapa();
}
return subRowsCapa;
}
ostream& PRow::Print(ostream& os) const
{ {
return os << "PRow: " << GetMinX() << ',' << GetMinY() << " : " << GetMaxX() << ',' << GetMaxY(); return os << "PRow: " << GetMinX() << ',' << GetMinY() << " : " << GetMaxX() << ',' << GetMaxY();
} }

View File

@ -66,6 +66,9 @@ class PRow : public PContainer
PSubRow& GetSubRow(const double X); PSubRow& GetSubRow(const double X);
double GetSubRowCost() const; double GetSubRowCost() const;
double GetBinCost() const; double GetBinCost() const;
double GetBinsSize() const;
double GetBinsCapa() const;
double GetSubRowsCapa() const;
ostream& Print(ostream& os) const; ostream& Print(ostream& os) const;
ofstream& Plot(ofstream& out) const; ofstream& Plot(ofstream& out) const;

View File

@ -56,7 +56,6 @@ PSubRow::Init(PRow* row, double y, double minx, double maxx, double margin, doub
PBBox binbbox; PBBox binbbox;
double xpos; double xpos;
int binswidth; int binswidth;
int binscapa;
int modulo = 0; int modulo = 0;
_bBox.SetMinY(y); _bBox.SetMinY(y);
@ -79,7 +78,6 @@ PSubRow::Init(PRow* row, double y, double minx, double maxx, double margin, doub
modulo = ((int)(maxx - minx) % _nBins); modulo = ((int)(maxx - minx) % _nBins);
binswidth = (int)((maxx - minx) / _nBins); binswidth = (int)((maxx - minx) / _nBins);
binscapa = (int)(binswidth * ( 1 - margin));
_bins.reserve(_nBins); _bins.reserve(_nBins);
for (unsigned binnumber = 0; binnumber < _nBins; binnumber++) for (unsigned binnumber = 0; binnumber < _nBins; binnumber++)
@ -98,7 +96,7 @@ PSubRow::Init(PRow* row, double y, double minx, double maxx, double margin, doub
binbbox.SetMaxX(xpos); binbbox.SetMaxX(xpos);
} }
_binsXMax[xpos] = binnumber; _binsXMax[xpos] = binnumber;
_bins.back()->Init(binbbox, binscapa, *this); _bins.back()->Init(binbbox, margin, *this);
} }
_row->MergeBBox(_bBox); _row->MergeBBox(_bBox);
} }
@ -147,15 +145,14 @@ PSubRow::ForceIns(PToPlaceIns& Ins, int BinNumber)
#ifndef Abs #ifndef Abs
#define Abs(x) ((x) < 0.0 ? -(x) : (x)) #define Abs(x) ((x) < 0.0 ? -(x) : (x))
#endif #endif
double double PSubRow::GetBinCost() const
PSubRow::GetBinCost() const
{ {
double BinCost = 0.0; double binCost = 0.0;
for (PBins::const_iterator bit = _bins.begin(); bit != _bins.end(); bit++) for (PBins::const_iterator bit = _bins.begin(); bit != _bins.end(); bit++)
{ {
BinCost += Abs((*bit)->GetSize() - (*bit)->GetCapa()); binCost += Abs((*bit)->GetSize() - (*bit)->GetCapa());
} }
return BinCost; return binCost;
} }
ofstream& ofstream&
@ -183,3 +180,24 @@ PSubRow::Print(ostream& os) const
{ {
return os << "PSubRow: " << GetMinX() << ',' << GetMinY() << " : " << GetMaxX() << ',' << GetMaxY(); return os << "PSubRow: " << GetMinX() << ',' << GetMinY() << " : " << GetMaxX() << ',' << GetMaxY();
} }
double PSubRow::GetBinsSize() const
{
double binsSize = 0.0;
for (PBins::const_iterator bit=_bins.begin(); bit!=_bins.end(); bit++)
{
binsSize += (*bit)->GetSize();
}
return binsSize;
}
double PSubRow::GetBinsCapa() const
{
double binsCapa = 0.0;
for (PBins::const_iterator bit=_bins.begin(); bit!=_bins.end(); bit++)
{
binsCapa += (*bit)->GetCapa();
}
return binsCapa;
}

View File

@ -50,8 +50,8 @@ class PSubRow : public PContainer {
PBins _bins; PBins _bins;
PBinsXMax _binsXMax; PBinsXMax _binsXMax;
double _size; // somme des Width des bins de la row double _size; // somme des Width des bins de la row
double _capa; // l'occupation ideale de la row double _capa; // l'occupation ideale de la subrow
double _max; // seuil de la ligne !!ne pas dépasser double _max; // seuil de la sousligne !!ne pas dépasser
unsigned _nBins; // Bins.size(); unsigned _nBins; // Bins.size();
public: public:
@ -64,6 +64,8 @@ class PSubRow : public PContainer {
PRow* GetRow() { return _row; } PRow* GetRow() { return _row; }
PBin& GetBin(const double X); PBin& GetBin(const double X);
PBins& GetBins() { return _bins; } PBins& GetBins() { return _bins; }
double GetBinsSize() const;
double GetBinsCapa() const;
double GetCapa() const { return _capa; } double GetCapa() const { return _capa; }
double GetSize() const { return _size; } double GetSize() const { return _size; }