OpenASIP 2.2
Loading...
Searching...
No Matches
DSDBManager.hh
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2009 Tampere University.
3
4 This file is part of TTA-Based Codesign Environment (TCE).
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23 */
24/**
25 * @file DSDBManager.hh
26 *
27 * Declaration of DSDBManager class.
28 *
29 * @author Veli-Pekka Jääskeläinen 2006 (vjaaskel-no.spam-cs.tut.fi)
30 * @note rating: red
31 */
32
33#ifndef TTA_DSDB_MANAGER_HH
34#define TTA_DSDB_MANAGER_HH
35
36#include <string>
37#include <set>
38#include <vector>
39#include <boost/tuple/tuple.hpp>
40#include <boost/tuple/tuple_comparison.hpp>
41#include "DBTypes.hh"
42#include "Exception.hh"
43#include "SimulatorConstants.hh"
44#include "CostEstimatorTypes.hh"
45
46
47class SQLite;
49
50namespace TTAMachine {
51 class Machine;
52}
53
54namespace IDF {
56}
57
58#define ILLEGAL_ROW_ID (-1)
59
60/**
61 * Design space database manager.
62 *
63 * Design space database stores information about explored machine
64 * configurations for test applications.
65 *
66 * The following information can be stored:
67 * - Machine architectures.
68 * - Implementations for architectures which define a working machine
69 * configuration.
70 * - Longest path delay estimates for implementations.
71 * - Area estimates for implementations.
72 * - Test applications for exploration.
73 * - Runtimes as clock cycle counts for application-architecture pairs.
74 * - Energy estimates for application-implementation pairs.
75 */
77public:
93
95 std::string id;
96 std::string name;
97 };
98
99 /// Struct for configuration costs with a specified application
108
111 if (c1.configurationID != c2.configurationID)
112 return (c1.configurationID < c2.configurationID);
113 // if the id's match then applications must differ
114 return (c1.application < c2.application);
115 }
116 };
117
120 if (c1.cycleCount == c2.cycleCount) {
121 if (c1.configurationID != c2.configurationID) {
122 return (c1.configurationID < c2.configurationID);
123 } else {
124 return (c1.application < c2.application);
125 }
126 }
127 return (c1.cycleCount < c2.cycleCount);
128 }
129 };
130
133 if (c1.energyEstimate == c2.energyEstimate) {
134 if (c1.configurationID != c2.configurationID) {
135 return (c1.configurationID < c2.configurationID);
136 } else {
137 return (c1.application < c2.application);
138 }
139 }
140 return (c1.energyEstimate < c2.energyEstimate);
141 }
142 };
143
146 if (c1.application == c2.application)
147 return (c1.configurationID < c2.configurationID);
148 return (c1.application < c2.application);
149 }
150 };
151
152 typedef boost::tuple<RowID, int, ClockCycleCount>
154
155 typedef std::set<ParetoPointConnectivityAndCycles>
157
158 /// Identifiers for ordering results.
165
166 DSDBManager(const std::string& file);
167
168 virtual ~DSDBManager();
169
170 static DSDBManager* createNew(const std::string& file);
171
172 std::string dsdbFile() const;
173
176 const IDF::MachineImplementation& impl, double longestPathDelay,
178
179 RowID addConfiguration(const MachineConfiguration& conf);
180
181 RowID addApplication(const std::string& path);
182
184 RowID application, RowID implementation, double energyEstimate);
185
186 void addCycleCount(
187 RowID application, RowID architecture, ClockCycleCount count);
188
190
192
193 bool hasApplication(RowID id) const;
194 bool hasApplication(const std::string& applicationPath) const;
195 void removeApplication(RowID id);
196
197 std::string applicationPath(RowID id) const;
198
199 bool hasArchitecture(RowID id) const;
201
202 RowID architectureId(const TTAMachine::Machine& mach) const;
203
204 bool hasImplementation(RowID id) const;
206
207 bool hasConfiguration(RowID id) const;
208 MachineConfiguration configuration(RowID id) const;
209 RowID configurationId(const MachineConfiguration& conf) const;
210
211 void removeConfiguration(RowID id);
212
213 bool hasEnergyEstimate(RowID application, RowID implementation) const;
214 double energyEstimate(RowID application, RowID implementation) const;
215
216 bool hasCycleCount(RowID application, RowID architecture) const;
218 std::vector<ClockCycleCount>
219 cycleCounts(const MachineConfiguration& conf) const;
220 bool
222 RowID application, RowID architecture) const;
223 void setUnschedulable(RowID application, RowID architecture);
224
227
228 std::set<RowID> applicationIDs() const;
229 std::set<RowID> architectureIDs() const;
230 std::set<RowID> configurationIDs() const;
231 std::set<RowID> archConfigurationIDs(RowID architectureID) const;
232
233 void writeArchitectureToFile(RowID id, const std::string& path) const;
234 void writeImplementationToFile(RowID id, const std::string& path) const;
236 const MachineConfiguration& conf, const std::string& path);
237
238 std::vector<ConfigurationCosts> applicationCostEstimatesByConf(
239 Order ordering = ORDER_BY_CONFIGURATION) const;
240
243
244 int applicationCount() const;
245private:
246 std::string architectureString(RowID id) const;
247 std::string implementationString(RowID id) const;
248
249 /// Handle to the database.
251 /// Handle to the database connection.
253 /// The DSDB file containing the current database.
254 std::string file_;
255};
256
257#endif
int RowID
Type definition of row ID in relational databases.
Definition DBTypes.hh:37
#define ILLEGAL_ROW_ID
IDF::MachineImplementation * implementation
the implementation definition of the estimated processor
find Finds info of the inner loops in the false
CycleCount ClockCycleCount
Alias for ClockCycleCount.
RowID addArchitecture(const TTAMachine::Machine &mom)
TTAMachine::Machine * architecture(RowID id) const
std::string file_
The DSDB file containing the current database.
bool hasApplication(RowID id) const
SQLite * db_
Handle to the database.
virtual ~DSDBManager()
void writeConfigurationToFile(const MachineConfiguration &conf, const std::string &path)
void setAreaEstimate(RowID implementation, CostEstimator::AreaInGates area)
static DSDBManager * createNew(const std::string &file)
std::set< RowID > configurationIDs() const
std::set< ParetoPointConnectivityAndCycles > ParetoSetConnectivityAndCycles
bool hasEnergyEstimate(RowID application, RowID implementation) const
ClockCycleCount cycleCount(RowID application, RowID architecture) const
RelationalDBConnection * dbConnection_
Handle to the database connection.
std::set< RowID > applicationIDs() const
RowID configurationId(const MachineConfiguration &conf) const
std::string dsdbFile() const
void setUnschedulable(RowID application, RowID architecture)
void setLongestPathDelayEstimate(RowID implementation, double delay)
MachineConfiguration configuration(RowID id) const
std::string applicationPath(RowID id) const
void writeArchitectureToFile(RowID id, const std::string &path) const
double energyEstimate(RowID application, RowID implementation) const
boost::tuple< RowID, int, ClockCycleCount > ParetoPointConnectivityAndCycles
std::vector< ConfigurationCosts > applicationCostEstimatesByConf(Order ordering=ORDER_BY_CONFIGURATION) const
bool hasConfiguration(RowID id) const
double longestPathDelayEstimate(RowID implementation) const
int applicationCount() const
std::string implementationString(RowID id) const
std::vector< ClockCycleCount > cycleCounts(const MachineConfiguration &conf) const
RowID addImplementation(const IDF::MachineImplementation &impl, double longestPathDelay, CostEstimator::AreaInGates area)
bool hasArchitecture(RowID id) const
bool hasCycleCount(RowID application, RowID architecture) const
CostEstimator::AreaInGates areaEstimate(RowID implementation) const
Order
Identifiers for ordering results.
@ ORDER_BY_ENERGY_ESTIMATE
void removeApplication(RowID id)
std::set< RowID > architectureIDs() const
void removeConfiguration(RowID id)
void writeImplementationToFile(RowID id, const std::string &path) const
bool hasImplementation(RowID id) const
RowID addConfiguration(const MachineConfiguration &conf)
ParetoSetConnectivityAndCycles paretoSetConnectivityAndCycles(RowID application=ILLEGAL_ROW_ID) const
std::set< RowID > archConfigurationIDs(RowID architectureID) const
RowID addApplication(const std::string &path)
std::string architectureString(RowID id) const
void addCycleCount(RowID application, RowID architecture, ClockCycleCount count)
bool isUnschedulable(RowID application, RowID architecture) const
RowID architectureId(const TTAMachine::Machine &mach) const
void addEnergyEstimate(RowID application, RowID implementation, double energyEstimate)
double AreaInGates
type for area values in equivalent gates
Struct for configuration costs with a specified application.
MachineConfiguration(RowID arch, bool hasImpl, RowID impl)
bool operator()(ConfigurationCosts c1, ConfigurationCosts c2) const
bool operator()(ConfigurationCosts c1, ConfigurationCosts c2) const
bool operator()(ConfigurationCosts c1, ConfigurationCosts c2) const
bool operator()(ConfigurationCosts c1, ConfigurationCosts c2) const