Ejemplo n.º 1
0
int main( int argc, char ** argv )
{
  srand(0);

  // parse command line
  if (config.ParseCommandLine(argc, argv)) {
    exit(1);
  }

  debug.Level(config.Debug());

  Timer timer;
  timer.Start();

  if (config.Test() != "") {
    if (config.A2wa()) {  // run conversion mode
      cmpConfig.WriteWorkloadArchFromArch(config.Test());
      return 0;
    }
    else {                // run selected testcase
      cmpConfig.CreateCmp(config.Test());

      double area = PhysicalModel::GetCmpArea(cmpConfig.Cmp());
      cout << "Area = " << area << " mm^2" << endl;

      double avgThr = 0, avgLat = 0, avgPow = 0;

      // for every workload
      for (int wlIdx = 0; wlIdx < cmpConfig.GetWlCnt(); ++wlIdx) {
        cmpConfig.SetWlIdx(wlIdx);
        IterativePerfModel m;
        //MatlabPerfModel m;
        StatMetrics * sm = m.Run();
        double power = PowerModel::GetTotalPower(cmpConfig.Cmp());

        avgThr += sm->Throughput();
        avgLat += sm->Latency();
        avgPow += power;

        cout << "WlName = " << cmpConfig.GetWorkload(wlIdx)->shortName
             << ": Power = " << power
             << ", Lat = " << sm->Latency() << ", Thr = " << sm->Throughput() << endl;
        delete sm;
      }

      avgPow /= cmpConfig.GetWlCnt();
      avgLat /= cmpConfig.GetWlCnt();
      avgThr /= cmpConfig.GetWlCnt();

      cout << "Average: Power = " << avgPow
           << ", Lat = " << avgLat << ", Thr = " << avgThr << endl;

    }
  }
  else { // run exploration based on config
    string configFile = (config.ConfigFile() == "") ? "config.txt" :
                         config.ConfigFile();
    cout << "-I- Config file for exploration is " << configFile << endl;
    config.ParseConfigFile(configFile);
    config.Print();

    if (config.ExpMode() == "ex") { // exhaustive exploration
      cout << "-I- Exploration mode is: Exhaustive" << endl;
      ExhEngine ee;
      ee.Explore();
    }
    else if (config.ExpMode() == "eo") {
      cout << "-I- Exploration mode is: Extremal Optimization" << endl;
      EoEngine ee;
      ee.Explore();
    }
    else if (config.ExpMode() == "sa") {
      cout << "-I- Exploration mode is: Simulated Annealing" << endl;
      SaEngine ee;
      ee.Explore();
    }
    else if (config.ExpMode() == "hc") {
      cout << "-I- Exploration mode is: Hill Climbing" << endl;
      HcEngine ee;
      ee.Explore();
    }
    else if (config.ExpMode() == "rb") {
      cout << "-I- Exploration mode is: Random Best" << endl;
      RbEngine ee;
      ee.Explore();
    }
    else {
      cout << "-E- Unknown exploration mode! -> Exiting..." << endl;
    }
  }

  cout << "Total time = " << timer.Current() << endl;

  return 0;
}