OpenASIP  2.0
Explorer.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2011 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file DesignSpaceExlorer.cc
26  *
27  * Implementation of explorer.
28  *
29  * The command line version of the Design Space Explorer.
30  *
31  * @author Jari Mäntyneva 2007 (jari.mantyneva-no.spam-tut.fi)
32  * @author Esa Määttä 2008 (esa.maatta-no.spam-tut.fi)
33  * @author Pekka Jääskeläinen 2011
34  * @note rating: red
35  */
36 
37 
38 #include <string>
39 #include <vector>
40 #include <algorithm>
41 #include <iostream>
42 
43 #include "StringTools.hh"
44 #include "Application.hh"
45 #include "Exception.hh"
46 #include "FileSystem.hh"
47 #include "DesignSpaceExplorer.hh"
50 #include "DSDBManager.hh"
51 #include "HDBRegistry.hh"
52 #include "MachineImplementation.hh"
53 #include "Machine.hh"
55 #include "Environment.hh"
56 #include "Conversion.hh"
57 
58 using std::vector;
59 using std::cout;
60 using std::cerr;
61 using std::endl;
62 using std::string;
63 
64 const string EXPLORER_DEFAULT_HDB = "asic_130nm_1.5V.hdb";
65 
66 /**
67  * Loads the output Design Space Database file and creates a DSDB from it.
68  *
69  * If the given filename doesn't exists creates a new DSDB file with the given
70  * name.
71  *
72  * @param dsdbFile The DSDB file name.
73  * @return DSDBManager of the DSDB file.
74  */
76 loadDSDB(const std::string& dsdbFile) {
77  if (FileSystem::fileExists(dsdbFile)) {
78  return new DSDBManager(dsdbFile);
79  } else {
80  return DSDBManager::createNew(dsdbFile);
81  }
82 }
83 
84 /**
85  * Parses the given parameter which has form 'paramname=paramvalue" to
86  * different strings.
87  *
88  * @param param The parameter.
89  * @param paramName Parameter name is stored here.
90  * @param paramValue Parameter value is stored here.
91  * @exception InvalidData If the given parameter is not in the correct form.
92  */
93 void
95  const std::string& param, std::string& paramName, std::string& paramValue) {
96  string::size_type separatorPos = param.find("=", 0);
97  if (separatorPos == string::npos) {
98  string errorMsg =
99  "Explorer plugin parameters must be in form "
100  "'parametername=parametervalue'.";
101  throw InvalidData(__FILE__, __LINE__, __func__, errorMsg);
102  }
103 
104  paramName = param.substr(0, separatorPos);
105  paramValue = param.substr(separatorPos+1, param.length());
106 }
107 
108 /**
109  * Determines the widest column so that column widths can be tuned.
110  *
111  * Lengths of the data values are returned through the parameters.
112  *
113  * @param confs Configuration costs which lengths are checked.
114  * @configurationID Length of the configuration ID string.
115  * @applicationPath Length of the path string of an application.
116  * @cycleCount Length of the program cycle count string.
117  * @energyEstimate Length of the programs energy estimate string.
118  */
119 void
121  const vector<DSDBManager::ConfigurationCosts>& confs,
122  int& configurationID,
123  int& applicationPath,
124  int& cycleCount,
125  int& energyEstimate,
126  int& longestPathDelay,
127  int& area) {
128 
129  for (unsigned int i = 0; i < confs.size(); i++) {
130  int size = Conversion::toString(confs[i].configurationID).size();
131  if (size > configurationID) {
132  configurationID = size;
133  }
134  size = confs[i].application.size();
135  if (size > applicationPath) {
136  applicationPath = size;
137  }
138  size = Conversion::toString(confs[i].cycleCount).size();
139  if (size > cycleCount) {
140  cycleCount = size;
141  }
142  size = Conversion::toString(confs[i].energyEstimate).size();
143  if (size > energyEstimate) {
144  energyEstimate = size;
145  }
146  size = Conversion::toString(confs[i].longestPathDelay).size();
147  if (size > longestPathDelay) {
148  longestPathDelay = size;
149  }
150 
151  size = Conversion::toString(confs[i].area).size();
152  if (size > area) {
153  area = size;
154  }
155  }
156 }
157 
158 /**
159  * Outputs given number of empty characters to cout.
160  *
161  * @param numberOfSpaces The number of empty characters to output.
162  */
163 void
164 printSpaces(unsigned int numberOfSpaces) {
165  while (numberOfSpaces != 0) {
166  cout << " ";
167  numberOfSpaces--;
168  }
169 }
170 
171 /**
172  * Returns the ordering of data indicated by the string.
173  *
174  * @order Option string given by user that tells the ordering.
175  * @return The ordering of the data.
176  */
177 DSDBManager::Order orderingOfData(const string& order) {
178  if (order == "I") {
180  } else if (order == "P") {
182  } else if (order == "C") {
184  } else if (order == "E") {
186  } else {
188  }
189 }
190 
191 /**
192  * Parses parameters given from command line and passes them to the plugin.
193  *
194  * @param plugin Explorer plugin that receives the parameters.
195  * @param options Explorer command line options where parameters are read.
196  */
197 bool
199  DesignSpaceExplorerPlugin* plugin,
201 
202  // Check the parameters to be passed to the explorer plugin.
203  for (int i = 0; i < options.explorerPluginParameterCount(); i++) {
204  string param = options.explorerPluginParameter(i);
205  string paramName;
206  string paramValue;
207  try {
208  parseParameter(param, paramName, paramValue);
209  plugin->giveParameter(paramName, paramValue);
210  } catch (const Exception& e) {
211  std::cerr << e.errorMessage() << std::endl;
212  return false;
213  }
214  }
215  return true;
216 }
217 
218 
219 /**
220  * Loads explorer plugin.
221  *
222  * @param plugin Explorer plugin name to be loaded.
223  * @param dsdb DSDB that plugin is associated with.
224  * @return explorer plugin as a pointer.
225  */
227 loadExplorerPlugin(const std::string& plugin, DSDBManager* dsdb) {
228 
229  // Try to load the explorer plugin.
230  DesignSpaceExplorerPlugin* explorer = NULL;
231  try {
232  explorer = DesignSpaceExplorer::loadExplorerPlugin(plugin, dsdb);
233  } catch (const FileNotFound& e) {
234  std::cerr << "No explorer plugin file named '" << plugin
235  << ".so' found." << std::endl;
236  delete dsdb;
237  return NULL;
238  } catch (const Exception& e) {
239  std::string msg = "Error while trying to load the explorer plugin "
240  "named '" + plugin + ".so'.";
241  verboseLog(msg)
242  msg = "With reason: " + e.errorMessage();
243  verboseLogC(msg, 1)
244  delete dsdb;
245  delete explorer;
246  return NULL;
247  }
248  return explorer;
249 }
250 
251 
252 /**
253  * Prints explorer plugins and their descriptions.
254  */
255 void
257  vector<string> found_plugins;
258  vector<string> stripped_plugins;
259  vector<string> searchPaths = Environment::explorerPluginPaths();
260  for (vector<string>::const_iterator iter = searchPaths.begin();
261  iter != searchPaths.end(); iter++) {
262  if (FileSystem::fileExists(*iter)) {
263  // now list all files with postfix ".so"
264  verboseLogC("Fetching plugins from directory: " + *iter, 1)
265  FileSystem::findFromDirectory(".*\\.so$", *iter, found_plugins);
266  }
267  }
268  cout << "| Plugin name | Description " << endl
269  << "--------------------------------------------" << endl;
270  cout.flags(std::ios::left);
271  // Eliminate duplicates such as ComponentAdded.0.so ComponentAdded.so
272  for (unsigned int i = 0; i < found_plugins.size(); ++i) {
273  std::string finalPluginName = found_plugins[i];
274  std::string pluginName = FileSystem::fileNameBody(found_plugins[i]);
275  // Repeat "basename" until all .0.0. are removed so symbol can be found
276  // correctly
277  while (pluginName != finalPluginName) {
278  finalPluginName = pluginName;
279  pluginName = FileSystem::fileNameBody(pluginName);
280  }
281  if(find(stripped_plugins.begin(), stripped_plugins.end(), pluginName)
282  == stripped_plugins.end()) {
283  stripped_plugins.push_back(pluginName);
284  }
285  }
286  for (unsigned int i = 0; i < stripped_plugins.size(); ++i) {
287  std::string pluginName = stripped_plugins[i];
288  DesignSpaceExplorerPlugin* plugin = loadExplorerPlugin(pluginName, NULL);
289  if (!plugin) {
290  return;
291  }
292  cout << std::setw(30) << pluginName << plugin->description() << endl;
293  }
294 }
295 
296 
297 /**
298  * Prints explorer plugin parameter info.
299  *
300  * @param plugin Explorer plugin which parameter info is to be printed.
301  */
302 void
304  using std::setw;
306  DesignSpaceExplorerPlugin::PMCIt it = pm.begin();
307  cout.flags(std::ios::left);
308  cout << setw(30) << "parameter name " << setw(15) << "type" << "default value" << endl;
309  cout << "-----------------------------------------------------------------------------" << endl;
310  while (it != pm.end()) {
311  cout << setw(30) << it->first << setw(15);
312  switch (it->second.type()) {
313  case UINT:
314  cout << "unsigned int";
315  break;
316  case INT:
317  cout << "int";
318  break;
319  case STRING:
320  cout << "string";
321  break;
322  case BOOL:
323  cout << "boolean";
324  break;
325  default:
326  cout << "unknown type";
327  }
328  if (!it->second.isCompulsory()) {
329  if (it->second.type() == BOOL) {
330  cout <<
331  (it->second.value() == "1" || it->second.value() == "true"
332  ? "true" : "false");
333  } else {
334  cout << it->second.value();
335  }
336  }
337  cout << std::endl;
338  if (it->second.description().size() > 0) {
339  cout << std::endl;
340  cout << it->second.description();
341  cout << std::endl;
342  cout << std::endl;
343  }
344  ++it;
345  }
346 }
347 
348 /**
349  * Prints the pareto set of configurations in the DSDB using the given
350  * criteria set.
351  */
352 void
353 printParetoSet(const DSDBManager& dsdb, TCEString criteriaSet) {
354  if (criteriaSet != "C")
355  return; // only connectivity,cycles criteria supported
356 
359 
360  const int CONF_COL_W = 6;
361  const int CONNECTIVITY_COL_W = 6;
362  const int CYCLES_COL_W = 8;
363 
364  std::cout << std::setw(CONF_COL_W) << std::right << "conf #"
365  << " | ";
366 
367  std::cout << std::setw(CONNECTIVITY_COL_W) << std::right << "conn"
368  << " | ";
369 
370  std::cout << std::setw(CYCLES_COL_W) << std::right << "cycles"
371  << std::endl;
372 
373  for (int i = 0; i < CONF_COL_W + CONNECTIVITY_COL_W + CYCLES_COL_W + 10;
374  ++i) {
375  std::cout << "-";
376  }
377  std::cout << std::endl;
378 
379  for (DSDBManager::ParetoSetConnectivityAndCycles::const_iterator i =
380  paretoSet.begin(); i != paretoSet.end(); ++i) {
382  std::cout << std::setw(CONF_COL_W) << std::right << point.get<0>()
383  << " | ";
384 
385  std::cout << std::setw(CONNECTIVITY_COL_W) << std::right << point.get<1>()
386  << " | ";
387 
388  std::cout << std::setw(CYCLES_COL_W) << std::right << point.get<2>()
389  << std::endl;
390  }
391 }
392 
393 /**
394  * Main function.
395  *
396  * Parses the command line and figures out what to do.
397  *
398  * @param argc The command line argument count.
399  * @param argv The command line arguments (passed to the interpreter).
400  * @return The return status.
401  */
402 int main(int argc, char* argv[]) {
403 
405 
406  // boolean to check if done something useful
407  bool doneUseful = false;
408 
409  // Parses the command line options.
411  try {
412  options->parse(argv, argc);
414  } catch (ParserStopRequest) {
415  return EXIT_SUCCESS;
416  } catch (const IllegalCommandLine& i) {
417  std::cerr << i.errorMessage() << std::endl;
418  return EXIT_FAILURE;
419  }
420 
421  int verboseLevel = Application::verboseLevel();
422  if (verboseLevel < 0) {
424  } else {
425  Application::setVerboseLevel(verboseLevel);
426  }
427 
428  if (options->printPlugins()) {
429  printPlugins();
430  return EXIT_SUCCESS;
431  }
432 
433  if (options->pluginInfo().length() != 0) {
434  std::string plugin = options->pluginInfo();
435  DesignSpaceExplorerPlugin* explorer = loadExplorerPlugin(plugin, NULL);
436  if (!explorer) {
437  return EXIT_FAILURE;
438  }
439  printPluginParamInfo(*explorer);
440  delete explorer;
441  explorer = NULL;
442  return EXIT_SUCCESS;
443  }
444 
445  // Only argument should be dsdb.
446  if (options->numberOfArguments() != 1) {
447  std::cerr << "Illegal number of arguments." << std::endl << std::endl;
448  options->printHelp();
449  return EXIT_FAILURE;
450  }
451  // Get the database file.
452  std::string dsdbFile = "";
453  dsdbFile = options->argument(1);
454 
455  // Loads the database.
456  DSDBManager* dsdb = NULL;
457  try {
458  dsdb = loadDSDB(dsdbFile);
459  } catch (const IOException& e) {
460  std::cerr << e.errorMessage() << std::endl;
461  delete dsdb;
462  return EXIT_FAILURE;
463  }
464 
465  // adds new configuration to the DSDB
466  if (options->adfFile()) {
467  TTAMachine::Machine* adf = NULL;
468  IDF::MachineImplementation* idf = NULL;
469  try {
471  conf.hasImplementation = false;
472  adf = TTAMachine::Machine::loadFromADF(options->adfFileName());
473  conf.architectureID = dsdb->addArchitecture(*adf);
474  if (options->idfFile()) {
475  idf =
477  options->idfFileName());
478  conf.implementationID = dsdb->addImplementation(*idf, 0, 0);
479  conf.hasImplementation = true;
480  }
481  RowID confID = dsdb->addConfiguration(conf);
482  std::cout
483  << "Added configuration " << confID << " into the DSDB."
484  << std::endl;
485  delete adf;
486  delete idf;
487  doneUseful = true;
488  } catch (const Exception& e) {
489  std::cout << "Error occured reading ADF or IDF. "
490  << e.errorMessage() << std::endl;
491  delete dsdb;
492  return EXIT_FAILURE;
493  }
494  }
495 
496  // Check and add the test application directories.
497  int testDirectories = options->testApplicationDirectoryCount();
498  for (int i = 0; i < testDirectories; i++) {
499  std::string testDir = options->testApplicationDirectory(i);
500  if (FileSystem::fileExists(testDir) &&
501  FileSystem::fileIsDirectory(testDir)) {
502  TestApplication app(testDir);
503  if (!app.isValid()) {
504  std::cerr
505  << "Application directory '" << testDir
506  << "' is invalid. Ensure that at least program.bc with "
507  << "the input program exists. Also either "
508  << "'correct_simulation_output' or 'verify.sh' is needed "
509  << "for verifying the program output."
510  << std::endl;
511  } else if (!dsdb->hasApplication(testDir)) {
512  dsdb->addApplication(testDir);
513  } else {
514  std::cerr
515  << "application directory '" << testDir
516  << "' has already been added" << std::endl;
517  }
518  } else {
519  std::cerr << "Application directory '" << testDir
520  << "' does not exist." << std::endl;
521  }
522  doneUseful = true;
523  }
524 
525  TCEString paretoSet = options->paretoSetValues();
526  if (paretoSet != "") {
527  // Prints the pareto sets
528  if (paretoSet != "C") {
529  std::cerr << "Unsupported pareto set value type." << std::endl;
530  return EXIT_FAILURE;
531  }
532  printParetoSet(*dsdb, paretoSet);
533  return EXIT_SUCCESS;
534  }
535 
536  // Prints the summary of the configurations in the database.
537  if (options->printSummary()) {
538  DSDBManager::Order ordering = orderingOfData(options->summaryOrdering());
539  cout << "Configurations in DSDB: " << endl;
540  int idLength = 7;
541  int pathLength = 16;
542  int cycleLength = 11;
543  int energyLength = 15;
544  int lpdLength = 18;
545  int areaLength = 4;
546  cout << "| Conf ID | Application path | cycle count | energy estimate | longest path delay | area "
547  << endl;
548  cout << "------------------------------------------------------------------------------------------"
549  << endl;
550  vector<DSDBManager::ConfigurationCosts> confCosts =
551  dsdb->applicationCostEstimatesByConf(ordering);
552  // Checks the longes strings of all data values that will be printed.
553  // Values are used to create a clean output of the results.
555  confCosts, idLength, pathLength, cycleLength,
556  energyLength, lpdLength, areaLength);
557  for (unsigned int i = 0; i < confCosts.size(); i++) {
558  cout << "| ";
559  cout << confCosts[i].configurationID;
560  printSpaces(
561  idLength - Conversion::toString(
562  confCosts[i].configurationID).size());
563  cout << " | ";
564  cout << confCosts[i].application;
565  printSpaces(
566  pathLength - confCosts[i].application.size());
567  cout << " | ";
568  cout << confCosts[i].cycleCount;
569  printSpaces(
570  cycleLength - Conversion::toString(
571  confCosts[i].cycleCount).size());
572  cout << " | ";
573  cout << confCosts[i].energyEstimate;
574  printSpaces(
575  energyLength - Conversion::toString(
576  confCosts[i].energyEstimate).size());
577  cout << " | ";
578  cout << confCosts[i].longestPathDelay;
579  printSpaces(
580  lpdLength - Conversion::toString(
581  confCosts[i].longestPathDelay).size());
582  cout << " | ";
583  cout << confCosts[i].area;
584  printSpaces(
585  areaLength - Conversion::toString(
586  confCosts[i].area).size());
587  cout << " |" << endl;
588  }
589  cout << "-----------------------------------------------------------------------------------------"
590  << endl;
591  }
592 
593  // Prints the total amount of configurations in the database.
594  if (options->printSummary() || options->numberOfConfigurations()) {
595  cout << "Total: " << dsdb->configurationIDs().size()
596  << " configurations "
597  << "in the database." << endl;
598  delete dsdb;
599  return EXIT_SUCCESS;
600  }
601 
602  // Write the configuration ADF and IDF to files.
603  if (options->writeOutConfiguration()) {
604  for (int i = 0; i < options->numberOfConfigurationsToWrite(); i++) {
605  if (dsdb->hasConfiguration(options->configurationToWrite(i))) {
606  DSDBManager::MachineConfiguration configuration =
607  dsdb->configuration(options->configurationToWrite(i));
608  std::string adfFileName =
609  Conversion::toString(options->configurationToWrite(i))
610  + ".adf";
611  try {
613  configuration.architectureID, adfFileName);
614  std::cout << "Written ADF file of configuration "
615  << options->configurationToWrite(i)
616  << std::endl;
617  } catch (const Exception& e) {
618  std::cerr << "Error occured while writing the ADF."
619  << std::endl;
620  delete dsdb;
621  return EXIT_FAILURE;
622  }
623 
624  if (configuration.hasImplementation) {
625  std::string idfFileName =
626  Conversion::toString(options->configurationToWrite(i))
627  + ".idf";
628  try {
630  configuration.implementationID, idfFileName);
631  std::cout << "Written IDF file of configuration "
632  << options->configurationToWrite(i)
633  << std::endl;
634  } catch (const Exception& e) {
635  std::cerr << "Error occured while writing the IDF."
636  << std::endl;
637  delete dsdb;
638  return EXIT_FAILURE;
639  }
640  }
641  } else {
642  // dsdb didn't have requested configuration
643  std::cerr << "No configuration found with id: "
644  << options->configurationToWrite(i) << "."
645  << std::endl;
646  delete dsdb;
647  return EXIT_FAILURE;
648  }
649  }
650  delete dsdb;
651  return EXIT_SUCCESS;
652  }
653 
654  // Remove applications from DSDB if requested
655  if (options->applicationIDToRemoveCount() > 0) {
656  for (int i = 0; i < options->applicationIDToRemoveCount(); i++) {
657  RowID id = options->applicationIDToRemove(i);
658  try {
659  dsdb->removeApplication(id);
660  } catch (const KeyNotFound&) {
661  std::cerr << "No application with ID: " << id << " in DSDB."
662  << std::endl;
663  }
664  }
665  delete dsdb;
666  return EXIT_SUCCESS;
667  }
668 
669  // If the list applications option is given.
670  if (options->printApplications()) {
671  std::cout << "Applications in the DSDB:" << std::endl;
672  std::cout << " ID | Application" << std::endl;
673  std::cout << "---------------------------------" << std::endl;
674  std::set<RowID> appIDs = dsdb->applicationIDs();
675  std::set<RowID>::const_iterator appIter = appIDs.begin();
676  for (; appIter != appIDs.end(); appIter++) {
677  std::cout << " " << (*appIter) << " | "
678  << dsdb->applicationPath(*appIter)
679  << std::endl;
680  }
681  std::cout << "---------------------------------" << std::endl;
682  std::cout << "Total: " << dsdb->applicationCount()
683  << " applications in DSDB." << std::endl;
684  delete dsdb;
685  return EXIT_SUCCESS;
686  }
687 
688  // Check the explorer plugin.
689  std::string pluginToUse = "";
690  pluginToUse = options->explorerPlugin();
691  if (pluginToUse == "") {
692  if (!doneUseful) {
693  std::cerr << "No explorer plugin given." << std::endl;
694  delete dsdb;
695  return EXIT_FAILURE;
696  } else {
697  delete dsdb;
698  return EXIT_SUCCESS;
699  }
700  }
701 
702  // Try to load the explorer plugin.
703  DesignSpaceExplorerPlugin* explorer = loadExplorerPlugin(pluginToUse, dsdb);
704  if (!explorer || !loadPluginParameters(explorer, *options)) {
705  delete dsdb;
706  return EXIT_FAILURE;
707  }
708 
709  if (testDirectories < 1 && !dsdb->applicationCount() &&
710  explorer->requiresApplication()) {
711  // used plugin may not need a test application, or the app is
712  // provided to the plugin with its own parameter
713  std::cerr << "No test application paths given or found in dsdb."
714  << std::endl;
715  return EXIT_FAILURE;
716  }
717 
718  // Load the HDB files if given as option
719  if (options->hdbFileNames()) {
720  vector<string> hdbPaths;
721  // put current working directory first in path find priority
722  hdbPaths.push_back(FileSystem::currentWorkingDir());
723  // concatenate search paths after current working dir path
724  vector<string> srchPaths = Environment::hdbPaths();
725  hdbPaths.insert(hdbPaths.end(), srchPaths.begin(), srchPaths.end());
726 
727  for (int i = 0; i < options->hdbFileNameCount(); i++) {
728  string pathToHdb = options->hdbFileName(i);
729  string hdbFile = options->hdbFileName(i);
730  for (unsigned int p = 0; p < hdbPaths.size(); p++) {
731  string tempPath =
732  hdbPaths.at(p) + FileSystem::DIRECTORY_SEPARATOR + hdbFile;
733  if (FileSystem::fileExists(tempPath)) {
734  pathToHdb = tempPath;
735  break;
736  }
737  }
738  try {
739  HDB::HDBRegistry::instance().hdb(pathToHdb);
740  } catch (const FileNotFound& e) {
741  std::cerr << "Could not find HDB file "
742  << options->hdbFileName(i) << std::endl;
743  }
744  }
745  } else {
746  // if no hdb was given, use default hdb
747  string pathToHdb = EXPLORER_DEFAULT_HDB;
748  vector<string> hdbPaths = Environment::hdbPaths();
749  for (unsigned int i = 0; i < hdbPaths.size(); i++) {
750  string tempPath =
751  hdbPaths.at(i) + FileSystem::DIRECTORY_SEPARATOR
753  if (FileSystem::fileExists(tempPath)) {
754  pathToHdb = tempPath;
755  break;
756  }
757  }
758  try {
759  HDB::HDBRegistry::instance().hdb(pathToHdb);
760  } catch (const FileNotFound& e) {
761  std::cerr << "Could not find HDB file "
762  << pathToHdb << std::endl;
763  }
764  }
765 
766  try {
767  RowID startPointConfigurationID = options->startConfiguration();
768  if (startPointConfigurationID == 0 &&
769  explorer->requiresStartingPointArchitecture()) {
770  std::cerr
771  << "No starting point configuration defined. " << std::endl
772  << "Use -s <confID> to define the configuration to "
773  << "start the exploration from." << std::endl;
774  return EXIT_FAILURE;
775 
776  }
777  vector<RowID> result =
778  explorer->explore(startPointConfigurationID);
779  if (result.empty()) {
780  cout
781  << "No fitting processor configurations were created." << endl;
782  } else {
783  std::cout << "Best result configurations:" << std::endl;
784  for (unsigned int i = 0; i < result.size(); i++) {
785  cout << " " << result[i] << endl;
786  }
787  }
788  } catch (const Exception& e) {
789  std::cerr << e.errorMessage()
790  << " " << e.fileName()
791  << " " << e.lineNum() << std::endl;
792  delete dsdb;
793  delete explorer;
794  return EXIT_FAILURE;
795  }
796 
797  delete dsdb;
798  delete explorer;
799  return EXIT_SUCCESS;
800 }
loadPluginParameters
bool loadPluginParameters(DesignSpaceExplorerPlugin *plugin, const ExplorerCmdLineOptions &options)
Definition: Explorer.cc:198
MachInfoCmdLineOptions::printHelp
virtual void printHelp() const
Definition: MachInfoCmdLineOptions.cc:89
DSDBManager::applicationCount
int applicationCount() const
Definition: DSDBManager.cc:1666
EXPLORER_DEFAULT_HDB
const string EXPLORER_DEFAULT_HDB
Definition: Explorer.cc:64
FileSystem.hh
Exception::lineNum
int lineNum() const
DSDBManager::ORDER_BY_APPLICATION
@ ORDER_BY_APPLICATION
Definition: DSDBManager.hh:163
FileNotFound
Definition: Exception.hh:224
printPluginParamInfo
void printPluginParamInfo(DesignSpaceExplorerPlugin &plugin)
Definition: Explorer.cc:303
parseParameter
void parseParameter(const std::string &param, std::string &paramName, std::string &paramValue)
Definition: Explorer.cc:94
ParserStopRequest
Definition: Exception.hh:491
Exception.hh
CmdLineParser::numberOfArguments
virtual int numberOfArguments() const
UINT
@ UINT
Definition: ExplorerPluginParameter.hh:40
ExplorerPluginParameter.hh
DSDBManager::MachineConfiguration::hasImplementation
bool hasImplementation
Definition: DSDBManager.hh:80
DSDBManager::ORDER_BY_ENERGY_ESTIMATE
@ ORDER_BY_ENERGY_ESTIMATE
Definition: DSDBManager.hh:162
DesignSpaceExplorerPlugin
Definition: DesignSpaceExplorerPlugin.hh:55
main
int main(int argc, char *argv[])
Definition: Explorer.cc:402
RowID
int RowID
Type definition of row ID in relational databases.
Definition: DBTypes.hh:37
Application::setVerboseLevel
static void setVerboseLevel(const int level=VERBOSE_LEVEL_DEFAULT)
Definition: Application.hh:186
HDB::HDBRegistry::hdb
CachedHDBManager & hdb(const std::string fileName)
Definition: HDBRegistry.cc:80
Application::setCmdLineOptions
static void setCmdLineOptions(CmdLineOptions *options_)
Definition: Application.cc:381
DSDBManager::writeArchitectureToFile
void writeArchitectureToFile(RowID id, const std::string &path) const
Definition: DSDBManager.cc:826
Application::verboseLevel
static int verboseLevel()
Definition: Application.hh:176
IllegalCommandLine
Definition: Exception.hh:438
printPlugins
void printPlugins()
Definition: Explorer.cc:256
FileSystem::findFromDirectory
static bool findFromDirectory(const std::string &regex, const std::string &directory, STLCONT &found)
printParetoSet
void printParetoSet(const DSDBManager &dsdb, TCEString criteriaSet)
Definition: Explorer.cc:353
Conversion::toString
static std::string toString(const T &source)
printSpaces
void printSpaces(unsigned int numberOfSpaces)
Definition: Explorer.cc:164
DesignSpaceExplorerPlugin.hh
verboseLog
#define verboseLog(text)
Definition: Application.hh:115
BOOL
@ BOOL
Definition: ExplorerPluginParameter.hh:40
Exception::fileName
std::string fileName() const
StringTools.hh
FileSystem::fileIsDirectory
static bool fileIsDirectory(const std::string fileName)
TestApplication::isValid
bool isValid() const
Definition: TestApplication.hh:62
DSDBManager::ORDER_BY_CYCLE_COUNT
@ ORDER_BY_CYCLE_COUNT
Definition: DSDBManager.hh:161
DSDBManager::MachineConfiguration::implementationID
RowID implementationID
Definition: DSDBManager.hh:81
DSDBManager::addApplication
RowID addApplication(const std::string &path)
Definition: DSDBManager.cc:440
DSDBManager::hasConfiguration
bool hasConfiguration(RowID id) const
Definition: DSDBManager.cc:1129
DSDBManager::hasApplication
bool hasApplication(RowID id) const
Definition: DSDBManager.cc:1013
DSDBManager::ParetoPointConnectivityAndCycles
boost::tuple< RowID, int, ClockCycleCount > ParetoPointConnectivityAndCycles
Definition: DSDBManager.hh:153
loadExplorerPlugin
DesignSpaceExplorerPlugin * loadExplorerPlugin(const std::string &plugin, DSDBManager *dsdb)
Definition: Explorer.cc:227
DesignSpaceExplorerPlugin::requiresStartingPointArchitecture
virtual bool requiresStartingPointArchitecture() const =0
ExplorerCmdLineOptions
Definition: ExplorerCmdLineOptions.hh:45
DSDBManager::MachineConfiguration
Definition: DSDBManager.hh:78
InvalidData
Definition: Exception.hh:149
STRING
@ STRING
Definition: ExplorerPluginParameter.hh:40
verboseLogC
#define verboseLogC(text, neededVerbosity)
Definition: Application.hh:110
Environment::hdbPaths
static std::vector< std::string > hdbPaths(bool libraryPathsOnly=false)
Definition: Environment.cc:683
Conversion.hh
Application.hh
__func__
#define __func__
Definition: Application.hh:67
DesignSpaceExplorerPlugin::giveParameter
virtual void giveParameter(const std::string &name, const std::string &value)
Definition: DesignSpaceExplorerPlugin.cc:89
DSDBManager::Order
Order
Identifiers for ordering results.
Definition: DSDBManager.hh:159
DSDBManager::ParetoSetConnectivityAndCycles
std::set< ParetoPointConnectivityAndCycles > ParetoSetConnectivityAndCycles
Definition: DSDBManager.hh:156
Environment.hh
Machine.hh
Exception
Definition: Exception.hh:54
DSDBManager
Definition: DSDBManager.hh:76
DesignSpaceExplorer::loadExplorerPlugin
static DesignSpaceExplorerPlugin * loadExplorerPlugin(const std::string &pluginName, DSDBManager *dsdb=NULL)
Definition: DesignSpaceExplorer.cc:527
ExplorerCmdLineOptions.hh
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
INT
@ INT
Definition: ExplorerPluginParameter.hh:40
CmdLineOptions::parse
void parse(char *argv[], int argc)
Definition: CmdLineOptions.cc:107
determineLongest
void determineLongest(const vector< DSDBManager::ConfigurationCosts > &confs, int &configurationID, int &applicationPath, int &cycleCount, int &energyEstimate, int &longestPathDelay, int &area)
Definition: Explorer.cc:120
DSDBManager.hh
DSDBManager::paretoSetConnectivityAndCycles
ParetoSetConnectivityAndCycles paretoSetConnectivityAndCycles(RowID application=ILLEGAL_ROW_ID) const
Definition: DSDBManager.cc:1697
FileSystem::DIRECTORY_SEPARATOR
static const std::string DIRECTORY_SEPARATOR
Definition: FileSystem.hh:189
DSDBManager::addConfiguration
RowID addConfiguration(const MachineConfiguration &conf)
Definition: DSDBManager.cc:299
options
static MachInfoCmdLineOptions options
Definition: MachInfo.cc:46
DSDBManager::addArchitecture
RowID addArchitecture(const TTAMachine::Machine &mom)
Definition: DSDBManager.cc:191
DSDBManager::createNew
static DSDBManager * createNew(const std::string &file)
Definition: DSDBManager.cc:141
DSDBManager::configuration
MachineConfiguration configuration(RowID id) const
Definition: DSDBManager.cc:361
DesignSpaceExplorerPlugin::explore
virtual std::vector< RowID > explore(const RowID &startPointConfigurationID, const unsigned int &maxIter=0)
Definition: DesignSpaceExplorerPlugin.cc:174
DesignSpaceExplorer.hh
FileSystem::fileExists
static bool fileExists(const std::string fileName)
Application::initialize
static void initialize()
Definition: Application.cc:99
TCEString
Definition: TCEString.hh:53
orderingOfData
DSDBManager::Order orderingOfData(const string &order)
Definition: Explorer.cc:177
Environment::explorerPluginPaths
static std::vector< std::string > explorerPluginPaths()
Definition: Environment.cc:809
DesignSpaceExplorerPlugin::description
virtual std::string description() const
DesignSpaceExplorerPlugin::PMCIt
std::map< std::string, ExplorerPluginParameter >::const_iterator PMCIt
Definition: DesignSpaceExplorerPlugin.hh:73
FileSystem::currentWorkingDir
static std::string currentWorkingDir()
Definition: FileSystem.cc:142
DesignSpaceExplorerPlugin::ParameterMap
std::map< std::string, ExplorerPluginParameter > ParameterMap
Definition: DesignSpaceExplorerPlugin.hh:69
KeyNotFound
Definition: Exception.hh:285
DSDBManager::applicationPath
std::string applicationPath(RowID id) const
Definition: DSDBManager.cc:947
DSDBManager::applicationCostEstimatesByConf
std::vector< ConfigurationCosts > applicationCostEstimatesByConf(Order ordering=ORDER_BY_CONFIGURATION) const
Definition: DSDBManager.cc:1524
IOException
Definition: Exception.hh:130
DSDBManager::writeImplementationToFile
void writeImplementationToFile(RowID id, const std::string &path) const
Definition: DSDBManager.cc:906
HDBRegistry.hh
FileSystem::fileNameBody
static std::string fileNameBody(const std::string &fileName)
Definition: FileSystem.cc:291
DSDBManager::MachineConfiguration::architectureID
RowID architectureID
Definition: DSDBManager.hh:79
CmdLineParser::argument
virtual std::string argument(int index) const
DesignSpaceExplorerPlugin::requiresApplication
virtual bool requiresApplication() const
Definition: DesignSpaceExplorerPlugin.hh:64
TestApplication
Definition: TestApplication.hh:46
loadDSDB
DSDBManager * loadDSDB(const std::string &dsdbFile)
Definition: Explorer.cc:76
DSDBManager::ORDER_BY_CONFIGURATION
@ ORDER_BY_CONFIGURATION
Definition: DSDBManager.hh:160
DesignSpaceExplorerPlugin::parameters
ParameterMap parameters() const
Definition: DesignSpaceExplorerPlugin.cc:117
DSDBManager::addImplementation
RowID addImplementation(const IDF::MachineImplementation &impl, double longestPathDelay, CostEstimator::AreaInGates area)
Definition: DSDBManager.cc:252
IDF::MachineImplementation
Definition: MachineImplementation.hh:54
IDF::MachineImplementation::loadFromIDF
static MachineImplementation * loadFromIDF(const std::string &idfFileName)
Definition: MachineImplementation.cc:1524
MachineImplementation.hh
DSDBManager::configurationIDs
std::set< RowID > configurationIDs() const
Definition: DSDBManager.cc:1451
DSDBManager::removeApplication
void removeApplication(RowID id)
Definition: DSDBManager.cc:1071
DSDBManager::applicationIDs
std::set< RowID > applicationIDs() const
Definition: DSDBManager.cc:1381
TTAMachine::Machine
Definition: Machine.hh:73
HDB::HDBRegistry::instance
static HDBRegistry & instance()
Definition: HDBRegistry.cc:62
TTAMachine::Machine::loadFromADF
static Machine * loadFromADF(const std::string &adfFileName)
Definition: Machine.cc:905