#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"
Go to the source code of this file.
|
DSDBManager * | loadDSDB (const std::string &dsdbFile) |
|
void | parseParameter (const std::string ¶m, std::string ¶mName, std::string ¶mValue) |
|
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) |
|
DesignSpaceExplorerPlugin * | loadExplorerPlugin (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[]) |
|
◆ 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
-
confs | Configuration 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.
129 for (
unsigned int i = 0; i < confs.size(); i++) {
131 if (size > configurationID) {
132 configurationID = size;
134 size = confs[i].application.size();
135 if (size > applicationPath) {
136 applicationPath = size;
139 if (size > cycleCount) {
143 if (size > energyEstimate) {
144 energyEstimate = size;
147 if (size > longestPathDelay) {
148 longestPathDelay = size;
References Conversion::toString().
Referenced by main().
◆ loadDSDB()
◆ loadExplorerPlugin()
◆ loadPluginParameters()
◆ main()
int main |
( |
int |
argc, |
|
|
char * |
argv[] |
|
) |
| |
Main function.
Parses the command line and figures out what to do.
- Parameters
-
argc | The command line argument count. |
argv | The command line arguments (passed to the interpreter). |
- Returns
- The return status.
Definition at line 402 of file Explorer.cc.
407 bool doneUseful =
false;
422 if (verboseLevel < 0) {
433 if (
options->pluginInfo().length() != 0) {
434 std::string plugin =
options->pluginInfo();
447 std::cerr <<
"Illegal number of arguments." << std::endl << std::endl;
452 std::string dsdbFile =
"";
483 <<
"Added configuration " << confID <<
" into the DSDB."
489 std::cout <<
"Error occured reading ADF or IDF. "
497 int testDirectories =
options->testApplicationDirectoryCount();
498 for (
int i = 0; i < testDirectories; i++) {
499 std::string testDir =
options->testApplicationDirectory(i);
503 if (!app.isValid()) {
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."
515 <<
"application directory '" << testDir
516 <<
"' has already been added" << std::endl;
519 std::cerr <<
"Application directory '" << testDir
520 <<
"' does not exist." << std::endl;
526 if (paretoSet !=
"") {
528 if (paretoSet !=
"C") {
529 std::cerr <<
"Unsupported pareto set value type." << std::endl;
539 cout <<
"Configurations in DSDB: " << endl;
542 int cycleLength = 11;
543 int energyLength = 15;
546 cout <<
"| Conf ID | Application path | cycle count | energy estimate | longest path delay | area "
548 cout <<
"------------------------------------------------------------------------------------------"
550 vector<DSDBManager::ConfigurationCosts> confCosts =
555 confCosts, idLength, pathLength, cycleLength,
556 energyLength, lpdLength, areaLength);
557 for (
unsigned int i = 0; i < confCosts.size(); i++) {
559 cout << confCosts[i].configurationID;
562 confCosts[i].configurationID).size());
564 cout << confCosts[i].application;
566 pathLength - confCosts[i].application.size());
568 cout << confCosts[i].cycleCount;
571 confCosts[i].cycleCount).size());
573 cout << confCosts[i].energyEstimate;
576 confCosts[i].energyEstimate).size());
578 cout << confCosts[i].longestPathDelay;
581 confCosts[i].longestPathDelay).size());
583 cout << confCosts[i].area;
586 confCosts[i].area).size());
587 cout <<
" |" << endl;
589 cout <<
"-----------------------------------------------------------------------------------------"
594 if (
options->printSummary() ||
options->numberOfConfigurations()) {
596 <<
" configurations "
597 <<
"in the database." << endl;
603 if (
options->writeOutConfiguration()) {
604 for (
int i = 0; i <
options->numberOfConfigurationsToWrite(); i++) {
608 std::string adfFileName =
614 std::cout <<
"Written ADF file of configuration "
615 <<
options->configurationToWrite(i)
618 std::cerr <<
"Error occured while writing the ADF."
625 std::string idfFileName =
631 std::cout <<
"Written IDF file of configuration "
632 <<
options->configurationToWrite(i)
635 std::cerr <<
"Error occured while writing the IDF."
643 std::cerr <<
"No configuration found with id: "
644 <<
options->configurationToWrite(i) <<
"."
655 if (
options->applicationIDToRemoveCount() > 0) {
656 for (
int i = 0; i <
options->applicationIDToRemoveCount(); i++) {
661 std::cerr <<
"No application with ID: " <<
id <<
" in DSDB."
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;
675 std::set<RowID>::const_iterator appIter = appIDs.begin();
676 for (; appIter != appIDs.end(); appIter++) {
677 std::cout <<
" " << (*appIter) <<
" | "
681 std::cout <<
"---------------------------------" << std::endl;
683 <<
" applications in DSDB." << std::endl;
689 std::string pluginToUse =
"";
690 pluginToUse =
options->explorerPlugin();
691 if (pluginToUse ==
"") {
693 std::cerr <<
"No explorer plugin given." << std::endl;
709 if (testDirectories < 1 && !dsdb->applicationCount() &&
713 std::cerr <<
"No test application paths given or found in dsdb."
720 vector<string> hdbPaths;
725 hdbPaths.insert(hdbPaths.end(), srchPaths.begin(), srchPaths.end());
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++) {
734 pathToHdb = tempPath;
741 std::cerr <<
"Could not find HDB file "
742 <<
options->hdbFileName(i) << std::endl;
749 for (
unsigned int i = 0; i < hdbPaths.size(); i++) {
754 pathToHdb = tempPath;
761 std::cerr <<
"Could not find HDB file "
762 << pathToHdb << std::endl;
767 RowID startPointConfigurationID =
options->startConfiguration();
768 if (startPointConfigurationID == 0 &&
771 <<
"No starting point configuration defined. " << std::endl
772 <<
"Use -s <confID> to define the configuration to "
773 <<
"start the exploration from." << std::endl;
777 vector<RowID> result =
778 explorer->
explore(startPointConfigurationID);
779 if (result.empty()) {
781 <<
"No fitting processor configurations were created." << endl;
783 std::cout <<
"Best result configurations:" << std::endl;
784 for (
unsigned int i = 0; i < result.size(); i++) {
785 cout <<
" " << result[i] << endl;
791 <<
" " << e.
lineNum() << std::endl;
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().
◆ orderingOfData()
◆ 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
-
param | The parameter. |
paramName | Parameter name is stored here. |
paramValue | Parameter value is stored here. |
- Exceptions
-
InvalidData | If the given parameter is not in the correct form. |
Definition at line 94 of file Explorer.cc.
96 string::size_type separatorPos = param.find(
"=", 0);
97 if (separatorPos == string::npos) {
99 "Explorer plugin parameters must be in form "
100 "'parametername=parametervalue'.";
104 paramName = param.substr(0, separatorPos);
105 paramValue = param.substr(separatorPos+1, param.length());
References __func__.
Referenced by loadPluginParameters().
◆ printParetoSet()
Prints the pareto set of configurations in the DSDB using the given criteria set.
Definition at line 353 of file Explorer.cc.
354 if (criteriaSet !=
"C")
360 const int CONF_COL_W = 6;
361 const int CONNECTIVITY_COL_W = 6;
362 const int CYCLES_COL_W = 8;
364 std::cout << std::setw(CONF_COL_W) << std::right <<
"conf #"
367 std::cout << std::setw(CONNECTIVITY_COL_W) << std::right <<
"conn"
370 std::cout << std::setw(CYCLES_COL_W) << std::right <<
"cycles"
373 for (
int i = 0; i < CONF_COL_W + CONNECTIVITY_COL_W + CYCLES_COL_W + 10;
377 std::cout << std::endl;
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>()
385 std::cout << std::setw(CONNECTIVITY_COL_W) << std::right << point.get<1>()
388 std::cout << std::setw(CYCLES_COL_W) << std::right << point.get<2>()
References DSDBManager::paretoSetConnectivityAndCycles().
Referenced by main().
◆ printPluginParamInfo()
Prints explorer plugin parameter info.
- Parameters
-
plugin | Explorer plugin which parameter info is to be printed. |
Definition at line 303 of file Explorer.cc.
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()) {
314 cout <<
"unsigned int";
326 cout <<
"unknown type";
328 if (!it->second.isCompulsory()) {
329 if (it->second.type() ==
BOOL) {
331 (it->second.value() ==
"1" || it->second.value() ==
"true"
334 cout << it->second.value();
338 if (it->second.description().size() > 0) {
340 cout << it->second.description();
References BOOL, INT, DesignSpaceExplorerPlugin::parameters(), STRING, and UINT.
Referenced by main().
◆ printPlugins()
Prints explorer plugins and their descriptions.
Definition at line 256 of file Explorer.cc.
257 vector<string> found_plugins;
258 vector<string> stripped_plugins;
260 for (vector<string>::const_iterator iter = searchPaths.begin();
261 iter != searchPaths.end(); iter++) {
264 verboseLogC(
"Fetching plugins from directory: " + *iter, 1)
265 FileSystem::findFromDirectory(".*\\.so$", *iter, found_plugins);
268 cout << "| Plugin name | Description " << endl
269 << "--------------------------------------------" << endl;
270 cout.flags(std::ios::left);
272 for (
unsigned int i = 0; i < found_plugins.size(); ++i) {
273 std::string finalPluginName = found_plugins[i];
277 while (pluginName != finalPluginName) {
278 finalPluginName = pluginName;
281 if(find(stripped_plugins.begin(), stripped_plugins.end(), pluginName)
282 == stripped_plugins.end()) {
283 stripped_plugins.push_back(pluginName);
286 for (
unsigned int i = 0; i < stripped_plugins.size(); ++i) {
287 std::string pluginName = stripped_plugins[i];
292 cout << std::setw(30) << pluginName << plugin->
description() << endl;
References DesignSpaceExplorerPlugin::description(), Environment::explorerPluginPaths(), FileSystem::fileExists(), FileSystem::fileNameBody(), FileSystem::findFromDirectory(), loadExplorerPlugin(), and verboseLogC.
Referenced by main().
◆ printSpaces()
void printSpaces |
( |
unsigned int |
numberOfSpaces | ) |
|
Outputs given number of empty characters to cout.
- Parameters
-
numberOfSpaces | The number of empty characters to output. |
Definition at line 164 of file Explorer.cc.
165 while (numberOfSpaces != 0) {
Referenced by main().
◆ EXPLORER_DEFAULT_HDB
const string EXPLORER_DEFAULT_HDB = "asic_130nm_1.5V.hdb" |
bool loadPluginParameters(DesignSpaceExplorerPlugin *plugin, const ExplorerCmdLineOptions &options)
virtual void printHelp() const
int applicationCount() const
const string EXPLORER_DEFAULT_HDB
void printPluginParamInfo(DesignSpaceExplorerPlugin &plugin)
void parseParameter(const std::string ¶m, std::string ¶mName, std::string ¶mValue)
virtual int numberOfArguments() const
@ ORDER_BY_ENERGY_ESTIMATE
int RowID
Type definition of row ID in relational databases.
static void setVerboseLevel(const int level=VERBOSE_LEVEL_DEFAULT)
CachedHDBManager & hdb(const std::string fileName)
static void setCmdLineOptions(CmdLineOptions *options_)
void writeArchitectureToFile(RowID id, const std::string &path) const
static int verboseLevel()
void printParetoSet(const DSDBManager &dsdb, TCEString criteriaSet)
static std::string toString(const T &source)
void printSpaces(unsigned int numberOfSpaces)
std::string fileName() const
static bool fileIsDirectory(const std::string fileName)
RowID addApplication(const std::string &path)
bool hasConfiguration(RowID id) const
bool hasApplication(RowID id) const
boost::tuple< RowID, int, ClockCycleCount > ParetoPointConnectivityAndCycles
DesignSpaceExplorerPlugin * loadExplorerPlugin(const std::string &plugin, DSDBManager *dsdb)
virtual bool requiresStartingPointArchitecture() const =0
#define verboseLogC(text, neededVerbosity)
static std::vector< std::string > hdbPaths(bool libraryPathsOnly=false)
virtual void giveParameter(const std::string &name, const std::string &value)
Order
Identifiers for ordering results.
std::set< ParetoPointConnectivityAndCycles > ParetoSetConnectivityAndCycles
static DesignSpaceExplorerPlugin * loadExplorerPlugin(const std::string &pluginName, DSDBManager *dsdb=NULL)
std::string errorMessage() const
void parse(char *argv[], int argc)
void determineLongest(const vector< DSDBManager::ConfigurationCosts > &confs, int &configurationID, int &applicationPath, int &cycleCount, int &energyEstimate, int &longestPathDelay, int &area)
ParetoSetConnectivityAndCycles paretoSetConnectivityAndCycles(RowID application=ILLEGAL_ROW_ID) const
static const std::string DIRECTORY_SEPARATOR
RowID addConfiguration(const MachineConfiguration &conf)
static MachInfoCmdLineOptions options
RowID addArchitecture(const TTAMachine::Machine &mom)
static DSDBManager * createNew(const std::string &file)
MachineConfiguration configuration(RowID id) const
virtual std::vector< RowID > explore(const RowID &startPointConfigurationID, const unsigned int &maxIter=0)
static bool fileExists(const std::string fileName)
DSDBManager::Order orderingOfData(const string &order)
static std::vector< std::string > explorerPluginPaths()
virtual std::string description() const
std::map< std::string, ExplorerPluginParameter >::const_iterator PMCIt
std::map< std::string, ExplorerPluginParameter > ParameterMap
static std::string currentWorkingDir()
std::string applicationPath(RowID id) const
std::vector< ConfigurationCosts > applicationCostEstimatesByConf(Order ordering=ORDER_BY_CONFIGURATION) const
void writeImplementationToFile(RowID id, const std::string &path) const
static std::string fileNameBody(const std::string &fileName)
virtual std::string argument(int index) const
virtual bool requiresApplication() const
DSDBManager * loadDSDB(const std::string &dsdbFile)
ParameterMap parameters() const
RowID addImplementation(const IDF::MachineImplementation &impl, double longestPathDelay, CostEstimator::AreaInGates area)
static MachineImplementation * loadFromIDF(const std::string &idfFileName)
std::set< RowID > configurationIDs() const
void removeApplication(RowID id)
std::set< RowID > applicationIDs() const
static HDBRegistry & instance()
static Machine * loadFromADF(const std::string &adfFileName)