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