OpenASIP 2.2
Loading...
Searching...
No Matches
Private Member Functions | Private Attributes | Static Private Attributes | List of all members
GrowMachine Class Reference
Inheritance diagram for GrowMachine:
Inheritance graph
Collaboration diagram for GrowMachine:
Collaboration graph

Private Member Functions

 PLUGIN_DESCRIPTION ("Adds resources until cycle count doesn't go down anymore.")
 
 GrowMachine ()
 
virtual bool requiresStartingPointArchitecture () const
 
virtual bool producesArchitecture () const
 
virtual bool requiresHDB () const
 
virtual bool requiresSimulationData () const
 
virtual std::vector< RowIDexplore (const RowID &configurationID, const unsigned int &)
 
void readParameters ()
 
bool checkSuperiority (const ClockCycleCount &newCC, const ClockCycleCount &oldCC) const
 
double calculateImprovement (const ClockCycleCount &newCC, const ClockCycleCount &oldCC) const
 

Private Attributes

unsigned int superiority_
 Percentage value of how much faster schedules are wanted until cycle count optimization is stopped.
 

Static Private Attributes

static const std::string superiorityPN_
 

Additional Inherited Members

- Public Types inherited from DesignSpaceExplorerPlugin
typedef std::pair< std::string, ExplorerPluginParameterParameter
 
typedef std::map< std::string, ExplorerPluginParameterParameterMap
 
typedef std::map< std::string, ExplorerPluginParameter >::iterator PMIt
 
typedef std::map< std::string, ExplorerPluginParameter >::const_iterator PMCIt
 
- Public Member Functions inherited from DesignSpaceExplorerPlugin
virtual bool requiresApplication () const
 
virtual std::string description () const
 
void addParameter (TCEString name, ExplorerPluginParameterType type, bool compulsory=true, TCEString defaultValue="", TCEString description="")
 
template<typename T >
void readCompulsoryParameter (const std::string paramName, T &param) const
 
template<typename T >
void readOptionalParameter (const std::string paramName, T &param) const
 
template<typename RT >
RT parameterValue (const std::string &paramName) const
 
virtual ~DesignSpaceExplorerPlugin ()
 
virtual void giveParameter (const std::string &name, const std::string &value)
 
virtual std::string name () const
 
virtual void setPluginName (const std::string &pluginName)
 
virtual bool hasParameter (const std::string &paramName) const
 
ParameterMap parameters () const
 
virtual bool booleanValue (const std::string &parameter) const
 
- Public Member Functions inherited from DesignSpaceExplorer
 DesignSpaceExplorer ()
 
virtual ~DesignSpaceExplorer ()
 
virtual void setDSDB (DSDBManager &dsdb)
 
virtual bool evaluate (const DSDBManager::MachineConfiguration &configuration, CostEstimates &results=dummyEstimate_, bool estimate=false)
 
virtual DSDBManagerdb ()
 
std::vector< DesignSpaceExplorerPlugin * > getPlugins ()
 
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")
 
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")
 
IDF::MachineImplementationselectComponents (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
 
void createEstimateData (const TTAMachine::Machine &mach, const IDF::MachineImplementation &idf, CostEstimator::AreaInGates &area, CostEstimator::DelayInNanoSeconds &longestPathDelay)
 
RowID addConfToDSDB (const DSDBManager::MachineConfiguration &conf)
 
- Static Public Member Functions inherited from DesignSpaceExplorer
static DesignSpaceExplorerPluginloadExplorerPlugin (const std::string &pluginName, DSDBManager *dsdb=NULL)
 
- Protected Member Functions inherited from DesignSpaceExplorerPlugin
 DesignSpaceExplorerPlugin ()
 
void checkParameters () const
 
- Protected Member Functions inherited from DesignSpaceExplorer
TTAProgram::Programschedule (const std::string applicationFile, TTAMachine::Machine &machine, TCEString paramOptions="-O3")
 
const ExecutionTracesimulate (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)
 
- Protected Attributes inherited from DesignSpaceExplorerPlugin
std::string pluginName_
 the name of the explorer plugin
 
ParameterMap parameters_
 Parameters for the plugin.
 

Detailed Description

Explorer plugin that adds resources until cycle count doesn't go down anymore.

Supported parameters:

Definition at line 61 of file GrowMachine.cc.

Constructor & Destructor Documentation

◆ GrowMachine()

GrowMachine::GrowMachine ( )
inlineprivate

Definition at line 64 of file GrowMachine.cc.

65 superiority_(10) {
66
67 // compulsory parameters
68 // no compulsory parameters
69
70 // parameters that have a default value
73 }
#define UINT(OPERAND)
Definition OSAL.hh:313
static std::string toString(const T &source)
void addParameter(TCEString name, ExplorerPluginParameterType type, bool compulsory=true, TCEString defaultValue="", TCEString description="")
unsigned int superiority_
Percentage value of how much faster schedules are wanted until cycle count optimization is stopped.
static const std::string superiorityPN_

References DesignSpaceExplorerPlugin::addParameter(), superiority_, superiorityPN_, Conversion::toString(), and UINT.

Here is the call graph for this function:

Member Function Documentation

◆ calculateImprovement()

double GrowMachine::calculateImprovement ( const ClockCycleCount newCC,
const ClockCycleCount oldCC 
) const
inlineprivate

Calculates the percentage of improvement in cycle count

Parameters
newCCThe new minimum cycle count.
oldCCThe old minimum cycle count.

Definition at line 300 of file GrowMachine.cc.

302 {
303
304 return (1.0 -(static_cast<double>(newCC)/oldCC))*100.0;
305 }

Referenced by explore().

◆ checkSuperiority()

bool GrowMachine::checkSuperiority ( const ClockCycleCount newCC,
const ClockCycleCount oldCC 
) const
inlineprivate

Checks whether cycle counts have been lowered enough.

Parameters
newCCThe new minimum cycle count.
oldCCThe old minimum cycle count.

Definition at line 282 of file GrowMachine.cc.

284 {
285
286 if ((newCC < oldCC) &&
287 (((static_cast<double>(superiority_) / 100) * oldCC) <
288 (oldCC - newCC))) {
289 return true;
290 }
291 return false;
292 }

References superiority_.

Referenced by explore().

◆ explore()

virtual std::vector< RowID > GrowMachine::explore ( const RowID configurationID,
const unsigned int &   
)
inlineprivatevirtual

Optimizes the architecture in regards of the cycle count.

Optimizes the architecture by growing it until cycle count doesn't go down anymore.

@TODO: average cycle count lowering, or lowest/largest lowering percentage among apps now it's largest lowering among apps. @TODO: parametrize machine growing, example how many buses to add each step.

Returns
Configurations (including only adf) generated by CycleOptimizer. Best result is at the top of the list.

Reimplemented from DesignSpaceExplorerPlugin.

Definition at line 95 of file GrowMachine.cc.

95 {
96 std::vector<RowID> result;
97
99
100 TTAMachine::Machine* adf = NULL;
102 DSDBManager& dsdb = db();
103
104 // get the architecture from the database
105 try {
106 configuration = dsdb.configuration(configurationID);
107 adf = dsdb.architecture(configuration.architectureID);
108 } catch (const KeyNotFound& e) {
109 debugLog(std::string("Fetching architecture from DSDB failed in "
110 "GrowMachine. ")
111 + e.errorMessage() + std::string(" ")
112 + e.errorMessageStack());
113 result.push_back(configurationID);
114 delete adf;
115 return result;
116 }
117
118 // evaluate to get current cycle counts
119 DesignSpaceExplorer explorer;
120 explorer.setDSDB(dsdb);
121 CostEstimates estimates;
123 startConf.architectureID = dsdb.addArchitecture(*adf);
124 startConf.hasImplementation = false;
125 try {
126 bool estimate = false;
127 if (!explorer.evaluate(startConf, estimates, estimate)) {
128 debugLog(std::string("Evaluate failed in GrowMachine."));
129 result.push_back(configurationID);
130 delete adf;
131 adf = NULL;
132 return result;
133 }
134 } catch (const Exception& e) {
135 debugLog(std::string("Error in GrowMachine: ")
136 + e.errorMessage() + std::string(" ")
137 + e.errorMessageStack());
138 result.push_back(configurationID);
139 delete adf;
140 adf = NULL;
141 return result;
142 }
143
144 std::vector<ClockCycleCount> cycleCounts =
145 db().cycleCounts(startConf);
146
147
148 if (cycleCounts.size() < 1) {
149 std::ostringstream msg(std::ostringstream::out);
150 msg << "GrowMachine error: Couldn't evaluate cycle "
151 << "counts for applications, correct_simulation_output"
152 << " probably missing." << std::endl;
153 verboseLog(msg.str());
154 result.push_back(configurationID);
155 delete adf;
156 adf = NULL;
157 return result;
158 }
159
160 // all applications minimum cycle count
161 ClockCycleCount currentMinCycles = cycleCounts.at(0);
162 for (int i = 1; i < (int)cycleCounts.size(); i++) {
163 if (cycleCounts.at(i) < currentMinCycles) {
164 currentMinCycles = cycleCounts.at(i);
165 }
166 }
167
168 ClockCycleCount prevMinCycles = 0;
170 std::map<ClockCycleCount, RowID> resultMap;
171 do {
172 prevMinCycles = currentMinCycles;
173 try {
174 // These parameters passed to the modifier can be changed.
175 // They tell how many units of same type are added each time.
176 modifier.addBusesByAmount(8, *adf);
177 modifier.increaseAllRFsThatDiffersByAmount(1, *adf);
178 modifier.increaseAllFUsThatDiffersByAmount(1, *adf);
179 // @TODO immediate unit addition
180
181 DSDBManager::MachineConfiguration newConfiguration;
182 try {
183 newConfiguration.architectureID = dsdb.addArchitecture(*adf);
184 } catch (const RelationalDBException& e) {
185 // Error occurred while adding adf to the dsdb, adf
186 // probably too big
187 break;
188 }
189 newConfiguration.hasImplementation = false;
190 RowID confID = dsdb.addConfiguration(newConfiguration);
191 CostEstimates newEstimates;
192
193 // evaluate to get new cycle counts
194 if (explorer.evaluate(newConfiguration, newEstimates, false)) {
195 // resets the currentMinCycles
196 std::vector<ClockCycleCount> newCycleCounts =
197 db().cycleCounts(newConfiguration);
198
199 currentMinCycles = newCycleCounts.at(0);
200 for (int i = 1; i < (int)newCycleCounts.size(); i++) {
201 if (newCycleCounts.at(i) < currentMinCycles) {
202 currentMinCycles = newCycleCounts.at(i);
203 }
204 }
205
206 if (Application::verboseLevel() > 0) {
207 std::ostringstream msg(std::ostringstream::out);
208 msg << "GrowMachine produced config: "
209 << confID << ", with cycle count: "
210 << currentMinCycles << " ("
211 << calculateImprovement(currentMinCycles,
212 prevMinCycles)
213 << "% better)";
214 verboseLog(msg.str())
215 }
216
217 if (checkSuperiority(currentMinCycles, prevMinCycles)) {
218 // only add config if it meets the superiority
219 // requirements regarding clock cycles
220 resultMap[currentMinCycles] = confID;
221 } else {
222 break;
223 }
224 } else {
225 // evaluating failed
226 debugLog("GrowMachine: Evaluating config with id: "
227 + Conversion::toString(confID)
228 + " failed. This is probably a bug.");
229 break;
230 }
231
232 } catch (const Exception& e) {
233 debugLog(std::string("Error in GrowMachine: ")
234 + e.errorMessage() + std::string(" ")
235 + e.errorMessageStack());
236 result.push_back(configurationID);
237 delete adf;
238 adf = NULL;
239 return result;
240 }
241 } while (true);
242
243 std::map<ClockCycleCount, RowID>::const_iterator mapIter =
244 resultMap.begin();
245 for (; mapIter != resultMap.end(); mapIter++) {
246 result.push_back((*mapIter).second);
247 }
248 if (result.empty()) {
249 // if now new configuration created return the old
250 verboseLogC("GrowMachine could not generate new configs.", 2)
251 result.push_back(configurationID);
252 }
253 delete adf;
254 adf = NULL;
255 return result;
256 }
#define debugLog(text)
#define verboseLog(text)
#define verboseLogC(text, neededVerbosity)
int RowID
Type definition of row ID in relational databases.
Definition DBTypes.hh:37
CycleCount ClockCycleCount
Alias for ClockCycleCount.
static int verboseLevel()
RowID addArchitecture(const TTAMachine::Machine &mom)
TTAMachine::Machine * architecture(RowID id) const
MachineConfiguration configuration(RowID id) const
std::vector< ClockCycleCount > cycleCounts(const MachineConfiguration &conf) const
RowID addConfiguration(const MachineConfiguration &conf)
virtual void setDSDB(DSDBManager &dsdb)
virtual DSDBManager & db()
virtual bool evaluate(const DSDBManager::MachineConfiguration &configuration, CostEstimates &results=dummyEstimate_, bool estimate=false)
std::string errorMessageStack(bool messagesOnly=false) const
Definition Exception.cc:138
std::string errorMessage() const
Definition Exception.cc:123
double calculateImprovement(const ClockCycleCount &newCC, const ClockCycleCount &oldCC) const
void readParameters()
bool checkSuperiority(const ClockCycleCount &newCC, const ClockCycleCount &oldCC) const
void increaseAllFUsThatDiffersByAmount(int moreFUs, TTAMachine::Machine &mach)
void addBusesByAmount(int busesToAdd, TTAMachine::Machine &mach)
void increaseAllRFsThatDiffersByAmount(int registersToAdd, TTAMachine::Machine &mach)

References DSDBManager::addArchitecture(), MachineResourceModifier::addBusesByAmount(), DSDBManager::addConfiguration(), DSDBManager::architecture(), DSDBManager::MachineConfiguration::architectureID, calculateImprovement(), checkSuperiority(), DSDBManager::configuration(), DSDBManager::cycleCounts(), DesignSpaceExplorer::db(), debugLog, Exception::errorMessage(), Exception::errorMessageStack(), DesignSpaceExplorer::evaluate(), DSDBManager::MachineConfiguration::hasImplementation, MachineResourceModifier::increaseAllFUsThatDiffersByAmount(), MachineResourceModifier::increaseAllRFsThatDiffersByAmount(), readParameters(), DesignSpaceExplorer::setDSDB(), Conversion::toString(), Application::verboseLevel(), verboseLog, and verboseLogC.

Here is the call graph for this function:

◆ PLUGIN_DESCRIPTION()

GrowMachine::PLUGIN_DESCRIPTION ( "Adds resources until cycle count doesn't go down anymore."  )
private

◆ producesArchitecture()

virtual bool GrowMachine::producesArchitecture ( ) const
inlineprivatevirtual

Implements DesignSpaceExplorerPlugin.

Definition at line 76 of file GrowMachine.cc.

76{ return true; }

◆ readParameters()

void GrowMachine::readParameters ( )
inlineprivate

Reads the parameters given to the plugin.

Definition at line 270 of file GrowMachine.cc.

270 {
271 // optional parameters
273 }
void readOptionalParameter(const std::string paramName, T &param) const

References DesignSpaceExplorerPlugin::readOptionalParameter(), superiority_, and superiorityPN_.

Referenced by explore().

Here is the call graph for this function:

◆ requiresHDB()

virtual bool GrowMachine::requiresHDB ( ) const
inlineprivatevirtual

Implements DesignSpaceExplorerPlugin.

Definition at line 77 of file GrowMachine.cc.

77{ return true; }

◆ requiresSimulationData()

virtual bool GrowMachine::requiresSimulationData ( ) const
inlineprivatevirtual

Implements DesignSpaceExplorerPlugin.

Definition at line 78 of file GrowMachine.cc.

78{ return false; }

◆ requiresStartingPointArchitecture()

virtual bool GrowMachine::requiresStartingPointArchitecture ( ) const
inlineprivatevirtual

Implements DesignSpaceExplorerPlugin.

Definition at line 75 of file GrowMachine.cc.

75{ return true; }

Member Data Documentation

◆ superiority_

unsigned int GrowMachine::superiority_
private

Percentage value of how much faster schedules are wanted until cycle count optimization is stopped.

Definition at line 265 of file GrowMachine.cc.

Referenced by checkSuperiority(), GrowMachine(), and readParameters().

◆ superiorityPN_

const std::string GrowMachine::superiorityPN_
staticprivate

Definition at line 260 of file GrowMachine.cc.

Referenced by GrowMachine(), and readParameters().


The documentation for this class was generated from the following file: