From 61824315e822c4427c9b2739e1dfaeb93699fa55 Mon Sep 17 00:00:00 2001 From: Christophe Alexandre Date: Fri, 16 Dec 2005 15:33:18 +0000 Subject: [PATCH] enables a empty abox for preplacement ... --- alliance/src/ocp/src/placer/Ocp.cpp | 6 +- alliance/src/ocp/src/placer/PBin.cpp | 34 ++- alliance/src/ocp/src/placer/PBin.h | 10 +- alliance/src/ocp/src/placer/PMove.cpp | 46 +++- alliance/src/ocp/src/placer/PPlacement.cpp | 223 +++++++++++------- alliance/src/ocp/src/placer/PPlacement.h | 37 ++- .../src/ocp/src/placer/PPlacementGlobal.cpp | 39 ++- alliance/src/ocp/src/placer/PRow.cpp | 34 ++- alliance/src/ocp/src/placer/PRow.h | 3 + alliance/src/ocp/src/placer/PSubRow.cpp | 34 ++- alliance/src/ocp/src/placer/PSubRow.h | 6 +- 11 files changed, 344 insertions(+), 128 deletions(-) diff --git a/alliance/src/ocp/src/placer/Ocp.cpp b/alliance/src/ocp/src/placer/Ocp.cpp index 0754f151..c8df54c3 100644 --- a/alliance/src/ocp/src/placer/Ocp.cpp +++ b/alliance/src/ocp/src/placer/Ocp.cpp @@ -151,9 +151,9 @@ main(int argc, char **argv) bool VerboseFlg = false; // verbose mode bool EqMarginFlg = false; // don't try to maximise // 2-pitch cells - double NetMult = 0.8 ; - double BinMult = 0.1 ; - double RowMult = 0.1 ; + double NetMult = 1.0 ; + double BinMult = 0 ; + double RowMult = 0 ; /* ###------------------------------------------------------### */ /* analyse the command line, set option flags and find the */ diff --git a/alliance/src/ocp/src/placer/PBin.cpp b/alliance/src/ocp/src/placer/PBin.cpp index 418b2f89..6bb620cb 100644 --- a/alliance/src/ocp/src/placer/PBin.cpp +++ b/alliance/src/ocp/src/placer/PBin.cpp @@ -26,6 +26,7 @@ // Authors-Tag #include #include +#include using namespace std; #include "PToPlaceIns.h" @@ -33,16 +34,16 @@ using namespace std; #include "PBin.h" PBin::PBin() - : PContainer(), _toPlaceInss(), _nHits(0) + : PContainer(), _toPlaceInss(), _sourceHits(0), _targetHits(0) { } void -PBin::Init(const PBBox bbox, const double capa, PSubRow &row) +PBin::Init(const PBBox& bbox, double margin, PSubRow &row) { _bBox = bbox; _pos = _bBox.GetCenter(); - _capa = capa; + _capa = bbox.GetWidth() * (1.0 - margin); _size = 0.0; _subRow = &row; } @@ -66,20 +67,29 @@ PBin::AddIns(PToPlaceIns *ins) ins->SetBin(this); } -void -PBin::IncrNbHits() -{ - _nHits++; -} - -void -PBin::RemoveIns(PToPlaceIns* ins) +void PBin::RemoveIns(PToPlaceIns* ins) { _toPlaceInss.remove(ins); AddSize(-ins->GetWidth()); 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& PBin::Print(ostream& os) const { @@ -109,7 +119,7 @@ PBin::PlotLabel(ofstream& out, unsigned totalMoves) const double percent; if (totalMoves != 0) { - percent = (_nHits * 100.0) / totalMoves; + percent = (_sourceHits * 100.0) / totalMoves; out << "set label \"" << percent << "%\" at " << x << "," << y << " center" << endl; diff --git a/alliance/src/ocp/src/placer/PBin.h b/alliance/src/ocp/src/placer/PBin.h index 4972549d..68c89d8b 100644 --- a/alliance/src/ocp/src/placer/PBin.h +++ b/alliance/src/ocp/src/placer/PBin.h @@ -47,12 +47,13 @@ class PBin : public PContainer{ double _size; // Sum of instances widths PToPlaceInss _toPlaceInss; // Instances of bin. PPos _pos; // Position of the center of the bin - unsigned _nHits; + unsigned _sourceHits; + unsigned _targetHits; public: 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; } bool GetOrientation() const { return _subRow->GetOrientation(); } @@ -61,13 +62,16 @@ class PBin : public PContainer{ PToPlaceInss& GetToPlaceInss() { return _toPlaceInss; } unsigned GetNIns() const { return _toPlaceInss.size(); } PPos GetPos() const { return _pos; } - void IncrNbHits(); + void IncrementSourceHits() { ++_sourceHits; } + void IncrementTargetHits() { ++_targetHits; } void AddSize(const double value) { _size += value; _subRow->AddSize(value); } bool UnderOccupied(const double margin) const; void AddIns(PToPlaceIns *ins); void RemoveIns(PToPlaceIns *ins); + void RemoveFrontIns(PToPlaceIns *ins); + void RemoveBackIns(PToPlaceIns *ins); ostream& Print(ostream& os) const; ofstream& Plot(ofstream& out) const; diff --git a/alliance/src/ocp/src/placer/PMove.cpp b/alliance/src/ocp/src/placer/PMove.cpp index de46f2a6..3e19663f 100644 --- a/alliance/src/ocp/src/placer/PMove.cpp +++ b/alliance/src/ocp/src/placer/PMove.cpp @@ -85,6 +85,16 @@ PMove::GetDeltaBinCost() DeltaBinCost -= _dstBinInitCost; DeltaBinCost += Abs(_srcBin->GetCapa() - _srcBin->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; } @@ -200,7 +210,7 @@ PMove::Move() } else { _srcBin->RemoveIns(_srcIns); _dstBin->AddIns(_srcIns); - _dstBin->RemoveIns(_dstIns); + _dstBin->RemoveFrontIns(_dstIns); _srcBin->AddIns(_dstIns); } } @@ -240,20 +250,35 @@ PMove::Next(double Dist) _dstRowInitCost = Abs(_dstSubRow->GetCapa() - _dstSubRow->GetSize()); if (_dstBin == _srcBin) + { MoveCondition = false; + _placement.IncrSourceEqualTargetMovementNumber(); + } - if (_dstBin->UnderOccupied(_placement.GetMargin())) { + if (_dstBin->UnderOccupied(_placement.GetMargin())) + { // Le bin destination est sous-occupé // On déplace l'instance if (_dstSubRow->GetMax() - _dstSubRow->GetSize() < _srcWidth) + { MoveCondition = false; - } else { + _placement.IncrSurOccupationTargetMovementNumber(); + } + } + else + { _dstIns = _dstBin->GetToPlaceInss().front(); _dstWidth = _dstIns->GetWidth(); if (_srcSubRow->GetMax() - _srcSubRow->GetSize() < _dstWidth - _srcWidth) + { MoveCondition = false; + _placement.IncrImpossibleExchangeMovementNumber(); + } if (_dstSubRow->GetMax() - _dstSubRow->GetSize() < _srcWidth - _dstWidth) + { MoveCondition = false; + _placement.IncrImpossibleExchangeMovementNumber(); + } } if (!MoveCondition) ++nbrefused; @@ -263,7 +288,8 @@ PMove::Next(double Dist) // Deplace les instances // ===================== - _dstBin->IncrNbHits(); + _srcBin->IncrementSourceHits(); + _dstBin->IncrementTargetHits(); Move(); return true; @@ -273,6 +299,10 @@ PMove::Next(double Dist) void PMove::Accept() { + if (_dstIns == NULL) + _placement.IncrAcceptedMoveNumber(); + else + _placement.IncrAcceptedExchangeNumber(); // Sauvegarde des cout des nets for (map::iterator it = _affectedNets.begin(); it != _affectedNets.end(); ++it) { PONet* net = (*it).first; @@ -288,12 +318,14 @@ void PMove::Reject() { if (_dstIns == NULL) { - _dstBin->RemoveIns(_srcIns); + _placement.IncrRejectedMoveNumber(); + _dstBin->RemoveBackIns(_srcIns); _srcBin->AddIns(_srcIns); } else { - _srcBin->RemoveIns(_dstIns); + _placement.IncrRejectedExchangeNumber(); + _srcBin->RemoveBackIns(_dstIns); + _dstBin->RemoveBackIns(_srcIns); _dstBin->AddIns(_dstIns); - _dstBin->RemoveIns(_srcIns); _srcBin->AddIns(_srcIns); } } diff --git a/alliance/src/ocp/src/placer/PPlacement.cpp b/alliance/src/ocp/src/placer/PPlacement.cpp index dd642b37..526f1afd 100644 --- a/alliance/src/ocp/src/placer/PPlacement.cpp +++ b/alliance/src/ocp/src/placer/PPlacement.cpp @@ -388,6 +388,11 @@ PPlacement::Init(lofig* fig, int NbRows) _biggestToPlaceInsWidth = 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); _binsMinWidth = (double)(int)(_binsMaxWidth / 2); @@ -1289,7 +1294,7 @@ PPlacement::InitPlace(int NbRows) if (_verbose) { - cout << " o User Margin : " << _margin << endl; + cout << " o User Margin : " << 100.0 * _margin << "%" << endl; } double rowwidth = SquareShape(_margin, _sumToPlaceInssWidth, @@ -1301,6 +1306,14 @@ PPlacement::InitPlace(int NbRows) } // 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); double Y = 0.0; @@ -1316,8 +1329,7 @@ PPlacement::InitPlace(int NbRows) _rowsYMinInv[Y] = rowidx; ++rowidx; PSubRow& subrow = *(_rows.back()->_subRows[0]); - subrow.Init(_rows.back(), Y, XMin, rowwidth, _margin, - _binsMaxWidth, _binsMinWidth); + subrow.Init(_rows.back(), Y, XMin, rowwidth, _realMargin, _binsMaxWidth, _binsMinWidth); _rows.back()->_subRowsXMax[rowwidth + XMin] = 0; _rows.back()->_subRowsXMaxInv[rowwidth + XMin] = 0; Y += ROWHEIGHT; @@ -1382,98 +1394,101 @@ PPlacement::InitPlaceWithPrePlace() // find the orientation of the first row. phins* refpins = _prePlaceFig->PHINS; - int ycoord = (int)((refpins->YINS - _dy) / (ROWHEIGHT * PITCH)); - phfig* refpinsmodel = getphfig(refpins->FIGNAME, 'P'); - int refpinsheight = (int)((refpinsmodel->YAB2 - refpinsmodel->YAB1) - / (ROWHEIGHT * PITCH)); - char transf = refpins->TRANSF; - - if (ycoord % 2 == 0) + if (refpins) { - if ((refpinsheight == 2) || (transf == NOSYM) || (transf == SYM_X)) - _rowZeroOrientation = true; - else - _rowZeroOrientation = false; - } else { - if ((refpinsheight == 2) || (transf == NOSYM) || (transf == SYM_X)) - _rowZeroOrientation = false; - else - _rowZeroOrientation = true; - } + int ycoord = (int)((refpins->YINS - _dy) / (ROWHEIGHT * PITCH)); + phfig* refpinsmodel = getphfig(refpins->FIGNAME, 'P'); + int refpinsheight = (int)((refpinsmodel->YAB2 - refpinsmodel->YAB1) + / (ROWHEIGHT * PITCH)); + char transf = refpins->TRANSF; - // tests for each instance - for (phins* pins = _prePlaceFig->PHINS; pins; pins = pins->NEXT) - { - phfig_list* phmodel = getphfig(pins->FIGNAME, '0'); - 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 (ycoord % 2 == 0) + { + if ((refpinsheight == 2) || (transf == NOSYM) || (transf == SYM_X)) + _rowZeroOrientation = true; + else + _rowZeroOrientation = false; + } else { + if ((refpinsheight == 2) || (transf == NOSYM) || (transf == SYM_X)) + _rowZeroOrientation = false; + else + _rowZeroOrientation = true; + } - if ((pins->YINS - _dy) % 50 != 0) - { - cerr << " o ERROR : in preplacement file : y position of " - << pins->INSNAME << " is incorrect" << endl; - exit (1); - } + // tests for each instance + for (phins* pins = _prePlaceFig->PHINS; pins; pins = pins->NEXT) + { + phfig_list* phmodel = getphfig(pins->FIGNAME, '0'); + 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) - { - cerr << " o ERROR : in preplacement file : x position of " - << pins->INSNAME << " is incorrect" << endl; - exit (1); - } + if ((pins->YINS - _dy) % 50 != 0) + { + cerr << " o ERROR : in preplacement file : y position of " + << pins->INSNAME << " is incorrect" << endl; + exit (1); + } - if ( (pins->TRANSF == ROT_P) || (pins->TRANSF == ROT_M) - || (pins->TRANSF == SY_RP) || (pins->TRANSF == SY_RM) ) - { - cerr << " o ERROR : " << pins->INSNAME << " : incorrect rotation" << endl; - 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 ((pins->XINS - _dx) % 5 != 0) + { + cerr << " o ERROR : in preplacement file : x position of " + << pins->INSNAME << " is incorrect" << endl; + exit (1); + } - if ( ((ycoord % 2 == 0) && (insOrient != _rowZeroOrientation)) - || ((ycoord % 2 != 0) && (insOrient == _rowZeroOrientation)) ) - { - cerr << " o ERROR : " << pins->INSNAME << " badly oriented" << endl - << " Incoherence with " << refpins->INSNAME << endl; - exit(1); - } - - for (int yit = ycoord; yit < ycoord + pinsheightrow; yit++) - { - for (int xit = xpos; xit < xpos + pinswidth; xit++) - { - 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); - } - } - } + if ( (pins->TRANSF == ROT_P) || (pins->TRANSF == ROT_M) + || (pins->TRANSF == SY_RP) || (pins->TRANSF == SY_RM) ) + { + cerr << " o ERROR : " << pins->INSNAME << " : incorrect rotation" << endl; + 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)) + || ((ycoord % 2 != 0) && (insOrient == _rowZeroOrientation)) ) + { + cerr << " o ERROR : " << pins->INSNAME << " badly oriented" << endl + << " Incoherence with " << refpins->INSNAME << endl; + exit(1); + } + + for (int yit = ycoord; yit < ycoord + pinsheightrow; yit++) + { + for (int xit = xpos; xit < xpos + pinswidth; xit++) + { + 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 @@ -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))); 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; +} diff --git a/alliance/src/ocp/src/placer/PPlacement.h b/alliance/src/ocp/src/placer/PPlacement.h index 3d46abc0..8147c723 100644 --- a/alliance/src/ocp/src/placer/PPlacement.h +++ b/alliance/src/ocp/src/placer/PPlacement.h @@ -110,6 +110,7 @@ class PPlacement { // parametres double _margin; + double _realMargin; int _maxDetLoop; // Maximum nb of loops for detailed placement double RowMult; double BinMult; @@ -124,6 +125,13 @@ class PPlacement { bool _prePlace; bool _eqMargin; unsigned _totalMoves; + unsigned _sourceEqualTargetMovementNumber; + unsigned _surOccupationTargetMovementNumber; + unsigned _impossibleExchangeMovementNumber; + unsigned _acceptedMoveNumber; + unsigned _acceptedExchangeNumber; + unsigned _rejectedMoveNumber; + unsigned _rejectedExchangeNumber; // Placement caracteristics char* _fileName; @@ -155,7 +163,15 @@ class PPlacement { RowMult(rowmult), BinMult(binmult), NetMult(netmult), _placeCons(conflg), _ringPlaceCons(ringflg), _iocFile(iocfile), _iocFileName(iocfilename), _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(); @@ -177,6 +193,10 @@ class PPlacement { void PlotStat(); void PlotOnlyBins(char* output) const; + double GetBinsSize() const; + double GetBinsCapa() const; + double GetSubRowsCapa() const; + double GetMinX() const { return BBox.GetMinX(); } double GetMinY() const { return BBox.GetMinY(); } double GetMaxX() const { return BBox.GetMaxX(); } @@ -188,6 +208,21 @@ class PPlacement { bool GetBoolPlot() const { return _boolPlot; } 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; void InitBBoxCost(); double TempBBoxCost(); diff --git a/alliance/src/ocp/src/placer/PPlacementGlobal.cpp b/alliance/src/ocp/src/placer/PPlacementGlobal.cpp index 18419743..83f4507b 100644 --- a/alliance/src/ocp/src/placer/PPlacementGlobal.cpp +++ b/alliance/src/ocp/src/placer/PPlacementGlobal.cpp @@ -228,6 +228,9 @@ PPlacement::PlaceGlobal() cout << " o Initial NetCost = " << NetCost << endl; cout << " o Initial Cost = " << Cost << 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 for (int i = 0; i < GetNInsToPlace(); ++i) { @@ -348,6 +351,18 @@ PPlacement::PlaceGlobal() cout << "Loop = " << Loop << ", Temperature = " << Temperature << ", Cost = " << Cost << endl; cout << " RowCost = " << RowCost << ", BinCost = " << BinCost << ", NetCost = " << NetCost << 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 << "."; @@ -429,18 +444,40 @@ PPlacement::PlaceGlobal() } else { Move.Reject(); } - _totalMoves += 1; } } if (_verbose) { + unsigned totalImpossibleMovements = + _impossibleExchangeMovementNumber + + _sourceEqualTargetMovementNumber + + _surOccupationTargetMovementNumber; cout << " o Global Placement finished ....." << 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 NetCost = " << 100.0 * (_initNetCost - NetCost) / _initNetCost << "%" << 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; } } diff --git a/alliance/src/ocp/src/placer/PRow.cpp b/alliance/src/ocp/src/placer/PRow.cpp index ca9f7533..c2551924 100644 --- a/alliance/src/ocp/src/placer/PRow.cpp +++ b/alliance/src/ocp/src/placer/PRow.cpp @@ -173,8 +173,38 @@ PRow::PlotLabel(ofstream& out, unsigned TotalMoves) const } 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(); } diff --git a/alliance/src/ocp/src/placer/PRow.h b/alliance/src/ocp/src/placer/PRow.h index 60f232e1..6a39c449 100644 --- a/alliance/src/ocp/src/placer/PRow.h +++ b/alliance/src/ocp/src/placer/PRow.h @@ -66,6 +66,9 @@ class PRow : public PContainer PSubRow& GetSubRow(const double X); double GetSubRowCost() const; double GetBinCost() const; + double GetBinsSize() const; + double GetBinsCapa() const; + double GetSubRowsCapa() const; ostream& Print(ostream& os) const; ofstream& Plot(ofstream& out) const; diff --git a/alliance/src/ocp/src/placer/PSubRow.cpp b/alliance/src/ocp/src/placer/PSubRow.cpp index 55e2e766..3f69a29b 100644 --- a/alliance/src/ocp/src/placer/PSubRow.cpp +++ b/alliance/src/ocp/src/placer/PSubRow.cpp @@ -56,7 +56,6 @@ PSubRow::Init(PRow* row, double y, double minx, double maxx, double margin, doub PBBox binbbox; double xpos; int binswidth; - int binscapa; int modulo = 0; _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); binswidth = (int)((maxx - minx) / _nBins); - binscapa = (int)(binswidth * ( 1 - margin)); _bins.reserve(_nBins); 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); } _binsXMax[xpos] = binnumber; - _bins.back()->Init(binbbox, binscapa, *this); + _bins.back()->Init(binbbox, margin, *this); } _row->MergeBBox(_bBox); } @@ -147,15 +145,14 @@ PSubRow::ForceIns(PToPlaceIns& Ins, int BinNumber) #ifndef Abs #define Abs(x) ((x) < 0.0 ? -(x) : (x)) #endif -double -PSubRow::GetBinCost() const +double PSubRow::GetBinCost() const { - double BinCost = 0.0; + double binCost = 0.0; 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& @@ -183,3 +180,24 @@ PSubRow::Print(ostream& os) const { 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; +} diff --git a/alliance/src/ocp/src/placer/PSubRow.h b/alliance/src/ocp/src/placer/PSubRow.h index 3cb603a6..0ede29d5 100644 --- a/alliance/src/ocp/src/placer/PSubRow.h +++ b/alliance/src/ocp/src/placer/PSubRow.h @@ -50,8 +50,8 @@ class PSubRow : public PContainer { PBins _bins; PBinsXMax _binsXMax; double _size; // somme des Width des bins de la row - double _capa; // l'occupation ideale de la row - double _max; // seuil de la ligne !!ne pas dépasser + double _capa; // l'occupation ideale de la subrow + double _max; // seuil de la sousligne !!ne pas dépasser unsigned _nBins; // Bins.size(); public: @@ -64,6 +64,8 @@ class PSubRow : public PContainer { PRow* GetRow() { return _row; } PBin& GetBin(const double X); PBins& GetBins() { return _bins; } + double GetBinsSize() const; + double GetBinsCapa() const; double GetCapa() const { return _capa; } double GetSize() const { return _size; }