OpenASIP
2.0
|
#include <CachedHDBManager.hh>
Public Member Functions | |
virtual | ~CachedHDBManager () |
virtual void | removeFUArchitecture (RowID archID) const |
virtual void | removeFUImplementation (RowID id) const |
virtual void | removeRFArchitecture (RowID archID) const |
virtual void | removeRFImplementation (RowID archID) const |
virtual void | modifyCostFunctionPlugin (RowID id, const CostFunctionPlugin &plugin) |
virtual void | removeCostFunctionPlugin (RowID pluginID) const |
virtual void | removeFUEntry (RowID id) const |
virtual void | removeRFEntry (RowID id) const |
virtual void | removeBusEntry (RowID id) const |
virtual void | removeSocketEntry (RowID id) const |
virtual void | removeCostEstimationData (RowID id) const |
virtual void | modifyCostEstimationData (RowID id, const CostEstimationData &data) |
virtual FUArchitecture * | fuArchitectureByID (RowID id) const |
virtual RFArchitecture * | rfArchitectureByID (RowID id) const |
virtual DataObject | costEstimationDataValue (const std::string &valueName, const std::string &pluginName) const |
const FUArchitecture & | fuArchitectureByIDConst (RowID id) const |
const RFArchitecture & | rfArchitectureByIDConst (RowID id) const |
virtual void | deleteCostEstimationDataIDsQueries () const |
virtual std::set< RowID > | costEstimationDataIDs (const CostEstimationData &match, bool useCompiledQueries=false, RelationalDBQueryResult *compiledQuery=NULL) const |
Public Member Functions inherited from HDB::HDBManager | |
virtual | ~HDBManager () |
std::string | fileName () const |
RowID | addCostFunctionPlugin (const CostFunctionPlugin &plugin) const |
RowID | addFUArchitecture (const FUArchitecture &architecture) const |
bool | canRemoveFUArchitecture (RowID archID) const |
RowID | addFUEntry () const |
RowID | addFUImplementation (const FUEntry &entry) const |
void | setArchitectureForFU (RowID fuID, RowID archID) const |
void | unsetArchitectureForFU (RowID fuID) const |
RowID | addRFArchitecture (const RFArchitecture &architecture) const |
bool | canRemoveRFArchitecture (RowID archID) const |
RowID | addRFEntry () const |
RowID | addRFImplementation (const RFImplementation &implementation, RowID rfEntryID) |
void | setArchitectureForRF (RowID rfID, RowID archID) const |
void | unsetArchitectureForRF (RowID rfID) const |
void | setCostFunctionPluginForFU (RowID fuID, RowID pluginID) const |
void | unsetCostFunctionPluginForFU (RowID fuID) const |
void | setCostFunctionPluginForRF (RowID rfID, RowID pluginID) const |
void | unsetCostFunctionPluginForRF (RowID rfID) const |
std::set< RowID > | fuEntryIDs () const |
std::set< RowID > | rfEntryIDs () const |
std::set< RowID > | busEntryIDs () const |
std::set< RowID > | socketEntryIDs () const |
std::set< RowID > | OperationImplementationIDs () const |
std::set< RowID > | OperationImplementationResourceIDs () const |
OperationImplementation | OperationImplementationByID (RowID id) const |
OperationImplementationResource | OperationImplementationResourceByID (RowID id) const |
void | addOperationImplementationResource (const OperationImplementationResource &resource) |
void | addOperationImplementation (const OperationImplementation &operation) |
void | removeOperationImplementation (RowID id) |
void | removeOperationImplementationResource (RowID id) |
std::set< RowID > | fuArchitectureIDs () const |
std::set< RowID > | fuArchitectureIDsByOperationSet (const std::set< std::string > &operationNames) const |
std::set< RowID > | rfArchitectureIDs () const |
RowID | fuEntryIDOfImplementation (RowID implID) const |
RowID | rfEntryIDOfImplementation (RowID implID) const |
FUEntry * | fuByEntryID (RowID id) const |
RFEntry * | rfByEntryID (RowID id) const |
std::set< RowID > | fuEntriesByArchitecture (const TTAMachine::FunctionUnit &fu) const |
std::set< RowID > | rfEntriesByArchitecture (int readPorts, int writePorts, int bidirPorts, int maxReads, int maxWrites, int latency, bool guardSupport, int guardLatency=0, int width=0, int size=0, bool zeroRegister=false) const |
DataObject | costEstimationDataValue (RowID entryId) const |
RowID | addFUCostEstimationData (RowID fuID, const std::string &valueName, const std::string &value, RowID pluginID) const |
RowID | addRFCostEstimationData (RowID rfID, const std::string &valueName, const std::string &value, RowID pluginID) const |
DataObject | fuCostEstimationData (const std::string &valueName, RowID implementationId, const std::string &pluginName) const |
DataObject | rfCostEstimationData (const std::string &valueName, RowID implementationId, const std::string &pluginName) const |
RowID | addBusEntry () const |
RowID | addBusCostEstimationData (RowID busID, const std::string &valueName, const std::string &value, RowID pluginID) const |
DataObject | busCostEstimationData (const std::string &valueName, RowID busID, const std::string &pluginName) const |
DataObjectList * | busCostEstimationDataList (const std::string &valueName, RowID implementationId, const std::string &pluginName) const |
RowID | addSocketEntry () const |
RowID | addSocketCostEstimationData (RowID socketID, const std::string &valueName, const std::string &value, RowID pluginID) const |
DataObject | socketCostEstimationData (const std::string &valueName, RowID socketID, const std::string &pluginName) const |
DataObjectList * | socketCostEstimationDataList (const std::string &valueName, RowID implementationID, const std::string &pluginName) const |
std::set< RowID > | fuCostEstimationDataIDs (RowID fuImplID) const |
std::set< RowID > | rfCostEstimationDataIDs (RowID rfImplID) const |
std::set< RowID > | busCostEstimationDataIDs (RowID busID) const |
std::set< RowID > | socketCostEstimationDataIDs (RowID socketID) const |
CostEstimationData | costEstimationData (RowID id) const |
std::set< RowID > | costFunctionPluginIDs () const |
std::set< RowID > | costFunctionPluginDataIDs (RowID pluginID) const |
CostFunctionPlugin * | costFunctionPluginByID (RowID pluginID) const |
RowID | addCostEstimationData (const CostEstimationData &data) const |
std::list< std::string > | blockSourceFile () |
Static Public Member Functions | |
static CachedHDBManager & | instance (const std::string &hdbFile) |
static CachedHDBManager & | createNew (const std::string &fileName) |
Static Public Member Functions inherited from HDB::HDBManager | |
static void | createNew (const std::string &file) |
static std::string | formatString (BlockImplementationFile::Format format) |
Private Member Functions | |
CachedHDBManager (const std::string &hdbFile) | |
virtual RFImplementation * | createImplementationOfRF (RowID id) const |
virtual FUImplementation * | createImplementationOfFU (FUArchitecture &architecture, RowID id) const |
void | validateCache () const |
Private Attributes | |
std::map< RowID, FUArchitecture * > | fuArchCache_ |
FU Architecture cache. More... | |
std::map< RowID, RFArchitecture * > | rfArchCache_ |
RF Architecture cache. More... | |
std::map< RowID, FUImplementation * > | fuImplCache_ |
FU Implementation cache. More... | |
std::map< RowID, RFImplementation * > | rfImplCache_ |
RF Implementation cache. More... | |
std::map< std::string, std::map< std::string, DataObject > > | costEstimationPluginValueCache_ |
Cost estimation plugin value cache (pluginName/valueName) More... | |
std::map< short int, RelationalDBQueryResult * > | costEstimationDataIDsQueries_ |
map of cached (compiled) queries for costEstimatioDataIDs function More... | |
std::time_t | lastModificationTime_ |
used to detect modifications to the HDB file (which invalidates cache) More... | |
uintmax_t | lastSizeInBytes_ |
used to detect modifications to the HDB file (which invalidates cache) More... | |
Additional Inherited Members | |
Public Types inherited from HDB::HDBManager | |
typedef std::list< DataObject > | DataObjectList |
Protected Member Functions inherited from HDB::HDBManager | |
void | createCostEstimatioDataIdsQuery (const CostEstimationData &match, std::string *query, RelationalDBQueryResult *compiledQuery=NULL, short int *queryHash=NULL, bool createBindableQuery=false) const |
RelationalDBConnection * | getDBConnection () const |
HDBManager (const std::string &hdbFile) | |
Cached interface to HDBs.
HDBManager class queries HDB file every time the manager is queried for an object in the database. Queries to the database are time consuming, especially when constructing FU and RF implementation objects based on data scattered across multiple HDB tables. CachedHDBManager caches the queried objects in memory, resulting in significant speedups if the same objects are queried repeatedly without any modifications to the related data in the HDB.
IMPORTANT NOTE:
If a new function which modifies or removes cached objects is added to the HDBManager, it must be derived here to remove corresponding objects from the cache! Please check that all functions you are using that modify cached data are reimplemented to remove cached objects.
Definition at line 63 of file CachedHDBManager.hh.
|
virtual |
The Destructor.
Deletes all cached items.
Definition at line 69 of file CachedHDBManager.cc.
References costEstimationPluginValueCache_, MapTools::deleteAllValues(), fuArchCache_, fuImplCache_, rfArchCache_, and rfImplCache_.
|
private |
The Constructor.
hdbFile | HDBFile to open. |
IOException | if an error occured opening the HDB file. |
Definition at line 58 of file CachedHDBManager.cc.
References FileSystem::lastModificationTime(), lastModificationTime_, lastSizeInBytes_, and FileSystem::sizeInBytes().
Referenced by instance().
|
virtual |
Wrapper for HDBManager costEstimationDataIDs.
Compiles and caches queries for HDBManager costEstimationDataIDs function.
Reimplemented from HDB::HDBManager.
Definition at line 517 of file CachedHDBManager.cc.
References assert, HDB::HDBManager::costEstimationDataIDs(), costEstimationDataIDsQueries_, HDB::HDBManager::createCostEstimatioDataIdsQuery(), HDB::HDBManager::getDBConnection(), and RelationalDBConnection::query().
|
virtual |
Returns cost estimation data which is not connected to any machine implementation id.
This version assumes that there's only one entry with given parameters. Caches values by plugin name.
valueName | Name of the value to fetch. |
pluginName | Name of the cost estimation plugin that owns the data. |
KeyNotFound | If the HDB does not contain cost estimation data with the given arguments. |
Reimplemented from HDB::HDBManager.
Definition at line 271 of file CachedHDBManager.cc.
References HDB::HDBManager::costEstimationDataValue(), costEstimationPluginValueCache_, and validateCache().
|
privatevirtual |
Returns implementation of a FU with the given index.
Returns NULL if the FU doesn't have implementation.
First the FU implementation cache is searched for the ID, if the implementation is found in the cache, a copy of the cached item is returned. If the implementation was not found in the cache, a DB query is made using the base class implementation and the item is then added to the cache.
id | ID of the FU implementation. |
Reimplemented from HDB::HDBManager.
Definition at line 461 of file CachedHDBManager.cc.
References HDB::HDBManager::createImplementationOfFU(), fuImplCache_, and validateCache().
|
privatevirtual |
Returns implementation of a RF with the given index.
Returns NULL if the RF doesn't have implementation.
First the RF implementation cache is searched for the ID, if the implementation is found in the cache, a copy of the cached item is returned. If the implementation was not found in the cache, a DB query is made using the base class implementation and the item is then added to the cache.
id | ID of the RF implementation. |
Reimplemented from HDB::HDBManager.
Definition at line 427 of file CachedHDBManager.cc.
References HDB::HDBManager::createImplementationOfRF(), rfImplCache_, and validateCache().
|
static |
Creates a new HDB and returns CachedHDBManager instance for accessing it.
file | Full path of the new HDB file. |
UnreachableStream | If the HDB creation was not succesful. |
Definition at line 105 of file CachedHDBManager.cc.
References HDB::HDBManager::createNew(), and instance().
Referenced by HDBEditorMainFrame::createHDB().
|
virtual |
Deletes cached costEstimationDataIDs queries.
Implements HDB::HDBManager.
Definition at line 555 of file CachedHDBManager.cc.
References costEstimationDataIDsQueries_.
|
virtual |
Returns FU architecture with the given ID.
First the fu architecture cache is searched for the ID, if the architecture is found in the cache, a copy of the cached item is returned. If the architecture was not found in the cache, a DB query is made using the base class implementation and the item is then added to the cache.
id | ID of the fu architecture. |
KeyNotFound | if an architecture with the given id was not found. |
Reimplemented from HDB::HDBManager.
Definition at line 218 of file CachedHDBManager.cc.
References fuArchCache_, HDB::HDBManager::fuArchitectureByID(), and validateCache().
Referenced by ComponentImplementationSelector::fuArchsByOpSetWithMinLatency().
const FUArchitecture & CachedHDBManager::fuArchitectureByIDConst | ( | RowID | id | ) | const |
Definition at line 484 of file CachedHDBManager.cc.
References fuArchCache_, HDB::HDBManager::fuArchitectureByID(), and validateCache().
|
static |
Returns a CachedHDBManager instance for the given file.
Only one instance is created per file.
hdbFile | Name of the HDB file to open. |
IOException | If connection to the DB cannot be established. |
Definition at line 89 of file CachedHDBManager.cc.
References HDB::HDBRegistry::addHDB(), CachedHDBManager(), HDB::HDBRegistry::hasHDB(), HDB::HDBRegistry::hdb(), and HDB::HDBRegistry::instance().
Referenced by Automagic::checkForSelectableFU(), ProGeTools::checkForSelectableFU(), Automagic::checkForSelectableIU(), ProGeTools::checkForSelectableIU(), ProGeTools::checkForSelectableRF(), Automagic::checkForSelectableRF(), Automagic::createFUGeneratableOperationInfos(), ProGeTools::createFUGeneratableOperationInfos(), FUGen::createImplementationFiles(), createNew(), HDB::HDBRegistry::hdb(), HDB::HDBRegistry::loadFromSearchPaths(), ImplementationTester::openHdb(), and FUGen::parseOperations().
|
virtual |
Cached (invalidates cache) function of HDBManager::modifyCostEstimationData.
id | |
data |
InvalidData | |
KeyNotFound |
Reimplemented from HDB::HDBManager.
Definition at line 405 of file CachedHDBManager.cc.
References costEstimationPluginValueCache_, and HDB::HDBManager::modifyCostEstimationData().
|
virtual |
Cached (invalidates cache) function of HDBManager::modifyCostFunctionPlugin.
id | |
plugin |
InvalidData | |
KeyNotFound |
Reimplemented from HDB::HDBManager.
Definition at line 307 of file CachedHDBManager.cc.
References costEstimationPluginValueCache_, and HDB::HDBManager::modifyCostFunctionPlugin().
|
virtual |
Cached (invalidates cache) function of HDBManager::removeBusEntry.
id |
Reimplemented from HDB::HDBManager.
Definition at line 363 of file CachedHDBManager.cc.
References costEstimationPluginValueCache_, and HDB::HDBManager::removeBusEntry().
|
virtual |
Cached (invalidates cache) function of HDBManager::removeCostEstimationData.
id |
Reimplemented from HDB::HDBManager.
Definition at line 389 of file CachedHDBManager.cc.
References costEstimationPluginValueCache_, and HDB::HDBManager::removeCostEstimationData().
|
virtual |
Cached (invalidates cache) function of HDBManager::removeCostFunctionPlugin.
pluginID |
Reimplemented from HDB::HDBManager.
Definition at line 322 of file CachedHDBManager.cc.
References costEstimationPluginValueCache_, and HDB::HDBManager::removeCostFunctionPlugin().
|
virtual |
Removes FU architecture from the HDB.
Removes architecture from the cache and calls base class function to actually remove the FU architecture.
archID | ID of the FU architecture to remove. |
Reimplemented from HDB::HDBManager.
Definition at line 119 of file CachedHDBManager.cc.
References fuArchCache_, and HDB::HDBManager::removeFUArchitecture().
|
virtual |
Cached (invalidates cache) function of HDBManager::removeFUEntry.
id |
Reimplemented from HDB::HDBManager.
Definition at line 337 of file CachedHDBManager.cc.
References costEstimationPluginValueCache_, and HDB::HDBManager::removeFUEntry().
|
virtual |
Removes FU implementation from the HDB.
Removes implementation from the cache and calls base class function to actually remove the FU implementation.
id | ID of the FU implementation to remove. |
Reimplemented from HDB::HDBManager.
Definition at line 141 of file CachedHDBManager.cc.
References HDB::HDBManager::fuEntryIDOfImplementation(), fuImplCache_, and HDB::HDBManager::removeFUImplementation().
|
virtual |
Removes RF architecture from the HDB.
Removes architecture from the cache and calls base class function to actually remove the RF architecture.
archID | ID of the RF architecture to remove. |
Reimplemented from HDB::HDBManager.
Definition at line 167 of file CachedHDBManager.cc.
References HDB::HDBManager::removeRFArchitecture(), and rfArchCache_.
|
virtual |
Cached (invalidates cache) function of HDBManager::removeRFEntry.
id |
Reimplemented from HDB::HDBManager.
Definition at line 350 of file CachedHDBManager.cc.
References costEstimationPluginValueCache_, and HDB::HDBManager::removeRFEntry().
|
virtual |
Removes RF implementation from the HDB.
Removes implementation from the cache and calls base class function to actually remove the RF implementation.
id | ID of the RF implementation to remove. |
Reimplemented from HDB::HDBManager.
Definition at line 189 of file CachedHDBManager.cc.
References HDB::HDBManager::removeRFImplementation(), HDB::HDBManager::rfEntryIDOfImplementation(), and rfImplCache_.
|
virtual |
Cached (invalidates cache) function of HDBManager::removeSocketEntry.
id |
Reimplemented from HDB::HDBManager.
Definition at line 376 of file CachedHDBManager.cc.
References costEstimationPluginValueCache_, and HDB::HDBManager::removeSocketEntry().
|
virtual |
Returns RF architecture with the given ID.
First the RF architecture cache is searched for the ID, if the architecture is found in the cache, a copy of the cached item is returned. If the architecture was not found in the cache, a DB query is made using the base class implementation and the item is then added to the cache.
id | ID of the fu architecture. |
KeyNotFound | if an architecture with the given id was not found. |
Reimplemented from HDB::HDBManager.
Definition at line 244 of file CachedHDBManager.cc.
References rfArchCache_, HDB::HDBManager::rfArchitectureByID(), and validateCache().
const RFArchitecture & CachedHDBManager::rfArchitectureByIDConst | ( | RowID | id | ) | const |
Definition at line 498 of file CachedHDBManager.cc.
References rfArchCache_, HDB::HDBManager::rfArchitectureByID(), and validateCache().
|
private |
Checks if HDB file is modified. In case it is, invalid cache is cleared.
Definition at line 572 of file CachedHDBManager.cc.
References costEstimationPluginValueCache_, MapTools::deleteAllValues(), HDB::HDBManager::fileName(), fuArchCache_, fuImplCache_, FileSystem::lastModificationTime(), lastModificationTime_, lastSizeInBytes_, rfArchCache_, rfImplCache_, and FileSystem::sizeInBytes().
Referenced by costEstimationDataValue(), createImplementationOfFU(), createImplementationOfRF(), fuArchitectureByID(), fuArchitectureByIDConst(), rfArchitectureByID(), and rfArchitectureByIDConst().
|
mutableprivate |
map of cached (compiled) queries for costEstimatioDataIDs function
Definition at line 143 of file CachedHDBManager.hh.
Referenced by costEstimationDataIDs(), and deleteCostEstimationDataIDsQueries().
|
mutableprivate |
Cost estimation plugin value cache (pluginName/valueName)
Definition at line 139 of file CachedHDBManager.hh.
Referenced by costEstimationDataValue(), modifyCostEstimationData(), modifyCostFunctionPlugin(), removeBusEntry(), removeCostEstimationData(), removeCostFunctionPlugin(), removeFUEntry(), removeRFEntry(), removeSocketEntry(), validateCache(), and ~CachedHDBManager().
|
mutableprivate |
FU Architecture cache.
Definition at line 130 of file CachedHDBManager.hh.
Referenced by fuArchitectureByID(), fuArchitectureByIDConst(), removeFUArchitecture(), validateCache(), and ~CachedHDBManager().
|
mutableprivate |
FU Implementation cache.
Definition at line 134 of file CachedHDBManager.hh.
Referenced by createImplementationOfFU(), removeFUImplementation(), validateCache(), and ~CachedHDBManager().
|
mutableprivate |
used to detect modifications to the HDB file (which invalidates cache)
Definition at line 146 of file CachedHDBManager.hh.
Referenced by CachedHDBManager(), and validateCache().
|
mutableprivate |
used to detect modifications to the HDB file (which invalidates cache)
Definition at line 148 of file CachedHDBManager.hh.
Referenced by CachedHDBManager(), and validateCache().
|
mutableprivate |
RF Architecture cache.
Definition at line 132 of file CachedHDBManager.hh.
Referenced by removeRFArchitecture(), rfArchitectureByID(), rfArchitectureByIDConst(), validateCache(), and ~CachedHDBManager().
|
mutableprivate |
RF Implementation cache.
Definition at line 136 of file CachedHDBManager.hh.
Referenced by createImplementationOfRF(), removeRFImplementation(), validateCache(), and ~CachedHDBManager().