00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #include "CommandLine.h"
00040 #include "ABKCommon/paramproc.h"
00041 #include "ABKCommon/verbosity.h"
00042
00043 #include "baseannealer.h"
00044
00045 #include <iostream>
00046 #include <string.h>
00047 #include <time.h>
00048 using namespace std;
00049 using namespace parquetfp;
00050
00051 #ifdef _MSC_VER
00052 #ifndef srand48
00053 #define srand48 srand
00054 #endif
00055 #endif
00056
00057 Command_Line::Command_Line ()
00058 : getSeed(false),
00059 budgetTime(0), softBlocks(0), initQP(0), FPrep("SeqPair"),
00060 seed(0), iterations(1),
00061 maxIterHier(10),
00062 seconds(0), plot(0), savePl(0), saveCapoPl(0), saveCapo(0),
00063 save(0), takePl(0), solveMulti(0), clusterPhysical(0),
00064 solveTop(0), maxWSHier(15), usePhyLocHier(0),
00065 dontClusterMacros(0), maxTopLevelNodes(-9999),
00066 timeInit(30000), timeCool(0.01),
00067 startTime(30000), reqdAR(-9999), maxWS(15), minWL(0),
00068 areaWeight(0.4), wireWeight(0.4),
00069 useFastSP(false), snapToGrid(false), initCompact(0), compact(0),
00070 verb("1 1 1")
00071 {
00072 setSeed();
00073 inFileName[0] = '\0';
00074 outPlFile[0] = '\0';
00075 capoPlFile[0] = '\0';
00076 capoBaseFile[0] = '\0';
00077 baseFile[0] = '\0';
00078 }
00079
00080 Command_Line::Command_Line (int argc, const char *argv[])
00081 : getSeed(0),
00082 budgetTime(0), softBlocks(0), initQP(0), FPrep("SeqPair"),
00083 seed(0), iterations(0),
00084 maxIterHier(10),
00085 seconds(0), plot(0), savePl(0), saveCapoPl(0), saveCapo(0),
00086 save(0), takePl(0), solveMulti(0), clusterPhysical(0),
00087 solveTop(0), maxWSHier(15), usePhyLocHier(0),
00088 dontClusterMacros(0), maxTopLevelNodes(-9999),
00089 timeInit(30000), timeCool(0.01),
00090 reqdAR(-9999), maxWS(15), minWL(0), areaWeight(0.4),
00091 wireWeight(0.4), useFastSP(false),
00092 snapToGrid(false), initCompact(0), compact(0),
00093 verb(argc,argv)
00094 {
00095 inFileName[0] = '\0';
00096 outPlFile[0] = '\0';
00097 capoPlFile[0] = '\0';
00098 capoBaseFile[0] = '\0';
00099 baseFile[0] = '\0';
00100 StringParam argInfile ("f", argc, argv);
00101 StringParam plOutFile ("savePl", argc, argv);
00102 StringParam saveCapoPlFile ("saveCapoPl", argc, argv);
00103 StringParam saveCapoFile ("saveCapo", argc, argv);
00104 StringParam saveFile ("save", argc, argv);
00105
00106 StringParam FPrep_("FPrep", argc, argv);
00107
00108 BoolParam help1 ("h", argc, argv);
00109 BoolParam help2 ("help", argc, argv);
00110 NoParams noParams(argc,argv);
00111 IntParam fixSeed ("s",argc,argv);
00112 IntParam numberOfRuns("n",argc,argv);
00113 DoubleParam timeReq("t",argc,argv);
00114 IntParam maxIterHier_("maxIterHier",argc,argv);
00115
00116 DoubleParam timeInit_("timeInit",argc,argv);
00117 DoubleParam timeCool_("timeCool",argc,argv);
00118 DoubleParam startTime_("startTime",argc,argv);
00119 DoubleParam reqdAR_("AR",argc,argv);
00120 DoubleParam maxWS_("maxWS",argc,argv);
00121 BoolParam minWL_("minWL",argc,argv);
00122 DoubleParam wireWeight_("wireWeight",argc,argv);
00123 DoubleParam areaWeight_("areaWeight",argc,argv);
00124 BoolParam softBlocks_("soft", argc, argv);
00125 BoolParam initQP_("initQP", argc, argv);
00126 BoolParam fastSP_("fastSP", argc, argv);
00127
00128 BoolParam plot_("plot",argc,argv);
00129 BoolParam plotNoNets_("plotNoNets", argc, argv);
00130 BoolParam plotNoSlacks_("plotNoSlacks", argc, argv);
00131 BoolParam plotNoNames_("plotNoNames",argc,argv);
00132 BoolParam takePl_("takePl",argc,argv);
00133 BoolParam solveMulti_("solveMulti",argc,argv);
00134 BoolParam clusterPhysical_("clusterPhysical",argc,argv);
00135 BoolParam solveTop_("solveTop",argc,argv);
00136 DoubleParam maxWSHier_("maxWSHier",argc,argv);
00137 BoolParam usePhyLocHier_("usePhyLocHier",argc,argv);
00138 BoolParam dontClusterMacros_("dontClusterMacros",argc,argv);
00139 IntParam maxTopLevelNodes_("maxTopLevelNodes",argc,argv);
00140 BoolParam compact_("compact",argc,argv);
00141 BoolParam initCompact_("initCompact", argc, argv);
00142 BoolParam snapToGrid_("snapToGrid", argc, argv);
00143
00144
00145 if (argInfile.found())
00146 {
00147 string temp;
00148 temp=argInfile;
00149 strcpy(inFileName,temp.c_str());
00150 }
00151 else
00152 {
00153 strcpy(inFileName,"TESTS/ami49");
00154 }
00155
00156 if(plOutFile.found())
00157 {
00158 strcpy(outPlFile, plOutFile);
00159 savePl = true;
00160 }
00161
00162 if(saveCapoPlFile.found())
00163 {
00164 strcpy(capoPlFile, saveCapoPlFile);
00165 saveCapoPl = true;
00166 }
00167
00168 if(saveCapoFile.found())
00169 {
00170 strcpy(capoBaseFile, saveCapoFile);
00171 saveCapo = true;
00172 }
00173
00174 if(saveFile.found())
00175 {
00176 strcpy(baseFile, saveFile);
00177 save = true;
00178 }
00179
00180 if (FPrep_.found())
00181 {
00182 FPrep = FPrep_;
00183 }
00184
00185 if (fixSeed.found())
00186 {
00187 getSeed = false;
00188 seed = fixSeed;
00189 }
00190 else
00191 getSeed = true;
00192
00193 if (numberOfRuns.found())
00194 iterations = numberOfRuns;
00195 else
00196 iterations = 1;
00197
00198 if (maxIterHier_.found())
00199 maxIterHier = maxIterHier_;
00200
00201 if (timeReq.found())
00202 {
00203 budgetTime=true;
00204 seconds = timeReq;
00205 }
00206 else
00207 budgetTime=false;
00208
00209
00210 if(timeInit_.found())
00211 timeInit = timeInit_;
00212
00213 if(startTime_.found())
00214 startTime = startTime_;
00215 else
00216 startTime = timeInit;
00217
00218
00219 if(timeCool_.found())
00220 timeCool = timeCool_;
00221
00222 if(reqdAR_.found())
00223 reqdAR = reqdAR_;
00224
00225 if(maxWS_.found())
00226 maxWS = maxWS_;
00227
00228 if(maxWSHier_.found())
00229 maxWSHier = maxWSHier_;
00230
00231 if(usePhyLocHier_.found())
00232 usePhyLocHier = 1;
00233
00234 if(maxTopLevelNodes_.found())
00235 maxTopLevelNodes = maxTopLevelNodes_;
00236
00237 if(minWL_.found())
00238 {
00239 minWL = 1;
00240 }
00241
00242 if(areaWeight_.found())
00243 {
00244 areaWeight = areaWeight_;
00245 if(areaWeight > 1 || areaWeight < 0)
00246 {
00247 cout<<"areaWeight should be : 0 <= areaWeight <= 1"<<endl;
00248 exit(0);
00249 }
00250 }
00251
00252 if(wireWeight_.found())
00253 {
00254 wireWeight = wireWeight_;
00255 if(wireWeight > 1 || wireWeight < 0)
00256 {
00257 cout<<"wireWeight should be : 0 <= wireWeight <= 1"<<endl;
00258 exit(0);
00259 }
00260
00261 if(wireWeight == 0)
00262 minWL = false;
00263 }
00264
00265 if(takePl_.found())
00266 takePl = 1;
00267
00268 if(solveMulti_.found())
00269 solveMulti = 1;
00270
00271 if(clusterPhysical_.found())
00272 clusterPhysical = 1;
00273
00274 if(solveTop_.found())
00275 solveTop = 1;
00276
00277 if(dontClusterMacros_.found())
00278 dontClusterMacros = 1;
00279
00280 if(softBlocks_.found())
00281 softBlocks = 1;
00282
00283 if(initQP_.found())
00284 initQP = 1;
00285
00286 if(fastSP_.found())
00287 useFastSP = 1;
00288
00289 if(compact_.found())
00290 compact = 1;
00291
00292 if(initCompact_.found())
00293 initCompact = 1;
00294
00295 if(snapToGrid_.found())
00296 snapToGrid = 1;
00297
00298 if(plot_.found() || plotNoNets_.found() || plotNoSlacks_.found() ||
00299 plotNoNames_.found())
00300 plot = 1;
00301
00302 plotNoNets = plotNoNets_;
00303 plotNoSlacks = plotNoSlacks_;
00304 plotNoNames = plotNoNames_;
00305
00306 setSeed();
00307 }
00308
00309 void Command_Line::printHelp(int argc, const char *argv[]) const
00310 {
00311 cerr<< argv[0] << endl
00312 <<"-f filename\n"
00313 <<"-s int (give a fixed seed)\n"
00314 <<"-n int (determine number of runs. default 1)\n"
00315 <<"-t double (set a time limit on the annealing run)\n"
00316 <<"-FPrep {SeqPair | BTree} (floorplan representation default: SeqPair)\n"
00317 <<"-save basefilename (save design in bookshelf format)\n"
00318 <<"-savePl baseFilename (save .pl file of solution)\n"
00319 <<"-saveCapoPl basefilename (save .pl in Capo format)\n"
00320 <<"-saveCapo basefilename (save design in Capo format)\n"
00321 <<"-plot (plot the output solution to out.plt file)\n"
00322 <<"-plotNoNets (plot without the nets)\n"
00323 <<"-plotNoSlacks (plot without slacks info)\n"
00324 <<"-plotNoNames (plot without name of blocks)\n"
00325 <<"-timeInit double (initial normalizing time: default 30000)\n"
00326 <<"-startTime double (annealing initial time: default timeInit)\n"
00327 <<"-timeCool double (annealing cool time: default 0.01\n"
00328 <<"-AR double (required Aspect Ratio of fixed outline: default no Fixed Outline)\n"
00329 <<"-maxWS double (maxWS(%) allowed if fixed outline constraints)\n"
00330 <<"-maxWSHier double (maxWS(%) for each hierarchical block)\n"
00331 <<"-usePhyLocHier (use physical locs which updating locs of sub-blocks of clustered blocks)\n"
00332 <<"-maxTopLevelNodes int (max # top level nodes during clustering)\n"
00333 <<"-maxIterHier int (max # of iterations in hierarchical mode to satisfy fixed-outline)\n"
00334 <<"-minWL (minimize WL default turned off)\n"
00335 <<"-wireWeight double (default 0.4)\n"
00336 <<"-areaWeight double (default 0.4)\n"
00337 <<"-soft (soft Blocks present in input default no)\n"
00338 <<"-initQP (start the annealing with a QP solution)\n"
00339 <<"-fastSP (use O(nlog n) algo for sequence pair evaluation)\n"
00340 <<"-takePl (take a placement and convert to sequence pair for use as initial solution)\n"
00341 <<"-solveMulti (solve as multiLevel heirarchy)\n"
00342 <<"-clusterPhysical (use Physical Heirarchy)\n"
00343 <<"-dontClusterMacros (keep Macros out of Clustering)\n"
00344 <<"-solveTop (solve only top level of heirarchy)\n"
00345 <<"-compact (compact the final solution)\n"
00346 <<"-initCompact (construct initial SP by compaction)\n"
00347 <<"-snapToGrid (snap to row and site grid)\n"
00348 <<endl;
00349 }
00350
00351 void Command_Line::printAnnealerParams() const
00352 {
00353 cout << "Annealer Parameters: " << endl;
00354 cout << " normalizing Time: " << timeInit << endl;
00355 cout << " start Time: " << startTime << endl;
00356 cout << " cooling Time: " << timeCool << endl;
00357 cout << " fixed-outline? "
00358 << ((reqdAR != BaseAnnealer::FREE_OUTLINE)? "Yes" : "No") << endl;
00359
00360 if (reqdAR != BaseAnnealer::FREE_OUTLINE)
00361 {
00362 cout << " -reqd Aspect Ratio: " << reqdAR << endl;
00363 cout << " -maximum WS: " << maxWS << "%" << endl;
00364 }
00365
00366 cout << " minimize WL? " << ((minWL)? "Yes" : "No") << endl;;
00367 if (minWL)
00368 {
00369 cout << " -wireWeight = " << wireWeight << endl;
00370 cout << " -areaWeight = " << areaWeight << endl;
00371 }
00372
00373 cout << " soft blks exist? " << ((softBlocks)? "Yes" : "No") << endl;
00374 cout << " use initial placement? " << ((takePl)? "Yes" : "No") << endl;
00375 cout << " compact init plmt? " << ((initCompact)? "Yes" : "No") << endl;
00376 cout << " compact final plmt? " << ((compact)? "Yes" : "No") << endl;
00377 cout << " use quad-pl as initial? " << ((initQP)? "Yes" : "No") << endl;
00378 cout << endl;
00379 }
00380
00381 void Command_Line::printAnnealerParamsClassic() const
00382 {
00383 cout << "Annealer Params: "<<endl;
00384 cout << "\tnormalizing Time " << timeInit << endl;
00385 cout << "\tstart Time " << startTime << endl;
00386 cout << "\tcooling Time " << timeCool << endl;
00387 cout<<"\treqd Aspect Ratio "<<reqdAR<<" (-9999 means no fixed shape)"<<endl;
00388 cout<<"\tminimize WL "<<minWL;
00389 if(minWL == 1)
00390 cout<<" : wireWeight = "<<wireWeight;
00391 cout<<endl;
00392 cout<<"\tmaximum WS "<<maxWS<<"% (only for fixed-outline)"<<endl<<endl;
00393 }
00394
00395 void Command_Line::setSeed()
00396 {
00397 int rseed;
00398 if(getSeed)
00399 rseed = int(time((time_t *)NULL));
00400 else
00401 rseed = seed;
00402
00403 srand(rseed);
00404 srand48(rseed);
00405
00406
00407 }
00408