Main Page | Namespace List | Class Hierarchy | Compound List | File List | Namespace Members | Compound Members | File Members

baseannealer.cxx

Go to the documentation of this file.
00001 /**************************************************************************
00002 ***    
00003 *** Copyright (c) 1995-2000 Regents of the University of California,
00004 ***               Andrew E. Caldwell, Andrew B. Kahng and Igor L. Markov
00005 *** Copyright (c) 2000-2004 Regents of the University of Michigan,
00006 ***               Saurabh N. Adya, Jarrod A. Roy and Igor L. Markov
00007 ***
00008 ***  Contact author(s): abk@cs.ucsd.edu, imarkov@umich.edu
00009 ***  Original Affiliation:   UCLA, Computer Science Department,
00010 ***                          Los Angeles, CA 90095-1596 USA
00011 ***
00012 ***  Permission is hereby granted, free of charge, to any person obtaining 
00013 ***  a copy of this software and associated documentation files (the
00014 ***  "Software"), to deal in the Software without restriction, including
00015 ***  without limitation 
00016 ***  the rights to use, copy, modify, merge, publish, distribute, sublicense, 
00017 ***  and/or sell copies of the Software, and to permit persons to whom the 
00018 ***  Software is furnished to do so, subject to the following conditions:
00019 ***
00020 ***  The above copyright notice and this permission notice shall be included
00021 ***  in all copies or substantial portions of the Software.
00022 ***
00023 *** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
00024 *** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
00025 *** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
00026 *** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
00027 *** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
00028 *** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
00029 *** THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00030 ***
00031 ***
00032 ***************************************************************************/
00033 
00034 
00035 
00036 
00037 
00038 
00039 
00040 
00041 
00042 
00043 
00044 
00045 
00046 
00047 
00048 
00049 #include "baseannealer.h"
00050 #include "CommandLine.h"
00051 #include "DB.h"
00052 #include "AnalytSolve.h"
00053 
00054 #ifdef _MSC_VER
00055 #ifndef srand48
00056 #define srand48 srand
00057 #endif
00058 #endif
00059 
00060 const int BaseAnnealer::UNINITIALIZED=-1;
00061 const unsigned int BaseAnnealer::UNSIGNED_UNINITIALIZED=0;
00062 const int BaseAnnealer::FREE_OUTLINE=-9999;
00063 const int BaseAnnealer::NOT_FOUND=-1;
00064    
00065 // --------------------------------------------------------
00066 BaseAnnealer::BaseAnnealer(const parquetfp::Command_Line *const params,
00067                            parquetfp::DB *const db)
00068    : _db(db),
00069      _params(params),
00070      _analSolve(new parquetfp::AnalytSolve(
00071                    const_cast<parquetfp::Command_Line*>(params),
00072                    const_cast<parquetfp::DB*>(db)))
00073 {
00074    // set the random seed for each invokation of the Annealer
00075    int rseed;
00076    if(_params->getSeed)
00077       rseed = int(time((time_t *)NULL));
00078    else
00079       rseed = _params->seed;
00080    
00081    srand(rseed);        //seed for rand function
00082    srand48(rseed);      //seed for random_shuffle function
00083    if(_params->verb.forMajStats > 0)
00084       cout << "The random seed for this run is: " << rseed << endl;
00085    
00086    const char* baseName = _params->inFileName;
00087    strcpy(_baseFileName, baseName);
00088    annealTime = 0.0;
00089 }
00090 // --------------------------------------------------------
00091 BaseAnnealer::~BaseAnnealer()
00092 {
00093    if (_analSolve != NULL)
00094       delete _analSolve;
00095 }
00096 // --------------------------------------------------------
00097 void BaseAnnealer::solveQP()  
00098 {
00099    _analSolve->solveSOR();
00100    _db->updatePlacement(_analSolve->getXLocs(), _analSolve->getYLocs());
00101 }
00102 // --------------------------------------------------------
00103 void BaseAnnealer::postHPWLOpt()
00104 {
00105 //    parquetfp::Point offset = _analSolve->getDesignOptLoc();
00106 //    cout << "offset.x " << offset.x
00107 //         << " offset.y " << offset.y << endl;
00108    
00109 //    double initHPWL = _db->evalHPWL();
00110 //    cout << "initHPWL: " << initHPWL << endl;
00111 //    _db->shiftDesign(offset);
00112    
00113 //    double afterHPWL = _db->evalHPWL();
00114 //    cout << "afterHPWL: " << afterHPWL << endl;      
00115 //    if(afterHPWL > initHPWL)
00116 //    {
00117 //       cout << "shifting not done." << endl;
00118 //       offset.x *= -1;
00119 //       offset.y *= -1;
00120 //       _db->shiftDesign(offset);
00121 //    }
00122 //    else
00123 //       cout << "shifting is done." << endl;
00124 
00125    // only shift in "fixed-outline" mode
00126    if (_params->reqdAR != FREE_OUTLINE)
00127    {
00128       double blocksArea = _db->getNodesArea();
00129       double reqdAR = _params->reqdAR;
00130       double reqdArea = blocksArea * (1 + _params->maxWS/100.0);
00131       double reqdWidth = sqrt(reqdArea * reqdAR);
00132       double reqdHeight = sqrt(reqdArea / reqdAR);
00133       
00134 //       printf("blocksArea: %.2f reqdWidth: %.2f reqdHeight: %.2f\n",
00135 //              blocksArea, reqdWidth, reqdHeight);
00136       _db->shiftOptimizeDesign(reqdWidth, reqdHeight);
00137    }
00138 }
00139 // --------------------------------------------------------
00140 void BaseAnnealer::printResults(const Timer& tm,
00141                                 const SolutionInfo& curr) const
00142 {
00143    double timeReqd = tm.getUserTime();
00144    double realTime = tm.getRealTime();
00145 
00146    double blocksArea = _db->getNodesArea();
00147    double currArea = curr.area;
00148    double currWidth = curr.width;
00149    double currHeight = curr.height;
00150    double currAR = currWidth / currHeight; 
00151    double whiteSpace = 100 * (currArea - blocksArea) / blocksArea;
00152    double HPWL = curr.HPWL;
00153 
00154    cout.precision(6);
00155    if(_params->verb.forSysRes > 0)
00156       cout << "realTime:" << realTime << "\tuserTime:" << timeReqd << endl;
00157    if(_params->verb.forMajStats > 0)
00158       cout << "Final Area: " << currArea << " WhiteSpace " << whiteSpace
00159            << "%" << " AR " << currAR << " HPWL " << HPWL << endl;
00160 
00161    double reqdAR = _params->reqdAR;
00162    double reqdArea = blocksArea * (1 + _params->maxWS/100.0);
00163    double reqdWidth = sqrt(reqdArea * reqdAR);
00164    double reqdHeight = sqrt(reqdArea / reqdAR);
00165    
00166    if(_params->verb.forMajStats > 0)
00167    {
00168       if (_params->dontClusterMacros && _params->solveTop)
00169          cout << "width w/ macros only: "
00170               << _db->getXSizeWMacroOnly() << " ";
00171       else
00172          cout << "width:  " << currWidth << " ";
00173 
00174       if (_params->reqdAR != FREE_OUTLINE)
00175          cout << "(outline width:  " << reqdWidth << ") ";
00176       cout << endl;
00177       
00178       if (_params->dontClusterMacros && _params->solveTop)
00179          cout << "height w/ macros only: "
00180               << _db->getYSizeWMacroOnly() << " ";
00181       else
00182          cout << "height: " << currHeight << " ";
00183 
00184       if (_params->reqdAR != FREE_OUTLINE)
00185           cout << "(outline height: " << reqdHeight << ") ";
00186       cout << endl;
00187       
00188       cout << "area utilization (wrt. total current area): "
00189            << (blocksArea / currArea) * 100 << "%." << endl;
00190       cout << "whitespace       (wrt. total current area): " 
00191            << (1 - (blocksArea/currArea)) * 100 << "% " << endl;
00192    }
00193 }
00194 // --------------------------------------------------------
00195 

Generated on Mon Apr 25 01:09:23 2005 for Parquete by doxygen 1.3.2