OpenASIP  2.0
DesignSpaceExplorer.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 DesignSpaceExplorer.cc
26  *
27  * Implementation of DesignSpaceExplorer class
28  *
29  * @author Jari Mäntyneva 2006 (jari.mantyneva-no.spam-tut.fi)
30  * @author Esa Määttä 2008 (esa.maatta-no.spam-tut.fi)
31  * @author Pekka Jääskeläinen 2011
32  * @note rating: red
33  */
34 
35 #include <boost/timer.hpp>
36 #include <sstream>
37 #include <fstream>
38 #include <algorithm>
39 #include <set>
40 #include <vector>
41 #include <string>
42 
43 #include "DesignSpaceExplorer.hh"
44 #include "ADFSerializer.hh"
47 #include "CostEstimates.hh"
48 #include "ExecutionTrace.hh"
49 #include "DSDBManager.hh"
50 #include "Machine.hh"
51 #include "Program.hh"
52 #include "MachineImplementation.hh"
53 #include "PluginTools.hh"
54 #include "CostEstimatorTypes.hh"
55 #include "UniversalMachine.hh"
56 #include "StringTools.hh"
57 #include "OperationBehavior.hh"
58 #include "SimulatorToolbox.hh"
59 #include "SimulatorFrontend.hh"
60 #include "SimulatorInterpreter.hh"
61 #include "ExecutableInstruction.hh"
62 #include "OperationGlobals.hh"
63 #include "Application.hh"
65 #include "Exception.hh"
66 
67 using std::set;
68 using std::vector;
69 using std::string;
70 using namespace CostEstimator;
71 
74 
77 
78 
79 /**
80  * The constructor.
81  */
83 
84  //schedulingPlan_ =
85  // SchedulingPlan::loadFromFile(Environment::oldGccSchedulerConf());
86  oStream_ = new std::ostringstream;
88 }
89 
90 /**
91  * The destructor.
92  */
94 
95  //delete schedulingPlan_;
96  //schedulingPlan_ = NULL;
97  delete oStream_;
98  oStream_ = NULL;
99 }
100 
101 /**
102  * Sets new design space database.
103  *
104  * @param dsdb Design space database to be used with the explorer.
105  */
106 void
108 
109  dsdb_ = &dsdb;
110 }
111 
112 /**
113  * Evaluates one processor configuration (architecture+implementation pair).
114  *
115  * Evaluates the total area and the longest path delay of the current
116  * processor configuration (architecture+implementation pair) and also the
117  * energy consumed in each program in the DSDB with this processor
118  * configuration. Also configurations without implementation can be evaluated
119  * but no cost estimations are performed so the CostEstimate object won't
120  * include area, energy and longest path delay estimations. Estimation is not
121  * included either if the estimate flag is set to false.
122  *
123  * @param configuration Machine configuration (architecture, implementation).
124  * @param result CostEstimates object where the configuration cost
125  * estimates are stored if the evaluation succeeds.
126  * @param estimate Flag indicating that the evaluate will also estimate the
127  * given configuration.
128  * @exception InvalidData thrown in case there are flaws in the application
129  * configuration which leads to evaluation failure.
130  * @return Returns true if the evaluation succeeds false otherwise.
131  */
132 bool
134  const DSDBManager::MachineConfiguration& configuration,
135  CostEstimates& result, bool estimate) {
136 
137  TTAMachine::Machine* adf = NULL;
138  IDF::MachineImplementation* idf = NULL;
139  if (configuration.hasImplementation) {
140  adf = dsdb_->architecture(configuration.architectureID);
141  idf = dsdb_->implementation(configuration.implementationID);
142  } else {
143  adf = dsdb_->architecture(configuration.architectureID);
144  }
145 
146  try {
147  // program independent estimations
148  if (configuration.hasImplementation && estimate) {
149 
150  // estimate total area and longest path delay
151  CostEstimator::AreaInGates totalArea = 0;
152  CostEstimator::DelayInNanoSeconds longestPathDelay = 0;
153  createEstimateData(*adf, *idf, totalArea, longestPathDelay);
154 
155  dsdb_->setAreaEstimate(configuration.implementationID, totalArea);
156  result.setArea(totalArea);
157 
158  dsdb_->setLongestPathDelayEstimate(
159  configuration.implementationID, longestPathDelay);
160  result.setLongestPathDelay(longestPathDelay);
161  }
162 
163  // get all programs from the dsdb
164  set<RowID> applicationIDs = dsdb_->applicationIDs();
165  for (set<RowID>::const_iterator i = applicationIDs.begin();
166  i != applicationIDs.end(); i++) {
167 
168  if (dsdb_->isUnschedulable((*i), configuration.architectureID)) {
169  return false;
170  }
171 
172  if (!estimate &&
173  dsdb_->hasCycleCount(*i, configuration.architectureID)) {
174  // this configuration has been compiled+simulated previously,
175  // the old cycle count can be reused for this app
176  continue;
177  }
178 
179  string applicationPath = dsdb_->applicationPath(*i);
180  TestApplication testApplication(applicationPath);
181 
182  std::string applicationFile = testApplication.applicationPath();
183 
184  // test that program is found
185  if (applicationFile.length() < 1) {
186  delete adf;
187  adf = NULL;
188  delete idf;
189  idf = NULL;
190  throw InvalidData(
191  __FILE__, __LINE__, __func__,
192  (boost::format(
193  "No program found from application dir '%s'")
194  % applicationPath).str());
195  return false;
196  }
197 
198 #if (!defined(HAVE_CXX11) && !defined(HAVE_CXX0X))
199  std::auto_ptr<TTAProgram::Program> scheduledProgram(
200  schedule(applicationFile, *adf));
201 #else
202  std::unique_ptr<TTAProgram::Program> scheduledProgram(
203  schedule(applicationFile, *adf));
204 #endif
205 
206  if (scheduledProgram.get() == NULL) {
207  dsdb_->setUnschedulable((*i), configuration.architectureID);
208  delete adf;
209  adf = NULL;
210  delete idf;
211  idf = NULL;
212  return false;
213  }
214 
215  // simulate the scheduled program
216  ClockCycleCount runnedCycles;
217  const ExecutionTrace* traceDB = NULL;
218  if (configuration.hasImplementation && estimate) {
219  traceDB = simulate(
220  *scheduledProgram, *adf, testApplication, 0, runnedCycles,
221  true);
222  } else {
223  simulate(
224  *scheduledProgram, *adf, testApplication, 0, runnedCycles,
225  false);
226  }
227 
228  //std::cerr << "DEBUG: simulated" << std::endl;
229  // verify the simulation
230  if (testApplication.hasCorrectOutput()) {
231  string correctResult = testApplication.correctOutput();
232  string resultString = oStream_->str();
233  if (resultString != correctResult) {
234  std::cerr << "Simulation FAILED, possible bug in scheduler!"
235  << std::endl;
236  std::cerr << "Architecture id in DSDB:" << std::endl;
237  std::cerr << configuration.architectureID << std::endl;
238  std::cerr << "use sqlite3 to find out which configuration "
239  << "has that id to get the machine written to "
240  << "ADF." << std::endl;
241  // @todo Do a method into DSDBManager to find out the
242  // configuration ID.
243  std::cerr << "********** result found:" << std::endl;
244  std::cerr << resultString << std::endl;
245  std::cerr << "********** expected result:" << std::endl;
246  std::cerr << correctResult << std::endl;
247  std::cerr << "**********" << std::endl;
248  delete idf;
249  idf = NULL;
250  delete adf;
251  adf = NULL;
252  return false;
253  }
254  //std::cerr << "DEBUG: simulation OK" << std::endl;
255  // reset the stream pointer in to the beginning and empty the
256  // stream
257  oStream_->str("");
258  oStream_->seekp(0);
259  }
260 
261  // add simulated cycle count to dsdb
262  dsdb_->addCycleCount(
263  (*i), configuration.architectureID,
264  runnedCycles);
265 
266  if (configuration.hasImplementation && estimate) {
267  // energy estimate the simulated program
268  EnergyInMilliJoules programEnergy =
269  estimator_.totalEnergy(
270  *adf, *idf, *scheduledProgram, *traceDB);
271  dsdb_->addEnergyEstimate(
272  (*i), configuration.implementationID, programEnergy);
273  result.setEnergy(*scheduledProgram, programEnergy);
274  }
275  delete traceDB;
276  traceDB = NULL;
277  }
278  } catch (const Exception& e) {
279  delete adf;
280  adf = NULL;
281  delete idf;
282  idf = NULL;
284  return false;
285  }
286  delete idf;
287  idf = NULL;
288  delete adf;
289  adf = NULL;
290  return true;
291 }
292 
293 
294 /**
295  * Returns the DSDBManager of the current exploration process.
296  *
297  * @return The DSDBManager of the current exploration process.
298  */
301 
302  return *dsdb_;
303 }
304 
305 
306 /**
307  * Compiles the given application bytecode file on the given target machine.
308  *
309  * @param bytecodeFile Bytecode filename with path.
310  * @param target The machine to compile the sequential program against.
311  * @param paramOptions Compiler options (if cmdline options are not given)
312  * @return Scheduled parallel program or NULL if scheduler produced exeption.
313  */
316  const std::string bytecodeFile,
317  TTAMachine::Machine& target,
318  TCEString paramOptions) {
319 
320  TCEString compilerOptions;
321 
324  if (options != NULL) {
325  if (options->compilerOptions()) {
326  compilerOptions = options->compilerOptionsString();
327  // use compiler options given by method parameters (-O3 by default)
328  } else {
329  compilerOptions = paramOptions;
330  }
331  }
332  // If compiler options did not provide optimization, we use default.
333  if (compilerOptions.find("-O") == std::string::npos) {
334  compilerOptions += " -O3";
335  }
336  static const std::string DS = FileSystem::DIRECTORY_SEPARATOR;
337 
338  // create temp directory for the target machine
339  std::string tmpDir = FileSystem::createTempDirectory();
340 
341  // write machine to a file for tcecc
342  std::string adf = tmpDir + DS + "mach.adf";
343  std::string tpef = tmpDir + DS + "program.tpef";
344  ADFSerializer serializer;
345  serializer.setDestinationFile(adf);
346  try {
347  serializer.writeMachine(target);
348  } catch (const SerializerException& exception) {
350  throw IOException(
351  __FILE__, __LINE__, __func__, exception.errorMessage());
352  }
353  // call tcecc to compile, link and schedule the program
354  std::vector<std::string> tceccOutputLines;
355  std::string tceccPath = Environment::tceCompiler();
356  std::string tceccCommand = tceccPath + " "
357  + compilerOptions + " --no-link -a " + adf + " -o "
358  + tpef + " " + bytecodeFile + " --no-plugin-cache 2>&1";
359 
360  const bool debug = Application::verboseLevel() > 0;
361 
362  Application::runShellCommandAndGetOutput(tceccCommand, tceccOutputLines);
363 
364  if (debug && tceccOutputLines.size() > 0) {
365  for (unsigned int i = 0; i < tceccOutputLines.size(); ++i) {
366  std::cout << tceccOutputLines.at(i) << std::endl;
367  }
368  }
369 
370  // check if tcecc produced any tpef output
371  if (!(FileSystem::fileExists(tpef) && FileSystem::fileIsReadable(tpef))) {
372  if (debug) {
373  std::cout << "failed command: " << tceccCommand << std::endl
374  << "temporary directory left for inspection at: "
375  << tmpDir << std::endl;
376  } else {
378  }
379  return NULL;
380  }
381 
382  TTAProgram::Program* prog = NULL;
383  try {
384  prog = TTAProgram::Program::loadFromTPEF(tpef, target);
385  } catch (const Exception& e) {
387  IOException error(__FILE__, __LINE__,__func__, e.errorMessage());
388  error.setCause(e);
389  throw error;
390  }
392  return prog;
393 }
394 
395 /**
396  * Simulates the parallel program.
397  *
398  * Simulates the target machine as long as the program runs or the maximum
399  * cycle count is reached. If maximum cycle count is reached an exception is
400  * thrown.
401  *
402  * @param program Sequential program.
403  * @param machine Target machine.
404  * @param testApplication Test application directory.
405  * @param maxCycles Maximum amount of clock cycles that program is allowed to
406  * run. Not used by this implementation.
407  * @param runnedCycles Simulated cycle amount is stored here.
408  * @param tracing Flag indicating is the tracing used.
409  * @return Execution trace of the program.
410  * @exception Exception All exceptions produced by simulator engine except
411  * SimulationCycleLimitReached in case of max cycles are reached without
412  * program finishing and SimulationTimeOut in case of simulation is killed
413  * after simulating maximum time that is currently 10h.
414  */
415 const ExecutionTrace*
418  const TestApplication& testApplication, const ClockCycleCount&,
419  ClockCycleCount& runnedCycles, const bool tracing,
420  const bool useCompiledSimulation,
421  std::vector<ClockCycleCount>* executionCounts) {
422  // initialize the simulator
423  SimulatorFrontend simulator(
424  useCompiledSimulation ?
427 
428  // setting simulator timeout in seconds
429  simulator.setTimeout(480);
430 
431  // use memory file in sqlite
432  // TODO: should use a tmp dir as now TraceDB produces multiple
433  // text files, thus only the SQL part goes to memory
434  const string traceFile = ":memory:";
435  simulator.forceTraceDBFileName(traceFile);
436  if (!useCompiledSimulation)
437  simulator.setRFAccessTracing(tracing);
438  simulator.setUtilizationDataSaving(tracing);
439  simulator.setExecutionTracing(tracing);
440 
441  simulator.loadMachine(machine);
442  simulator.loadProgram(program);
443  // run the 'setup.sh' in the test application directory
444  testApplication.setupSimulation();
445  // if there is 'simulate.ttasim' file in the application dir we use that
446  if (testApplication.hasSimulateTTASim()) {
447  std::string command = "";
448  std::istream* input = testApplication.simulateTTASim();
449  BaseLineReader reader(*input, *oStream_);
450  reader.initialize();
451  reader.setPromptPrinting(false);
452  SimulatorInterpreterContext interpreterContext(simulator);
453  SimulatorInterpreter interpreter(0, NULL, interpreterContext, reader);
454  while (!interpreter.isQuitCommandGiven()) {
455  try {
456  command = reader.readLine();
457  } catch (const EndOfFile&) {
458  interpreter.interpret(SIM_INTERP_QUIT_COMMAND);
459  if (interpreter.result().size() > 0) {
460  *oStream_ << interpreter.result() << std::endl;
461  }
462  break;
463  }
464  command = StringTools::trim(command);
465  if (command == "") {
466  continue;
467  }
468  interpreter.interpret(command);
469  if (interpreter.result().size() > 0) {
470  *oStream_ << interpreter.result() << std::endl;
471  }
472  }
473  delete input;
474  input = NULL;
475  } else {
476  // no 'simulate.ttasim' file
477  BaseLineReader reader(std::cin, *oStream_);
478  reader.initialize();
479  SimulatorInterpreterContext interpreterContext(simulator);
480  SimulatorInterpreter interpreter(0, NULL, interpreterContext, reader);
481  simulator.run();
482  if (interpreter.result().size() > 0) {
483  *oStream_ << interpreter.result() << std::endl;
484  }
485  }
486 
487  runnedCycles = simulator.cycleCount();
488 
489  int instructionCount = program.instructionVector().size();
490  if (executionCounts) {
491  executionCounts->resize(instructionCount, 0);
492  for (int i=0; i<instructionCount; ++i) {
493  (*executionCounts)[i] = simulator.executableInstructionAt(i)
494  .executionCount();
495  }
496  }
497 
498  // Flush data collected during simulation to the trace file.
499  const ExecutionTrace* db = NULL;
500  if (tracing) {
501  db = simulator.lastTraceDB();
502  }
503 
504  simulator.killSimulation();
505 
506  return db;
507 }
508 
509 #pragma GCC diagnostic ignored "-Wstrict-aliasing"
510 /**
511  * Loads the given explorer plugin from the default search pathes of the
512  * explorer plugins.
513  *
514  * Searches for file named the plugin with an extension ".so".
515  * e.g. if the plugin is namen SimplePlugin is the file SimplePlugin.so
516  * loaded. Plugins are searched from the default search pathes of explorer
517  * plugins.
518  *
519  * @param pluginName Name of the plugin to be loaded.
520  * @param dsdb DSDBManager to be used by the plugin.
521  * @return Returns the loaded DesignSpacsExplorerPlugin instance.
522  * @exception FileNotFound If the given plugin is not found from the search
523  * paths of explorer plugins.
524  * @exception DynamicLibraryException If the dynamic library cannot be opened.
525  */
528  const std::string& pluginName, DSDBManager* dsdb) {
529  string pluginFileName = pluginName + ".so";
530  vector<string> searchPaths = Environment::explorerPluginPaths();
531  for (vector<string>::const_iterator iter = searchPaths.begin();
532  iter != searchPaths.end(); iter++) {
533 
534  if (FileSystem::fileExists(*iter)) {
535  pluginTool_.addSearchPath(*iter);
536  }
537  }
538  pluginTool_.registerModule(pluginFileName);
539  DesignSpaceExplorerPlugin* (*pluginCreator)();
540  pluginTool_.importSymbol(
541  "create_explorer_plugin_" + pluginName, pluginCreator,
542  pluginFileName);
543 
544  DesignSpaceExplorerPlugin* plugin = pluginCreator();
545  if (dsdb) {
546  plugin->setDSDB(*dsdb);
547  }
548  return plugin;
549 }
550 
551 #pragma GCC diagnostic warning "-Wstrict-aliasing"
552 
553 /**
554  *
555  * Parses the plugin search directories and loads all available plugins
556  */
557 std::vector<DesignSpaceExplorerPlugin*> DesignSpaceExplorer::getPlugins() {
558 
559  std::vector<DesignSpaceExplorerPlugin*> plugins;
560  vector<string> found_plugins;
561  vector<string> searchPaths = Environment::explorerPluginPaths();
562  for (vector<string>::const_iterator iter = searchPaths.begin();
563  iter != searchPaths.end(); iter++) {
564 
565  if (FileSystem::fileExists(*iter)) {
566  FileSystem::findFromDirectory(".*\\.so$", *iter, found_plugins);
567  }
568  }
569  for (unsigned int i = 0; i < found_plugins.size(); ++i) {
570  std::string pluginName = FileSystem::fileNameBody(found_plugins[i]);
571  DesignSpaceExplorerPlugin* plugin = loadExplorerPlugin(pluginName, NULL);
572  if (!plugin) {
573  continue;
574  }
575 
576  plugins.push_back(plugin);
577  }
578 
579  return plugins;
580 }
581 
582 
583 /**
584  * Selects components for a machine and creates a new configuration.
585  *
586  * Also stores the new configuration to the dsdb and returns it's rowID.
587  *
588  * @param conf MachineConfiguration of which architecture is used.
589  * @param frequency The minimum frequency of the implementations.
590  * @param maxArea Maximum area for implementations.
591  * @param createEstimates Boolean for creating estimates.
592  * @param icDec IC decoder to be used.
593  * @param icDecHDB IC decoder HDB file.
594  * @return RowID of the new machine configuration having adf and idf.
595  * */
596 RowID
599  const double& frequency,
600  const double& maxArea,
601  const bool& createEstimates,
602  const std::string& icDec,
603  const std::string& icDecHDB) {
604 
605  const TTAMachine::Machine* mach = dsdb_->architecture(conf.architectureID);
606  IDF::MachineImplementation* idf = NULL;
607 
608  idf = selectComponents(*mach, frequency, maxArea, icDec, icDecHDB);
609  if (!idf) {
610  return 0;
611  }
612 
614  CostEstimator::DelayInNanoSeconds longestPathDelay = 0;
615  if (createEstimates) {
616  createEstimateData(*mach, *idf, area, longestPathDelay);
617  }
618 
619  delete mach;
620  mach = NULL;
621 
623  newConf.architectureID = conf.architectureID;
624 
625  newConf.implementationID =
626  dsdb_->addImplementation(*idf, longestPathDelay, area);
627  newConf.hasImplementation = true;
628 
629  // idf written to the dsdb so it can be deleted
630  delete idf;
631  idf = NULL;
632 
633  return addConfToDSDB(newConf);
634 }
635 
636 
637 /**
638  * Selects components for a machine and ands them to a given config.
639  *
640  * @param conf MachineConfiguration of which architecture is used.
641  * @param newConf MachineConfiguration where idf is to be added.
642  * @param frequency The minimum frequency of the implementations.
643  * @param maxArea Maximum area for implementations.
644  * @param createEstimates Boolean for creating estimates.
645  * @param icDec IC decoder to be used.
646  * @param icDecHDB IC decoder HDB file.
647  * @return RowID of the new machine configuration having adf and idf.
648  * */
649 bool
653  const double& frequency,
654  const double& maxArea,
655  const bool& createEstimates,
656  const std::string& icDec,
657  const std::string& icDecHDB) {
658 
659  const TTAMachine::Machine* mach = dsdb_->architecture(conf.architectureID);
660  IDF::MachineImplementation* idf = NULL;
661 
662  idf = selectComponents(*mach, frequency, maxArea, icDec, icDecHDB);
663  if (!idf) {
664  return false;
665  }
666 
668  CostEstimator::DelayInNanoSeconds longestPathDelay = 0;
669  if (createEstimates) {
670  createEstimateData(*mach, *idf, area, longestPathDelay);
671  }
672 
673  delete mach;
674  mach = NULL;
675 
676  newConf.architectureID = conf.architectureID;
677  newConf.implementationID = dsdb_->addImplementation(*idf, longestPathDelay, area);
678  newConf.hasImplementation = true;
679 
680  // idf written to the dsdb so it can be deleted
681  delete idf;
682  idf = NULL;
683  return true;
684 }
685 
686 
687 /**
688  * Selects components for a machine, creates a idf.
689  *
690  * @param mach Target machine for which components are selected.
691  * @param frequency The minimum frequency of the implementations.
692  * @param maxArea Maximum area for implementations.
693  * @param icDec IC decoder to be used.
694  * @param icDecHDB IC decoder HDB file.
695  * @return Machine Implementation pointer if ok, else NULL.
696  * */
699  const TTAMachine::Machine& mach,
700  const double& frequency,
701  const double& maxArea,
702  const std::string& icDec,
703  const std::string& icDecHDB) const {
704 
706  IDF::MachineImplementation* idf = NULL;
707 
708  try {
709  // TODO: check that idf is deleted when it has been written to the
710  // dsdb, and not in use anymore (selectComponents reserves it with
711  // new)
712  idf = impSelector.selectComponents(&mach, icDec,
713  icDecHDB, frequency, maxArea);
714  } catch (const Exception& e) {
715  debugLog(e.errorMessage());
716  if (idf != NULL) {
717  delete idf;
718  idf = NULL;
719  }
720  }
721 
722  return idf;
723 }
724 
725 
726 /**
727  * creates estimate data for machine and idf.
728  *
729  * @param mach Machine mathcing given idf.
730  * @param idf Implementation definition for given machine.
731  * @param area Estimated area cost.
732  * @param longestPathDelay Estimated longest path delay.
733  * */
734 void
736  const TTAMachine::Machine& mach,
737  const IDF::MachineImplementation& idf,
739  CostEstimator::DelayInNanoSeconds& longestPathDelay) {
740 
741  area = estimator_.totalArea(mach, idf);
742  longestPathDelay = estimator_.longestPath(mach, idf);
743 }
744 
745 
746 /**
747  * Add given configuration to the database.
748  *
749  * @param conf Configuration to be added to the database.
750  * @param dsdb Database where to add the configuration.
751  * @return RowID Row ID of the config in the database. 0 if adding
752  * failed.
753  */
754 RowID
756  const DSDBManager::MachineConfiguration& conf) {
757 
758  try {
759  return dsdb_->addConfiguration(conf);
760  } catch (const Exception& e) {
761  debugLog(e.errorMessage());
762  return 0;
763  }
764 }
DesignSpaceExplorer::evaluate
virtual bool evaluate(const DSDBManager::MachineConfiguration &configuration, CostEstimates &results=dummyEstimate_, bool estimate=false)
Definition: DesignSpaceExplorer.cc:133
SimulatorInterpreterContext
Definition: SimulatorInterpreterContext.hh:45
ComponentImplementationSelector::selectComponents
IDF::MachineImplementation * selectComponents(const TTAMachine::Machine *mach, const std::string &icDecoder="ic_hdb", const std::string &icDecoderHDB="asic_130nm_1.5V.hdb", const double &frequency=0, const double &maxArea=0)
Definition: ComponentImplementationSelector.cc:645
BaseLineReader::setPromptPrinting
virtual void setPromptPrinting(bool flag)
Definition: BaseLineReader.cc:82
TTAProgram::Program
Definition: Program.hh:63
TestApplication::simulateTTASim
std::istream * simulateTTASim() const
Definition: TestApplication.cc:186
TestApplication::setupSimulation
void setupSimulation() const
Definition: TestApplication.cc:168
FileSystem::removeFileOrDirectory
static bool removeFileOrDirectory(const std::string &path)
Definition: FileSystem.cc:493
TestApplication::applicationPath
const std::string applicationPath() const
Definition: TestApplication.cc:312
CostEstimates::setLongestPathDelay
void setLongestPathDelay(double delay)
Definition: CostEstimates.cc:69
CostEstimates::setEnergy
void setEnergy(const TTAProgram::Program &program, double energy)
Definition: CostEstimates.cc:83
SimulatorFrontend::SIM_COMPILED
@ SIM_COMPILED
Compiled, faster simulation.
Definition: SimulatorFrontend.hh:103
DesignSpaceExplorer::db
virtual DSDBManager & db()
Definition: DesignSpaceExplorer.cc:300
CostEstimates
Definition: CostEstimates.hh:57
machine
TTAMachine::Machine * machine
the architecture definition of the estimated processor
Definition: EstimatorCmdLineUI.cc:59
ScriptInterpreter::result
virtual std::string result()
Definition: ScriptInterpreter.cc:191
Exception.hh
TestApplication::correctOutput
const std::string correctOutput() const
Definition: TestApplication.cc:140
ExecutableInstruction::executionCount
ClockCycleCount executionCount() const
Definition: ExecutableInstruction.cc:85
PluginTools
Definition: PluginTools.hh:53
DSDBManager::MachineConfiguration::hasImplementation
bool hasImplementation
Definition: DSDBManager.hh:80
Application::runShellCommandAndGetOutput
static int runShellCommandAndGetOutput(const std::string &command, std::vector< std::string > &outputLines, std::size_t maxOutputLines=DEFAULT_MAX_OUTPUT_LINES, bool includeStdErr=false)
Definition: Application.cc:338
DesignSpaceExplorer::addConfToDSDB
RowID addConfToDSDB(const DSDBManager::MachineConfiguration &conf)
Definition: DesignSpaceExplorer.cc:755
OperationGlobals::setOutputStream
static void setOutputStream(std::ostream &newOutputStream)
Definition: OperationGlobals.cc:59
DesignSpaceExplorerPlugin
Definition: DesignSpaceExplorerPlugin.hh:55
Exception::setCause
void setCause(const Exception &cause)
Definition: Exception.cc:75
RowID
int RowID
Type definition of row ID in relational databases.
Definition: DBTypes.hh:37
SimulatorInterpreter::isQuitCommandGiven
bool isQuitCommandGiven() const
Definition: SimulatorInterpreter.cc:134
DesignSpaceExplorer::dummyEstimate_
static CostEstimates dummyEstimate_
Used for the default evaluate() argument.
Definition: DesignSpaceExplorer.hh:139
Application::verboseLevel
static int verboseLevel()
Definition: Application.hh:176
CostEstimator::AreaInGates
double AreaInGates
type for area values in equivalent gates
Definition: CostEstimatorTypes.hh:35
DesignSpaceExplorer::createImplementationAndStore
RowID createImplementationAndStore(const DSDBManager::MachineConfiguration &conf, const double &frequency=0.0, const double &maxArea=0.0, const bool &createEstimates=true, const std::string &icDec="DefaultICDecoder", const std::string &icDecHDB="asic_130nm_1.5V.hdb")
Definition: DesignSpaceExplorer.cc:597
FileSystem::findFromDirectory
static bool findFromDirectory(const std::string &regex, const std::string &directory, STLCONT &found)
TestApplication::hasSimulateTTASim
bool hasSimulateTTASim() const
Definition: TestApplication.cc:259
SimulatorFrontend::run
virtual void run()
Definition: SimulatorFrontend.cc:997
BaseLineReader
Definition: BaseLineReader.hh:47
DesignSpaceExplorerPlugin.hh
Environment::tceCompiler
static std::string tceCompiler()
Definition: Environment.cc:928
SimulatorFrontend::setTimeout
void setTimeout(unsigned int value)
Definition: SimulatorFrontend.cc:1965
DesignSpaceExplorer::createEstimateData
void createEstimateData(const TTAMachine::Machine &mach, const IDF::MachineImplementation &idf, CostEstimator::AreaInGates &area, CostEstimator::DelayInNanoSeconds &longestPathDelay)
Definition: DesignSpaceExplorer.cc:735
CostEstimator::EnergyInMilliJoules
double EnergyInMilliJoules
type for consumed energy in milli joules
Definition: CostEstimatorTypes.hh:37
DesignSpaceExplorer::selectComponents
IDF::MachineImplementation * selectComponents(const TTAMachine::Machine &mach, const double &frequency=0.0, const double &maxArea=0.0, const std::string &icDec="DefaultICDecoder", const std::string &icDecHDB="asic_130nm_1.5V.hdb") const
Definition: DesignSpaceExplorer.cc:698
StringTools.hh
SimulatorFrontend::loadMachine
virtual void loadMachine(const std::string &fileName)
Definition: SimulatorFrontend.cc:534
UniversalMachine.hh
DesignSpaceExplorer::schedule
TTAProgram::Program * schedule(const std::string applicationFile, TTAMachine::Machine &machine, TCEString paramOptions="-O3")
Definition: DesignSpaceExplorer.cc:315
DSDBManager::MachineConfiguration::implementationID
RowID implementationID
Definition: DSDBManager.hh:81
CostEstimatorTypes.hh
SimulatorToolbox.hh
loadExplorerPlugin
DesignSpaceExplorerPlugin * loadExplorerPlugin(const std::string &plugin, DSDBManager *dsdb)
Definition: Explorer.cc:227
SimulatorInterpreter
Definition: SimulatorInterpreter.hh:49
SIM_INTERP_QUIT_COMMAND
#define SIM_INTERP_QUIT_COMMAND
The command used to quit the command line interface.
Definition: SimulatorConstants.hh:45
ExplorerCmdLineOptions
Definition: ExplorerCmdLineOptions.hh:45
DSDBManager::MachineConfiguration
Definition: DSDBManager.hh:78
InvalidData
Definition: Exception.hh:149
DesignSpaceExplorer::DesignSpaceExplorer
DesignSpaceExplorer()
Definition: DesignSpaceExplorer.cc:82
DesignSpaceExplorer::getPlugins
std::vector< DesignSpaceExplorerPlugin * > getPlugins()
Definition: DesignSpaceExplorer.cc:557
ExecutionTrace
Definition: ExecutionTrace.hh:56
ADFSerializer
Definition: ADFSerializer.hh:49
CostEstimates.hh
Application.hh
SimulatorFrontend::executableInstructionAt
const ExecutableInstruction & executableInstructionAt(InstructionAddress address) const
Definition: SimulatorFrontend.cc:2208
Application::cmdLineOptions
static CmdLineOptions * cmdLineOptions()
Definition: Application.cc:397
XMLSerializer::setDestinationFile
void setDestinationFile(const std::string &fileName)
Definition: XMLSerializer.cc:142
__func__
#define __func__
Definition: Application.hh:67
SimulatorFrontend::loadProgram
virtual void loadProgram(const std::string &fileName)
Definition: SimulatorFrontend.cc:299
Exception::errorMessageStack
std::string errorMessageStack(bool messagesOnly=false) const
Definition: Exception.cc:138
TclInterpreter::interpret
virtual bool interpret(const std::string &commandLine)
Definition: TclInterpreter.cc:138
SerializerException
Definition: Exception.hh:675
Machine.hh
DesignSpaceExplorer::pluginTool_
static PluginTools pluginTool_
The plugin tool.
Definition: DesignSpaceExplorer.hh:133
Exception
Definition: Exception.hh:54
BaseLineReader::readLine
virtual std::string readLine(std::string prompt="")
Definition: BaseLineReader.cc:96
DSDBManager
Definition: DSDBManager.hh:76
DesignSpaceExplorer::loadExplorerPlugin
static DesignSpaceExplorerPlugin * loadExplorerPlugin(const std::string &pluginName, DSDBManager *dsdb=NULL)
Definition: DesignSpaceExplorer.cc:527
ComponentImplementationSelector.hh
PluginTools.hh
ExplorerCmdLineOptions.hh
SimulatorFrontend.hh
DesignSpaceExplorer::simulate
const ExecutionTrace * simulate(const TTAProgram::Program &program, const TTAMachine::Machine &machine, const TestApplication &testApplication, const ClockCycleCount &maxCycles, ClockCycleCount &runnedCycles, const bool tracing, const bool useCompiledSimulation=false, std::vector< ClockCycleCount > *executionCounts=NULL)
Definition: DesignSpaceExplorer.cc:416
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
DSDBManager.hh
FileSystem::DIRECTORY_SEPARATOR
static const std::string DIRECTORY_SEPARATOR
Definition: FileSystem.hh:189
SimulatorFrontend::forceTraceDBFileName
void forceTraceDBFileName(const std::string &fileName)
Definition: SimulatorFrontend.hh:178
options
static MachInfoCmdLineOptions options
Definition: MachInfo.cc:46
ComponentImplementationSelector
Definition: ComponentImplementationSelector.hh:74
CostEstimator::DelayInNanoSeconds
double DelayInNanoSeconds
type for propagation delays in nano seconds
Definition: CostEstimatorTypes.hh:39
StringTools::trim
static std::string trim(const std::string &source)
Definition: StringTools.cc:55
SimulatorFrontend::killSimulation
virtual void killSimulation()
Definition: SimulatorFrontend.cc:1784
SimulatorFrontend::setRFAccessTracing
void setRFAccessTracing(bool value)
Definition: SimulatorFrontend.cc:1920
DesignSpaceExplorer::createImplementation
bool createImplementation(const DSDBManager::MachineConfiguration &conf, DSDBManager::MachineConfiguration &newConf, const double &frequency=0.0, const double &maxArea=0.0, const bool &createEstimates=true, const std::string &icDec="DefaultICDecoder", const std::string &icDecHDB="asic_130nm_1.5V.hdb")
Definition: DesignSpaceExplorer.cc:650
OperationBehavior.hh
SimulatorFrontend::cycleCount
ClockCycleCount cycleCount() const
Definition: SimulatorFrontend.cc:1194
DesignSpaceExplorer.hh
ADFSerializer.hh
SimulatorFrontend::setUtilizationDataSaving
void setUtilizationDataSaving(bool value)
Definition: SimulatorFrontend.cc:2008
Program.hh
DesignSpaceExplorer::setDSDB
virtual void setDSDB(DSDBManager &dsdb)
Definition: DesignSpaceExplorer.cc:107
CostEstimates::setArea
void setArea(double area)
Definition: CostEstimates.cc:58
FileSystem::fileExists
static bool fileExists(const std::string fileName)
SimulatorFrontend::setExecutionTracing
void setExecutionTracing(bool value)
Definition: SimulatorFrontend.cc:1900
TCEString
Definition: TCEString.hh:53
DesignSpaceExplorer::~DesignSpaceExplorer
virtual ~DesignSpaceExplorer()
Definition: DesignSpaceExplorer.cc:93
ExecutableInstruction.hh
SimulatorInterpreter.hh
ADFSerializer::writeMachine
void writeMachine(const TTAMachine::Machine &machine)
Definition: ADFSerializer.cc:259
TTAProgram::Program::loadFromTPEF
static Program * loadFromTPEF(const std::string &tpefFileName, const TTAMachine::Machine &theMachine)
Definition: Program.cc:1112
Environment::explorerPluginPaths
static std::vector< std::string > explorerPluginPaths()
Definition: Environment.cc:809
ClockCycleCount
CycleCount ClockCycleCount
Alias for ClockCycleCount.
Definition: SimulatorConstants.hh:57
program
find Finds info of the inner loops in the program
Definition: InnerLoopFinder.cc:80
IOException
Definition: Exception.hh:130
EndOfFile
Definition: Exception.hh:189
DS
#define DS
Definition: LLVMBackend.cc:124
FileSystem::fileIsReadable
static bool fileIsReadable(const std::string fileName)
CostEstimator
Definition: CostEstimationPlugin.cc:36
debugLog
#define debugLog(text)
Definition: Application.hh:95
FileSystem::fileNameBody
static std::string fileNameBody(const std::string &fileName)
Definition: FileSystem.cc:291
DSDBManager::MachineConfiguration::architectureID
RowID architectureID
Definition: DSDBManager.hh:79
TestApplication::hasCorrectOutput
bool hasCorrectOutput() const
Definition: TestApplication.cc:272
TestApplication
Definition: TestApplication.hh:46
SimulatorFrontend
Definition: SimulatorFrontend.hh:89
FileSystem::createTempDirectory
static std::string createTempDirectory(const std::string &path="/tmp", const std::string &tempDirPrefix="tmp_tce_")
Definition: FileSystem.cc:441
IDF::MachineImplementation
Definition: MachineImplementation.hh:54
MachineImplementation.hh
OperationGlobals.hh
TTAMachine::Machine
Definition: Machine.hh:73
SimulatorFrontend::lastTraceDB
ExecutionTrace * lastTraceDB(int core=-1)
Definition: SimulatorFrontend.cc:2243
BaseLineReader::initialize
virtual void initialize(std::string defPrompt="", FILE *in=stdin, FILE *out=stdout, FILE *err=stderr)
Definition: BaseLineReader.cc:65
ExecutionTrace.hh
SimulatorFrontend::SIM_NORMAL
@ SIM_NORMAL
Default, interpreted simulation (debugging engine).
Definition: SimulatorFrontend.hh:102