OpenASIP 2.2
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
DSDBManager Class Reference

#include <DSDBManager.hh>

Collaboration diagram for DSDBManager:
Collaboration graph

Classes

struct  appComparator
 
struct  ApplicationData
 
struct  ConfigurationCosts
 Struct for configuration costs with a specified application. More...
 
struct  cycleComparator
 
struct  energyComparator
 
struct  idComparator
 
struct  MachineConfiguration
 

Public Types

enum  Order { ORDER_BY_CONFIGURATION , ORDER_BY_CYCLE_COUNT , ORDER_BY_ENERGY_ESTIMATE , ORDER_BY_APPLICATION }
 Identifiers for ordering results. More...
 
typedef boost::tuple< RowID, int, ClockCycleCountParetoPointConnectivityAndCycles
 
typedef std::set< ParetoPointConnectivityAndCyclesParetoSetConnectivityAndCycles
 

Public Member Functions

 DSDBManager (const std::string &file)
 
virtual ~DSDBManager ()
 
std::string dsdbFile () const
 
RowID addArchitecture (const TTAMachine::Machine &mom)
 
RowID addImplementation (const IDF::MachineImplementation &impl, double longestPathDelay, CostEstimator::AreaInGates area)
 
RowID addConfiguration (const MachineConfiguration &conf)
 
RowID addApplication (const std::string &path)
 
void addEnergyEstimate (RowID application, RowID implementation, double energyEstimate)
 
void addCycleCount (RowID application, RowID architecture, ClockCycleCount count)
 
void setLongestPathDelayEstimate (RowID implementation, double delay)
 
void setAreaEstimate (RowID implementation, CostEstimator::AreaInGates area)
 
bool hasApplication (RowID id) const
 
bool hasApplication (const std::string &applicationPath) const
 
void removeApplication (RowID id)
 
std::string applicationPath (RowID id) const
 
bool hasArchitecture (RowID id) const
 
TTAMachine::Machinearchitecture (RowID id) const
 
RowID architectureId (const TTAMachine::Machine &mach) const
 
bool hasImplementation (RowID id) const
 
IDF::MachineImplementationimplementation (RowID id) const
 
bool hasConfiguration (RowID id) const
 
MachineConfiguration configuration (RowID id) const
 
RowID configurationId (const MachineConfiguration &conf) const
 
void removeConfiguration (RowID id)
 
bool hasEnergyEstimate (RowID application, RowID implementation) const
 
double energyEstimate (RowID application, RowID implementation) const
 
bool hasCycleCount (RowID application, RowID architecture) const
 
ClockCycleCount cycleCount (RowID application, RowID architecture) const
 
std::vector< ClockCycleCountcycleCounts (const MachineConfiguration &conf) const
 
bool isUnschedulable (RowID application, RowID architecture) const
 
void setUnschedulable (RowID application, RowID architecture)
 
double longestPathDelayEstimate (RowID implementation) const
 
CostEstimator::AreaInGates areaEstimate (RowID implementation) const
 
std::set< RowIDapplicationIDs () const
 
std::set< RowIDarchitectureIDs () const
 
std::set< RowIDconfigurationIDs () const
 
std::set< RowIDarchConfigurationIDs (RowID architectureID) const
 
void writeArchitectureToFile (RowID id, const std::string &path) const
 
void writeImplementationToFile (RowID id, const std::string &path) const
 
void writeConfigurationToFile (const MachineConfiguration &conf, const std::string &path)
 
std::vector< ConfigurationCostsapplicationCostEstimatesByConf (Order ordering=ORDER_BY_CONFIGURATION) const
 
ParetoSetConnectivityAndCycles paretoSetConnectivityAndCycles (RowID application=ILLEGAL_ROW_ID) const
 
int applicationCount () const
 

Static Public Member Functions

static DSDBManagercreateNew (const std::string &file)
 

Private Member Functions

std::string architectureString (RowID id) const
 
std::string implementationString (RowID id) const
 

Private Attributes

SQLitedb_
 Handle to the database.
 
RelationalDBConnectiondbConnection_
 Handle to the database connection.
 
std::string file_
 The DSDB file containing the current database.
 

Detailed Description

Design space database manager.

Design space database stores information about explored machine configurations for test applications.

The following information can be stored:

Definition at line 76 of file DSDBManager.hh.

Member Typedef Documentation

◆ ParetoPointConnectivityAndCycles

Definition at line 153 of file DSDBManager.hh.

◆ ParetoSetConnectivityAndCycles

Definition at line 156 of file DSDBManager.hh.

Member Enumeration Documentation

◆ Order

Identifiers for ordering results.

Enumerator
ORDER_BY_CONFIGURATION 
ORDER_BY_CYCLE_COUNT 
ORDER_BY_ENERGY_ESTIMATE 
ORDER_BY_APPLICATION 

Definition at line 159 of file DSDBManager.hh.

Constructor & Destructor Documentation

◆ DSDBManager()

DSDBManager::DSDBManager ( const std::string &  file)

The Constructor.

Loads a DSDB from the given file.

Parameters
fileDSDB file to load.
Exceptions
IOExceptionif the DSDB file couldn't be succesfully loaded.

Definition at line 108 of file DSDBManager.cc.

109 : db_(new SQLite()), dbConnection_(NULL), file_(file) {
110 if (!FileSystem::fileExists(file)) {
111 string msg = "File '" + file + "' doesn't exist.";
112 throw FileNotFound(__FILE__, __LINE__, __func__, msg);
113 }
114
115 try {
116 dbConnection_ = &db_->connect(file);
117 } catch (const RelationalDBException& exception) {
118 throw IOException(
119 __FILE__, __LINE__, __func__, exception.errorMessage());
120 }
121}
#define __func__
std::string file_
The DSDB file containing the current database.
SQLite * db_
Handle to the database.
RelationalDBConnection * dbConnection_
Handle to the database connection.
std::string errorMessage() const
Definition Exception.cc:123
static bool fileExists(const std::string fileName)
virtual RelationalDBConnection & connect(const std::string &database, const std::string &login="", const std::string &password="", bool readOnly=false)
Definition SQLite.cc:69

References __func__, SQLite::connect(), db_, dbConnection_, Exception::errorMessage(), and FileSystem::fileExists().

Here is the call graph for this function:

◆ ~DSDBManager()

DSDBManager::~DSDBManager ( )
virtual

The Destructor.

Closes the database connection.

Definition at line 128 of file DSDBManager.cc.

128 {
130 delete db_;
131}
virtual void close(const RelationalDBConnection &connection)
Definition SQLite.cc:100

References SQLite::close(), db_, and dbConnection_.

Here is the call graph for this function:

Member Function Documentation

◆ addApplication()

RowID DSDBManager::addApplication ( const std::string &  path)

Adds a new application to the database.

Parameters
pathPath of the application test case.
Returns
RowID of the added application.
Exceptions
InvalidDatain case the application dir is not valid.

Definition at line 440 of file DSDBManager.cc.

440 {
441
442 RowID id = -1;
443 try {
446 std::string(
447 "INSERT INTO application(id, path) VALUES"
448 "(NULL,\"" +
449 // remove trailing file system separator from path
450 ((path.substr(path.length() - 1)
452 path.substr(0,path.length()-1) :
453 path) + "\");"));
454
457 } catch (const RelationalDBException& e) {
460 assert(false);
461 } catch (const Exception& e) {
464 assert(false);
465 }
466 return id;
467}
#define debugLog(text)
#define assert(condition)
int RowID
Type definition of row ID in relational databases.
Definition DBTypes.hh:37
static const std::string DIRECTORY_SEPARATOR
virtual int updateQuery(const std::string &queryString)=0
virtual RowID lastInsertRowID()=0

References assert, RelationalDBConnection::beginTransaction(), RelationalDBConnection::commit(), dbConnection_, debugLog, FileSystem::DIRECTORY_SEPARATOR, Exception::errorMessage(), RelationalDBConnection::lastInsertRowID(), RelationalDBConnection::rollback(), and RelationalDBConnection::updateQuery().

Referenced by main().

Here is the call graph for this function:

◆ addArchitecture()

RowID DSDBManager::addArchitecture ( const TTAMachine::Machine mom)

Adds machine architecture to the database.

In case an existing equal architecture is found in the DB, does not add a new one, but returns the ID of the old one.

Parameters
momMachine architecture to add.
Returns
RowID of the added architecture.

Definition at line 191 of file DSDBManager.cc.

191 {
192 RowID existing = architectureId(mom);
193 if (existing != ILLEGAL_ROW_ID) {
194 return existing;
195 }
196
197 string adf = "";
198 try {
200 ADFSerializer serializer;
201 serializer.setDestinationString(adf);
202 ObjectState* os = mom.saveState();
203 serializer.writeState(os);
204 delete os;
205 os = NULL;
206
207 // limit the size of the adf
208 if (adf.size() >= 5000000) {
210 __FILE__, __LINE__, __func__,
211 "ADF size too big.");
212 throw error;
213 }
214 } catch (const SerializerException& e) {
216 assert(false);
217 }
218
219 RowID id = -1;
220 try {
222 (boost::format(
223 "INSERT INTO architecture(id, adf_hash, adf_xml, "
224 "connection_count) VALUES"
225 "(NULL, \'%s\', \'%s\', %d);") %
226 mom.hash() % adf %
230 } catch (const RelationalDBException& e) {
233 assert(false);
234 } catch (const Exception& e) {
237 assert(false);
238 }
239
240 return id;
241}
#define ILLEGAL_ROW_ID
void writeState(const ObjectState *machineState)
RowID architectureId(const TTAMachine::Machine &mach) const
static int totalConnectionCount(const TTAMachine::Machine &mach)
TCEString hash() const
Definition Machine.cc:926
virtual ObjectState * saveState() const
Definition Machine.cc:686
void setDestinationString(std::string &destination)

References __func__, architectureId(), assert, RelationalDBConnection::beginTransaction(), RelationalDBConnection::commit(), dbConnection_, debugLog, Exception::errorMessage(), TTAMachine::Machine::hash(), ILLEGAL_ROW_ID, RelationalDBConnection::lastInsertRowID(), RelationalDBConnection::rollback(), TTAMachine::Machine::saveState(), XMLSerializer::setDestinationString(), MachineConnectivityCheck::totalConnectionCount(), RelationalDBConnection::updateQuery(), and ADFSerializer::writeState().

Referenced by Evaluate::createConfig(), MinimalOpSet::createConfig(), BlocksConnectICCmd::Do(), VLIWConnectICCmd::Do(), MinimizeMachine::evalNewConfigWithoutImplementation(), ADFCombiner::explore(), BlocksConnectIC::explore(), ComponentAdder::explore(), GrowMachine::explore(), ImplementationSelector::explore(), MinimalOpSet::explore(), RemoveUnconnectedComponents::explore(), VectorLSGenerator::explore(), VLIWConnectIC::explore(), ImmediateGenerator::explore(), SimpleICOptimizer::explore(), main(), MinimizeMachine::minimizeBuses(), MinimizeMachine::minimizeFunctionUnits(), MinimizeMachine::minimizeRegisterFiles(), CallExplorerPluginWindow::onRun(), ConnectionSweeper::removeAllConnections(), and ConnectionSweeper::removeLeastNecessaryConnections().

Here is the call graph for this function:

◆ addConfiguration()

RowID DSDBManager::addConfiguration ( const MachineConfiguration conf)

Adds a new machine configuration to the database.

In case a same configuration found in the DB, reuses that one.

Parameters
confConfiguration to add.
Returns
RowID of the new configuration.
Exceptions
KeyNotFoundif the configuration contained unknown IDs.

Definition at line 299 of file DSDBManager.cc.

299 {
300 RowID existing = configurationId(conf);
301 if (existing != ILLEGAL_ROW_ID) {
302 return existing;
303 }
304 RowID id = -1;
305 if (!hasArchitecture(conf.architectureID)) {
306 std::string msg =
307 "Architecture with ID " +
308 Conversion::toString(conf.architectureID) +
309 "not found.";
310 throw KeyNotFound(__FILE__, __LINE__, __func__, msg);
311 }
312
313 if (conf.hasImplementation && !hasImplementation(conf.implementationID)) {
314 std::string msg =
315 "Implementation with ID " +
316 Conversion::toString(conf.implementationID) +
317 " not found.";
318 throw KeyNotFound(__FILE__, __LINE__, __func__, msg);
319 }
320
321 try {
323 std::string implID;
324 if (conf.hasImplementation) {
325 implID = Conversion::toString(conf.implementationID);
326 } else {
327 implID = "NULL";
328 }
329
331 std::string(
332 "INSERT INTO machine_configuration("
333 "id, architecture, implementation) VALUES"
334 "(NULL,") +
335 Conversion::toString(conf.architectureID) + ", " +
336 implID + ");");
337
340 } catch (const RelationalDBException& e) {
343 assert(false);
344 } catch (const Exception& e) {
347 assert(false);
348 }
349
350 return id;
351}
static std::string toString(const T &source)
RowID configurationId(const MachineConfiguration &conf) const
bool hasArchitecture(RowID id) const
bool hasImplementation(RowID id) const

References __func__, DSDBManager::MachineConfiguration::architectureID, assert, RelationalDBConnection::beginTransaction(), RelationalDBConnection::commit(), configurationId(), dbConnection_, debugLog, Exception::errorMessage(), hasArchitecture(), DSDBManager::MachineConfiguration::hasImplementation, hasImplementation(), ILLEGAL_ROW_ID, DSDBManager::MachineConfiguration::implementationID, RelationalDBConnection::lastInsertRowID(), RelationalDBConnection::rollback(), Conversion::toString(), and RelationalDBConnection::updateQuery().

Referenced by DesignSpaceExplorer::addConfToDSDB(), BlocksConnectICCmd::Do(), VLIWConnectICCmd::Do(), MinimizeMachine::evalNewConfigWithoutImplementation(), ADFCombiner::explore(), BlocksConnectIC::explore(), ComponentAdder::explore(), GrowMachine::explore(), ImplementationSelector::explore(), RemoveUnconnectedComponents::explore(), VectorLSGenerator::explore(), VLIWConnectIC::explore(), ImmediateGenerator::explore(), SimpleICOptimizer::explore(), main(), MinimizeMachine::minimizeBuses(), CallExplorerPluginWindow::onRun(), ConnectionSweeper::removeAllConnections(), and ConnectionSweeper::removeLeastNecessaryConnections().

Here is the call graph for this function:

◆ addCycleCount()

void DSDBManager::addCycleCount ( RowID  application,
RowID  architecture,
ClockCycleCount  count 
)

Adds cycle count of an application on specific architecture.

Parameters
applicationRowID of the application.
architectureRowID of the machine architecture.
countCycle count

Definition at line 583 of file DSDBManager.cc.

584 {
585 if (!hasApplication(application)) {
586 const std::string error = (boost::format(
587 "DSDB file '%s' has no application with id '%d'."
588 "Can't add a cycle count.")
589 % file_ % application).str();
590 throw KeyNotFound(__FILE__, __LINE__, __func__, error);
591 }
593 const std::string error = (boost::format(
594 "DSDB file '%s' has no architecture with id '%d'."
595 "Can't add a cycle count.")
596 % file_ % architecture).str();
597 throw KeyNotFound(__FILE__, __LINE__, __func__, error);
598 }
599
600 std::string q =
601 "INSERT INTO cycle_count(application, architecture, cycles, "
602 "unschedulable) VALUES(" +
603 Conversion::toString(application) + ", " +
605 Conversion::toString(count) + ", 0);";
606
608}
TTAMachine::Machine * architecture(RowID id) const
bool hasApplication(RowID id) const

References __func__, architecture(), dbConnection_, file_, hasApplication(), hasArchitecture(), Conversion::toString(), and RelationalDBConnection::updateQuery().

Referenced by DesignSpaceExplorer::evaluate().

Here is the call graph for this function:

◆ addEnergyEstimate()

void DSDBManager::addEnergyEstimate ( RowID  application,
RowID  implementation,
double  energyEstimate 
)

Adds an energy estimate for application on specific implementation.

Parameters
applicationRowID of the application.
implementationRowID of the machine implementation.
energyApplication energy estimate as joules.

Definition at line 477 of file DSDBManager.cc.

478 {
479 if (!hasApplication(application)) {
480 const std::string error = (boost::format(
481 "DSDP file '%s' has no application with id '%d'."
482 "Can't add an energy estimate.")
483 % file_ % application).str();
484 throw KeyNotFound(__FILE__, __LINE__, __func__, error);
485 }
487 const std::string error = (boost::format(
488 "DSDP file '%s' has no implementation with id '%d'."
489 "Can't add an energy estimate.")
490 % file_ % implementation).str();
491 throw KeyNotFound(__FILE__, __LINE__, __func__, error);
492 }
493
494 std::string q =
495 "INSERT INTO energy_estimate ("
496 "application, implementation, energy_estimate) VALUES(" +
497 Conversion::toString(application) + ", " +
500
502}
IDF::MachineImplementation * implementation
the implementation definition of the estimated processor
double energyEstimate(RowID application, RowID implementation) const

References __func__, dbConnection_, energyEstimate(), file_, hasApplication(), hasImplementation(), implementation, Conversion::toString(), and RelationalDBConnection::updateQuery().

Referenced by DesignSpaceExplorer::evaluate().

Here is the call graph for this function:

◆ addImplementation()

RowID DSDBManager::addImplementation ( const IDF::MachineImplementation impl,
double  longestPathDelay,
CostEstimator::AreaInGates  area 
)

Adds machine implementation to the database.

Parameters
implMachine implementation to add.
longestPathDelayLongest path delay in seconds.
areaArea as number of gates.
Returns
RowID of the added architecture.

Definition at line 252 of file DSDBManager.cc.

254 {
255 RowID id = -1;
256 try {
258 IDF::IDFSerializer serializer;
259 string idf = "";
260 serializer.setDestinationString(idf);
261 ObjectState* is = impl.saveState();
262 serializer.writeState(is);
263 delete is;
264 is = NULL;
265
267 std::string(
268 "INSERT INTO implementation("
269 "id, idf_xml, lpd, area) VALUES"
270 "(NULL,\'" + idf + "\'," +
271 Conversion::toString(longestPathDelay) + ", "+
272 Conversion::toString(area) + ");"));
273
276 } catch (const RelationalDBException& e) {
279 assert(false);
280 } catch (const Exception& e) {
283 assert(false);
284 }
285
286 return id;
287}
virtual void writeState(const ObjectState *state)
virtual ObjectState * saveState() const

References assert, RelationalDBConnection::beginTransaction(), RelationalDBConnection::commit(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBConnection::lastInsertRowID(), RelationalDBConnection::rollback(), IDF::MachineImplementation::saveState(), XMLSerializer::setDestinationString(), Conversion::toString(), RelationalDBConnection::updateQuery(), and IDF::IDFSerializer::writeState().

Referenced by Evaluate::createConfig(), MinimalOpSet::createConfig(), DesignSpaceExplorer::createImplementation(), DesignSpaceExplorer::createImplementationAndStore(), ImplementationSelector::explore(), RemoveUnconnectedComponents::explore(), ImmediateGenerator::explore(), main(), MinimizeMachine::minimizeBuses(), and ComponentImplementationSelector::selectComponentsToConf().

Here is the call graph for this function:

◆ applicationCostEstimatesByConf()

std::vector< DSDBManager::ConfigurationCosts > DSDBManager::applicationCostEstimatesByConf ( Order  ordering = ORDER_BY_CONFIGURATION) const

Returs set of ConfigurationCosts ordered by the given ordering.

Parameters
orderingOrdering of the results.
Returns
ConfigurationCosts of all configurations in the DSDB ordered by the given option.

Definition at line 1524 of file DSDBManager.cc.

1524 {
1525
1526 RelationalDBQueryResult* appResult = NULL;
1527 try {
1528 appResult = dbConnection_->query("select * from application;");
1529 }
1530 catch (const Exception& e) {
1531 delete appResult;
1533 }
1534 vector<ApplicationData> appData;
1535
1536 while (appResult->hasNext()) {
1537 appResult->next();
1538 ApplicationData data;
1539 data.id = appResult->data(0).stringValue();
1540 data.name = appResult->data(1).stringValue();
1541 appData.push_back(data);
1542 }
1543 delete appResult;
1544 RelationalDBQueryResult* queryResult = NULL;
1545 try {
1546 queryResult = dbConnection_->query(
1547 "SELECT id from machine_configuration;");
1548 } catch (const Exception& e) {
1549 delete queryResult;
1551 }
1552
1553 vector<ConfigurationCosts> res;
1554
1555 set<ConfigurationCosts, idComparator> results;
1556
1557 while (queryResult->hasNext()) {
1558 queryResult->next();
1559 for (unsigned int i = 0; i < appData.size(); i++) {
1560 ConfigurationCosts cc;
1561 cc.configurationID = queryResult->data(0).integerValue();
1562 cc.application = appData.at(i).name;
1563 RelationalDBQueryResult* impResult = NULL;
1564
1565 try {
1566 impResult = dbConnection_->query(
1567 "select lpd, area from implementation, machine_configuration "
1568 "where machine_configuration.id=" + queryResult->data(0).stringValue() +
1569 " and machine_configuration.implementation = implementation.id limit 1;");
1570 } catch (const Exception& e) {
1571 delete impResult;
1573 }
1574 if (impResult->hasNext()) {
1575 impResult->next();
1576 cc.longestPathDelay = impResult->data(0).doubleValue();
1577 cc.area = impResult->data(1).doubleValue();
1578 } else {
1579 cc.longestPathDelay = 0.0;
1580 cc.area = 0.0;
1581 }
1582 RelationalDBQueryResult* energyResult = NULL;
1583 try {
1584 energyResult = dbConnection_->query(
1585 "select energy_estimate from energy_estimate, machine_configuration, application "
1586 "where application.id=" + appData[i].id + " and machine_configuration.id="
1587 + queryResult->data(0).stringValue() + " and machine_configuration.implementation="
1588 "energy_estimate.implementation and application.id=energy_estimate.application;");
1589 } catch (const Exception& e) {
1590 delete energyResult;
1592 }
1593 if (energyResult->hasNext()) {
1594 energyResult->next();
1595 cc.energyEstimate = energyResult->data(0).doubleValue();
1596 } else {
1597 cc.energyEstimate = 0.0;
1598 }
1599 delete energyResult;
1600
1601 RelationalDBQueryResult* cycleResult = NULL;
1602 try {
1603 cycleResult = dbConnection_->query(
1604 "select cycles from cycle_count, application, machine_configuration where application.id="
1605 + appData.at(i).id + " and machine_configuration.id=" +
1606 queryResult->data(0).stringValue() +
1607 " and machine_configuration.architecture=cycle_count.architecture and application.id="
1608 "cycle_count.application;");
1609 } catch (const Exception& e) {
1610 delete cycleResult;
1612 }
1613 if (cycleResult->hasNext()) {
1614 cycleResult->next();
1615 cc.cycleCount = cycleResult->data(0).integerValue();
1616 } else {
1617 cc.cycleCount = 0;
1618 }
1619 delete cycleResult;
1620
1621 results.insert(cc);
1622 }
1623 }
1624 delete queryResult;
1625 if (ordering == ORDER_BY_CYCLE_COUNT) {
1626 set<ConfigurationCosts, cycleComparator> cycleResults;
1627 for (set<ConfigurationCosts, idComparator>::iterator i = results.begin(); i != results.end(); i++) {
1628 cycleResults.insert(*i);
1629 }
1630
1631 for (set<ConfigurationCosts, cycleComparator>::iterator i = cycleResults.begin(); i != cycleResults.end(); i++) {
1632 res.push_back(*i);
1633 }
1634 return res;
1635 } else if (ordering == ORDER_BY_APPLICATION) {
1636 set<ConfigurationCosts, appComparator> appResults;
1637 for (set<ConfigurationCosts, idComparator>::iterator i = results.begin(); i != results.end(); i++) {
1638 appResults.insert(*i);
1639 }
1640 for (set<ConfigurationCosts, appComparator>::iterator i = appResults.begin(); i != appResults.end(); i++) {
1641 res.push_back(*i);
1642 }
1643 } else if (ordering == ORDER_BY_ENERGY_ESTIMATE) {
1644 set<ConfigurationCosts, energyComparator> energyResults;
1645 for (set<ConfigurationCosts, idComparator>::iterator i = results.begin(); i != results.end(); i++) {
1646 energyResults.insert(*i);
1647 }
1648 for (set<ConfigurationCosts, energyComparator>::iterator i = energyResults.begin(); i != energyResults.end(); i++) {
1649 res.push_back(*i);
1650 }
1651 } else {
1652 for (set<ConfigurationCosts, idComparator>::iterator i = results.begin(); i != results.end(); i++) {
1653 res.push_back(*i);
1654 }
1655 }
1656
1657 return res;
1658}
#define abortWithError(message)
virtual std::string stringValue() const
virtual double doubleValue() const
virtual int integerValue() const
virtual RelationalDBQueryResult * query(const std::string &queryString, bool init=true)=0
virtual const DataObject & data(std::size_t column) const =0

References abortWithError, DSDBManager::ConfigurationCosts::application, DSDBManager::ConfigurationCosts::area, DSDBManager::ConfigurationCosts::configurationID, DSDBManager::ConfigurationCosts::cycleCount, RelationalDBQueryResult::data(), dbConnection_, DataObject::doubleValue(), DSDBManager::ConfigurationCosts::energyEstimate, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), DSDBManager::ApplicationData::id, DataObject::integerValue(), DSDBManager::ConfigurationCosts::longestPathDelay, DSDBManager::ApplicationData::name, RelationalDBQueryResult::next(), ORDER_BY_APPLICATION, ORDER_BY_CYCLE_COUNT, ORDER_BY_ENERGY_ESTIMATE, RelationalDBConnection::query(), and DataObject::stringValue().

Referenced by main().

Here is the call graph for this function:

◆ applicationCount()

int DSDBManager::applicationCount ( ) const

Returns the number of applications in the dsdb.

Returns
The number of applications in the dsdb.

Definition at line 1666 of file DSDBManager.cc.

1666 {
1667
1668 // make the SQL query to obtain IDs.
1669 RelationalDBQueryResult* queryResult = NULL;
1670 try {
1671 std::string theQuery =
1672 "SELECT COUNT(id) FROM application;";
1673
1674 queryResult = dbConnection_->query(theQuery);
1675
1676 } catch (const Exception& e) {
1677 // should not throw in any case
1679 delete queryResult;
1680 assert(false);
1681 }
1682
1683 int result = 0;
1684 if (queryResult->hasNext()) {
1685 queryResult->next();
1686 result = queryResult->data(0).integerValue();
1687 }
1688 delete queryResult;
1689 return result;
1690}

References assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), DataObject::integerValue(), RelationalDBQueryResult::next(), and RelationalDBConnection::query().

Referenced by main().

Here is the call graph for this function:

◆ applicationIDs()

std::set< RowID > DSDBManager::applicationIDs ( ) const

Returns IDs of all applications in the database.

Returns
RowIDs of all applications in the database.

Definition at line 1381 of file DSDBManager.cc.

1381 {
1382
1383 // make the SQL query to obtain IDs.
1384 RelationalDBQueryResult* result = NULL;
1385 try {
1386 std::string theQuery =
1387 std::string("SELECT id FROM application;");
1388
1389 result = dbConnection_->query(theQuery);
1390
1391 } catch (const Exception& e) {
1392 // should not throw in any case
1394 delete result;
1395 assert(false);
1396 }
1397
1398 std::set<RowID> ids;
1399
1400 while (result->hasNext()) {
1401 result->next();
1402
1403 ids.insert(result->data("id").integerValue());
1404 }
1405
1406 delete result;
1407 return ids;
1408}

References assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), DataObject::integerValue(), RelationalDBQueryResult::next(), and RelationalDBConnection::query().

Referenced by ConnectionSweeper::averageWorsening(), MinimizeMachine::checkCycleCounts(), cycleCounts(), DesignSpaceExplorer::evaluate(), ConnectionSweeper::explore(), SimpleICOptimizer::explore(), FrequencySweepExplorer::fastEnough(), main(), MinimizeMachine::minimizeMachine(), and paretoSetConnectivityAndCycles().

Here is the call graph for this function:

◆ applicationPath()

std::string DSDBManager::applicationPath ( RowID  id) const

Returns path of an application with the given ID.

Parameters
idRowID of the application test case.
Returns
Path of the application test case.

Definition at line 947 of file DSDBManager.cc.

947 {
948 if (!hasApplication(id)) {
949 const std::string error = (boost::format(
950 "DSDP file '%s' has no application with id '%d'.")
951 % file_ % id).str();
952 throw KeyNotFound(__FILE__, __LINE__, __func__, error);
953 }
954
955 RelationalDBQueryResult* result = NULL;
956 try {
957 result = dbConnection_->query(
958 "SELECT path FROM application WHERE id=" +
959 Conversion::toString(id) + ";");
960 } catch (const Exception& e) {
962 }
963
964 if (!result->hasNext()) {
965 abortWithError("No rows in result!");
966 }
967
968 result->next();
969 const std::string path = result->data(0).stringValue();
970 delete result;
971 return path;
972}

References __func__, abortWithError, RelationalDBQueryResult::data(), dbConnection_, Exception::errorMessage(), file_, hasApplication(), RelationalDBQueryResult::hasNext(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), DataObject::stringValue(), and Conversion::toString().

Referenced by DesignSpaceExplorer::evaluate(), SimpleICOptimizer::explore(), FrequencySweepExplorer::fastEnough(), hasApplication(), main(), and MinimizeMachine::minimizeMachine().

Here is the call graph for this function:

◆ archConfigurationIDs()

std::set< RowID > DSDBManager::archConfigurationIDs ( RowID  architectureID) const

Returns IDs of all configurations referencing the given architecture.

Parameters
architectureIDID of the architecture to search configurations for.
Returns
Configuration IDs of a machine architecture.

Definition at line 1487 of file DSDBManager.cc.

1487 {
1488 // make the SQL query to obtain IDs.
1489 RelationalDBQueryResult* queryResult = NULL;
1490 try {
1491 std::string theQuery =
1492 "SELECT id FROM machine_configuration WHERE architecture=" +
1493 Conversion::toString(architectureID) + ";";
1494
1495 queryResult = dbConnection_->query(theQuery);
1496
1497 } catch (const Exception& e) {
1498 // should not throw in any case
1500 delete queryResult;
1501 assert(false);
1502 }
1503
1504 std::set<RowID> ids;
1505
1506 while (queryResult->hasNext()) {
1507 queryResult->next();
1508
1509 ids.insert(queryResult->data("id").integerValue());
1510 }
1511
1512 delete queryResult;
1513 return ids;
1514}

References assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), DataObject::integerValue(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), and Conversion::toString().

Here is the call graph for this function:

◆ architecture()

TTAMachine::Machine * DSDBManager::architecture ( RowID  id) const

Returns machine architecture with the given id.

Parameters
idRowID of the machine architecture.
Returns
Machine object model of the architecture.

Definition at line 807 of file DSDBManager.cc.

807 {
808 const std::string adf = architectureString(id);
809 ADFSerializer serializer;
810 serializer.setSourceString(adf);
811 ObjectState* state = serializer.readState();
813 mach->loadState(state);
814 delete state;
815
816 return mach;
817}
ObjectState * readState()
std::string architectureString(RowID id) const
virtual void loadState(const ObjectState *state)
Definition Machine.cc:728
void setSourceString(const std::string &source)

References architectureString(), TTAMachine::Machine::loadState(), ADFSerializer::readState(), and XMLSerializer::setSourceString().

Referenced by addCycleCount(), DesignSpaceExplorer::createImplementation(), DesignSpaceExplorer::createImplementationAndStore(), cycleCount(), BlocksConnectICCmd::Do(), VLIWConnectICCmd::Do(), DesignSpaceExplorer::evaluate(), ADFCombiner::explore(), BlocksConnectIC::explore(), ComponentAdder::explore(), GrowMachine::explore(), ImplementationSelector::explore(), MinimalOpSet::explore(), RemoveUnconnectedComponents::explore(), VectorLSGenerator::explore(), VLIWConnectIC::explore(), ConnectionSweeper::explore(), ImmediateGenerator::explore(), SimpleICOptimizer::explore(), hasCycleCount(), isUnschedulable(), MinimizeMachine::minimizeBuses(), MinimizeMachine::minimizeFunctionUnits(), MinimizeMachine::minimizeRegisterFiles(), CallExplorerPluginWindow::onRun(), ConnectionSweeper::removeLeastNecessaryConnections(), ComponentImplementationSelector::selectComponentsToConf(), setUnschedulable(), ConnectionSweeper::sweepBypasses(), and ConnectionSweeper::sweepRFs().

Here is the call graph for this function:

◆ architectureId()

RowID DSDBManager::architectureId ( const TTAMachine::Machine mach) const

Returns the row ID of the given architecture.

Searches for the architecture using its Machine::hash() string. e

Parameters
idRowID of the machine architecture. ILLEGAL_ROW_ID, if not found.
Returns
The architecture ID.

Definition at line 705 of file DSDBManager.cc.

705 {
706
707 RelationalDBQueryResult* result = NULL;
708 try {
709 result = dbConnection_->query(
710 TCEString("SELECT id FROM architecture WHERE adf_hash = \'") +
711 mach.hash() + "\';");
712 } catch (const Exception& e) {
713 delete result;
715 }
716
717 if (!result->hasNext()) {
718 delete result;
719 return ILLEGAL_ROW_ID;
720 }
721
722 result->next();
723 const DataObject& data = result->data(0);
724
725 int id = data.integerValue();
726 delete result;
727 return id;
728}

References abortWithError, RelationalDBQueryResult::data(), dbConnection_, Exception::errorMessage(), TTAMachine::Machine::hash(), RelationalDBQueryResult::hasNext(), ILLEGAL_ROW_ID, DataObject::integerValue(), RelationalDBQueryResult::next(), and RelationalDBConnection::query().

Referenced by addArchitecture().

Here is the call graph for this function:

◆ architectureIDs()

std::set< RowID > DSDBManager::architectureIDs ( ) const

Returns IDs of all machine architectures in the database.

Returns
RowIDs of all architectures in the database.

Definition at line 1416 of file DSDBManager.cc.

1416 {
1417
1418 // make the SQL query to obtain IDs.
1419 RelationalDBQueryResult* queryResult = NULL;
1420 try {
1421 std::string theQuery =
1422 std::string("SELECT id FROM architecture;");
1423
1424 queryResult = dbConnection_->query(theQuery);
1425
1426 } catch (const Exception& e) {
1427 // should not throw in any case
1429 delete queryResult;
1430 assert(false);
1431 }
1432
1433 std::set<RowID> ids;
1434
1435 while (queryResult->hasNext()) {
1436 queryResult->next();
1437
1438 ids.insert(queryResult->data("id").integerValue());
1439 }
1440
1441 delete queryResult;
1442 return ids;
1443}

References assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), DataObject::integerValue(), RelationalDBQueryResult::next(), and RelationalDBConnection::query().

Here is the call graph for this function:

◆ architectureString()

std::string DSDBManager::architectureString ( RowID  id) const
private

Returns the machine architecture of the given id as string.

Parameters
idRowID of the machine architecture.
Returns
The architecture as string.

Definition at line 665 of file DSDBManager.cc.

665 {
666 if (!hasArchitecture(id)) {
667 const std::string error = (boost::format(
668 "DSDP file '%s' has no architecture with id '%d'.")
669 % file_ % id).str();
670 throw KeyNotFound(__FILE__, __LINE__, __func__, error);
671 }
672
673 RelationalDBQueryResult* result = NULL;
674 try {
675 result = dbConnection_->query(
676 "SELECT adf_xml FROM architecture WHERE id=" +
677 Conversion::toString(id) + ";");
678 } catch (const Exception& e) {
679 delete result;
681 }
682
683 if (!result->hasNext()) {
684 delete result;
685 abortWithError("No rows in result!");
686 }
687
688 result->next();
689 const DataObject& adfData = result->data(0);
690
691 std::string arch = adfData.stringValue();
692 delete result;
693 return arch;
694}

References __func__, abortWithError, RelationalDBQueryResult::data(), dbConnection_, Exception::errorMessage(), file_, hasArchitecture(), RelationalDBQueryResult::hasNext(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), DataObject::stringValue(), and Conversion::toString().

Referenced by architecture(), and writeArchitectureToFile().

Here is the call graph for this function:

◆ areaEstimate()

AreaInGates DSDBManager::areaEstimate ( RowID  implementation) const

Returns area estimate for an specific implementation.

Parameters
implementationRowID of the machine implementation.
Returns
Area estimate in gates.
Exceptions
KeyNotFoundIf the implementation was not found in DB.

Definition at line 1343 of file DSDBManager.cc.

1343 {
1345 const std::string error = (boost::format(
1346 "DSDP file '%s' has no implementation with id '%d'.")
1347 % file_ % implementation).str();
1348 throw KeyNotFound(__FILE__, __LINE__, __func__, error);
1349 }
1350
1351 RelationalDBQueryResult* result = NULL;
1352
1353 try {
1354 result = dbConnection_->query(
1355 "SELECT area FROM implementation WHERE id=" +
1357
1358 } catch (const Exception& e) {
1359 delete result;
1361 }
1362
1363 if (!result->hasNext()) {
1364 delete result;
1365 abortWithError("No rows in result!");
1366 }
1367
1368 result->next();
1369 const DataObject& data = result->data(0);
1370 AreaInGates area = data.integerValue();
1371 delete result;
1372 return area;
1373}
double AreaInGates
type for area values in equivalent gates

References __func__, abortWithError, RelationalDBQueryResult::data(), dbConnection_, Exception::errorMessage(), file_, hasImplementation(), RelationalDBQueryResult::hasNext(), implementation, DataObject::integerValue(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), and Conversion::toString().

Referenced by setAreaEstimate().

Here is the call graph for this function:

◆ configuration()

DSDBManager::MachineConfiguration DSDBManager::configuration ( RowID  id) const

Returns machine configuration with the give ID.

Parameters
idID of the machine configuration to return.
Returns
Machine configuration with the give ID.
Exceptions
KeyNotFoundIf a configuration with the given ID was not found.

Definition at line 361 of file DSDBManager.cc.

361 {
362 if (!hasConfiguration(id)) {
363 const std::string error = (boost::format(
364 "DSDP file '%s' has no configuration with id '%d'.")
365 % file_ % id).str();
366 throw KeyNotFound(__FILE__, __LINE__, __func__, error);
367 }
368
369 RelationalDBQueryResult* result = NULL;
370
371 try {
372 result = dbConnection_->query(
373 "SELECT architecture, implementation FROM "
374 "machine_configuration WHERE id=" +
375 Conversion::toString(id) + ";");
376
377 } catch (const Exception& e) {
379 }
380
381 if (!result->hasNext()) {
382 abortWithError("No rows in result!");
383 }
384
385 result->next();
386 MachineConfiguration conf;
387 conf.architectureID = result->data(0).integerValue();
388 if (result->data(1).isNull()) {
389 conf.hasImplementation = false;
390 conf.implementationID = -1;
391 } else {
392 conf.hasImplementation = true;
393 conf.implementationID = result->data(1).integerValue();
394 }
395 delete result;
396 return conf;
397}
bool hasConfiguration(RowID id) const
virtual bool isNull() const

References __func__, abortWithError, DSDBManager::MachineConfiguration::architectureID, RelationalDBQueryResult::data(), dbConnection_, Exception::errorMessage(), file_, hasConfiguration(), DSDBManager::MachineConfiguration::hasImplementation, RelationalDBQueryResult::hasNext(), DSDBManager::MachineConfiguration::implementationID, DataObject::integerValue(), DataObject::isNull(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), and Conversion::toString().

Referenced by ConnectionSweeper::averageWorsening(), FrequencySweepExplorer::callPlugin(), BlocksConnectIC::explore(), ComponentAdder::explore(), Evaluate::explore(), GrowMachine::explore(), ImplementationSelector::explore(), MinimalOpSet::explore(), RemoveUnconnectedComponents::explore(), VectorLSGenerator::explore(), VLIWConnectIC::explore(), ConnectionSweeper::explore(), ImmediateGenerator::explore(), SimpleICOptimizer::explore(), FrequencySweepExplorer::fastEnough(), main(), MinimizeMachine::minimizeBuses(), MinimizeMachine::minimizeFunctionUnits(), MinimizeMachine::minimizeMachine(), MinimizeMachine::minimizeRegisterFiles(), ConnectionSweeper::removeAllConnections(), ConnectionSweeper::removeLeastNecessaryConnections(), ConnectionSweeper::sweepBypasses(), and ConnectionSweeper::sweepRFs().

Here is the call graph for this function:

◆ configurationId()

RowID DSDBManager::configurationId ( const MachineConfiguration conf) const

Returns the row ID of the given configuration.

Parameters
idRowID of the configuration. ILLEGAL_ROW_ID, if not found.
Returns
The configuration ID.

Definition at line 762 of file DSDBManager.cc.

762 {
763
764 RelationalDBQueryResult* result = NULL;
765 try {
766 TCEString queryStr;
767 if (conf.hasImplementation) {
768 queryStr =
769 (boost::format(
770 "SELECT id FROM machine_configuration "
771 "WHERE architecture = %d AND implementation = %d;")
772 % conf.architectureID % conf.implementationID).str();
773 } else {
774 queryStr =
775 (boost::format(
776 "SELECT id FROM machine_configuration "
777 "WHERE architecture = %d AND implementation IS NULL;")
778 % conf.architectureID).str();
779 }
780 result = dbConnection_->query(queryStr);
781 } catch (const Exception& e) {
782 delete result;
784 }
785
786 if (!result->hasNext()) {
787 delete result;
788 return ILLEGAL_ROW_ID;
789 }
790
791 result->next();
792 const DataObject& data = result->data(0);
793
794 int id = data.integerValue();
795 delete result;
796 return id;
797}

References abortWithError, DSDBManager::MachineConfiguration::architectureID, RelationalDBQueryResult::data(), dbConnection_, Exception::errorMessage(), DSDBManager::MachineConfiguration::hasImplementation, RelationalDBQueryResult::hasNext(), ILLEGAL_ROW_ID, DSDBManager::MachineConfiguration::implementationID, DataObject::integerValue(), RelationalDBQueryResult::next(), and RelationalDBConnection::query().

Referenced by addConfiguration().

Here is the call graph for this function:

◆ configurationIDs()

std::set< RowID > DSDBManager::configurationIDs ( ) const

Returns IDs of all machine configurations in the database.

Returns
RowIDs of all configurations in the database.

Definition at line 1451 of file DSDBManager.cc.

1451 {
1452
1453 // make the SQL query to obtain IDs.
1454 RelationalDBQueryResult* queryResult = NULL;
1455 try {
1456 std::string theQuery =
1457 std::string("SELECT id FROM machine_configuration;");
1458
1459 queryResult = dbConnection_->query(theQuery);
1460
1461 } catch (const Exception& e) {
1462 // should not throw in any case
1464 delete queryResult;
1465 assert(false);
1466 }
1467
1468 std::set<RowID> ids;
1469
1470 while (queryResult->hasNext()) {
1471 queryResult->next();
1472
1473 ids.insert(queryResult->data("id").integerValue());
1474 }
1475
1476 delete queryResult;
1477 return ids;
1478}

References assert, RelationalDBQueryResult::data(), dbConnection_, debugLog, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), DataObject::integerValue(), RelationalDBQueryResult::next(), and RelationalDBConnection::query().

Referenced by main().

Here is the call graph for this function:

◆ createNew()

DSDBManager * DSDBManager::createNew ( const std::string &  file)
static

Creates a new DSDB file, and a DSDB manager for it.

Parameters
fileFull path to the DSDB file to create.
Returns
An instance of DSDBManager with the newly created empty DSDB.
Exceptions
IOExceptionif the DSDB file creation was not succesful.

Definition at line 141 of file DSDBManager.cc.

141 {
142 if (!FileSystem::fileIsCreatable(file)) {
143 const string procName = "DSDBManager::createNew";
144 throw IOException(__FILE__, __LINE__, procName);
145 }
146
147 try {
148 SQLite db;
149 RelationalDBConnection& connection = db.connect(file);
150
151 // create tables to the database
152 connection.DDLQuery(CREATE_ARCH_TABLE);
153 connection.DDLQuery(CREATE_IMPL_TABLE);
158
159 db.close(connection);
160 } catch (const Exception& e) {
161 debugLog(
162 std::string("Initialization of DSDB failed. ") +
163 e.errorMessage());
164 std::cerr << e.errorMessage() << std::endl;
165 assert(false);
166 }
167
168 return new DSDBManager(file);
169}
const string CREATE_CYCLE_COUNT_TABLE
const string CREATE_APPLICATION_TABLE
const string CREATE_MACHINE_CFG_TABLE
const string CREATE_ENERGY_ESTIMATE_TABLE
const string CREATE_ARCH_TABLE
const string CREATE_IMPL_TABLE
static bool fileIsCreatable(const std::string fileName)
virtual void DDLQuery(const std::string &queryString)=0

References assert, SQLite::close(), SQLite::connect(), CREATE_APPLICATION_TABLE, CREATE_ARCH_TABLE, CREATE_CYCLE_COUNT_TABLE, CREATE_ENERGY_ESTIMATE_TABLE, CREATE_IMPL_TABLE, CREATE_MACHINE_CFG_TABLE, RelationalDBConnection::DDLQuery(), debugLog, Exception::errorMessage(), and FileSystem::fileIsCreatable().

Referenced by BlocksConnectICCmd::Do(), VLIWConnectICCmd::Do(), loadDSDB(), and CallExplorerPluginWindow::onRun().

Here is the call graph for this function:

◆ cycleCount()

ClockCycleCount DSDBManager::cycleCount ( RowID  application,
RowID  architecture 
) const

Returns cycle count for an application on specific architecture.

Parameters
applicationRowID of the application.
architectureRowID of the architecture.
Returns
Cycle count in cycles.
Exceptions
KeyNotFoundIf cycle count was not found in DB.

Definition at line 1261 of file DSDBManager.cc.

1261 {
1262 if (!hasCycleCount(application, architecture)) {
1263 const std::string error = (boost::format(
1264 "No cycle count found for application in DSDB file '%s'")
1265 % file_).str();
1266 throw KeyNotFound(__FILE__, __LINE__, __func__, error);
1267 }
1268
1269 RelationalDBQueryResult* result = NULL;
1270
1271 try {
1272 result = dbConnection_->query(
1273 "SELECT cycles FROM cycle_count WHERE application=" +
1274 Conversion::toString(application) + " AND architecture=" +
1276
1277 } catch (const Exception& e) {
1278 delete result;
1280 }
1281
1282 if (!result->hasNext()) {
1283 delete result;
1284 abortWithError("No rows in result!");
1285 }
1286
1287 result->next();
1288 const DataObject& data = result->data(0);
1289 ClockCycleCount count = static_cast<ClockCycleCount>(data.doubleValue());
1290 delete result;
1291 result = NULL;
1292 return count;
1293}
CycleCount ClockCycleCount
Alias for ClockCycleCount.
bool hasCycleCount(RowID application, RowID architecture) const

References __func__, abortWithError, architecture(), RelationalDBQueryResult::data(), dbConnection_, DataObject::doubleValue(), Exception::errorMessage(), file_, hasCycleCount(), RelationalDBQueryResult::hasNext(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), and Conversion::toString().

Referenced by ConnectionSweeper::averageWorsening(), cycleCounts(), ConnectionSweeper::explore(), and FrequencySweepExplorer::fastEnough().

Here is the call graph for this function:

◆ cycleCounts()

std::vector< ClockCycleCount > DSDBManager::cycleCounts ( const MachineConfiguration conf) const

Returns the cycle counts for the given configuration for all applications, if known.

Returns
The cycle counts ordered by the application order. Empty if at least one application missed a cycle count.

Definition at line 738 of file DSDBManager.cc.

738 {
739
740 std::vector<ClockCycleCount> ccs;
741 std::set<RowID> appIds = applicationIDs();
742 for (std::set<RowID>::const_iterator appI = appIds.begin();
743 appI != appIds.end(); ++appI) {
744 RowID appID = *appI;
745 if (!hasCycleCount(appID, conf.architectureID)) {
746 ccs.clear();
747 return ccs;
748 }
749 ccs.push_back(cycleCount(appID, conf.architectureID));
750 }
751 return ccs;
752}
ClockCycleCount cycleCount(RowID application, RowID architecture) const
std::set< RowID > applicationIDs() const

References applicationIDs(), DSDBManager::MachineConfiguration::architectureID, cycleCount(), and hasCycleCount().

Referenced by GrowMachine::explore(), and Evaluate::printEstimates().

Here is the call graph for this function:

◆ dsdbFile()

std::string DSDBManager::dsdbFile ( ) const

Returns absolute path of the database file.

Returns
Database file path.

Definition at line 177 of file DSDBManager.cc.

177 {
179}
static std::string absolutePathOf(const std::string &pathName)

References FileSystem::absolutePathOf(), and file_.

Here is the call graph for this function:

◆ energyEstimate()

double DSDBManager::energyEstimate ( RowID  application,
RowID  implementation 
) const

Returns energy estimate for an application on specific implementation.

Parameters
applicationRowID of the application.
implementationRowID of the implementation.
Returns
Energy estimate in joules.
Exceptions
KeyNotFoundIf an energy estimate was not found.

Definition at line 1187 of file DSDBManager.cc.

1187 {
1188 if (!hasEnergyEstimate(application, implementation)) {
1189 const std::string error = (boost::format(
1190 "DSDP file '%s' has no energy estimate with an application id "
1191 "'%d', and with an implementation id '%d'.")
1192 % file_ % application % implementation).str();
1193 throw KeyNotFound(__FILE__, __LINE__, __func__, error);
1194 }
1195
1196 RelationalDBQueryResult* result = NULL;
1197
1198 try {
1199 result = dbConnection_->query(
1200 "SELECT energy_estimate FROM energy_estimate WHERE application=" +
1201 Conversion::toString(application) + " AND implementation=" +
1203
1204 } catch (const Exception& e) {
1206 }
1207
1208 if (!result->hasNext()) {
1209 abortWithError("No rows in result!");
1210 }
1211
1212 result->next();
1213 const DataObject& data = result->data(0);
1214 double energyEstimate = data.doubleValue();
1215 delete result;
1216 return energyEstimate;
1217}
bool hasEnergyEstimate(RowID application, RowID implementation) const

References __func__, abortWithError, RelationalDBQueryResult::data(), dbConnection_, DataObject::doubleValue(), energyEstimate(), Exception::errorMessage(), file_, hasEnergyEstimate(), RelationalDBQueryResult::hasNext(), implementation, RelationalDBQueryResult::next(), RelationalDBConnection::query(), and Conversion::toString().

Referenced by addEnergyEstimate(), and energyEstimate().

Here is the call graph for this function:

◆ hasApplication() [1/2]

bool DSDBManager::hasApplication ( const std::string &  applicationPath) const

Checks if the database contains application with the given application path.

Parameters
applicationPathPath of the application.
Returns
True, if an application with the given path exists in the DB.

Definition at line 1041 of file DSDBManager.cc.

1041 {
1042
1043 RelationalDBQueryResult* result = NULL;
1044 try {
1045 result = dbConnection_->query(
1046 "SELECT * FROM application WHERE path='" +
1047 // remove trailing file system separator from path
1048 ((applicationPath.substr(applicationPath.length() - 1)
1050 applicationPath.substr(0,applicationPath.length()-1) :
1051 applicationPath) + "';");
1052 } catch (Exception&) {
1053 assert(false);
1054 }
1055
1056 if (result->hasNext()) {
1057 delete result;
1058 return true;
1059 } else {
1060 delete result;
1061 return false;
1062 }
1063}
std::string applicationPath(RowID id) const

References applicationPath(), assert, dbConnection_, FileSystem::DIRECTORY_SEPARATOR, RelationalDBQueryResult::hasNext(), and RelationalDBConnection::query().

Here is the call graph for this function:

◆ hasApplication() [2/2]

bool DSDBManager::hasApplication ( RowID  id) const

Checks if the database contains application with the given RowID.

Parameters
idID of the application.
Returns
True, if an application with the given ID exists in the DB.

Definition at line 1013 of file DSDBManager.cc.

1013 {
1014
1015 RelationalDBQueryResult* result = NULL;
1016
1017 try {
1018 result = dbConnection_->query(
1019 "SELECT path FROM application WHERE id=" +
1020 Conversion::toString(id) + ";");
1021 } catch (Exception&) {
1022 assert(false);
1023 }
1024
1025 if (result->hasNext()) {
1026 delete result;
1027 return true;
1028 } else {
1029 delete result;
1030 return false;
1031 }
1032}

References assert, dbConnection_, RelationalDBQueryResult::hasNext(), RelationalDBConnection::query(), and Conversion::toString().

Referenced by addCycleCount(), addEnergyEstimate(), applicationPath(), main(), removeApplication(), and setUnschedulable().

Here is the call graph for this function:

◆ hasArchitecture()

bool DSDBManager::hasArchitecture ( RowID  id) const

Checks if the database contains architecture with the given RowID.

Parameters
idID of the architecture.
Returns
True, if an architecture with the given ID exists in the DB.

Definition at line 1101 of file DSDBManager.cc.

1101 {
1102
1103 RelationalDBQueryResult* result = NULL;
1104
1105 try {
1106 result = dbConnection_->query(
1107 "SELECT id FROM architecture WHERE id=" +
1108 Conversion::toString(id) + ";");
1109 } catch (Exception&) {
1110 assert(false);
1111 }
1112
1113 if (result->hasNext()) {
1114 delete result;
1115 return true;
1116 } else {
1117 delete result;
1118 return false;
1119 }
1120}

References assert, dbConnection_, RelationalDBQueryResult::hasNext(), RelationalDBConnection::query(), and Conversion::toString().

Referenced by addConfiguration(), addCycleCount(), architectureString(), and setUnschedulable().

Here is the call graph for this function:

◆ hasConfiguration()

bool DSDBManager::hasConfiguration ( RowID  id) const

Checks if the database contains configuration with the given RowID.

Parameters
idID of the configuration.
Returns
True, if a configuration with the given ID exists in the DB.

Definition at line 1129 of file DSDBManager.cc.

1129 {
1130
1131 RelationalDBQueryResult* result = NULL;
1132
1133 try {
1134 result = dbConnection_->query(
1135 "SELECT id FROM machine_configuration WHERE id=" +
1136 Conversion::toString(id) + ";");
1137 } catch (Exception&) {
1138 assert(false);
1139 }
1140
1141 if (result->hasNext()) {
1142 delete result;
1143 return true;
1144 } else {
1145 delete result;
1146 return false;
1147 }
1148}

References assert, dbConnection_, RelationalDBQueryResult::hasNext(), RelationalDBConnection::query(), and Conversion::toString().

Referenced by configuration(), main(), and removeConfiguration().

Here is the call graph for this function:

◆ hasCycleCount()

bool DSDBManager::hasCycleCount ( RowID  application,
RowID  architecture 
) const

Checks if cycle count exists for an application and architecture with given IDs.

Parameters
applicationID of the application.
architectureID of the machine architecture
Returns
True, if a cycle count exists in the DB.

Definition at line 1228 of file DSDBManager.cc.

1228 {
1229
1230 RelationalDBQueryResult* result = NULL;
1231
1232 try {
1233 result = dbConnection_->query(
1234 "SELECT cycles FROM cycle_count WHERE cycles IS NOT NULL AND "
1235 " application=" +
1236 Conversion::toString(application) + " AND " +
1237 "architecture=" + Conversion::toString(architecture) + ";");
1238 } catch (Exception&) {
1239 assert(false);
1240 }
1241
1242 if (result->hasNext()) {
1243 delete result;
1244 return true;
1245 } else {
1246 delete result;
1247 return false;
1248 }
1249}

References architecture(), assert, dbConnection_, RelationalDBQueryResult::hasNext(), RelationalDBConnection::query(), and Conversion::toString().

Referenced by MinimizeMachine::checkCycleCounts(), cycleCount(), cycleCounts(), DesignSpaceExplorer::evaluate(), and ConnectionSweeper::explore().

Here is the call graph for this function:

◆ hasEnergyEstimate()

bool DSDBManager::hasEnergyEstimate ( RowID  application,
RowID  implementation 
) const

Checks if energy estimate exists for an application and implementation with given IDs.

Parameters
applicationID of the application.
implementationID of the machine implementation.
Returns
True, if an energy estimate exists in the DB.

Definition at line 983 of file DSDBManager.cc.

984 {
985
986 RelationalDBQueryResult* result = NULL;
987
988 try {
989 result = dbConnection_->query(
990 "SELECT energy_estimate FROM energy_estimate WHERE application=" +
991 Conversion::toString(application) + " AND " +
992 "implementation=" + Conversion::toString(implementation) + ";");
993 } catch (Exception&) {
994 assert(false);
995 }
996
997 if (result->hasNext()) {
998 delete result;
999 return true;
1000 } else {
1001 delete result;
1002 return false;
1003 }
1004}

References assert, dbConnection_, RelationalDBQueryResult::hasNext(), implementation, RelationalDBConnection::query(), and Conversion::toString().

Referenced by energyEstimate().

Here is the call graph for this function:

◆ hasImplementation()

bool DSDBManager::hasImplementation ( RowID  id) const

Checks if the database contains implementation with the given RowID.

Parameters
idID of the implementation
Returns
True, if implementation with the given ID exists in the DB.

Definition at line 1157 of file DSDBManager.cc.

1157 {
1158
1159 RelationalDBQueryResult* result = NULL;
1160
1161 try {
1162 result = dbConnection_->query(
1163 "SELECT id FROM implementation WHERE id=" +
1164 Conversion::toString(id) + ";");
1165 } catch (Exception&) {
1166 assert(false);
1167 }
1168
1169 if (result->hasNext()) {
1170 delete result;
1171 return true;
1172 } else {
1173 delete result;
1174 return false;
1175 }
1176}

References assert, dbConnection_, RelationalDBQueryResult::hasNext(), RelationalDBConnection::query(), and Conversion::toString().

Referenced by addConfiguration(), addEnergyEstimate(), areaEstimate(), implementationString(), longestPathDelayEstimate(), setAreaEstimate(), and setLongestPathDelayEstimate().

Here is the call graph for this function:

◆ implementation()

IDF::MachineImplementation * DSDBManager::implementation ( RowID  id) const

Returns machine implementation with the given id.

Parameters
idRowID of the machine implementation.
Returns
MachineImplementation object containing the implementation.

Definition at line 887 of file DSDBManager.cc.

887 {
888 const std::string idf = implementationString(id);
889 IDF::IDFSerializer serializer;
890 serializer.setSourceString(idf);
891 ObjectState* state = serializer.readState();
893 impl->loadState(state);
894 delete state;
895
896 return impl;
897}
std::string implementationString(RowID id) const
virtual ObjectState * readState()
virtual void loadState(const ObjectState *state)

References implementationString(), IDF::MachineImplementation::loadState(), IDF::IDFSerializer::readState(), and XMLSerializer::setSourceString().

Referenced by DesignSpaceExplorer::evaluate(), RemoveUnconnectedComponents::explore(), ImmediateGenerator::explore(), and MinimizeMachine::minimizeBuses().

Here is the call graph for this function:

◆ implementationString()

std::string DSDBManager::implementationString ( RowID  id) const
private

Returns machine implementation with the given id as string.

Parameters
idRowID of the machine implementation.
Returns
The implementation as string.

Definition at line 847 of file DSDBManager.cc.

847 {
848 if (!hasImplementation(id)) {
849 const std::string error = (boost::format(
850 "DSDP file '%s' has no implementation with id '%d'.")
851 % file_ % id).str();
852 throw KeyNotFound(__FILE__, __LINE__, __func__, error);
853 }
854
855 RelationalDBQueryResult* result = NULL;
856
857 try {
858 result = dbConnection_->query(
859 "SELECT idf_xml FROM implementation WHERE id=" +
860 Conversion::toString(id) + ";");
861
862 } catch (const Exception& e) {
863 delete result;
865 }
866
867 if (!result->hasNext()) {
868 delete result;
869 abortWithError("No rows in result!");
870 }
871
872 result->next();
873 const DataObject& idfData = result->data(0);
874
875 std::string implString = idfData.stringValue();
876 delete result;
877 return implString;
878}

References __func__, abortWithError, RelationalDBQueryResult::data(), dbConnection_, Exception::errorMessage(), file_, hasImplementation(), RelationalDBQueryResult::hasNext(), RelationalDBQueryResult::next(), RelationalDBConnection::query(), DataObject::stringValue(), and Conversion::toString().

Referenced by implementation(), and writeImplementationToFile().

Here is the call graph for this function:

◆ isUnschedulable()

bool DSDBManager::isUnschedulable ( RowID  application,
RowID  architecture 
) const

Checks if the application has been scheduled for the given architecture previously unsuccessfully.

Parameters
applicationRowID of the application.
architectureRowID of the machine architecture.
Returns
True, if it's known that the application is unschedulable for the given architecture.

Definition at line 550 of file DSDBManager.cc.

551 {
552
553 RelationalDBQueryResult* result = NULL;
554
555 try {
556 result = dbConnection_->query(
557 "SELECT unschedulable FROM cycle_count WHERE application=" +
558 Conversion::toString(application) + " AND " +
559 "architecture=" + Conversion::toString(architecture) + " "
560 "AND unschedulable = 1;");
561 } catch (Exception& e) {
563 }
564
565 if (result->hasNext()) {
566 delete result;
567 return true;
568 } else {
569 delete result;
570 return false;
571 }
572}

References abortWithError, architecture(), dbConnection_, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), RelationalDBConnection::query(), and Conversion::toString().

Referenced by DesignSpaceExplorer::evaluate().

Here is the call graph for this function:

◆ longestPathDelayEstimate()

double DSDBManager::longestPathDelayEstimate ( RowID  implementation) const

Returns longest path delay estimate for an specific implementation.

Parameters
implementationRowID of the machine implementation.
Returns
Longest path delay in nanoseconds.
Exceptions
KeyNotFoundIf the implmentation was not found in DB.

Definition at line 1303 of file DSDBManager.cc.

1303 {
1305 const std::string error = (boost::format(
1306 "DSDP file '%s' has no implementation with id '%d'.")
1307 % file_ % implementation).str();
1308 throw KeyNotFound(__FILE__, __LINE__, __func__, error);
1309 }
1310
1311 RelationalDBQueryResult* result = NULL;
1312
1313 try {
1314 result = dbConnection_->query(
1315 "SELECT lpd FROM implementation WHERE id=" +
1317
1318 } catch (const Exception& e) {
1319 delete result;
1321 }
1322
1323 if (!result->hasNext()) {
1324 delete result;
1325 abortWithError("No rows in result!");
1326 }
1327
1328 result->next();
1329 const DataObject& data = result->data(0);
1330 double delay = data.doubleValue();
1331 delete result;
1332 return delay;
1333}

References __func__, abortWithError, RelationalDBQueryResult::data(), dbConnection_, DataObject::doubleValue(), Exception::errorMessage(), file_, hasImplementation(), RelationalDBQueryResult::hasNext(), implementation, RelationalDBQueryResult::next(), RelationalDBConnection::query(), and Conversion::toString().

Here is the call graph for this function:

◆ paretoSetConnectivityAndCycles()

DSDBManager::ParetoSetConnectivityAndCycles DSDBManager::paretoSetConnectivityAndCycles ( RowID  application = ILLEGAL_ROW_ID) const

Finds a pareto set of configurations using the connection count and the cycle count of the given application as criteria.

Definition at line 1697 of file DSDBManager.cc.

1697 {
1698
1699 std::set<RowID> ids;
1700 if (application == ILLEGAL_ROW_ID) {
1701 ids = applicationIDs();
1702 } else {
1703 ids.insert(application);
1704 }
1705
1706 //build the "GROUP BY" clause to include all requested applications
1707 std::string appsGroup = "(";
1708 for (auto const& e : ids) {
1709 appsGroup += std::to_string(e);
1710 appsGroup += ",";
1711 }
1712 appsGroup[appsGroup.size() - 1] = ')'; //replace last comma with closing brace
1713
1715
1716 // make the SQL query to obtain IDs.
1717 RelationalDBQueryResult* queryResult = NULL;
1718 TCEString theQuery;
1719 try {
1720 theQuery =
1721 (boost::format(
1722 "SELECT machine_configuration.id AS id, CAST(AVG(connection_count) as INT), "
1723 " cycles "
1724 "FROM application, architecture, machine_configuration, "
1725 " cycle_count "
1726 "WHERE machine_configuration.architecture = "
1727 " cycle_count.architecture AND "
1728 " cycle_count.unschedulable = 0 AND "
1729 " cycle_count.cycles IS NOT NULL AND "
1730 " cycle_count.application IN %s AND "
1731 " architecture.id = cycle_count.architecture "
1732 "GROUP BY machine_configuration.id;") %
1733 appsGroup).str();
1734
1735 queryResult = dbConnection_->query(theQuery);
1736
1737 } catch (const Exception& e) {
1738 // should not throw in any case
1739 delete queryResult;
1740 abortWithError(TCEString("FAIL: ") + theQuery + ": " + e.errorMessage());
1741 }
1742
1743 while (queryResult->hasNext()) {
1744 queryResult->next();
1746 boost::make_tuple(
1747 queryResult->data(0).integerValue(),
1748 queryResult->data(1).integerValue(),
1749 queryResult->data(2).integerValue());
1750 // go through the old pareto sets and remove those that are
1751 // dominated by the new point, in case at least one point that
1752 // dominates this point is found, do not add the point
1753 bool dominated = false;
1754 for (ParetoSetConnectivityAndCycles::iterator i = paretoSet.begin();
1755 i != paretoSet.end(); ) {
1757 if (newPoint.get<1>() <= oldPoint.get<1>() &&
1758 newPoint.get<2>() <= oldPoint.get<2>() &&
1759 (newPoint.get<1>() < oldPoint.get<1>() ||
1760 newPoint.get<2>() < oldPoint.get<2>())) {
1761 // newPoint dominates the oldPoint, remove the oldPoint
1762 paretoSet.erase(i++);
1763 continue;
1764 } else if (oldPoint.get<1>() <= newPoint.get<1>() &&
1765 oldPoint.get<2>() <= newPoint.get<2>() &&
1766 (oldPoint.get<1>() < newPoint.get<1>() ||
1767 oldPoint.get<2>() < newPoint.get<2>())) {
1768 // there was an old point in the set that dominates this one,
1769 // we cannot add it to the set but we should look for other
1770 // points this point could dominate
1771 dominated = true;
1772 }
1773 i++;
1774 }
1775 if (!dominated) paretoSet.insert(newPoint);
1776
1777 }
1778 delete queryResult;
1779 return paretoSet;
1780}
std::set< ParetoPointConnectivityAndCycles > ParetoSetConnectivityAndCycles
boost::tuple< RowID, int, ClockCycleCount > ParetoPointConnectivityAndCycles

References abortWithError, applicationIDs(), RelationalDBQueryResult::data(), dbConnection_, Exception::errorMessage(), RelationalDBQueryResult::hasNext(), ILLEGAL_ROW_ID, DataObject::integerValue(), RelationalDBQueryResult::next(), and RelationalDBConnection::query().

Referenced by printParetoSet().

Here is the call graph for this function:

◆ removeApplication()

void DSDBManager::removeApplication ( RowID  id)

Removes the application that has the given ID.

Parameters
idApplication ID to remove.
Exceptions
KeyNotFoundIf the application ID was not found in the database.

Definition at line 1071 of file DSDBManager.cc.

1071 {
1072 if (!hasApplication(id)) {
1073 const std::string error = (boost::format(
1074 "DSDP file '%s' has no application with id '%d'.")
1075 % file_ % id).str();
1076 throw KeyNotFound(__FILE__, __LINE__, __func__, error);
1077 }
1078
1079 try {
1082 std::string(
1083 "DELETE FROM application "
1084 "WHERE id=" + Conversion::toString(id) + ";"));
1085
1087 } catch (const Exception& e) {
1090 assert(false);
1091 }
1092}

References __func__, assert, RelationalDBConnection::beginTransaction(), RelationalDBConnection::commit(), dbConnection_, debugLog, Exception::errorMessage(), file_, hasApplication(), RelationalDBConnection::rollback(), Conversion::toString(), and RelationalDBConnection::updateQuery().

Referenced by main().

Here is the call graph for this function:

◆ removeConfiguration()

void DSDBManager::removeConfiguration ( RowID  id)

Removes configuration with the give ID from the database.

Arhcitecture and implementation that are referenced by the configuration are not removed.

Parameters
idID of the configuration to remove.
Exceptions
KeyNotFoundIf a configuration ID was not found in the database.

Definition at line 409 of file DSDBManager.cc.

409 {
410 if (!hasConfiguration(id)) {
411 const std::string error = (boost::format(
412 "DSDP file '%s' has no configuration with id '%d'.")
413 % file_ % id).str();
414 throw KeyNotFound(__FILE__, __LINE__, __func__, error);
415 }
416
417 try {
420 std::string(
421 "DELETE FROM machine_configuration "
422 "WHERE id=" + Conversion::toString(id) + ";"));
423
425 } catch (const Exception& e) {
428 assert(false);
429 }
430}

References __func__, assert, RelationalDBConnection::beginTransaction(), RelationalDBConnection::commit(), dbConnection_, debugLog, Exception::errorMessage(), file_, hasConfiguration(), RelationalDBConnection::rollback(), Conversion::toString(), and RelationalDBConnection::updateQuery().

Here is the call graph for this function:

◆ setAreaEstimate()

void DSDBManager::setAreaEstimate ( RowID  implementation,
CostEstimator::AreaInGates  area 
)

Sets the area estimate for an implementation.

Parameters
implementationRowID of the machine implementation.
areaImplementation area estimate in gates.

Definition at line 641 of file DSDBManager.cc.

641 {
643 const std::string error = (boost::format(
644 "DSDP file '%s' has no implementation with id '%d'.")
645 % file_ % implementation).str();
646 throw KeyNotFound(__FILE__, __LINE__, __func__, error);
647 }
648
649 std::string q =
650 "UPDATE implementation SET "
651 "area=" +
652 Conversion::toString(areaEstimate) + " WHERE implementation.id=" +
654
656}
CostEstimator::AreaInGates areaEstimate(RowID implementation) const

References __func__, areaEstimate(), dbConnection_, file_, hasImplementation(), implementation, Conversion::toString(), and RelationalDBConnection::updateQuery().

Referenced by DesignSpaceExplorer::evaluate().

Here is the call graph for this function:

◆ setLongestPathDelayEstimate()

void DSDBManager::setLongestPathDelayEstimate ( RowID  implementation,
double  delay 
)

Sets the longest path delay estimate for an implementation.

Parameters
implementationRowID of the machine implementation.
delayLongest path delay estimate of implementation in nanoseconds.

Definition at line 617 of file DSDBManager.cc.

617 {
619 const std::string error = (boost::format(
620 "DSDP file '%s' has no implementation with id '%d'.")
621 % file_ % implementation).str();
622 throw KeyNotFound(__FILE__, __LINE__, __func__, error);
623 }
624
625 std::string q =
626 "UPDATE implementation SET "
627 "lpd=" +
628 Conversion::toString(delay) + " WHERE implementation.id=" +
630
632}

References __func__, dbConnection_, file_, hasImplementation(), implementation, Conversion::toString(), and RelationalDBConnection::updateQuery().

Referenced by DesignSpaceExplorer::evaluate().

Here is the call graph for this function:

◆ setUnschedulable()

void DSDBManager::setUnschedulable ( RowID  application,
RowID  architecture 
)

Sets the application to be unschedulable for an architecture, thus cycle count nor further estimation could not be done.

This is saved to the DB so future evaluations of the same architecture can be skipped.

Parameters
applicationRowID of the application.
architectureRowID of the machine architecture.

Definition at line 515 of file DSDBManager.cc.

515 {
516 if (!hasApplication(application)) {
517 const std::string error = (boost::format(
518 "DSDB file '%s' has no application with id '%d'."
519 "Can't add a cycle count.")
520 % file_ % application).str();
521 throw KeyNotFound(__FILE__, __LINE__, __func__, error);
522 }
524 const std::string error = (boost::format(
525 "DSDB file '%s' has no architecture with id '%d'."
526 "Can't add a cycle count.")
527 % file_ % architecture).str();
528 throw KeyNotFound(__FILE__, __LINE__, __func__, error);
529 }
530
531 std::string q =
532 "INSERT INTO cycle_count(application, architecture, "
533 "unschedulable) VALUES(" +
534 Conversion::toString(application) + ", " +
536
538}

References __func__, architecture(), dbConnection_, file_, hasApplication(), hasArchitecture(), Conversion::toString(), and RelationalDBConnection::updateQuery().

Referenced by DesignSpaceExplorer::evaluate().

Here is the call graph for this function:

◆ writeArchitectureToFile()

void DSDBManager::writeArchitectureToFile ( RowID  id,
const std::string &  path 
) const

Writes the machine architecture of given ID to file.

Parameters
idRowID of the machine architecture.
pathFile path where the ADF file is written.

Definition at line 826 of file DSDBManager.cc.

826 {
827 const std::string adf = architectureString(id);
828 ADFSerializer serializer;
829 serializer.setSourceString(adf);
830 serializer.setDestinationFile(path);
831 try {
832 ObjectState* state = serializer.readState();
833 serializer.writeState(state);
834 } catch (const SerializerException& exception) {
835 throw IOException(
836 __FILE__, __LINE__, __func__, exception.errorMessage());
837 }
838}
void setDestinationFile(const std::string &fileName)

References __func__, architectureString(), Exception::errorMessage(), ADFSerializer::readState(), XMLSerializer::setDestinationFile(), XMLSerializer::setSourceString(), and ADFSerializer::writeState().

Referenced by main(), and writeConfigurationToFile().

Here is the call graph for this function:

◆ writeConfigurationToFile()

void DSDBManager::writeConfigurationToFile ( const MachineConfiguration conf,
const std::string &  path 
)

Writes the machine configuration to files path.{idf,adf}.

Parameters
confMachineConfiguration to be written to a path.
pathPath where the ADF and possibly the IDF of the configuration will be written.

Definition at line 929 of file DSDBManager.cc.

930 {
931 const std::string adfFile = path + ".adf";
932 const std::string idfFile = path + ".idf";
933
934 writeArchitectureToFile(conf.architectureID, adfFile);
935 if (conf.hasImplementation) {
936 writeImplementationToFile(conf.implementationID, idfFile);
937 }
938}
void writeArchitectureToFile(RowID id, const std::string &path) const
void writeImplementationToFile(RowID id, const std::string &path) const

References DSDBManager::MachineConfiguration::architectureID, DSDBManager::MachineConfiguration::hasImplementation, DSDBManager::MachineConfiguration::implementationID, writeArchitectureToFile(), and writeImplementationToFile().

Here is the call graph for this function:

◆ writeImplementationToFile()

void DSDBManager::writeImplementationToFile ( RowID  id,
const std::string &  path 
) const

Writes the machine implementation of given ID to file.

Parameters
idRowID of the machine implementation.
pathFile path where the IDF file is written.

Definition at line 906 of file DSDBManager.cc.

907 {
908 const std::string idf = implementationString(id);
909 IDF::IDFSerializer serializer;
910 serializer.setSourceString(idf);
911 serializer.setDestinationFile(path);
912 try {
913 ObjectState* state = serializer.readState();
914 serializer.writeState(state);
915 } catch (const SerializerException& exception) {
916 throw IOException(
917 __FILE__, __LINE__, __func__, exception.errorMessage());
918 }
919}

References __func__, Exception::errorMessage(), implementationString(), IDF::IDFSerializer::readState(), XMLSerializer::setDestinationFile(), XMLSerializer::setSourceString(), and IDF::IDFSerializer::writeState().

Referenced by main(), and writeConfigurationToFile().

Here is the call graph for this function:

Member Data Documentation

◆ db_

SQLite* DSDBManager::db_
private

Handle to the database.

Definition at line 250 of file DSDBManager.hh.

Referenced by DSDBManager(), and ~DSDBManager().

◆ dbConnection_

RelationalDBConnection* DSDBManager::dbConnection_
private

◆ file_

std::string DSDBManager::file_
private

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