OpenASIP 2.2
Loading...
Searching...
No Matches
Functions | Variables
Explorer.cc File Reference
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include "StringTools.hh"
#include "Application.hh"
#include "Exception.hh"
#include "FileSystem.hh"
#include "DesignSpaceExplorer.hh"
#include "DesignSpaceExplorerPlugin.hh"
#include "ExplorerCmdLineOptions.hh"
#include "DSDBManager.hh"
#include "HDBRegistry.hh"
#include "MachineImplementation.hh"
#include "Machine.hh"
#include "ExplorerPluginParameter.hh"
#include "Environment.hh"
#include "Conversion.hh"
Include dependency graph for Explorer.cc:

Go to the source code of this file.

Functions

DSDBManagerloadDSDB (const std::string &dsdbFile)
 
void parseParameter (const std::string &param, std::string &paramName, std::string &paramValue)
 
void determineLongest (const vector< DSDBManager::ConfigurationCosts > &confs, int &configurationID, int &applicationPath, int &cycleCount, int &energyEstimate, int &longestPathDelay, int &area)
 
void printSpaces (unsigned int numberOfSpaces)
 
DSDBManager::Order orderingOfData (const string &order)
 
bool loadPluginParameters (DesignSpaceExplorerPlugin *plugin, const ExplorerCmdLineOptions &options)
 
DesignSpaceExplorerPluginloadExplorerPlugin (const std::string &plugin, DSDBManager *dsdb)
 
void printPlugins ()
 
void printPluginParamInfo (DesignSpaceExplorerPlugin &plugin)
 
void printParetoSet (const DSDBManager &dsdb, TCEString criteriaSet)
 
int main (int argc, char *argv[])
 

Variables

const string EXPLORER_DEFAULT_HDB = "asic_130nm_1.5V.hdb"
 

Function Documentation

◆ determineLongest()

void determineLongest ( const vector< DSDBManager::ConfigurationCosts > &  confs,
int &  configurationID,
int &  applicationPath,
int &  cycleCount,
int &  energyEstimate,
int &  longestPathDelay,
int &  area 
)

Determines the widest column so that column widths can be tuned.

Lengths of the data values are returned through the parameters.

Parameters
confsConfiguration costs which lengths are checked. @configurationID Length of the configuration ID string. @applicationPath Length of the path string of an application. @cycleCount Length of the program cycle count string. @energyEstimate Length of the programs energy estimate string.

Definition at line 120 of file Explorer.cc.

127 {
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}
static std::string toString(const T &source)

References Conversion::toString().

Referenced by main().

Here is the call graph for this function:

◆ loadDSDB()

DSDBManager * loadDSDB ( const std::string &  dsdbFile)

Loads the output Design Space Database file and creates a DSDB from it.

If the given filename doesn't exists creates a new DSDB file with the given name.

Parameters
dsdbFileThe DSDB file name.
Returns
DSDBManager of the DSDB file.

Definition at line 76 of file Explorer.cc.

76 {
77 if (FileSystem::fileExists(dsdbFile)) {
78 return new DSDBManager(dsdbFile);
79 } else {
80 return DSDBManager::createNew(dsdbFile);
81 }
82}
static DSDBManager * createNew(const std::string &file)
static bool fileExists(const std::string fileName)

References DSDBManager::createNew(), and FileSystem::fileExists().

Referenced by main().

Here is the call graph for this function:

◆ loadExplorerPlugin()

DesignSpaceExplorerPlugin * loadExplorerPlugin ( const std::string &  plugin,
DSDBManager dsdb 
)

Loads explorer plugin.

Parameters
pluginExplorer plugin name to be loaded.
dsdbDSDB that plugin is associated with.
Returns
explorer plugin as a pointer.

Definition at line 227 of file Explorer.cc.

227 {
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}
#define verboseLog(text)
#define verboseLogC(text, neededVerbosity)
static DesignSpaceExplorerPlugin * loadExplorerPlugin(const std::string &pluginName, DSDBManager *dsdb=NULL)
std::string errorMessage() const
Definition Exception.cc:123

References Exception::errorMessage(), DesignSpaceExplorer::loadExplorerPlugin(), verboseLog, and verboseLogC.

Referenced by main(), and printPlugins().

Here is the call graph for this function:

◆ loadPluginParameters()

bool loadPluginParameters ( DesignSpaceExplorerPlugin plugin,
const ExplorerCmdLineOptions options 
)

Parses parameters given from command line and passes them to the plugin.

Parameters
pluginExplorer plugin that receives the parameters.
optionsExplorer command line options where parameters are read.

Definition at line 198 of file Explorer.cc.

200 {
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}
void parseParameter(const std::string &param, std::string &paramName, std::string &paramValue)
Definition Explorer.cc:94
static MachInfoCmdLineOptions options
Definition MachInfo.cc:46
virtual void giveParameter(const std::string &name, const std::string &value)

References Exception::errorMessage(), DesignSpaceExplorerPlugin::giveParameter(), options, and parseParameter().

Referenced by main().

Here is the call graph for this function:

◆ main()

int main ( int  argc,
char *  argv[] 
)

Main function.

Parses the command line and figures out what to do.

Parameters
argcThe command line argument count.
argvThe command line arguments (passed to the interpreter).
Returns
The return status.

Definition at line 402 of file Explorer.cc.

402 {
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 const&) {
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;
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) &&
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;
561 idLength - Conversion::toString(
562 confCosts[i].configurationID).size());
563 cout << " | ";
564 cout << confCosts[i].application;
566 pathLength - confCosts[i].application.size());
567 cout << " | ";
568 cout << confCosts[i].cycleCount;
570 cycleLength - Conversion::toString(
571 confCosts[i].cycleCount).size());
572 cout << " | ";
573 cout << confCosts[i].energyEstimate;
575 energyLength - Conversion::toString(
576 confCosts[i].energyEstimate).size());
577 cout << " | ";
578 cout << confCosts[i].longestPathDelay;
580 lpdLength - Conversion::toString(
581 confCosts[i].longestPathDelay).size());
582 cout << " | ";
583 cout << confCosts[i].area;
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 &&
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}
int RowID
Type definition of row ID in relational databases.
Definition DBTypes.hh:37
DesignSpaceExplorerPlugin * loadExplorerPlugin(const std::string &plugin, DSDBManager *dsdb)
Definition Explorer.cc:227
void determineLongest(const vector< DSDBManager::ConfigurationCosts > &confs, int &configurationID, int &applicationPath, int &cycleCount, int &energyEstimate, int &longestPathDelay, int &area)
Definition Explorer.cc:120
void printPluginParamInfo(DesignSpaceExplorerPlugin &plugin)
Definition Explorer.cc:303
bool loadPluginParameters(DesignSpaceExplorerPlugin *plugin, const ExplorerCmdLineOptions &options)
Definition Explorer.cc:198
DSDBManager::Order orderingOfData(const string &order)
Definition Explorer.cc:177
DSDBManager * loadDSDB(const std::string &dsdbFile)
Definition Explorer.cc:76
void printParetoSet(const DSDBManager &dsdb, TCEString criteriaSet)
Definition Explorer.cc:353
void printPlugins()
Definition Explorer.cc:256
const string EXPLORER_DEFAULT_HDB
Definition Explorer.cc:64
void printSpaces(unsigned int numberOfSpaces)
Definition Explorer.cc:164
static void setCmdLineOptions(CmdLineOptions *options_)
static void setVerboseLevel(const int level=VERBOSE_LEVEL_DEFAULT)
static int verboseLevel()
static void initialize()
void parse(char *argv[], int argc)
virtual std::string argument(int index) const
virtual int numberOfArguments() const
RowID addArchitecture(const TTAMachine::Machine &mom)
bool hasApplication(RowID id) const
std::set< RowID > configurationIDs() const
std::set< RowID > applicationIDs() const
MachineConfiguration configuration(RowID id) const
std::string applicationPath(RowID id) const
void writeArchitectureToFile(RowID id, const std::string &path) const
std::vector< ConfigurationCosts > applicationCostEstimatesByConf(Order ordering=ORDER_BY_CONFIGURATION) const
bool hasConfiguration(RowID id) const
int applicationCount() const
RowID addImplementation(const IDF::MachineImplementation &impl, double longestPathDelay, CostEstimator::AreaInGates area)
Order
Identifiers for ordering results.
void removeApplication(RowID id)
void writeImplementationToFile(RowID id, const std::string &path) const
RowID addConfiguration(const MachineConfiguration &conf)
RowID addApplication(const std::string &path)
virtual bool requiresStartingPointArchitecture() const =0
virtual std::vector< RowID > explore(const RowID &startPointConfigurationID, const unsigned int &maxIter=0)
static std::vector< std::string > hdbPaths(bool libraryPathsOnly=false)
std::string fileName() const
int lineNum() const
static const std::string DIRECTORY_SEPARATOR
static std::string currentWorkingDir()
static bool fileIsDirectory(const std::string fileName)
static HDBRegistry & instance()
CachedHDBManager & hdb(const std::string fileName)
static MachineImplementation * loadFromIDF(const std::string &idfFileName)
virtual void printHelp() const
static Machine * loadFromADF(const std::string &adfFileName)
Definition Machine.cc:899

References DSDBManager::addApplication(), DSDBManager::addArchitecture(), DSDBManager::addConfiguration(), DSDBManager::addImplementation(), DSDBManager::applicationCostEstimatesByConf(), DSDBManager::applicationCount(), DSDBManager::applicationIDs(), DSDBManager::applicationPath(), DSDBManager::MachineConfiguration::architectureID, CmdLineParser::argument(), DSDBManager::configuration(), DSDBManager::configurationIDs(), FileSystem::currentWorkingDir(), determineLongest(), FileSystem::DIRECTORY_SEPARATOR, Exception::errorMessage(), DesignSpaceExplorerPlugin::explore(), EXPLORER_DEFAULT_HDB, FileSystem::fileExists(), FileSystem::fileIsDirectory(), Exception::fileName(), DSDBManager::hasApplication(), DSDBManager::hasConfiguration(), DSDBManager::MachineConfiguration::hasImplementation, HDB::HDBRegistry::hdb(), Environment::hdbPaths(), DSDBManager::MachineConfiguration::implementationID, Application::initialize(), HDB::HDBRegistry::instance(), TestApplication::isValid(), Exception::lineNum(), loadDSDB(), loadExplorerPlugin(), TTAMachine::Machine::loadFromADF(), IDF::MachineImplementation::loadFromIDF(), loadPluginParameters(), CmdLineParser::numberOfArguments(), options, orderingOfData(), CmdLineOptions::parse(), MachInfoCmdLineOptions::printHelp(), printParetoSet(), printPluginParamInfo(), printPlugins(), printSpaces(), DSDBManager::removeApplication(), DesignSpaceExplorerPlugin::requiresApplication(), DesignSpaceExplorerPlugin::requiresStartingPointArchitecture(), Application::setCmdLineOptions(), Application::setVerboseLevel(), Conversion::toString(), Application::verboseLevel(), DSDBManager::writeArchitectureToFile(), and DSDBManager::writeImplementationToFile().

Here is the call graph for this function:

◆ orderingOfData()

DSDBManager::Order orderingOfData ( const string &  order)

Returns the ordering of data indicated by the string.

@order Option string given by user that tells the ordering.

Returns
The ordering of the data.

Definition at line 177 of file Explorer.cc.

177 {
178 if (order == "I") {
180 } else if (order == "P") {
182 } else if (order == "C") {
184 } else if (order == "E") {
186 } else {
188 }
189}
@ ORDER_BY_ENERGY_ESTIMATE

References DSDBManager::ORDER_BY_APPLICATION, DSDBManager::ORDER_BY_CONFIGURATION, DSDBManager::ORDER_BY_CYCLE_COUNT, and DSDBManager::ORDER_BY_ENERGY_ESTIMATE.

Referenced by main().

◆ parseParameter()

void parseParameter ( const std::string &  param,
std::string &  paramName,
std::string &  paramValue 
)

Parses the given parameter which has form 'paramname=paramvalue" to different strings.

Parameters
paramThe parameter.
paramNameParameter name is stored here.
paramValueParameter value is stored here.
Exceptions
InvalidDataIf the given parameter is not in the correct form.

Definition at line 94 of file Explorer.cc.

95 {
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}
#define __func__

References __func__.

Referenced by loadPluginParameters().

◆ printParetoSet()

void printParetoSet ( const DSDBManager dsdb,
TCEString  criteriaSet 
)

Prints the pareto set of configurations in the DSDB using the given criteria set.

Definition at line 353 of file Explorer.cc.

353 {
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}
std::set< ParetoPointConnectivityAndCycles > ParetoSetConnectivityAndCycles
boost::tuple< RowID, int, ClockCycleCount > ParetoPointConnectivityAndCycles
ParetoSetConnectivityAndCycles paretoSetConnectivityAndCycles(RowID application=ILLEGAL_ROW_ID) const

References DSDBManager::paretoSetConnectivityAndCycles().

Referenced by main().

Here is the call graph for this function:

◆ printPluginParamInfo()

void printPluginParamInfo ( DesignSpaceExplorerPlugin plugin)

Prints explorer plugin parameter info.

Parameters
pluginExplorer plugin which parameter info is to be printed.

Definition at line 303 of file Explorer.cc.

303 {
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}
#define UINT(OPERAND)
Definition OSAL.hh:313
#define INT(OPERAND)
Definition OSAL.hh:312
#define BOOL()
std::map< std::string, ExplorerPluginParameter > ParameterMap
std::map< std::string, ExplorerPluginParameter >::const_iterator PMCIt

References BOOL, INT, DesignSpaceExplorerPlugin::parameters(), STRING, and UINT.

Referenced by main().

Here is the call graph for this function:

◆ printPlugins()

void printPlugins ( )

Prints explorer plugins and their descriptions.

Definition at line 256 of file Explorer.cc.

256 {
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}
virtual std::string description() const
static std::vector< std::string > explorerPluginPaths()
static std::string fileNameBody(const std::string &fileName)

References DesignSpaceExplorerPlugin::description(), Environment::explorerPluginPaths(), FileSystem::fileExists(), FileSystem::fileNameBody(), FileSystem::findFromDirectory(), loadExplorerPlugin(), and verboseLogC.

Referenced by main().

Here is the call graph for this function:

◆ printSpaces()

void printSpaces ( unsigned int  numberOfSpaces)

Outputs given number of empty characters to cout.

Parameters
numberOfSpacesThe number of empty characters to output.

Definition at line 164 of file Explorer.cc.

164 {
165 while (numberOfSpaces != 0) {
166 cout << " ";
167 numberOfSpaces--;
168 }
169}

Referenced by main().

Variable Documentation

◆ EXPLORER_DEFAULT_HDB

const string EXPLORER_DEFAULT_HDB = "asic_130nm_1.5V.hdb"

Definition at line 64 of file Explorer.cc.

Referenced by main().