OpenASIP  2.0
Private Member Functions | Private Attributes | Static Private Attributes | List of all members
RemoveUnconnectedComponents Class Reference
Inheritance diagram for RemoveUnconnectedComponents:
Inheritance graph
Collaboration diagram for RemoveUnconnectedComponents:
Collaboration graph

Private Member Functions

 PLUGIN_DESCRIPTION ("Removes unconnected components from a configuration.")
 
 RemoveUnconnectedComponents ()
 
virtual bool requiresStartingPointArchitecture () const
 
virtual bool producesArchitecture () const
 
virtual bool requiresHDB () const
 
virtual bool requiresSimulationData () const
 
virtual bool requiresApplication () const
 
virtual std::vector< RowIDexplore (const RowID &configurationID, const unsigned int &)
 
void readParameters ()
 
void removeUnconnectedFUs (TTAMachine::Machine &mach, std::vector< std::string > &removedFUNames)
 
void checkFUPorts (TTAMachine::Machine &mach)
 
void checkRFPorts (TTAMachine::Machine &mach, std::vector< std::string > &removedRFNames)
 
void checkBuses (TTAMachine::Machine &mach)
 
void removeSockets (TTAMachine::Machine &mach)
 

Private Attributes

bool allowRemoval_
 parameter allow removal of unused ports and RFs without ports. More...
 

Static Private Attributes

static const std::string allowRemovalPN_
 

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 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 More...
 
ParameterMap parameters_
 Parameters for the plugin. More...
 

Detailed Description

Explorer plugin that removes unconnected ports from units or creates connections to these ports in case of a FUs. Also removes unconnected buses. If all ports from a unit are removed, removes also the unit.

Definition at line 57 of file RemoveUnconnectedComponents.cc.

Constructor & Destructor Documentation

◆ RemoveUnconnectedComponents()

RemoveUnconnectedComponents::RemoveUnconnectedComponents ( )
inlineprivate

Definition at line 60 of file RemoveUnconnectedComponents.cc.

61  allowRemoval_(false) {
62 
63  // compulsory parameters
64  // no compulsory parameters
65 
66  // parameters that have a default value
69  }

References BOOL, and Conversion::toString().

Here is the call graph for this function:

Member Function Documentation

◆ checkBuses()

void RemoveUnconnectedComponents::checkBuses ( TTAMachine::Machine mach)
inlineprivate

Checks buses and removes the ones that have no connections to sockets.

Parameters
machMachine which buses are checked.

Definition at line 300 of file RemoveUnconnectedComponents.cc.

300  {
301  Machine::SocketNavigator socketNav = mach.socketNavigator();
302  Machine::BusNavigator busNav = mach.busNavigator();
303  for (int i = 0; i < busNav.count(); ++i) {
304  bool isConnected = false;
305  for (int j = 0; j < socketNav.count(); ++j) {
306  if ((busNav.item(i))->isConnectedTo(
307  *socketNav.item(j))) {
308  isConnected = true;
309  }
310  }
311  // if not connected to any socket remove bus
312  if (!isConnected) {
313  mach.removeBus(*busNav.item(i));
314  }
315  }
316  }

References TTAMachine::Machine::busNavigator(), TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Machine::removeBus(), and TTAMachine::Machine::socketNavigator().

Here is the call graph for this function:

◆ checkFUPorts()

void RemoveUnconnectedComponents::checkFUPorts ( TTAMachine::Machine mach)
inlineprivate

Checks that every FU port has at least one connection.

Adds an new connection to some available socket if port has no connections

Parameters
machMachine which FU ports are checked.

Definition at line 221 of file RemoveUnconnectedComponents.cc.

221  {
222  MachineTester& tester = mach.machineTester();
223  Machine::SocketNavigator socketNav = mach.socketNavigator();
224 
226  for (int i = 0; i < FUNav.count(); ++i) {
227  FunctionUnit* FU = FUNav.item(i);
228  for (int j = 0; j < FU->portCount(); ++j) {
229  Port* port = FU->port(j);
230  // if no connections, make a connection to some socket
231  if (port->socketCount() < 1) {
232  Socket* socket = NULL;
233  // find a socket where FU port can be connected
234  for (int soc = 0; i < socketNav.count(); ++soc) {
235  socket = socketNav.item(soc);
236  if (tester.canConnect(*socket, *port)) {
237  port->attachSocket(*socket);
238  break;
239  }
240  }
241  }
242  }
243  }
244  }

References TTAMachine::Port::attachSocket(), MachineTester::canConnect(), TTAMachine::Machine::Navigator< ComponentType >::count(), FU, TTAMachine::Machine::functionUnitNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Machine::machineTester(), TTAMachine::Port::socketCount(), and TTAMachine::Machine::socketNavigator().

Here is the call graph for this function:

◆ checkRFPorts()

void RemoveUnconnectedComponents::checkRFPorts ( TTAMachine::Machine mach,
std::vector< std::string > &  removedRFNames 
)
inlineprivate

Checks that every RF port has connections.

Removes every port of a RF that has no connections to sockets if allowRemoval_ is true else makes connection to available socket. If RF ends up having no ports, removes the RF from machine.

Parameters
machMachine which RF ports are checked.
removedRFNamesNames of RF units that were removed from machine content only added not read in this function.

Definition at line 257 of file RemoveUnconnectedComponents.cc.

258  {
259 
260  MachineTester& tester = mach.machineTester();
261  Machine::SocketNavigator socketNav = mach.socketNavigator();
262 
264  for (int i = 0; i < RFNav.count(); ++i) {
265  RegisterFile* RF = RFNav.item(i);
266  for (int j = 0; j < RF->portCount(); ++j) {
267  Port* port = RF->port(j);
268  // if no connections
269  if (port->socketCount() < 1) {
270  if (allowRemoval_) {
271  delete port;
272  port = NULL;
273  --j;
274  if (RF->portCount() < 1) {
275  mach.removeRegisterFile(*RF);
276  removedRFNames.push_back(RF->name());
277  --i;
278  }
279  } else {
280  Socket* socket = NULL;
281  // find a socket where RF port can be connected
282  for (int soc = 0; i < socketNav.count(); ++soc) {
283  socket = socketNav.item(soc);
284  if (tester.canConnect(*socket, *port)) {
285  port->attachSocket(*socket);
286  break;
287  }
288  }
289  }
290  }
291  }
292  }
293  }

References TTAMachine::Port::attachSocket(), MachineTester::canConnect(), TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Machine::machineTester(), TTAMachine::Machine::registerFileNavigator(), TTAMachine::Machine::removeRegisterFile(), RF, TTAMachine::Port::socketCount(), and TTAMachine::Machine::socketNavigator().

Here is the call graph for this function:

◆ explore()

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

Removes unconnected components from a configuration.

Explorer plugin that removes unconnected ports from units or creates connections to these ports in case of a FUs. Also removes unconnected buses. If all ports from a unit are removed, removes also the unit. Removes also unconnected FUs. First unconnected sockets are removed.

Supported parameters:

  • allow_remove, Allows the RFs port removal and portless RFs removal.
Parameters
configurationIDConfiguration to optimize.

Reimplemented from DesignSpaceExplorerPlugin.

Definition at line 92 of file RemoveUnconnectedComponents.cc.

92  {
93 
94  std::vector<RowID> result;
95 
97 
98  try {
99  DSDBManager& dsdb = db();
101  dsdb.configuration(configurationID);
102 
103  // get the machine belonging to the configuration
104  Machine* mach = NULL;
105  try {
106  mach = dsdb.architecture(conf.architectureID);
107  } catch (const Exception& e) {
108  return result;
109  }
110 
111  // removes sockets not connected to any bus
112  removeSockets(*mach);
113 
114  // removes FUs not connected to any socket by any port
115  std::vector<std::string> removedFUNames;
116  removeUnconnectedFUs(*mach, removedFUNames);
117 
118  // checks that every FU port is connected to a socket
119  checkFUPorts(*mach);
120 
121  // register files are removed only if allow_remove parameter is
122  // given, else connections to sockets are made for RFs
123  std::vector<std::string> removedRFNames;
124  checkRFPorts(*mach, removedRFNames);
125 
126  // removes buses that have no connections to any socket
127  checkBuses(*mach);
128 
130  if (conf.hasImplementation) {
131  newConf.hasImplementation = true;
133  dsdb.implementation(conf.implementationID);
134  // removes removed RFs from idf
135  while (!removedRFNames.empty()) {
136  idf->removeRFImplementation(removedRFNames.at(
137  removedRFNames.size()-1));
138  removedRFNames.pop_back();
139  }
140  // removes removed FUs from idf
141  while (!removedFUNames.empty()) {
142  idf->removeFUImplementation(removedFUNames.at(
143  removedFUNames.size()-1));
144  removedFUNames.pop_back();
145  }
146  newConf.implementationID =
147  dsdb.addImplementation(*idf, 0, 0);
148  } else {
149  newConf.hasImplementation = false;
150  }
151  newConf.architectureID = dsdb.addArchitecture(*mach);
152 
153  RowID confID = dsdb.addConfiguration(newConf);
154  result.push_back(confID);
155 
156  } catch (const Exception& e) {
157  std::ostringstream msg(std::ostringstream::out);
158  msg << "Error while using RemoveUnconnectedComponents:"
159  << endl << e.errorMessage() << endl;
160  verboseLog(msg.str());
161  return result;
162  }
163  return result;
164  }

References DSDBManager::addArchitecture(), DSDBManager::addConfiguration(), DSDBManager::addImplementation(), DSDBManager::architecture(), DSDBManager::MachineConfiguration::architectureID, DSDBManager::configuration(), Exception::errorMessage(), DSDBManager::MachineConfiguration::hasImplementation, DSDBManager::implementation(), DSDBManager::MachineConfiguration::implementationID, IDF::MachineImplementation::removeFUImplementation(), IDF::MachineImplementation::removeRFImplementation(), and verboseLog.

Here is the call graph for this function:

◆ PLUGIN_DESCRIPTION()

RemoveUnconnectedComponents::PLUGIN_DESCRIPTION ( "Removes unconnected components from a configuration."  )
private

◆ producesArchitecture()

virtual bool RemoveUnconnectedComponents::producesArchitecture ( ) const
inlineprivatevirtual

Implements DesignSpaceExplorerPlugin.

Definition at line 73 of file RemoveUnconnectedComponents.cc.

73 { return true; }

◆ readParameters()

void RemoveUnconnectedComponents::readParameters ( )
inlineprivate

Reads the parameters given to the plugin.

Definition at line 175 of file RemoveUnconnectedComponents.cc.

◆ removeSockets()

void RemoveUnconnectedComponents::removeSockets ( TTAMachine::Machine mach)
inlineprivate

Removes sockets that are not needed in the machine.

Parameters
machMachine which extra sockets are removed.

Definition at line 323 of file RemoveUnconnectedComponents.cc.

323  {
324 
325  // remove not connected sockets
326  MachineResourceModifier modifier;
327  std::list<std::string> removedSocketNames;
328  modifier.removeNotConnectedSockets(mach, removedSocketNames);
329  }

References MachineResourceModifier::removeNotConnectedSockets().

Here is the call graph for this function:

◆ removeUnconnectedFUs()

void RemoveUnconnectedComponents::removeUnconnectedFUs ( TTAMachine::Machine mach,
std::vector< std::string > &  removedFUNames 
)
inlineprivate

Removes totally unconnected FUs.

Parameters
machMachine which unconnected FUs are removed.
removedFUNamesNames of FU units that were removed from machine

Definition at line 186 of file RemoveUnconnectedComponents.cc.

187  {
188 
189  //MachineTester& tester = mach.machineTester();
190  Machine::SocketNavigator socketNav = mach.socketNavigator();
191 
193  for (int i = 0; i < FUNav.count(); ++i) {
194  FunctionUnit* FU = FUNav.item(i);
195  bool noConnections = true;
196  for (int j = 0; j < FU->portCount(); ++j) {
197  Port* port = FU->port(j);
198  // if no connections
199  if (port->socketCount() > 0) {
200  noConnections = false;
201  break;
202  }
203  }
204  // remove FU if it did not have any connections
205  if (noConnections) {
206  mach.removeFunctionUnit(*FU);
207  removedFUNames.push_back(FU->name());
208  --i;
209  }
210  }
211  }

References TTAMachine::Machine::Navigator< ComponentType >::count(), FU, TTAMachine::Machine::functionUnitNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Machine::removeFunctionUnit(), TTAMachine::Port::socketCount(), and TTAMachine::Machine::socketNavigator().

Here is the call graph for this function:

◆ requiresApplication()

virtual bool RemoveUnconnectedComponents::requiresApplication ( ) const
inlineprivatevirtual

Reimplemented from DesignSpaceExplorerPlugin.

Definition at line 76 of file RemoveUnconnectedComponents.cc.

76 { return false; }

◆ requiresHDB()

virtual bool RemoveUnconnectedComponents::requiresHDB ( ) const
inlineprivatevirtual

Implements DesignSpaceExplorerPlugin.

Definition at line 74 of file RemoveUnconnectedComponents.cc.

74 { return false; }

◆ requiresSimulationData()

virtual bool RemoveUnconnectedComponents::requiresSimulationData ( ) const
inlineprivatevirtual

Implements DesignSpaceExplorerPlugin.

Definition at line 75 of file RemoveUnconnectedComponents.cc.

75 { return false; }

◆ requiresStartingPointArchitecture()

virtual bool RemoveUnconnectedComponents::requiresStartingPointArchitecture ( ) const
inlineprivatevirtual

Implements DesignSpaceExplorerPlugin.

Definition at line 72 of file RemoveUnconnectedComponents.cc.

72 { return true; }

Member Data Documentation

◆ allowRemoval_

bool RemoveUnconnectedComponents::allowRemoval_
private

parameter allow removal of unused ports and RFs without ports.

Definition at line 169 of file RemoveUnconnectedComponents.cc.

◆ allowRemovalPN_

const std::string RemoveUnconnectedComponents::allowRemovalPN_
staticprivate

Definition at line 167 of file RemoveUnconnectedComponents.cc.


The documentation for this class was generated from the following file:
TTAMachine::Machine::removeFunctionUnit
virtual void removeFunctionUnit(FunctionUnit &unit)
Definition: Machine.cc:530
IDF::MachineImplementation::removeFUImplementation
void removeFUImplementation(const std::string &unitName)
Definition: MachineImplementation.cc:634
MachineTester::canConnect
virtual bool canConnect(const TTAMachine::Socket &socket, const TTAMachine::Segment &segment)
Definition: MachineTester.cc:86
IDF::MachineImplementation::removeRFImplementation
void removeRFImplementation(const std::string &unitName)
Definition: MachineImplementation.cc:659
DesignSpaceExplorer::db
virtual DSDBManager & db()
Definition: DesignSpaceExplorer.cc:300
FU
const string FU
Definition: IDFSerializer.cc:64
DSDBManager::architecture
TTAMachine::Machine * architecture(RowID id) const
Definition: DSDBManager.cc:807
DSDBManager::MachineConfiguration::hasImplementation
bool hasImplementation
Definition: DSDBManager.hh:80
TTAMachine::Machine::removeBus
virtual void removeBus(Bus &bus)
Definition: Machine.cc:477
RemoveUnconnectedComponents::removeUnconnectedFUs
void removeUnconnectedFUs(TTAMachine::Machine &mach, std::vector< std::string > &removedFUNames)
Definition: RemoveUnconnectedComponents.cc:186
RowID
int RowID
Type definition of row ID in relational databases.
Definition: DBTypes.hh:37
DesignSpaceExplorerPlugin::DesignSpaceExplorerPlugin
DesignSpaceExplorerPlugin()
Definition: DesignSpaceExplorerPlugin.cc:48
MachineResourceModifier
Definition: MachineResourceModifier.hh:49
RemoveUnconnectedComponents::allowRemoval_
bool allowRemoval_
parameter allow removal of unused ports and RFs without ports.
Definition: RemoveUnconnectedComponents.cc:169
TTAMachine::Machine::Navigator::count
int count() const
Conversion::toString
static std::string toString(const T &source)
verboseLog
#define verboseLog(text)
Definition: Application.hh:115
BOOL
@ BOOL
Definition: ExplorerPluginParameter.hh:40
TTAMachine::Port::socketCount
virtual int socketCount() const
Definition: Port.cc:375
RemoveUnconnectedComponents::checkBuses
void checkBuses(TTAMachine::Machine &mach)
Definition: RemoveUnconnectedComponents.cc:300
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
TTAMachine::Port::attachSocket
virtual void attachSocket(Socket &socket)
Definition: Port.cc:191
DSDBManager::MachineConfiguration::implementationID
RowID implementationID
Definition: DSDBManager.hh:81
DesignSpaceExplorerPlugin::readOptionalParameter
void readOptionalParameter(const std::string paramName, T &param) const
DSDBManager::MachineConfiguration
Definition: DSDBManager.hh:78
TTAMachine::Machine::machineTester
MachineTester & machineTester() const
Definition: Machine.cc:671
TTAMachine::Port
Definition: Port.hh:54
TTAMachine::Machine::functionUnitNavigator
virtual FunctionUnitNavigator functionUnitNavigator() const
Definition: Machine.cc:380
TTAMachine::Socket
Definition: Socket.hh:53
TTAMachine::Machine::removeRegisterFile
virtual void removeRegisterFile(RegisterFile &unit)
Definition: Machine.cc:554
Exception
Definition: Exception.hh:54
DSDBManager
Definition: DSDBManager.hh:76
TTAMachine::Machine::socketNavigator
virtual SocketNavigator socketNavigator() const
Definition: Machine.cc:368
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
RemoveUnconnectedComponents::checkRFPorts
void checkRFPorts(TTAMachine::Machine &mach, std::vector< std::string > &removedRFNames)
Definition: RemoveUnconnectedComponents.cc:257
DSDBManager::addConfiguration
RowID addConfiguration(const MachineConfiguration &conf)
Definition: DSDBManager.cc:299
DSDBManager::addArchitecture
RowID addArchitecture(const TTAMachine::Machine &mom)
Definition: DSDBManager.cc:191
TTAMachine::Machine::registerFileNavigator
virtual RegisterFileNavigator registerFileNavigator() const
Definition: Machine.cc:450
DSDBManager::configuration
MachineConfiguration configuration(RowID id) const
Definition: DSDBManager.cc:361
RemoveUnconnectedComponents::checkFUPorts
void checkFUPorts(TTAMachine::Machine &mach)
Definition: RemoveUnconnectedComponents.cc:221
TTAMachine::Machine::busNavigator
virtual BusNavigator busNavigator() const
Definition: Machine.cc:356
RemoveUnconnectedComponents::readParameters
void readParameters()
Definition: RemoveUnconnectedComponents.cc:175
DSDBManager::implementation
IDF::MachineImplementation * implementation(RowID id) const
Definition: DSDBManager.cc:887
TTAMachine::Machine::Navigator::item
ComponentType * item(int index) const
TTAMachine::RegisterFile
Definition: RegisterFile.hh:47
RemoveUnconnectedComponents::removeSockets
void removeSockets(TTAMachine::Machine &mach)
Definition: RemoveUnconnectedComponents.cc:323
MachineTester
Definition: MachineTester.hh:46
RemoveUnconnectedComponents::allowRemovalPN_
static const std::string allowRemovalPN_
Definition: RemoveUnconnectedComponents.cc:167
DSDBManager::MachineConfiguration::architectureID
RowID architectureID
Definition: DSDBManager.hh:79
TTAMachine::Machine::Navigator
Definition: Machine.hh:186
DesignSpaceExplorerPlugin::addParameter
void addParameter(TCEString name, ExplorerPluginParameterType type, bool compulsory=true, TCEString defaultValue="", TCEString description="")
DSDBManager::addImplementation
RowID addImplementation(const IDF::MachineImplementation &impl, double longestPathDelay, CostEstimator::AreaInGates area)
Definition: DSDBManager.cc:252
IDF::MachineImplementation
Definition: MachineImplementation.hh:54
RF
const string RF
Definition: IDFSerializer.cc:68
MachineResourceModifier::removeNotConnectedSockets
void removeNotConnectedSockets(TTAMachine::Machine &mach, std::list< std::string > &removedSocketNames)
Definition: MachineResourceModifier.cc:244
TTAMachine::Machine
Definition: Machine.hh:73